From patchwork Sun Feb 5 00:30:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Gutman X-Patchwork-Id: 9555803 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 9102660236 for ; Sun, 5 Feb 2017 00:32:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E106269DA for ; Sun, 5 Feb 2017 00:32:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72E3926BE9; Sun, 5 Feb 2017 00:32: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=unavailable 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 2C058269DA for ; Sun, 5 Feb 2017 00:32:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751918AbdBEAbs (ORCPT ); Sat, 4 Feb 2017 19:31:48 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35197 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751821AbdBEAbq (ORCPT ); Sat, 4 Feb 2017 19:31:46 -0500 Received: by mail-pg0-f68.google.com with SMTP id 204so5458962pge.2; Sat, 04 Feb 2017 16:31:46 -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; bh=wkmjxjLoqSBtBmnODJcVjOMknlc/0idDkyo47YnftaA=; b=NUAv0nkjfJyvpJ1NdDXIyTavQofXzLe5FMY/BL0qoXw6Rc8V8P04CStaFnBAFMB8nk 3warcTUAgGEBMDnZ7G8zKIcJ021q+S1ozIKsrOE/the43T9cBq3YCp5PYGBB/oMEfsnI SYBFrX8IaLdC2ue2uGd6sI9p11mywkNJCd896OHXH5B9hPokQ/VZkCrp0MwZZoPy/RFX Pk+SMhrmklruEVxOvTiafK3zFOS8xsprNxli99z6oCwpiipE3PHjUHnoUoNNyP/irnUX COsAa/4uYe7lVjqRKYF3veCqFsJ7zgPs4S8L+yVkODjtK2ekLjYbRWfDtnGjxJHivD6j Rv6w== 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; bh=wkmjxjLoqSBtBmnODJcVjOMknlc/0idDkyo47YnftaA=; b=cuMySa+y2EGVECWsGTBOUakw3nyzYcNaRMkccvVcOUvVal10H/JKrGuBeCV0SdYRjZ tdOs1Y6vN5BwXkAOX/Ks8dIRZAvMwA3DRj0W2o5+p92fVS3+6pO/NOSitmL9/JTQZNl8 CfBj9YWRnXiy5o+pgJegb6rLnJOCU2bxr+NunklpIllMMqkLuupHC4bHjlXUifZ1EaYX LEvdqM7riWW0ILSzIvCJu/Ofb/4ks+2A0Ua2I/wz90Wg7tyNt65SdIME2d/feq9sCsos K5yktzEWWArcTwg6cEhSrGpmZlLkJnkDsefCqSr/F8Jq5FPsU+lgSeX/Yy2tEHonOt3p thkg== X-Gm-Message-State: AIkVDXLVuyJY7ftn1VxUdwXzsYFl/SJ8JzTxLUN7K64PNKEkcbtd70Tpev1zhV5v3jH6bQ== X-Received: by 10.84.211.137 with SMTP id c9mr6893186pli.8.1486254700914; Sat, 04 Feb 2017 16:31:40 -0800 (PST) Received: from localhost.localdomain ([174.127.240.168]) by smtp.gmail.com with ESMTPSA id s8sm77744303pfj.30.2017.02.04.16.31.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Feb 2017 16:31:40 -0800 (PST) From: Cameron Gutman To: dmitry.torokhov@gmail.com, rojtberg@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Cameron Gutman Subject: [PATCH 5/5] Input: xpad - fix stuck mode button on Xbox One S pad Date: Sat, 4 Feb 2017 16:30:02 -0800 Message-Id: <20170205003002.28160-6-aicommander@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170205003002.28160-1-aicommander@gmail.com> References: <20170205003002.28160-1-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 1179266..eb01c54 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -414,6 +414,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 @@ -647,6 +648,14 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char /* the xbox button has its own special report */ if (data[0] == 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]); + input_report_key(dev, BTN_MODE, data[4] & 0x01); input_sync(dev); return; @@ -983,6 +992,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) {