From patchwork Tue Aug 16 04:10:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Gutman X-Patchwork-Id: 9282579 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 BB27E6086A for ; Tue, 16 Aug 2016 04:10:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A898A28B9F for ; Tue, 16 Aug 2016 04:10:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A1AC28BB5; Tue, 16 Aug 2016 04:10:23 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 4AE9E28BB2 for ; Tue, 16 Aug 2016 04:10:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751532AbcHPEKW (ORCPT ); Tue, 16 Aug 2016 00:10:22 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33107 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751563AbcHPEKV (ORCPT ); Tue, 16 Aug 2016 00:10:21 -0400 Received: by mail-pf0-f193.google.com with SMTP id i6so4772320pfe.0 for ; Mon, 15 Aug 2016 21:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zDB58z7wNk38jnqirngoN8HL2UDEd/upty6XcdRQlXk=; b=Gy2gZvy7IxlPk1laPEAHfO0wF9YD5Sys4FutxY7Ond07xhVVWAgY3CTRLpGcIp+UeB M61pwKJHh6HqECQZNRuStLOdhiRZFMsRUf2Prl2duZA40k3DVbV0Ex8uoQvc/RuFeL4x wCjULhuds35DjXkfKkkaqtagtTnRTAw73zReV6x15e3P9vjRPg6Nmcav2URZX2K6L7tl y0en1oN8NuQFhR34wHkkgWvro3dyQ495ND/8li8LwJCR9vnyhIRFqsFXaZ7T32/p3yAY qMYFoaC8T7aeIneFfwgSbk0DWr2b6h2MQHWXskEjFqbqDHT7IXMlHwYyr8EGhtd8Qz/t uXBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zDB58z7wNk38jnqirngoN8HL2UDEd/upty6XcdRQlXk=; b=mmvVq/OW24y+v988xcukgpAPtoQ5Lk+lIq7p+H6W/ak5gf9fmjUl7RtaANZhaOnEX2 VJ0P9up+EiaDI04pea1i2GBeKyDYjj3DO8lVbIcejcyapClK/gbf2sUy/Ur/faKJ22EW WpP8Cw6VVZukaU0jzjKM5Z4tPnKZYMvySI7GmQt0wN3R6Tfj4nv0EFJAd7NoZMpQJ3yg Ar7s1b6H+UtTufbF7qzyiOK1Zl7zsQ9P96WIlmow1gZqflNMQOr2os9UPyr3FGBWnFuI lspmU19f4nA4K7ao4JQb+ol62gMwzuOrQSYsImmHlk3IeCfXtpTrEKE2y1qp+pXDorQh IH6g== X-Gm-Message-State: AEkooutKM0xqVb12yjmg94qY9/LRi1SgcuqNBCUf7q8O3buTPST7oS9ZoZCOtgUspPLGLQ== X-Received: by 10.98.27.11 with SMTP id b11mr801782pfb.111.1471320620553; Mon, 15 Aug 2016 21:10:20 -0700 (PDT) Received: from localhost.localdomain (c-24-16-1-64.hsd1.wa.comcast.net. [24.16.1.64]) by smtp.gmail.com with ESMTPSA id 15sm34819577pfz.36.2016.08.15.21.10.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Aug 2016 21:10:20 -0700 (PDT) From: Cameron Gutman To: dmitry.torokhov@gmail.com, rojtberg@gmail.com Cc: linux-input@vger.kernel.org Subject: [PATCH v2 3/4] Input: xpad - fix stuck mode button on Xbox One S pad Date: Mon, 15 Aug 2016 21:10:15 -0700 Message-Id: <1471320616-13110-4-git-send-email-aicommander@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471320616-13110-1-git-send-email-aicommander@gmail.com> References: <1471320616-13110-1-git-send-email-aicommander@gmail.com> 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 Xbox One S requires an ack to its mode button report otherwise it continuously retransmits the report. This makes the mode button appear to be stuck down after it is pressed for the first time. Signed-off-by: Cameron Gutman --- drivers/input/joystick/xpad.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 3577253..42723ba 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -389,6 +389,7 @@ struct usb_xpad { static int xpad_init_input(struct usb_xpad *xpad); static void xpad_deinit_input(struct usb_xpad *xpad); +static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num); /* * xpad_process_packet @@ -699,6 +700,14 @@ static void xpadone_process_packet(struct usb_xpad *xpad, break; case 0x07: + /* + * The Xbox One S controller requires these reports to be + * acked otherwise it continues sending them forever and + * won't report further mode button events. + */ + if (data[1] == 0x30) + xpadone_ack_mode_report(xpad, data[2]); + /* the xbox button has its own special report */ input_report_key(dev, BTN_MODE, data[4] & 0x01); input_sync(dev); @@ -974,6 +983,30 @@ static int xpad_start_xbox_one(struct usb_xpad *xpad) return retval; } +static void xpadone_ack_mode_report(struct usb_xpad *xpad, u8 seq_num) +{ + unsigned long flags; + struct xpad_output_packet *packet = + &xpad->out_packets[XPAD_OUT_CMD_IDX]; + static const u8 mode_report_ack[] = { + 0x01, 0x20, 0x00, 0x09, 0x00, 0x07, 0x20, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + spin_lock_irqsave(&xpad->odata_lock, flags); + + packet->len = sizeof(mode_report_ack); + memcpy(packet->data, mode_report_ack, packet->len); + packet->data[2] = seq_num; + packet->pending = true; + + /* Reset the sequence so we send out the ack now */ + xpad->last_out_packet = -1; + xpad_try_sending_next_out_packet(xpad); + + spin_unlock_irqrestore(&xpad->odata_lock, flags); +} + #ifdef CONFIG_JOYSTICK_XPAD_FF static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) {