From patchwork Sun Jan 8 08:14:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Gutman X-Patchwork-Id: 9503327 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 B1DAE601EB for ; Sun, 8 Jan 2017 08:14:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DBE52837F for ; Sun, 8 Jan 2017 08:14:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69B66283C2; Sun, 8 Jan 2017 08:14:28 +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=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 1CD2B2837F for ; Sun, 8 Jan 2017 08:14:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752246AbdAHIOW (ORCPT ); Sun, 8 Jan 2017 03:14:22 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:34809 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750747AbdAHIOW (ORCPT ); Sun, 8 Jan 2017 03:14:22 -0500 Received: by mail-it0-f67.google.com with SMTP id q186so6296998itb.1 for ; Sun, 08 Jan 2017 00:14:21 -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; bh=v9gdPfG5V9+nVVMZmj3EzMj3aMUAFZXWHOE/pc858FU=; b=b+/ohdvQEU4A2+TN1tH6s01ED99daq3dFKodsdeSMLIGoL5O+wrNOdWS/gxZIKsUZN R/+Dhx4srHRmYccDOd6RLuSsWg4kfx6F3AOEIW0GWCbpXt3hLEMmVScWLbrgtKjksCWE /TS0TsYMn32NjR2eupg9HfMDjHC5k6ZMXJdPpxj5sUQRJOMnrv6jwVKcWlpRu+pilBu6 9boNRWebrc6ygYVU1RSSQKBH+J65h0kVfCvagWYmFGDeMvYbHjavTcDVzAmQO8zuS/2m ajAtYDUTK0C9ElHouaAiJp5h9vekMgDjlYsRlM0cE27ld/2ZOg5Lz/+FdT44F/V6GazM 9lPg== 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; bh=v9gdPfG5V9+nVVMZmj3EzMj3aMUAFZXWHOE/pc858FU=; b=ooe2+Yjjl9jqgFUawyzIwByal+lyY2VVH5S94vZgyZCrUka07hPhoQc8RRu5HOjwtR /B17WzZoUFvFK7seJ0OAWAmq6L/fGMIVK59tIBjNA7ECvpi5SBMUk17VoTCdx2ZjXvBM HFS5qDE2vzzXs37c/8Fbr5z0khC9Isu+9z3aYc9Q9hTFQe3qEO8ddyAKH80Q/ow1yW6B 5UzgX55TjtHasNAhXKGriMwrxb9UsEjTVk7EUmUF8SRBGLwpyYHEJtX990VXb/Z8W3tX 9thaUDz3rtc/bCXJiO1psZ8yTJyXphT6G1tAMq7NnVokniOJRVmbMYk6dX3TFxFAzPhK UExA== X-Gm-Message-State: AIkVDXL0nL8BGz4OYhFf06t5sxTBRbMAHSE6b677nH1gAGYZnUKWiUCm7nj+jnoT+owIIg== X-Received: by 10.36.11.65 with SMTP id 62mr5255872itd.118.1483863261334; Sun, 08 Jan 2017 00:14:21 -0800 (PST) Received: from isys.cwru.edu (isys.student.CWRU.Edu. [129.22.149.112]) by smtp.gmail.com with ESMTPSA id o195sm5364618ioo.32.2017.01.08.00.14.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jan 2017 00:14:20 -0800 (PST) From: Cameron Gutman To: dmitry.torokhov@gmail.com, rojtberg@gmail.com Cc: linux-input@vger.kernel.org, Cameron Gutman Subject: [PATCH] Input: xpad - restore LED state after device resume Date: Sun, 8 Jan 2017 03:14:18 -0500 Message-Id: <1483863258-12005-1-git-send-email-aicommander@gmail.com> X-Mailer: git-send-email 2.7.4 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 state of pad LEDs can be inconsistent when the system is woken up after sleep. Rather than leaving the controllers blinking, let's resend the last LED command to Xbox 360 pads on resume. Since Xbox One pads stop flashing only when reinitialized, we'll send them the initialization packet so they calm down too. Signed-off-by: Cameron Gutman --- drivers/input/joystick/xpad.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index c06b717..f18274a 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1648,11 +1648,23 @@ static int xpad_resume(struct usb_interface *intf) retval = xpad360w_start_input(xpad); } else { mutex_lock(&input->mutex); - if (input->users) + if (input->users) { retval = xpad_start_input(xpad); + } else if (xpad->xtype == XTYPE_XBOXONE) { + /* + * Even if there are no users, we'll send Xbox One pads + * the startup sequence so they don't sit there and + * blink until somebody opens the input device again. + */ + retval = xpad_start_xbox_one(xpad); + } mutex_unlock(&input->mutex); } + /* LED state is lost across resume, so resend the last command */ + if (xpad->led) + xpad_send_led_command(xpad, xpad->led->led_cdev.brightness); + return retval; }