From patchwork Sat Dec 29 02:02:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongye Yuan X-Patchwork-Id: 10744725 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 182FB6C5 for ; Sat, 29 Dec 2018 02:02:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06A3028ABC for ; Sat, 29 Dec 2018 02:02:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE2D028AFD; Sat, 29 Dec 2018 02:02:38 +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 E1A3128ABC for ; Sat, 29 Dec 2018 02:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726876AbeL2CCh (ORCPT ); Fri, 28 Dec 2018 21:02:37 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46064 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbeL2CCh (ORCPT ); Fri, 28 Dec 2018 21:02:37 -0500 Received: by mail-pf1-f195.google.com with SMTP id g62so11108572pfd.12 for ; Fri, 28 Dec 2018 18:02:36 -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=aQRJ9qLh9+e+9D+1u5mxoajVnxWA5eOyuHXviGqAhHw=; b=gNUaI/kDPoTHgDq3rI7bSr96UcPTkew584DvsMI0msdoBV3u5BkG+cV38lQikTIgqX ZWa64ymWRcvaNoqP42Ldn3iTX0960O/IAtPSYGPB3w8HWb1+7N2xd3/EniiqZGOfisJs fzrjOeVSfXmoWnHUN81rtD3aLZoODdS6GalluGyhP8lKi4Hnf3YvWdq2HMkMPn8269uf q/IDgvX/K5F+7iNPkTnqxmyqzppU8CPgGLyB/KfxBf8eNXBNl2s9lYn1fdTcDAjOGxQF M59sD+Rh2/tmSQx86Mk7VJRX5ETmcUqLpPRBj78PwXoc23cEfgAq7UIhpcFa60g2SHKB zw1A== 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=aQRJ9qLh9+e+9D+1u5mxoajVnxWA5eOyuHXviGqAhHw=; b=C/+Y7FYsYigDZxDB4+DJKOzDI7FjyiFqEG+nWrdVsoTnaIYhmBjLeI4yrZQnc0g4rw HP3J7eWzUZ9DQWRVNOCf81nwhbVR+fQ2oUBz5QFWBFF080Ol9i5HQkUGqRGA3eHoI3dK 2KyqFiSem9cJLr5XvWh/64SECVsz8JBLUOk1sFv3A9tbadNu/HAfGMGshK1gqXKkvZD+ 3mkcxzrm6rev2ba5isc+X7HkXSbrAJ00vyD6xFJ4Nu7fayfgnvBpCtdiOmu+6X3HiAdQ b55KNJQX5lrYJ+KFNK6zPUKVyGorTtd0fTzzumZNiQjPPprV3+Pv4D8U3ZWtTl7NzxzA g9cw== X-Gm-Message-State: AA+aEWZXOwSZzoA+keKvp018kSH1wMnR3gPbBES1+brRvP3kCjMJuGul 3RNBSP9RnFS9UZy50BRRS808z12Sg3A= X-Google-Smtp-Source: AFSGD/XyrPdfOuv1ILtccJeLWRqTJ5ljALNizBckFVXisHPUtqWxsALjGjwsNiVYIelqHp/VUX7QRA== X-Received: by 2002:a62:3305:: with SMTP id z5mr30730475pfz.112.1546048955452; Fri, 28 Dec 2018 18:02:35 -0800 (PST) Received: from localhost ([45.77.70.206]) by smtp.gmail.com with ESMTPSA id k24sm60673011pfj.13.2018.12.28.18.02.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Dec 2018 18:02:34 -0800 (PST) From: Hongye Yuan To: linux-input@vger.kernel.org Cc: jikos@kernel.org, benjamin.tissoires@redhat.com, rydberg@bitmath.org, roderick.colenbrander@sony.com, ao2@ao2.it, Hongye Yuan Subject: [PATCH v2] HID: sony: Fix SHANWAN PS3 GamePad rumbling on USB again Date: Sat, 29 Dec 2018 10:02:28 +0800 Message-Id: <20181229020228.29383-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 - SHANWAN DS3 clone gamepad requires HID Output Reports via Interrupt EP. - Added a quirk for SHANWAN PS3 GamePad. Signed-off-by: Hongye Yuan --- Changes in V2: - Tidy up commit message and source line indention - Fixed inverted logic in sixaxis_set_operational_usb() --- drivers/hid/hid-sony.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 9671a4bad643..26fae90b931a 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: @@ -2097,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) @@ -2811,6 +2819,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");