linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Input: xpad: fix wireless controller LEDs this picks up the work of "[PATCH 0/7] Input: xpad: Fix wireless controller connection and leds" and updates the patches as discussed in the thread, while leaving the conroversal parts out. Only the constantly blinking LED on the Xbox360 Wireless controller is fixed. So hopefully there is a better chance to merge this one. This also obsoletes my first attempt at this: "[PATCH] Xbox 360 wireless controller light continues blinking after sync with receiver."
@ 2015-06-07 13:31 Pavel Rojtberg
  2015-06-07 13:31 ` [PATCH 1/2] Input: xpad: 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 Pavel Rojtberg
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pavel Rojtberg @ 2015-06-07 13:31 UTC (permalink / raw)
  To: linux-input, pgriffais, dmitry.torokhov, gregkh; +Cc: Pavel Rojtberg

From: Pavel Rojtberg <rojtberg@gmail.com>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] Input: xpad: 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.
  2015-06-07 13:31 [PATCH 0/2] Input: xpad: fix wireless controller LEDs this picks up the work of "[PATCH 0/7] Input: xpad: Fix wireless controller connection and leds" and updates the patches as discussed in the thread, while leaving the conroversal parts out. Only the constantly blinking LED on the Xbox360 Wireless controller is fixed. So hopefully there is a better chance to merge this one. This also obsoletes my first attempt at this: "[PATCH] Xbox 360 wireless controller light continues blinking after sync with receiver." Pavel Rojtberg
@ 2015-06-07 13:31 ` Pavel Rojtberg
  2015-06-07 13:31 ` [PATCH 2/2] Input: xpad: re-send led command for xbox360 wireless after controller becomes present. move led_no to xpad struct to this end Pavel Rojtberg
  2015-06-07 16:43 ` [PATCH 0/2] Input: xpad: fix wireless controller LEDs this picks up the work of "[PATCH 0/7] Input: xpad: Fix wireless controller connection and leds" and updates the patches as discussed in the thread, while leaving the conroversal parts out. Only the constantly blinking LED on the Xbox360 Wireless controller is fixed. So hopefully there is a better chance to merge this one. This also obsoletes my first attempt at this: "[PATCH] Xbox 360 wireless controller light continues blinking after sync with receiver." Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Rojtberg @ 2015-06-07 13:31 UTC (permalink / raw)
  To: linux-input, pgriffais, dmitry.torokhov, gregkh; +Cc: Pavel Rojtberg

From: "Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>

Signed-off-by: "Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

unify codepaths for xbox360/ wireless based on ML discussion. also
document xpad_send_led_command command values for clarification.

Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
---
 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 61c7611..e50c03f 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -881,17 +881,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 %= 15;
