Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2567931imu; Thu, 29 Nov 2018 07:02:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/X5exeQRjLIdrpLg6dIp3WiTWxhauSQfM3GCNQQRquoE2T2iSIwBq/rQhvcQ+9OGmlzuw/4 X-Received: by 2002:a63:fd53:: with SMTP id m19mr338341pgj.340.1543503729586; Thu, 29 Nov 2018 07:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543503729; cv=none; d=google.com; s=arc-20160816; b=D1XxPLblM32TNIbxkofcSM5CixSUyKMa59qxSirqkxlxcYaUrsKaBpR9kuAi2zKE+5 gmaSCDa0ZnncPS4JmuCJWUfEtosJgfDhDps0RMvQvCLsOWMkbj4iPzG9ExdJIe860FQT 4aeTg888/97tX0aFDbIHZSm3nMXwGjb7uJB28tVfSU1XXWvytox1nO3a0iGC38bdTftK 6QNlPWAn86J8CpzxoJftaGFMvObiU/uXpQMLW+x+rv/DrEDK8J28WdgZiSMiFBwr0DMs uCkcJg4E65iU1X1SQ91cKjC2AodQ5k31JgJoF+9+lpJ0fvN6ANSYx3CI5PC0XUpneC8p 2koQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7ajX1uanwSeSfugiH1kGd7DhD5Lqe7x0kGifNy3JK0Q=; b=TmW8X/t5dD5a3Brwtho8D6igAQGzJVychkMpXOM7sUQ+jqf6Is/eCkI+qfCLryQeDR UHDSYnTzQfczPKa5if7lkwStyx25I0qJP346YjN7rZpyfgm5uZ8IAjrYbgWPPjH7qImT 9+aC0P5IdEshlLrexlQ/3WapSH4AMMSWHapRnGLTrOHJBKXLP3SteuRLgkBFXD2Xr0AT faAtudcTQhe4cqcs7Xd0q9ZYPxAuuRjmNfvYRq8SinX8gbeRdhWfxb8OynmK+yR6wIdj mTCrr3hYXM1Euq4ULHEvgeVSzJwY8QKNWbjBOxygAp06FFpYPqGOre8a2L+pzMM5Anto b5bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sxjEneS4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t136si2503924pfc.262.2018.11.29.07.01.29; Thu, 29 Nov 2018 07:02:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sxjEneS4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730815AbeK3BYL (ORCPT + 99 others); Thu, 29 Nov 2018 20:24:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:46758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728756AbeK3BYK (ORCPT ); Thu, 29 Nov 2018 20:24:10 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C5097205C9; Thu, 29 Nov 2018 14:18:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501119; bh=GhqmWHPwxnuSdMozcE6rVuzOi/JeJX6gAHv3TxzsLag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sxjEneS4MCgbsZUx00sfdeIZFyLeb7qFNuJVl/5hC3f9O7HNwUK0RRpdxaTUFzf11 HxWxaS/pMrwjBx+iK9g0x5ODwCRUV9FVX1UVmXmeotSdB1uthlw7ysBmYJu1M+0Vxp UddeMgdLBfIQFLkQIp3X+8TwNULsX/ar6bpx93Vg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cameron Gutman , Dmitry Torokhov , Sasha Levin Subject: [PATCH 4.4 51/86] Input: xpad - fix stuck mode button on Xbox One S pad Date: Thu, 29 Nov 2018 15:12:16 +0100 Message-Id: <20181129140114.455748550@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140109.832117862@linuxfoundation.org> References: <20181129140109.832117862@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 57b8443d3e5bd046a519ff714ca31c64c7f04309 ] 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 Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- 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 dd0503562b1c..14da79ead653 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -391,6 +391,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 @@ -624,6 +625,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; @@ -956,6 +965,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) { -- 2.17.1