From patchwork Sun Dec 30 10:56:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongye Yuan X-Patchwork-Id: 10745067 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 B3BBE13BF for ; Sun, 30 Dec 2018 10:56:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3A26289DD for ; Sun, 30 Dec 2018 10:56:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 969F928B37; Sun, 30 Dec 2018 10:56:31 +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 3FB6D289DD for ; Sun, 30 Dec 2018 10:56:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726208AbeL3K4a (ORCPT ); Sun, 30 Dec 2018 05:56:30 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39887 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726063AbeL3K4a (ORCPT ); Sun, 30 Dec 2018 05:56:30 -0500 Received: by mail-pl1-f196.google.com with SMTP id 101so11739527pld.6 for ; Sun, 30 Dec 2018 02:56:29 -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=kaYQRVYDzRHQ4mUBTYvqrYagKSfoRCWoS8qtH8PVMN0=; b=TWA3rWfeK9fYQnCSzUSoqG8WfJjUhQ1YU2BB73o1oaitTk3bEjX29gX5WO8GChMQjR usqE6iotloNHnZjxR4BC7avitONfXWBlv0XiO9T1Xtd7H6Hu9yqWSjhok0aJphNXzl8S uYHb1ECpgb7o6wn5hmdzvLvT1P0efF4jNkBeSYIBvDSdvYv8YfcfFfK4taoxCV6bBNuD rSF67cox335QrRYQf+jRbs+qNGDo4UZxmK/Ek4ExeUnlomU4ybnAzY5MzchlXSMyc9DP T4haefyQqYMZX2jWVSkWr2XDRKSTPBLE4ZOIVGs7NOKhmzy/+YpLOc2VGVDtVZDY0dh/ Uy8w== 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=kaYQRVYDzRHQ4mUBTYvqrYagKSfoRCWoS8qtH8PVMN0=; b=ncsxJZIpLIuxDc+skGTWQlzBWrUlDrc4rBdIY9MHeZia3cZ2tzYNzfdq9cBZCe0fHz PVuH1Yarla8QP4IVSq5D7ajS8jzGKriO5rZgwd3vRqXFfdMp3MnfAfaFGkcb5kx5GWUJ 8ApShzafBz2kSjQKUNmW03NGrPNzyCa/RtPwql/Grkm+bDaMyaXvGmblkYlORMW7ce3P ejv+0oZvmcG2lXc2jUA+DQ//EWHNBaeS+Nbvs1+qY940Q79MVOi3DqvMkVZ+0xZRaT+z 5j/aIX6VuU3w7+uShra3efGJmcf8KeUCBASC2GV5+wfzLcfPlwzZtfOivjMKNHJ0N+Qz CScg== X-Gm-Message-State: AJcUukebhYLmFtq399JLtDdLSaUx/CwzZxOTWZUdjuiVrhtvUIa7Waz8 RFluTZUx7cq6CdYKdnodaJ2MiEQQpsE= X-Google-Smtp-Source: ALg8bN5XNVkdlccf46djR3976ObmhT0WxSTnE+A8UzIgpOAr6Udodse1jP9Ls64dp7ZUZm+BoSZB0A== X-Received: by 2002:a17:902:7481:: with SMTP id h1mr34179882pll.341.1546167388800; Sun, 30 Dec 2018 02:56:28 -0800 (PST) Received: from localhost (104.224.165.23.16clouds.com. [104.224.165.23]) by smtp.gmail.com with ESMTPSA id i193sm72529606pgc.22.2018.12.30.02.56.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Dec 2018 02:56:28 -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, outmatch@gmail.com Subject: [PATCH v3 1/2] HID: sony: add a quirk for SHANWAN PS3 GamePad. Date: Sun, 30 Dec 2018 18:56:17 +0800 Message-Id: <20181230105618.11867-2-outmatch@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181230105618.11867-1-outmatch@gmail.com> References: <20181230105618.11867-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 - Add a quirk for SHANWAN PS3 GamePad controller. - Tiny up SHANWAN controller logic to skip output reports. Signed-off-by: Hongye Yuan --- 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");