aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Rojtberg <rojtberg@gmail.com>2015-06-22 17:11:30 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-06-22 17:24:58 -0400
commitcae705baa40b2c20de8f9bb79ef4bcc6b2418c7c (patch)
tree0fd3f0839f8cf75d1351b260bce94606311b83aa
parent75b7f05d2798ee3a1cc5bbdd54acd0e318a80396 (diff)
Input: xpad - re-send LED command on present event
The controller only receives commands when its present. So for the correct LED to be lit the LED command has to be sent on the present event. Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/joystick/xpad.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 6f8755e2c491..f8850f9cb331 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -344,6 +344,7 @@ struct usb_xpad {
344 344
345 int mapping; /* map d-pad to buttons or to axes */ 345 int mapping; /* map d-pad to buttons or to axes */
346 int xtype; /* type of xbox device */ 346 int xtype; /* type of xbox device */
347 unsigned long led_no; /* led to lit on xbox360 controllers */
347}; 348};
348 349
349/* 350/*
@@ -488,6 +489,8 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
488 input_sync(dev); 489 input_sync(dev);
489} 490}
490 491
492static void xpad_identify_controller(struct usb_xpad *xpad);
493
491/* 494/*
492 * xpad360w_process_packet 495 * xpad360w_process_packet
493 * 496 *
@@ -510,6 +513,11 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha
510 if (data[1] & 0x80) { 513 if (data[1] & 0x80) {
511 xpad->pad_present = 1; 514 xpad->pad_present = 1;
512 usb_submit_urb(xpad->bulk_out, GFP_ATOMIC); 515 usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
516 /*
517 * Light up the segment corresponding to
518 * controller number.
519 */
520 xpad_identify_controller(xpad);
513 } else 521 } else
514 xpad->pad_present = 0; 522 xpad->pad_present = 0;
515 } 523 }
@@ -934,6 +942,12 @@ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
934 mutex_unlock(&xpad->odata_mutex); 942 mutex_unlock(&xpad->odata_mutex);
935} 943}
936 944
945static void xpad_identify_controller(struct usb_xpad *xpad)
946{
947 /* Light up the segment corresponding to controller number */
948 xpad_send_led_command(xpad, (xpad->led_no % 4) + 2);
949}
950
937static void xpad_led_set(struct led_classdev *led_cdev, 951static void xpad_led_set(struct led_classdev *led_cdev,
938 enum led_brightness value) 952 enum led_brightness value)
939{ 953{
@@ -945,8 +959,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
945 959
946static int xpad_led_probe(struct usb_xpad *xpad) 960static int xpad_led_probe(struct usb_xpad *xpad)
947{ 961{
948 static atomic_t led_seq = ATOMIC_INIT(-1); 962 static atomic_t led_seq = ATOMIC_INIT(-1);
949 unsigned long led_no;
950 struct xpad_led *led; 963 struct xpad_led *led;
951 struct led_classdev *led_cdev; 964 struct led_classdev *led_cdev;
952 int error; 965 int error;
@@ -958,9 +971,9 @@ static int xpad_led_probe(struct usb_xpad *xpad)
958 if (!led) 971 if (!led)
959 return -ENOMEM; 972 return -ENOMEM;
960 973
961 led_no = atomic_inc_return(&led_seq); 974 xpad->led_no = atomic_inc_return(&led_seq);
962 975
963 snprintf(led->name, sizeof(led->name), "xpad%lu", led_no); 976 snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no);
964 led->xpad = xpad; 977 led->xpad = xpad;
965 978
966 led_cdev = &led->led_cdev; 979 led_cdev = &led->led_cdev;
@@ -974,10 +987,8 @@ static int xpad_led_probe(struct usb_xpad *xpad)
974 return error; 987 return error;
975 } 988 }
976 989
977 /* 990 /* Light up the segment corresponding to controller number */
978 * Light up the segment corresponding to controller number 991 xpad_identify_controller(xpad);
979 */
980 xpad_send_led_command(xpad, (led_no % 4) + 2);
981 992
982 return 0; 993 return 0;
983} 994}
@@ -994,6 +1005,7 @@ static void xpad_led_disconnect(struct usb_xpad *xpad)
994#else 1005#else
995static int xpad_led_probe(struct usb_xpad *xpad) { return 0; } 1006static int xpad_led_probe(struct usb_xpad *xpad) { return 0; }
996static void xpad_led_disconnect(struct usb_xpad *xpad) { } 1007static void xpad_led_disconnect(struct usb_xpad *xpad) { }
1008static void xpad_identify_controller(struct usb_xpad *xpad) { }
997#endif 1009#endif
998 1010
999 1011