From patchwork Tue Jul 24 11:54:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanno Zulla X-Patchwork-Id: 10541947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21E141805 for ; Tue, 24 Jul 2018 11:55:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D29A22B26 for ; Tue, 24 Jul 2018 11:55:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2424260CD; Tue, 24 Jul 2018 11:55:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC8741FFB2 for ; Tue, 24 Jul 2018 11:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388271AbeGXNBH (ORCPT ); Tue, 24 Jul 2018 09:01:07 -0400 Received: from zoot.epublica.de ([78.46.103.157]:51552 "EHLO zoot.epublica.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388248AbeGXNBH (ORCPT ); Tue, 24 Jul 2018 09:01:07 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by zoot.epublica.de (Postfix) with ESMTP id 1437E1841757; Tue, 24 Jul 2018 13:54:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zoot.epublica.de Received: from zoot.epublica.de ([127.0.0.1]) by localhost (zoot.epublica.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id obXv1lV0Vacv; Tue, 24 Jul 2018 13:54:57 +0200 (CEST) Received: from [10.1.0.41] (ip1f103e43.dynamic.kabel-deutschland.de [31.16.62.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zoot.epublica.de (Postfix) with ESMTPSA id 1161A1841758; Tue, 24 Jul 2018 13:54:57 +0200 (CEST) Subject: [PATCH v3 1/1] HID: hid-sony: Only allow four LED states to identify controller From: Hanno Zulla To: Roderick Colenbrander , Jiri Kosina Cc: Frank Praznik , Benjamin Tissoires , linux-input References: <2AE476B4-2C49-479A-8C6A-E878E3E11483@gmail.com> Message-ID: <1c4d7bee-9410-dd56-a74f-185b7de827a1@hanno.de> Date: Tue, 24 Jul 2018 13:54:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Language: de-LU Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP HID: hid-sony: Only allow four LED states to identify controller The PS3 and PS4 consoles only support four game controllers, while Linux supports any number of game controller connected to it. The kernel driver should mirror the original console's behaviour here and leave the use of additional LED patterns/colours to user space. Signed-off-by: Hanno Zulla --- drivers/hid/hid-sony.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index e475c5073c99..147750b8dea7 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -1798,17 +1798,11 @@ static int dualshock4_get_version_info(struct sony_sc *sc) static void sixaxis_set_leds_from_id(struct sony_sc *sc) { - static const u8 sixaxis_leds[10][4] = { + static const u8 sixaxis_leds[4][4] = { { 0x01, 0x00, 0x00, 0x00 }, { 0x00, 0x01, 0x00, 0x00 }, { 0x00, 0x00, 0x01, 0x00 }, - { 0x00, 0x00, 0x00, 0x01 }, - { 0x01, 0x00, 0x00, 0x01 }, - { 0x00, 0x01, 0x00, 0x01 }, - { 0x00, 0x00, 0x01, 0x01 }, - { 0x01, 0x00, 0x01, 0x01 }, - { 0x00, 0x01, 0x01, 0x01 }, - { 0x01, 0x01, 0x01, 0x01 } + { 0x00, 0x00, 0x00, 0x01 } }; int id = sc->device_id; @@ -1818,21 +1812,18 @@ static void sixaxis_set_leds_from_id(struct sony_sc *sc) if (id < 0) return; - id %= 10; + id %= 4; memcpy(sc->led_state, sixaxis_leds[id], sizeof(sixaxis_leds[id])); } static void dualshock4_set_leds_from_id(struct sony_sc *sc) { - /* The first 4 color/index entries match what the PS4 assigns */ - static const u8 color_code[7][3] = { + /* The 4 color/index entries match what the PS4 assigns */ + static const u8 color_code[4][3] = { /* Blue */ { 0x00, 0x00, 0x40 }, - /* Red */ { 0x40, 0x00, 0x00 }, + /* Red */ { 0x40, 0x00, 0x00 }, /* Green */ { 0x00, 0x40, 0x00 }, - /* Pink */ { 0x20, 0x00, 0x20 }, - /* Orange */ { 0x02, 0x01, 0x00 }, - /* Teal */ { 0x00, 0x01, 0x01 }, - /* White */ { 0x01, 0x01, 0x01 } + /* Pink */ { 0x20, 0x00, 0x20 } }; int id = sc->device_id; @@ -1842,7 +1833,7 @@ static void dualshock4_set_leds_from_id(struct sony_sc *sc) if (id < 0) return; - id %= 7; + id %= 4; memcpy(sc->led_state, color_code[id], sizeof(color_code[id])); }