From patchwork Wed Jan 9 01:18:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongye Yuan X-Patchwork-Id: 10753273 X-Patchwork-Delegate: jikos@jikos.cz 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 36AE213BF for ; Wed, 9 Jan 2019 01:18:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CBF628DDC for ; Wed, 9 Jan 2019 01:18:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0ECB728DE5; Wed, 9 Jan 2019 01:18:20 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 A4A1528DDC for ; Wed, 9 Jan 2019 01:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728403AbfAIBSS (ORCPT ); Tue, 8 Jan 2019 20:18:18 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46875 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729169AbfAIBSS (ORCPT ); Tue, 8 Jan 2019 20:18:18 -0500 Received: by mail-pl1-f194.google.com with SMTP id t13so2728230ply.13 for ; Tue, 08 Jan 2019 17:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/VMaWcpNs96TS4K541xul8R5N5Kv3JoYlBOq9FF+Uoo=; b=lbksRybC5VwwZwNwVNEXSnEaG7XwwwtAPLzkwShm3Hp8W4yrmp4J6WKk0WovMILtY/ qPkFl7tERA7rKEg+35j9xKJNoxz3ldoFnl0XFuxvBAC6xS08OVIg+niWL1M+myJX8/L8 Hw9ZcYlMFtoCXdkYKjgBHOcPopY9z0yvRz8VBJi3wyz37En7F9eK0jUOGhmr1EMJc3WQ JS6Vmp7K3n+5oXhRmKJB3zPXSapABKZs1eWpsbq2FZk1pv967oH0JpP6d0fuYKKQBoc1 JSfjkJAZGNfQCU7urH2UJ4RY/TzOOkZPEpamjo2niELplf+9cM4cp/7ASWxWbRinEQLR JBAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/VMaWcpNs96TS4K541xul8R5N5Kv3JoYlBOq9FF+Uoo=; b=P1taiKBgVjllZmTB9eGyaOMi/Jx9pT0/+SQLlkQHjFiVbYOxoZ7BF3w5FkWF9id1wz 5jeXAbNNfN5AyFPgg/11SdWbUnxb/S5kKR1Y+1LU5/rC5xiJJa73eML1YElnmQaemYIF WU3/OS9xwXlgyNlKgiD/oOgMxrmC2ioZlzg2M5KZpgQmZGvtAe7nrQ0jc6SisBa0S1Zd C+zuYU4dHm7IXbdsx93Sm0pAURfC2zVRuzsj4QBco5lpH8U6xylpYeAXScnYCl46/8hz lP/cXT2TaS5kN0TsjbTh4ZxZs6jdMFzhMg5iUJVw8bES2IWlAbOFbkdiwsRGy2p3CpIY towQ== X-Gm-Message-State: AJcUukdjPlKHgfZ8qKwZTk6f0dPir50Go+A6vHfggMGbfpmaWRthAraz Qxn6D83YC7ho/QCs+h+cObmQ4BNK X-Google-Smtp-Source: ALg8bN7GIi9g2VsWi8196nGJKw+8Rg7cfNZf1JUw5cvtvDw3YLYYlLxRwAAup3KlMqnlSRSsG3fS3Q== X-Received: by 2002:a17:902:2e01:: with SMTP id q1mr3904915plb.97.1546996697453; Tue, 08 Jan 2019 17:18:17 -0800 (PST) Received: from localhost ([45.77.70.206]) by smtp.gmail.com with ESMTPSA id l3sm114244735pga.92.2019.01.08.17.18.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Jan 2019 17:18:16 -0800 (PST) From: Hongye Yuan To: linux-input@vger.kernel.org Cc: jikos@kernel.org, hadess@hadess.net, benjamin.tissoires@redhat.com, rydberg@bitmath.org, roderick.colenbrander@sony.com, ao2@ao2.it, Hongye Yuan Subject: [PATCH v4 1/2] HID: sony: Transform one-time SHANWAN check into quirk Date: Wed, 9 Jan 2019 09:18:08 +0800 Message-Id: <20190109011809.16542-1-outmatch@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 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 Transform the one-time check for a SHANWAN PS3 clone gamepad into a quirk, to avoid doing the same string comparison in multiple places. Signed-off-by: Hongye Yuan Reviewed-by: Bastien Nocera --- Changes in v4: - Rewrite commit message to make it clearer. --- drivers/hid/hid-sony.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 9671a4bad643..fc82f02bae75 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -58,6 +58,7 @@ #define FUTUREMAX_DANCE_MAT BIT(13) #define NSG_MR5U_REMOTE_BT BIT(14) #define NSG_MR7U_REMOTE_BT BIT(15) +#define SHANWAN_GAMEPAD BIT(16) #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT) #define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT) @@ -1490,6 +1491,7 @@ static int sony_register_sensors(struct sony_sc *sc) */ static int sixaxis_set_operational_usb(struct hid_device *hdev) { + struct sony_sc *sc = hid_get_drvdata(hdev); const int buf_size = max(SIXAXIS_REPORT_0xF2_SIZE, SIXAXIS_REPORT_0xF5_SIZE); u8 *buf; @@ -1519,14 +1521,15 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev) /* * But the USB interrupt would cause SHANWAN controllers to - * start rumbling non-stop. + * start rumbling non-stop, so skip step 3 for these controllers. */ - if (strcmp(hdev->name, "SHANWAN PS3 GamePad")) { - ret = hid_hw_output_report(hdev, buf, 1); - if (ret < 0) { - hid_info(hdev, "can't set operational mode: step 3, ignoring\n"); - ret = 0; - } + if (sc->quirks & SHANWAN_GAMEPAD) + goto out; + + ret = hid_hw_output_report(hdev, buf, 1); + if (ret < 0) { + hid_info(hdev, "can't set operational mode: step 3, ignoring\n"); + ret = 0; } out: @@ -2811,6 +2814,9 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) if (!strcmp(hdev->name, "FutureMax Dance Mat")) quirks |= FUTUREMAX_DANCE_MAT; + if (!strcmp(hdev->name, "SHANWAN PS3 GamePad")) + quirks |= SHANWAN_GAMEPAD; + sc = devm_kzalloc(&hdev->dev, sizeof(*sc), GFP_KERNEL); if (sc == NULL) { hid_err(hdev, "can't alloc sony descriptor\n"); From patchwork Wed Jan 9 01:18:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongye Yuan X-Patchwork-Id: 10753275 X-Patchwork-Delegate: jikos@jikos.cz 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 2D7DE13BF for ; Wed, 9 Jan 2019 01:18:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19E6128DDC for ; Wed, 9 Jan 2019 01:18:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09DA728DE5; Wed, 9 Jan 2019 01:18:32 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 AEA4728DDC for ; Wed, 9 Jan 2019 01:18:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728854AbfAIBSb (ORCPT ); Tue, 8 Jan 2019 20:18:31 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:40546 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728835AbfAIBSb (ORCPT ); Tue, 8 Jan 2019 20:18:31 -0500 Received: by mail-pl1-f196.google.com with SMTP id u18so2748323plq.7 for ; Tue, 08 Jan 2019 17:18:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/y0mlt16gmxTOJwgnHyvBaONSQ5EQu+h0C2qU/wSqaY=; b=dnTV4QDotyVbXYF6sPvxcyU5oCpBVw+PiK9seklSkihclQorgEJ2abx43EL6LVe9bC xOb0Vjp9oaGjGE7dEtZZE3yHtQV6Y83JHqiDDFLmMZhD9YHXRzvNl1CnnG/DL4C6yp5y PSJHdHc7QEITCPlM8G/WcMX1vbLn4m4C/Kx7ZKQJT7/Z9SLnyfApFdQOQPLU6TI05E+R BmdkjaAYOEXI3Prns524udQs/WxhZZqzZLvkynilUEXeMXphvtpnK2MuQjyNyzgaEHgr oflw+pvf17rJkj/nl/y9bh+UUR7xPQQ/BerpxAMltxhxcXdIuk7fEVGuRTjoL0ojEjFL IfDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/y0mlt16gmxTOJwgnHyvBaONSQ5EQu+h0C2qU/wSqaY=; b=XC80TdepvLJbcArVLIqrjmQUbozF+aFhEzJd6U3Rd5D/C3oIWQ6J/TdmqZRQjqzr6U tXSe6r/05Hmg2Oz4KqEVJvXVA35Lyb8gCb343eCSU1RPkZAaP2TRfdoyR5M+61zQjfNn LoZmyaVgv47j3/840IAanI3Gbz6FQhR+KQUM84liSReMFVrxBqsBvmVOhm1hjEG22M7t 61bdiGxsQWtEw7zGoAeHf78K0PAxoeg7wVxh9dmN3h9zYfqyX4jV4dk9Dg3yRFQe/+/n hfgvMvgsOpuo1+Wyxdq9LvMYx7I+y+7EvMtu1BU6KPyCK5btIwCuI7J1w45I90yaYOJN WgeQ== X-Gm-Message-State: AJcUukcg2YPnzO89D9mrkpGVsle8ozXX9TKWMeruopLUh33WuIyILrCU gdTHAvSrXoGI6OioEOpupydl+Jn2OFo= X-Google-Smtp-Source: ALg8bN4KvhbOTaU4+Vk84vzaMJxiib//yGDfuwYo8hidd7lfFceK1itG0efY72NhoNki1+MNUK60uA== X-Received: by 2002:a17:902:830a:: with SMTP id bd10mr4032771plb.321.1546996710073; Tue, 08 Jan 2019 17:18:30 -0800 (PST) Received: from localhost ([45.77.70.206]) by smtp.gmail.com with ESMTPSA id p2sm97732209pfb.28.2019.01.08.17.18.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Jan 2019 17:18:29 -0800 (PST) From: Hongye Yuan To: linux-input@vger.kernel.org Cc: jikos@kernel.org, hadess@hadess.net, benjamin.tissoires@redhat.com, rydberg@bitmath.org, roderick.colenbrander@sony.com, ao2@ao2.it, Hongye Yuan Subject: [PATCH v4 2/2] HID: sony: Fix SHANWAN PS3 GamePad rumble and led settings support Date: Wed, 9 Jan 2019 09:18:09 +0800 Message-Id: <20190109011809.16542-2-outmatch@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190109011809.16542-1-outmatch@gmail.com> References: <20190109011809.16542-1-outmatch@gmail.com> MIME-Version: 1.0 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 Rumble support on SHANWAN PS3 gamepad is not working when a user program has asked it to. If a HID Output Reports is sent via Control Channel then it will be discard by gamepad, thus rumble motor and led settings in Output Report are ignored. This patch therefore sends HID Output Report via Interrupt Channel to SHANWAN gamepad instead of Control Channel, fixing rumble motor and led settings. Signed-off-by: Hongye Yuan Reviewed-by: Bastien Nocera --- Changes in v4: - Explain what this patch fixes in detail. --- drivers/hid/hid-sony.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index fc82f02bae75..26fae90b931a 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -2100,9 +2100,14 @@ static void sixaxis_send_output_report(struct sony_sc *sc) } } - hid_hw_raw_request(sc->hdev, report->report_id, (u8 *)report, - sizeof(struct sixaxis_output_report), - HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); + /* SHANWAN controllers require output reports via intr channel */ + if (sc->quirks & SHANWAN_GAMEPAD) + hid_hw_output_report(sc->hdev, (u8 *)report, + sizeof(struct sixaxis_output_report)); + else + hid_hw_raw_request(sc->hdev, report->report_id, (u8 *)report, + sizeof(struct sixaxis_output_report), + HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); } static void dualshock4_send_output_report(struct sony_sc *sc)