From patchwork Sat Aug 6 21:30:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Gutman X-Patchwork-Id: 9266061 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 9AC9260760 for ; Sat, 6 Aug 2016 21:30:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D4E627FAC for ; Sat, 6 Aug 2016 21:30:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 820DC283EF; Sat, 6 Aug 2016 21:30:35 +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 2FCB327FAC for ; Sat, 6 Aug 2016 21:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751724AbcHFVae (ORCPT ); Sat, 6 Aug 2016 17:30:34 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:36106 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751110AbcHFVad (ORCPT ); Sat, 6 Aug 2016 17:30:33 -0400 Received: by mail-pa0-f68.google.com with SMTP id ez1so21353264pab.3 for ; Sat, 06 Aug 2016 14:30:33 -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=cgI2w7SOU9XYhXyo2LN1iVN6bvRl3fpkbMWldMqrM2U=; b=x1zlz3MxLomQ3+5wTI399ngiqtlEyG0lOlfswjaKq+GZfDJ/AmbeLvcPNeMQdvFEij 8HTT4xG5qyFkLOK3onCTqc4//p8Trbwdh98CicPgBnw6s/tW7Ip8gVelcs60Xp0mF75B ejJiH1nrMcD82OLqceeE0M4MhijJB4g2poYh/SWisfzufLbEcdgq0TUJshnx1XnYOv3T xcbY7wVJQGHulrbbmQS9lVKRBZkpOoLhLfGab/5d2QBSOKFwhDGjxDhyCFQ6c3Vg3OyY DrKzZod0O+TjNvkfG3EgaGKllbjtEHNDsDFsfHcPLX1uMTMPT4X3a6ehe1Z66bK6x1w9 Qbng== 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=cgI2w7SOU9XYhXyo2LN1iVN6bvRl3fpkbMWldMqrM2U=; b=Ja6rn7XLNCl3wwEAMWbl57z/IV+OHLYjiJ2W4UVP+K2uybK8JOwaynsWGJWg/bxbG5 OZo397ioUpeXJNtGobI1HWCjSXUCprG8cAw1hWb+4sNZ7fUTgm2EjSQyDEXlHV4uVy8/ GZoWmJ/eJM9FIAV/OUqsVmDBnpvpt0pNIkY7e1qFog9kxwZYo927I2PGuYXy4exb+NzK wlazrOn4fGe954MX+jBrqqg6KX+213g+m/snQR0weeaDV506+TtlSG416o5bjqWflT85 3tOWzN8ogYckkDc5MefHihEaI8KkuqBzsDGhMgEdOpj934dLZJeVvdh01h0W3w62+kRm RhVQ== X-Gm-Message-State: AEkooutExQo+ldv922EwTAsVsS6EJvLv66wGOhyr2dJpoVJrq/Ycu0Nz3Imz2RJYilnbnA== X-Received: by 10.66.220.194 with SMTP id py2mr94107581pac.77.1470519033048; Sat, 06 Aug 2016 14:30:33 -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 o2sm37266645pfg.10.2016.08.06.14.30.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 06 Aug 2016 14:30:32 -0700 (PDT) From: Cameron Gutman To: dmitry.torokhov@gmail.com, rojtberg@gmail.com Cc: linux-input@vger.kernel.org Subject: [PATCH 2/3] Input: xpad - fix One S pad disconnecting when not opened Date: Sat, 6 Aug 2016 14:30:29 -0700 Message-Id: <1470519030-23051-3-git-send-email-aicommander@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470519030-23051-1-git-send-email-aicommander@gmail.com> References: <1470519030-23051-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 controller will hang after ~2 seconds of input if it isn't being read by the OS. After another ~5 seconds the controller will reset itself and reconnect to the host. To avoid this, we'll just read Xbox One controllers all the time, like we do for Xbox 360 wireless adapters. Signed-off-by: Cameron Gutman --- drivers/input/joystick/xpad.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 19886db..6a3a775 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1381,7 +1381,7 @@ static int xpad_init_input(struct usb_xpad *xpad) input_set_drvdata(input_dev, xpad); - if (xpad->xtype != XTYPE_XBOX360W) { + if (xpad->xtype != XTYPE_XBOX360W && xpad->xtype != XTYPE_XBOXONE) { input_dev->open = xpad_open; input_dev->close = xpad_close; } @@ -1573,9 +1573,20 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id error = xpad_init_input(xpad); if (error) goto err_deinit_output; + + /* Newer Xbox One controllers will hang and disconnect if + * not initialized and read from when receiving user input. + */ + if (xpad->xtype == XTYPE_XBOXONE) { + error = xpad_start_input(xpad); + if (error) + goto err_deinit_input; + } } return 0; +err_deinit_input: + xpad_deinit_input(xpad); err_deinit_output: xpad_deinit_output(xpad); err_free_in_urb: @@ -1593,6 +1604,8 @@ static void xpad_disconnect(struct usb_interface *intf) if (xpad->xtype == XTYPE_XBOX360W) xpad360w_stop_input(xpad); + else if (xpad->xtype == XTYPE_XBOXONE) + xpad_stop_input(xpad); xpad_deinit_input(xpad); @@ -1636,7 +1649,7 @@ static int xpad_suspend(struct usb_interface *intf, pm_message_t message) xpad360w_poweroff_controller(xpad); } else { mutex_lock(&input->mutex); - if (input->users) + if (input->users || xpad->xtype == XTYPE_XBOXONE) xpad_stop_input(xpad); mutex_unlock(&input->mutex); } @@ -1656,7 +1669,7 @@ static int xpad_resume(struct usb_interface *intf) retval = xpad360w_start_input(xpad); } else { mutex_lock(&input->mutex); - if (input->users) + if (input->users || xpad->xtype == XTYPE_XBOXONE) retval = xpad_start_input(xpad); mutex_unlock(&input->mutex); }