+
+	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,
@@ -911,7 +951,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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Input: xpad: re-send led command for xbox360 wireless after controller becomes present. move led_no to xpad struct to this end.
  2015-06-07 13:31 [PATCH 0/2] Input: xpad: fix wireless controller LEDs this picks up the work of "[PATCH 0/7] Input: xpad: Fix wireless controller connection and leds" and updates the patches as discussed in the thread, while leaving the conroversal parts out. Only the constantly blinking LED on the Xbox360 Wireless controller is fixed. So hopefully there is a better chance to merge this one. This also obsoletes my first attempt at this: "[PATCH] Xbox 360 wireless controller light continues blinking after sync with receiver." Pavel Rojtberg
  2015-06-07 13:31 ` [PATCH 1/2] Input: xpad: 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 Pavel Rojtberg
@ 2015-06-07 13:31 ` Pavel Rojtberg
  2015-06-07 16:43 ` [PATCH 0/2] Input: xpad: fix wireless controller LEDs this picks up the work of "[PATCH 0/7] Input: xpad: Fix wireless controller connection and leds" and updates the patches as discussed in the thread, while leaving the conroversal parts out. Only the constantly blinking LED on the Xbox360 Wireless controller is fixed. So hopefully there is a better chance to merge this one. This also obsoletes my first attempt at this: "[PATCH] Xbox 360 wireless controller light continues blinking after sync with receiver." Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Rojtberg @ 2015-06-07 13:31 UTC (permalink / raw)
  To: linux-input, pgriffais, dmitry.torokhov, gregkh; +Cc: Pavel Rojtberg

From: Pavel Rojtberg <rojtberg@gmail.com>

Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
---
 drivers/input/joystick/xpad.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 3e4d3e2..76bdbb7 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -344,6 +344,7 @@ struct usb_xpad {
 
 	int mapping;			/* map d-pad to buttons or to axes */
 	int xtype;			/* type of xbox device */
+	unsigned long led_no;		/* led to lit on xbox360 controllers */
 };
 
 /*
@@ -488,6 +489,8 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
 	input_sync(dev);
 }
 
+static void xpad_send_led_command(struct usb_xpad *xpad, int command);
+
 /*
  * xpad360w_process_packet
  *
@@ -510,6 +513,8 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha
 		if (data[1] & 0x80) {
 			xpad->pad_present = 1;
 			usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
+			/* Light up the segment corresponding to controller number */
+			xpad_send_led_command(xpad, (xpad->led_no % 4) + 2);
 		} else
 			xpad->pad_present = 0;
 	}
@@ -945,7 +950,6 @@ static void xpad_led_set(struct led_classdev *led_cdev,
 static int xpad_led_probe(struct usb_xpad *xpad)
 {
 	static atomic_t led_seq	= ATOMIC_INIT(-1);
-	unsigned long led_no;
 	struct xpad_led *led;
 	struct led_classdev *led_cdev;
 	int error;
@@ -957,9 +961,9 @@ static int xpad_led_probe(struct usb_xpad *xpad)
 	if (!led)
 		return -ENOMEM;
 
-	led_no = atomic_inc_return(&led_seq);
+	xpad->led_no = atomic_inc_return(&led_seq);
 
-	snprintf(led->name, sizeof(led->name), "xpad%lu", led_no);
+	snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no);
 	led->xpad = xpad;
 
 	led_cdev = &led->led_cdev;
@@ -973,10 +977,8 @@ static int xpad_led_probe(struct usb_xpad *xpad)
 		return error;
 	}
 
-	/*
-	 * Light up the segment corresponding to controller number
-	 */
-	xpad_send_led_command(xpad, (led_no % 4) + 2);
+	/* Light up the segment corresponding to controller number */
+	xpad_send_led_command(xpad, (xpad->led_no % 4) + 2);
 
 	return 0;
 }
@@ -993,6 +995,7 @@ static void xpad_led_disconnect(struct usb_xpad *xpad)
 #else
 static int xpad_led_probe(struct usb_xpad *xpad) { return 0; }
 static void xpad_led_disconnect(struct usb_xpad *xpad) { }
+static void xpad_send_led_command(struct usb_xpad *xpad, int command) { }
 #endif
 
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Input: xpad: fix wireless controller LEDs this picks up the work of "[PATCH 0/7] Input: xpad: Fix wireless controller connection and leds" and updates the patches as discussed in the thread, while leaving the conroversal parts out. Only the constantly blinking LED on the Xbox360 Wireless controller is fixed. So hopefully there is a better chance to merge this one. This also obsoletes my first attempt at this: "[PATCH] Xbox 360 wireless controller light continues blinking after sync with receiver."
  2015-06-07 13:31 [PATCH 0/2] Input: xpad: fix wireless controller LEDs this picks up the work of "[PATCH 0/7] Input: xpad: Fix wireless controller connection and leds" and updates the patches as discussed in the thread, while leaving the conroversal parts out. Only the constantly blinking LED on the Xbox360 Wireless controller is fixed. So hopefully there is a better chance to merge this one. This also obsoletes my first attempt at this: "[PATCH] Xbox 360 wireless controller light continues blinking after sync with receiver." Pavel Rojtberg
  2015-06-07 13:31 ` [PATCH 1/2] Input: xpad: 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 Pavel Rojtberg
  2015-06-07 13:31 ` [PATCH 2/2] Input: xpad: re-send led command for xbox360 wireless after controller becomes present. move led_no to xpad struct to this end Pavel Rojtberg
@ 2015-06-07 16:43 ` Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2015-06-07 16:43 UTC (permalink / raw)
  To: Pavel Rojtberg; +Cc: linux-input, pgriffais, dmitry.torokhov

On Sun, Jun 07, 2015 at 03:31:04PM +0200, Pavel Rojtberg wrote:
> From: Pavel Rojtberg <rojtberg@gmail.com>
> 

Your subject is crazy :(

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-07 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-07 13:31 [PATCH 0/2] Input: xpad: fix wireless controller LEDs this picks up the work of "[PATCH 0/7] Input: xpad: Fix wireless controller connection and leds" and updates the patches as discussed in the thread, while leaving the conroversal parts out. Only the constantly blinking LED on the Xbox360 Wireless controller is fixed. So hopefully there is a better chance to merge this one. This also obsoletes my first attempt at this: "[PATCH] Xbox 360 wireless controller light continues blinking after sync with receiver." Pavel Rojtberg
2015-06-07 13:31 ` [PATCH 1/2] Input: xpad: 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 Pavel Rojtberg
2015-06-07 13:31 ` [PATCH 2/2] Input: xpad: re-send led command for xbox360 wireless after controller becomes present. move led_no to xpad struct to this end Pavel Rojtberg
2015-06-07 16:43 ` [PATCH 0/2] Input: xpad: fix wireless controller LEDs this picks up the work of "[PATCH 0/7] Input: xpad: Fix wireless controller connection and leds" and updates the patches as discussed in the thread, while leaving the conroversal parts out. Only the constantly blinking LED on the Xbox360 Wireless controller is fixed. So hopefully there is a better chance to merge this one. This also obsoletes my first attempt at this: "[PATCH] Xbox 360 wireless controller light continues blinking after sync with receiver." Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).