Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2580993imu; Thu, 29 Nov 2018 07:11:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/VonJQtpn3Tb/pHt/pe4owmG2kEp53sXmXFwAAKGFu5UtqMS8hsLwCs58Y9zSmNdIYv4nz7 X-Received: by 2002:a63:4d0e:: with SMTP id a14mr1571928pgb.408.1543504290136; Thu, 29 Nov 2018 07:11:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543504290; cv=none; d=google.com; s=arc-20160816; b=PbYWId5j0vlz4vAtLN4H662MqIdyBsClSe3la+Vt7De4gkg2W/vQGfu1NzC1wrBSVv L25kLKcFpv+AW/4+1FogV51PJD5KmNbkWAO7qko/DiUm0WRG2U2lSVypi+s6rSanTZTJ O2VkXNBScGWgT5fb6py0GyrurL0E/iXk7lyDIPrzVT+jhu4YNxrsGP8IiO1J+6np1dx1 D9F3kOOhkRYA2u1uHsNTxtQ+tTAOaOxJmPJ1fMm3Sqj2ga80Y05MlJaJKyqHpCCHV465 7DIRJzpT9fbBfvBdb1JcZzJ/N4Ne7DgtKN2GAmHCBaHTHXn6A/Drs+WRySg7R4FjMVPE cN5g== 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=dCbfjkWVvlUllY0PFC91PJUQJ0Gt3DG3hUIkoLVEF+4=; b=tgZTE4qadyo9za4dv0KUm8NUUHARbShEES60GjibOzd1cZN+AzbuNL1qJsZWEMGVG5 YXWM1O+BWSX9q5Anoyg/54QAOogGsgsIqepX2e6u6fUQEp2r81pa4+JxMXDfpGIISEW6 Z4Vvgk3OgeF/6mF1nxA3ZueSN51BG812yvHSa8OAJgcrM0FVMok8gTs88clui/dtL4kh 4iiJb1fqvL/QR4SsLOaz5TCnFi66/YBNbAj4kQBQl1YW0nKjI1CYwMVUBhL683vjW+re x1vWCOAMOOtNLihR1MJdouiZTHiUP+Ey75OvDChlfai+I0GT+ZOa1OtKcEwkvLSJUk0i xRRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=beJmjkrO; 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 h88si2553080pfa.49.2018.11.29.07.11.13; Thu, 29 Nov 2018 07:11:30 -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=beJmjkrO; 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 S1728921AbeK3BTi (ORCPT + 99 others); Thu, 29 Nov 2018 20:19:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:40218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728198AbeK3BTh (ORCPT ); Thu, 29 Nov 2018 20:19:37 -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 D2A38208E7; Thu, 29 Nov 2018 14:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543500847; bh=Hw6enrK7/zn90U991yI4PjKQuMk+u7O6If8fw/BJdw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=beJmjkrO6bCMypJGICh8bv5nkdBLdj2u5WHBqEZTL/Ahokt0CLPQQrJfAOVAw5fyl o7Z5Hej04DFEE7S0JfgJaISaDTmSJTcJOJpZV4wtScMbQjhm0J0wNCVXSWBIZABQKp cR7L+sjSWe2ZKk7iVDAwbVfJVBqZI2sTbtUVg26I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Rojtberg , Dmitry Torokhov , Sasha Levin Subject: [PATCH 3.18 22/83] Input: xpad - set the LEDs properly on XBox Wireless controllers Date: Thu, 29 Nov 2018 15:11:40 +0100 Message-Id: <20181129140139.318230802@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140138.002176596@linuxfoundation.org> References: <20181129140138.002176596@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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 75b7f05d2798ee3a1cc5bbdd54acd0e318a80396 ] Based on Patch by Pierre-Loup A. Griffais : Add the logic to set the LEDs on XBox Wireless controllers. Command sequence found by sniffing the Windows data stream when plugging the device in. Updated based on comments on linux-input: unify codepaths in xpad_send_led_command for wired/ wireless controller. Also document command values for clarification. All values tested on Xbox 360 Wireless Controller. Signed-off-by: Pavel Rojtberg Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/joystick/xpad.c | 50 +++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index c4205ed022fd..5606e66ca5a5 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -883,17 +883,57 @@ struct xpad_led { struct usb_xpad *xpad; }; +/** + * @param command + * 0: off + * 1: all blink, then previous setting + * 2: 1/top-left blink, then on + * 3: 2/top-right blink, then on + * 4: 3/bottom-left blink, then on + * 5: 4/bottom-right blink, then on + * 6: 1/top-left on + * 7: 2/top-right on + * 8: 3/bottom-left on + * 9: 4/bottom-right on + * 10: rotate + * 11: blink, based on previous setting + * 12: slow blink, based on previous setting + * 13: rotate with two lights + * 14: persistent slow all blink + * 15: blink once, then previous setting + */ static void xpad_send_led_command(struct usb_xpad *xpad, int command) { - if (command >= 0 && command < 14) { - mutex_lock(&xpad->odata_mutex); + command %= 16; + + mutex_lock(&xpad->odata_mutex); + + switch (xpad->xtype) { + case XTYPE_XBOX360: xpad->odata[0] = 0x01; xpad->odata[1] = 0x03; xpad->odata[2] = command; xpad->irq_out->transfer_buffer_length = 3; - usb_submit_urb(xpad->irq_out, GFP_KERNEL); - mutex_unlock(&xpad->odata_mutex); + break; + case XTYPE_XBOX360W: + xpad->odata[0] = 0x00; + xpad->odata[1] = 0x00; + xpad->odata[2] = 0x08; + xpad->odata[3] = 0x40 + command; + xpad->odata[4] = 0x00; + xpad->odata[5] = 0x00; + xpad->odata[6] = 0x00; + xpad->odata[7] = 0x00; + xpad->odata[8] = 0x00; + xpad->odata[9] = 0x00; + xpad->odata[10] = 0x00; + xpad->odata[11] = 0x00; + xpad->irq_out->transfer_buffer_length = 12; + break; } + + usb_submit_urb(xpad->irq_out, GFP_KERNEL); + mutex_unlock(&xpad->odata_mutex); } static void xpad_led_set(struct led_classdev *led_cdev, @@ -913,7 +953,7 @@ static int xpad_led_probe(struct usb_xpad *xpad) struct led_classdev *led_cdev; int error; - if (xpad->xtype != XTYPE_XBOX360) + if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W) return 0; xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL); -- 2.17.1