From patchwork Fri Jul 14 03:58:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Gutman X-Patchwork-Id: 9839871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A10FA60212 for ; Fri, 14 Jul 2017 03:59:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E47A28727 for ; Fri, 14 Jul 2017 03:59:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92ED62874F; Fri, 14 Jul 2017 03:59:02 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 DAFB62874B for ; Fri, 14 Jul 2017 03:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753350AbdGND7B (ORCPT ); Thu, 13 Jul 2017 23:59:01 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33785 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753059AbdGND7A (ORCPT ); Thu, 13 Jul 2017 23:59:00 -0400 Received: by mail-pg0-f68.google.com with SMTP id u62so9110923pgb.0 for ; Thu, 13 Jul 2017 20:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+Zuwb/jQ4zAacZlB4y3UdHkPrVCoZEHqLGQm5lmeB/U=; b=NFlZqBEHPHqISJ/55ArXXhGzamHxKZmO3ewpmoIszGau21V1iHH90hIXZz+26cZkq1 l2V5qi4+Y0JIAespQi6NyDijPyLDNoWz/D8thMKeIlDN912SpxeCyeEmAi7KvrXCFWDr tsxMG1rONjG45+ShWujmWE0nQPJ+qPBSL3hHNHgbrv/N2hHtXF6o0wSUMQgovBeoCSY5 Gb9Jk01vGdKuJ9zjDM4cVQN5jcL0bM7PXJS5J5YDLsXX+LZZm4F18A9PJJjmBMKCRiz7 iZD8hq6DOH8PvHpIBsub/UAtpXFwa4eRRSILvQ1LY2xIVbETD+tDO6Z0LzGI7n0Yq47G gDAw== 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; bh=+Zuwb/jQ4zAacZlB4y3UdHkPrVCoZEHqLGQm5lmeB/U=; b=SILOndojW0ZpV7at0o8/ILimIwiqyp4c+qxBgCapsHUMSG0fVSO6JW2awFuaMrtVja 96Z6+soSbu4weEcs1wxRnD8XIKXP981XF+FUhZlJpsoe0DRLvK6z5pctv8hkdLl7sl6k NKg7h49cs9zjg7WDh25Rd4E69vYy8XnPtXml9mgIGViIxBlrc3QtFegzI/fz2b4VrQQl T5ebLY0NRWnVqgaywPPjnVlrmdJaQZGnnswXJ5BQUYBw9M8jZ855JUNRBx/B31T9dQ1W YIjp1+wcCxQhw7tsEm3nUZjrnyBJkLfEkoAC0yk8BxGmAgWjgk5C2hcTnADM+OZIMiLn HjAw== X-Gm-Message-State: AIVw110MgnlM4znlJSNq0WqCH/JdG1IaV0hW5HzV4KtqvoX3MHo71i3y Xxwj14TG8W5YkS4zjfA= X-Received: by 10.84.169.67 with SMTP id g61mr13549939plb.155.1500004739764; Thu, 13 Jul 2017 20:58:59 -0700 (PDT) Received: from JUPITER.localdomain ([174.127.240.150]) by smtp.gmail.com with ESMTPSA id 75sm13557851pfk.84.2017.07.13.20.58.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 20:58:58 -0700 (PDT) From: Cameron Gutman To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, rojtberg@gmail.com Cc: kyleabeauchamp@gmail.com, Cameron Gutman Subject: [PATCH] Input: xpad - fix PowerA init quirk for some gamepad models Date: Thu, 13 Jul 2017 20:58:38 -0700 Message-Id: <20170714035838.6053-1-aicommander@gmail.com> X-Mailer: git-send-email 2.13.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 The PowerA gamepad initialization quirk worked with the PowerA wired gamepad I had around (0x24c6:0x543a), but a user reported [0] that it didn't work for him, even though our gamepads shared the same vendor and product IDs. When I initially implemented the PowerA quirk, I wanted to avoid actually triggering the rumble action during init. My tests showed that my gamepad would work correctly even if it received a rumble of 0 intensity, so that's what I went with. Unfortunately, this apparently isn't true for all models (perhaps a firmware difference?). This non-working gamepad seems to require the real magic rumble packet that the Microsoft driver sends, which actually vibrates the gamepad. To counteract this effect, I still send the old zero-rumble PowerA quirk packet which cancels the rumble effect before the motors can spin up enough to vibrate. [0]: https://github.com/paroj/xpad/issues/48#issuecomment-313904867 Reported-by: Kyle Beauchamp Tested-by: Kyle Beauchamp Fixes: 81093c9848a7 ("Input: xpad - support some quirky Xbox One pads") Cc: stable@vger.kernel.org # v4.12 Signed-off-by: Cameron Gutman --- drivers/input/joystick/xpad.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 298a6ba51411..ca0e19ae7a90 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -476,10 +476,21 @@ static const u8 xboxone_hori_init[] = { }; /* - * A rumble packet is required for some PowerA pads to start + * A specific rumble packet is required for some PowerA pads to start * sending input reports. One of those pads is (0x24c6:0x543a). */ -static const u8 xboxone_zerorumble_init[] = { +static const u8 xboxone_rumblebegin_init[] = { + 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, + 0x1D, 0x1D, 0xFF, 0x00, 0x00 +}; + +/* + * A rumble packet with zero FF intensity will immediately + * terminate the rumbling required to init PowerA pads. + * This should happen fast enough that the motors don't + * spin up to enough speed to actually vibrate the gamepad. + */ +static const u8 xboxone_rumbleend_init[] = { 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -494,9 +505,12 @@ static const struct xboxone_init_packet xboxone_init_packets[] = { XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init), XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init), XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init), - XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_zerorumble_init), - XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_zerorumble_init), - XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_zerorumble_init), + XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumblebegin_init), + XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumblebegin_init), + XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumblebegin_init), + XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_rumbleend_init), + XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_rumbleend_init), + XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumbleend_init), }; struct xpad_output_packet {