From patchwork Tue Aug 16 04:10:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Gutman X-Patchwork-Id: 9282577 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 7D9BD607FD 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 6B79A28B9F for ; Tue, 16 Aug 2016 04:10:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6090428BB6; 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 09AA028B9F for ; Tue, 16 Aug 2016 04:10:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751581AbcHPEKV (ORCPT ); Tue, 16 Aug 2016 00:10:21 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33104 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532AbcHPEKU (ORCPT ); Tue, 16 Aug 2016 00:10:20 -0400 Received: by mail-pf0-f194.google.com with SMTP id i6so4772296pfe.0 for ; Mon, 15 Aug 2016 21:10:20 -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=KMJS2FDs8EDnHyeSUohk/xDQFMerv4/HA1eFRxbI9Ig=; b=uElKIkrTkOEerhP8Bhtere+R/7KsCOyoXGuQtCTdsh63DspD1CX7484So7tqP2RDik yvui3TCtz9apj52pyvWpgjjeCqI/0+RjEL1262jRbjNE9xuoz6YnNVEFGf0xy3J6BDql A5PzQg6eIo+NvoX4h8u2O83Wb0Kkofyc74JLbKNRQ9Oh84VLjBFqmQgwaHJEvQqyZqgZ DB84vBJhgWKikpb/feL9gQU1AwxRB6HxsVSzvY4+rV8LjIPjaHw1WWEaGl96/7FwqpUq JTJnqsHPryBJTu08X5ZDTlX9MTkVRIo5FRmZeLxnOf1UrMEYgyPi4m1kRKZx6HixmeYC mVWw== 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=KMJS2FDs8EDnHyeSUohk/xDQFMerv4/HA1eFRxbI9Ig=; b=KLvXurIJU5TREf7bYWtgSeV87vMz5MAO2JG8Ikk43PssRO1x1LzyhBz8uyMwMQmgon 8Lkk7l+nI03XoSvV3aftVc3hQgy6IBFyNzZQZhI1shH4/DE10phAY5aD2tW8LxvI3r+4 E5B9wTLC4So8B3tYmxYY+4liqM+EGx+TiIwJOzc0H/1n8Xk8hYGiW04OI9SKvt/jyJ1a /mz0oVqzzdwnsb5Q2oQyL8bctc16d/q1gxAxc9hUJpvueNC1jg+rwt23IzpmHqcJL7xj +KYiJheLJVnwxscN8IIkLVIKCqjXG/cmcUaNXEFaCIpH6LX3T5FkV9j8MOuQMsHOVAIa aVnQ== X-Gm-Message-State: AEkoouvtZOEYQ8aS3XoS3p6Po5rAN41mvfDQRCbmwgWuWU09E2p+A54USFpnJCb/mTgOZQ== X-Received: by 10.98.192.12 with SMTP id x12mr135920pff.54.1471320619762; Mon, 15 Aug 2016 21:10:19 -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:19 -0700 (PDT) From: Cameron Gutman To: dmitry.torokhov@gmail.com, rojtberg@gmail.com Cc: linux-input@vger.kernel.org Subject: [PATCH v2 2/4] Input: xpad - fix One S pad disconnecting when not opened Date: Mon, 15 Aug 2016 21:10:14 -0700 Message-Id: <1471320616-13110-3-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 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 | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 19886db..3577253 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,21 @@ 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 +1605,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 +1650,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 +1670,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); }