* [PATCH 0/6] Input: xpad: updates and refactoring
@ 2015-09-05 20:58 Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 1/6] Input: xpad: add Covert Forces edition of the Xbox One controller Pavel Rojtberg
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Pavel Rojtberg @ 2015-09-05 20:58 UTC (permalink / raw)
To: linux-input, pgriffais, dmitry.torokhov, gregkh; +Cc: Pavel Rojtberg
From: Pavel Rojtberg <rojtberg@gmail.com>
This series contains several bug-fixes and updates for the xpad driver.
They are loosely sorted in order of controversy.
Patch 1 just adds a new device id for the Xbox One controller. The original
patch was sent to me via github: https://github.com/paroj/xpad/pull/9
Patches 2-4 are minor refactorings of the code that should make it
more maintainable.
Patch 5 makes the x360 wireless pads support the x360 wired button interface.
See the commit message for details and a link to the preceding discussion.
Patch 6 fixes issues of the x360 wireless pads after suspend/ resume.
Erik Lundgren (1):
Input: xpad: add Covert Forces edition of the Xbox One controller
Pavel Rojtberg (5):
Input: xpad: clarify LED enumeration
Input: xpad: remove needless bulk out URB used for LED setup
Input: xpad: factor out URB submission in xpad_play_effect
Input: xpad: x360w: report dpad as buttons and axes
Input: xpad: reset usb device on resume
drivers/input/joystick/xpad.c | 286 +++++++++++++++++++++++++++--------------------------------------
1 file changed, 119 insertions(+), 167 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] Input: xpad: add Covert Forces edition of the Xbox One controller
2015-09-05 20:58 [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
@ 2015-09-05 20:58 ` Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 2/6] Input: xpad: clarify LED enumeration Pavel Rojtberg
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Rojtberg @ 2015-09-05 20:58 UTC (permalink / raw)
To: linux-input, pgriffais, dmitry.torokhov, gregkh
Cc: Erik Lundgren, Pavel Rojtberg
From: Erik Lundgren <eriklundgren93@gmail.com>
It is identical to the Xbox One controller but has a different product
ID
Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
---
drivers/input/joystick/xpad.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index f8850f9..c3ba5be 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -125,6 +125,7 @@ static const struct xpad_device {
{ 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
{ 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
{ 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
+ { 0x045e, 0x02dd, "Microsoft X-Box One pad (Covert Forces)", 0, XTYPE_XBOXONE },
{ 0x045e, 0x0291, "Xbox 360 Wireless Receiver (XBOX)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
{ 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
{ 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] Input: xpad: clarify LED enumeration
2015-09-05 20:58 [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 1/6] Input: xpad: add Covert Forces edition of the Xbox One controller Pavel Rojtberg
@ 2015-09-05 20:58 ` Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 3/6] Input: xpad: remove needless bulk out URB used for LED setup Pavel Rojtberg
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Rojtberg @ 2015-09-05 20:58 UTC (permalink / raw)
To: linux-input, pgriffais, dmitry.torokhov, gregkh; +Cc: Pavel Rojtberg
From: Pavel Rojtberg <rojtberg@gmail.com>
this changes helps understanding the code
1. rename led_no -> pad_nr: the number stored there is not the LED Nr -
it gets translated later on to a LED Nr in xpad_identify_controller
2. move all comments regarding xpad_identify_controller to the function
definition to prevent inconsistent documentation.
Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
---
drivers/input/joystick/xpad.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index c3ba5be..4cb450c 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -345,7 +345,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 */
+ unsigned long pad_nr; /* the order x360 pads were attached */
};
/*
@@ -357,7 +357,6 @@ struct usb_xpad {
* The used report descriptor was taken from ITO Takayukis website:
* http://euc.jp/periphs/xbox-controller.ja.html
*/
-
static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
{
struct input_dev *dev = xpad->dev;
@@ -506,7 +505,6 @@ static void xpad_identify_controller(struct usb_xpad *xpad);
* 01.1 - Pad state (Bytes 4+) valid
*
*/
-
static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
{
/* Presence change */
@@ -514,10 +512,6 @@ 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_identify_controller(xpad);
} else
xpad->pad_present = 0;
@@ -891,6 +885,7 @@ struct xpad_led {
};
/**
+ * set the LEDs on Xbox360 / Wireless Controllers
* @param command
* 0: off
* 1: all blink, then previous setting
@@ -943,10 +938,12 @@ static void xpad_send_led_command(struct usb_xpad *xpad, int command)
mutex_unlock(&xpad->odata_mutex);
}
+/*
+ * Light up the segment corresponding to the pad number on Xbox 360 Controllers
+ */
static void xpad_identify_controller(struct usb_xpad *xpad)
{
- /* Light up the segment corresponding to controller number */
- xpad_send_led_command(xpad, (xpad->led_no % 4) + 2);
+ xpad_send_led_command(xpad, (xpad->pad_nr % 4) + 2);
}
static void xpad_led_set(struct led_classdev *led_cdev,
@@ -972,9 +969,9 @@ static int xpad_led_probe(struct usb_xpad *xpad)
if (!led)
return -ENOMEM;
- xpad->led_no = atomic_inc_return(&led_seq);
+ xpad->pad_nr = atomic_inc_return(&led_seq);
- snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no);
+ snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->pad_nr);
led->xpad = xpad;
led_cdev = &led->led_cdev;
@@ -988,7 +985,6 @@ static int xpad_led_probe(struct usb_xpad *xpad)
return error;
}
- /* Light up the segment corresponding to controller number */
xpad_identify_controller(xpad);
return 0;
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] Input: xpad: remove needless bulk out URB used for LED setup
2015-09-05 20:58 [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 1/6] Input: xpad: add Covert Forces edition of the Xbox One controller Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 2/6] Input: xpad: clarify LED enumeration Pavel Rojtberg
@ 2015-09-05 20:58 ` Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 4/6] Input: xpad: factor out URB submission in xpad_play_effect Pavel Rojtberg
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Rojtberg @ 2015-09-05 20:58 UTC (permalink / raw)
To: linux-input, pgriffais, dmitry.torokhov, gregkh; +Cc: Pavel Rojtberg
From: Pavel Rojtberg <rojtberg@gmail.com>
this code was probably wrong ever since and is redundant with
xpad_send_led_command.
Both try to send a similar command to the xbox360 controller. However
xpad_send_led_command correctly uses the pad_nr instead of
bInterfaceNumber to select the led and re-uses the irq_out URB instead
of creating a new one.
Note that this change only affects the two supported wireless
controllers. Tested using the xbox360 wireless controller (PC).
Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
---
drivers/input/joystick/xpad.c | 79 +-----------------------------------------------------------------
1 file changed, 1 insertion(+), 78 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 4cb450c..9c95db7 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -329,9 +329,6 @@ struct usb_xpad {
unsigned char *idata; /* input data */
dma_addr_t idata_dma;
- struct urb *bulk_out;
- unsigned char *bdata;
-
struct urb *irq_out; /* urb for interrupt out report */
unsigned char *odata; /* output data */
dma_addr_t odata_dma;
@@ -511,7 +508,6 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha
if (data[0] & 0x08) {
if (data[1] & 0x80) {
xpad->pad_present = 1;
- usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
xpad_identify_controller(xpad);
} else
xpad->pad_present = 0;
@@ -669,28 +665,6 @@ exit:
__func__, retval);
}
-static void xpad_bulk_out(struct urb *urb)
-{
- struct usb_xpad *xpad = urb->context;
- struct device *dev = &xpad->intf->dev;
-
- switch (urb->status) {
- case 0:
- /* success */
- break;
- case -ECONNRESET:
- case -ENOENT:
- case -ESHUTDOWN:
- /* this urb is terminated, clean up */
- dev_dbg(dev, "%s - urb shutting down with status: %d\n",
- __func__, urb->status);
- break;
- default:
- dev_dbg(dev, "%s - nonzero urb status received: %d\n",
- __func__, urb->status);
- }
-}
-
static void xpad_irq_out(struct urb *urb)
{
struct usb_xpad *xpad = urb->context;
@@ -1216,52 +1190,6 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
if (xpad->xtype == XTYPE_XBOX360W) {
/*
- * Setup the message to set the LEDs on the
- * controller when it shows up
- */
- xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL);
- if (!xpad->bulk_out) {
- error = -ENOMEM;
- goto fail7;
- }
-
- xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL);
- if (!xpad->bdata) {
- error = -ENOMEM;
- goto fail8;
- }
-
- xpad->bdata[2] = 0x08;
- switch (intf->cur_altsetting->desc.bInterfaceNumber) {
- case 0:
- xpad->bdata[3] = 0x42;
- break;
- case 2:
- xpad->bdata[3] = 0x43;
- break;
- case 4:
- xpad->bdata[3] = 0x44;
- break;
- case 6:
- xpad->bdata[3] = 0x45;
- }
-
- ep_irq_in = &intf->cur_altsetting->endpoint[1].desc;
- if (usb_endpoint_is_bulk_out(ep_irq_in)) {
- usb_fill_bulk_urb(xpad->bulk_out, udev,
- usb_sndbulkpipe(udev,
- ep_irq_in->bEndpointAddress),
- xpad->bdata, XPAD_PKT_LEN,
- xpad_bulk_out, xpad);
- } else {
- usb_fill_int_urb(xpad->bulk_out, udev,
- usb_sndintpipe(udev,
- ep_irq_in->bEndpointAddress),
- xpad->bdata, XPAD_PKT_LEN,
- xpad_bulk_out, xpad, 0);
- }
-
- /*
* Submit the int URB immediately rather than waiting for open
* because we get status messages from the device whether
* or not any controllers are attached. In fact, it's
@@ -1271,13 +1199,11 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
xpad->irq_in->dev = xpad->udev;
error = usb_submit_urb(xpad->irq_in, GFP_KERNEL);
if (error)
- goto fail9;
+ goto fail7;
}
return 0;
- fail9: kfree(xpad->bdata);
- fail8: usb_free_urb(xpad->bulk_out);
fail7: input_unregister_device(input_dev);
input_dev = NULL;
fail6: xpad_led_disconnect(xpad);
@@ -1301,8 +1227,6 @@ static void xpad_disconnect(struct usb_interface *intf)
xpad_deinit_output(xpad);
if (xpad->xtype == XTYPE_XBOX360W) {
- usb_kill_urb(xpad->bulk_out);
- usb_free_urb(xpad->bulk_out);
usb_kill_urb(xpad->irq_in);
}
@@ -1310,7 +1234,6 @@ static void xpad_disconnect(struct usb_interface *intf)
usb_free_coherent(xpad->udev, XPAD_PKT_LEN,
xpad->idata, xpad->idata_dma);
- kfree(xpad->bdata);
kfree(xpad);
usb_set_intfdata(intf, NULL);
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] Input: xpad: factor out URB submission in xpad_play_effect
2015-09-05 20:58 [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
` (2 preceding siblings ...)
2015-09-05 20:58 ` [PATCH 3/6] Input: xpad: remove needless bulk out URB used for LED setup Pavel Rojtberg
@ 2015-09-05 20:58 ` Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 5/6] Input: xpad: x360w: report dpad as buttons and axes Pavel Rojtberg
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Rojtberg @ 2015-09-05 20:58 UTC (permalink / raw)
To: linux-input, pgriffais, dmitry.torokhov, gregkh; +Cc: Pavel Rojtberg
From: Pavel Rojtberg <rojtberg@gmail.com>
Move submisson logic to a single point at the end of the function.
This makes it easy to add locking/ queuing code later on.
Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
---
drivers/input/joystick/xpad.c | 140 ++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 69 insertions(+), 71 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 9c95db7..3fe8500 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -759,80 +759,78 @@ static void xpad_deinit_output(struct usb_xpad *xpad)
static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect)
{
struct usb_xpad *xpad = input_get_drvdata(dev);
+ __u16 strong;
+ __u16 weak;
- if (effect->type == FF_RUMBLE) {
- __u16 strong = effect->u.rumble.strong_magnitude;
- __u16 weak = effect->u.rumble.weak_magnitude;
-
- switch (xpad->xtype) {
-
- case XTYPE_XBOX:
- xpad->odata[0] = 0x00;
- xpad->odata[1] = 0x06;
- xpad->odata[2] = 0x00;
- xpad->odata[3] = strong / 256; /* left actuator */
- xpad->odata[4] = 0x00;
- xpad->odata[5] = weak / 256; /* right actuator */
- xpad->irq_out->transfer_buffer_length = 6;
-
- return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
-
- case XTYPE_XBOX360:
- xpad->odata[0] = 0x00;
- xpad->odata[1] = 0x08;
- xpad->odata[2] = 0x00;
- xpad->odata[3] = strong / 256; /* left actuator? */
- xpad->odata[4] = weak / 256; /* right actuator? */
- xpad->odata[5] = 0x00;
- xpad->odata[6] = 0x00;
- xpad->odata[7] = 0x00;
- xpad->irq_out->transfer_buffer_length = 8;
-
- return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
-
- case XTYPE_XBOX360W:
- xpad->odata[0] = 0x00;
- xpad->odata[1] = 0x01;
- xpad->odata[2] = 0x0F;
- xpad->odata[3] = 0xC0;
- xpad->odata[4] = 0x00;
- xpad->odata[5] = strong / 256;
- xpad->odata[6] = weak / 256;
- 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;
-
- return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
-
- case XTYPE_XBOXONE:
- xpad->odata[0] = 0x09; /* activate rumble */
- xpad->odata[1] = 0x08;
- xpad->odata[2] = 0x00;
- xpad->odata[3] = 0x08; /* continuous effect */
- xpad->odata[4] = 0x00; /* simple rumble mode */
- xpad->odata[5] = 0x03; /* L and R actuator only */
- xpad->odata[6] = 0x00; /* TODO: LT actuator */
- xpad->odata[7] = 0x00; /* TODO: RT actuator */
- xpad->odata[8] = strong / 256; /* left actuator */
- xpad->odata[9] = weak / 256; /* right actuator */
- xpad->odata[10] = 0x80; /* length of pulse */
- xpad->odata[11] = 0x00; /* stop period of pulse */
- xpad->irq_out->transfer_buffer_length = 12;
-
- return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
-
- default:
- dev_dbg(&xpad->dev->dev,
- "%s - rumble command sent to unsupported xpad type: %d\n",
- __func__, xpad->xtype);
- return -1;
- }
+ if (effect->type != FF_RUMBLE)
+ return 0;
+
+ strong = effect->u.rumble.strong_magnitude;
+ weak = effect->u.rumble.weak_magnitude;
+
+ switch (xpad->xtype) {
+ case XTYPE_XBOX:
+ xpad->odata[0] = 0x00;
+ xpad->odata[1] = 0x06;
+ xpad->odata[2] = 0x00;
+ xpad->odata[3] = strong / 256; /* left actuator */
+ xpad->odata[4] = 0x00;
+ xpad->odata[5] = weak / 256; /* right actuator */
+ xpad->irq_out->transfer_buffer_length = 6;
+ break;
+
+ case XTYPE_XBOX360:
+ xpad->odata[0] = 0x00;
+ xpad->odata[1] = 0x08;
+ xpad->odata[2] = 0x00;
+ xpad->odata[3] = strong / 256; /* left actuator? */
+ xpad->odata[4] = weak / 256; /* right actuator? */
+ xpad->odata[5] = 0x00;
+ xpad->odata[6] = 0x00;
+ xpad->odata[7] = 0x00;
+ xpad->irq_out->transfer_buffer_length = 8;
+ break;
+
+ case XTYPE_XBOX360W:
+ xpad->odata[0] = 0x00;
+ xpad->odata[1] = 0x01;
+ xpad->odata[2] = 0x0F;
+ xpad->odata[3] = 0xC0;
+ xpad->odata[4] = 0x00;
+ xpad->odata[5] = strong / 256;
+ xpad->odata[6] = weak / 256;
+ 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;
+
+ case XTYPE_XBOXONE:
+ xpad->odata[0] = 0x09; /* activate rumble */
+ xpad->odata[1] = 0x08;
+ xpad->odata[2] = 0x00;
+ xpad->odata[3] = 0x08; /* continuous effect */
+ xpad->odata[4] = 0x00; /* simple rumble mode */
+ xpad->odata[5] = 0x03; /* L and R actuator only */
+ xpad->odata[6] = 0x00; /* TODO: LT actuator */
+ xpad->odata[7] = 0x00; /* TODO: RT actuator */
+ xpad->odata[8] = strong / 256; /* left actuator */
+ xpad->odata[9] = weak / 256; /* right actuator */
+ xpad->odata[10] = 0x80; /* length of pulse */
+ xpad->odata[11] = 0x00; /* stop period of pulse */
+ xpad->irq_out->transfer_buffer_length = 12;
+ break;
+
+ default:
+ dev_dbg(&xpad->dev->dev,
+ "%s - rumble command sent to unsupported xpad type: %d\n",
+ __func__, xpad->xtype);
+ return -EINVAL;
}
- return 0;
+ return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
}
static int xpad_init_ff(struct usb_xpad *xpad)
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] Input: xpad: x360w: report dpad as buttons and axes
2015-09-05 20:58 [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
` (3 preceding siblings ...)
2015-09-05 20:58 ` [PATCH 4/6] Input: xpad: factor out URB submission in xpad_play_effect Pavel Rojtberg
@ 2015-09-05 20:58 ` Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 6/6] Input: xpad: reset usb device on resume Pavel Rojtberg
2015-09-13 12:04 ` [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Rojtberg @ 2015-09-05 20:58 UTC (permalink / raw)
To: linux-input, pgriffais, dmitry.torokhov, gregkh; +Cc: Pavel Rojtberg
From: Pavel Rojtberg <rojtberg@gmail.com>
as discussed here[0], x360w is the only pad that maps dpad_to_button.
This is bad for downstream developers as they have to differ between
x360 and x360w which is not intuitive.
This patch implements the suggested solution of exposing the dpad both
as axes and as buttons. This retains backward compability with software
already dealing with the difference while makes new software work as
expected across x360/ x360w pads.
[0] http://www.spinics.net/lists/linux-input/msg34421.html
Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
---
drivers/input/joystick/xpad.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 3fe8500..ae441a2 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -436,7 +436,14 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08);
input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01);
input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02);
- } else {
+ }
+ /* this should be a simple else block. However historically xbox360w
+ * has mapped DPAD to buttons while xbox360 did not.
+ * This made no sense, but now we can not just switch back and have to
+ * support both behaviors.
+ */
+ if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) ||
+ xpad->xtype == XTYPE_XBOX360W) {
input_report_abs(dev, ABS_HAT0X,
!!(data[2] & 0x08) - !!(data[2] & 0x04));
input_report_abs(dev, ABS_HAT0Y,
@@ -1144,7 +1151,14 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
for (i = 0; xpad_btn_pad[i] >= 0; i++)
__set_bit(xpad_btn_pad[i], input_dev->keybit);
- } else {
+ }
+ /* this should be a simple else block. However historically xbox360w
+ * has mapped DPAD to buttons while xbox360 did not.
+ * This made no sense, but now we can not just switch back and have to
+ * support both behaviors.
+ */
+ if(!(xpad->mapping & MAP_DPAD_TO_BUTTONS) ||
+ xpad->xtype == XTYPE_XBOX360W) {
for (i = 0; xpad_abs_pad[i] >= 0; i++)
xpad_set_up_abs(input_dev, xpad_abs_pad[i]);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] Input: xpad: reset usb device on resume
2015-09-05 20:58 [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
` (4 preceding siblings ...)
2015-09-05 20:58 ` [PATCH 5/6] Input: xpad: x360w: report dpad as buttons and axes Pavel Rojtberg
@ 2015-09-05 20:58 ` Pavel Rojtberg
2015-09-13 12:04 ` [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Rojtberg @ 2015-09-05 20:58 UTC (permalink / raw)
To: linux-input, pgriffais, dmitry.torokhov, gregkh; +Cc: Pavel Rojtberg
From: Pavel Rojtberg <rojtberg@gmail.com>
on my machine using the x360w pad the irq_out URB is dead after suspend/
resume. This means that neither sending LED nor FF commands works.
The error seems not to be related to the driver as it also occurs when
xpad is not even loaded. The only fix I found is unplugging the
receiver.
Workaround this error by resetting the usb device on resume. Implemented
suspend/ resume callbacks to this end.
Also ensure usb_kill_urb(xpad->irq_out) is called before
usb_free_urb(xpad->irq_out) in xpad_disconnect.
Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
---
drivers/input/joystick/xpad.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index ae441a2..986db4b 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1230,17 +1230,24 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
}
+static void xpad_stop_communication(struct usb_xpad *xpad) {
+ xpad_stop_output(xpad);
+
+ if (xpad->xtype == XTYPE_XBOX360W) {
+ usb_kill_urb(xpad->irq_in);
+ }
+}
+
static void xpad_disconnect(struct usb_interface *intf)
{
struct usb_xpad *xpad = usb_get_intfdata (intf);
xpad_led_disconnect(xpad);
input_unregister_device(xpad->dev);
- xpad_deinit_output(xpad);
- if (xpad->xtype == XTYPE_XBOX360W) {
- usb_kill_urb(xpad->irq_in);
- }
+ xpad_stop_communication(xpad);
+
+ xpad_deinit_output(xpad);
usb_free_urb(xpad->irq_in);
usb_free_coherent(xpad->udev, XPAD_PKT_LEN,
@@ -1251,10 +1258,23 @@ static void xpad_disconnect(struct usb_interface *intf)
usb_set_intfdata(intf, NULL);
}
+static int xpad_suspend(struct usb_interface *intf, pm_message_t message) {
+ struct usb_xpad *xpad = usb_get_intfdata (intf);
+ xpad_stop_communication(xpad);
+ return 0;
+}
+
+static int xpad_resume(struct usb_interface *intf) {
+ usb_queue_reset_device(intf);
+ return 0;
+}
+
static struct usb_driver xpad_driver = {
.name = "xpad",
.probe = xpad_probe,
.disconnect = xpad_disconnect,
+ .suspend = xpad_suspend,
+ .resume = xpad_resume,
.id_table = xpad_table,
};
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/6] Input: xpad: updates and refactoring
2015-09-05 20:58 [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
` (5 preceding siblings ...)
2015-09-05 20:58 ` [PATCH 6/6] Input: xpad: reset usb device on resume Pavel Rojtberg
@ 2015-09-13 12:04 ` Pavel Rojtberg
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Rojtberg @ 2015-09-13 12:04 UTC (permalink / raw)
To: linux-input, pgriffais, dmitry.torokhov, gregkh
feel free to ask for details. If you have no objections, please merge.
Am 05.09.2015 um 22:58 schrieb Pavel Rojtberg:
> From: Pavel Rojtberg <rojtberg@gmail.com>
>
> This series contains several bug-fixes and updates for the xpad driver.
> They are loosely sorted in order of controversy.
>
> Patch 1 just adds a new device id for the Xbox One controller. The original
> patch was sent to me via github: https://github.com/paroj/xpad/pull/9
>
> Patches 2-4 are minor refactorings of the code that should make it
> more maintainable.
>
> Patch 5 makes the x360 wireless pads support the x360 wired button interface.
> See the commit message for details and a link to the preceding discussion.
>
> Patch 6 fixes issues of the x360 wireless pads after suspend/ resume.
>
> Erik Lundgren (1):
> Input: xpad: add Covert Forces edition of the Xbox One controller
>
> Pavel Rojtberg (5):
> Input: xpad: clarify LED enumeration
> Input: xpad: remove needless bulk out URB used for LED setup
> Input: xpad: factor out URB submission in xpad_play_effect
> Input: xpad: x360w: report dpad as buttons and axes
> Input: xpad: reset usb device on resume
>
> drivers/input/joystick/xpad.c | 286 +++++++++++++++++++++++++++--------------------------------------
> 1 file changed, 119 insertions(+), 167 deletions(-)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-09-13 12:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-05 20:58 [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 1/6] Input: xpad: add Covert Forces edition of the Xbox One controller Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 2/6] Input: xpad: clarify LED enumeration Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 3/6] Input: xpad: remove needless bulk out URB used for LED setup Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 4/6] Input: xpad: factor out URB submission in xpad_play_effect Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 5/6] Input: xpad: x360w: report dpad as buttons and axes Pavel Rojtberg
2015-09-05 20:58 ` [PATCH 6/6] Input: xpad: reset usb device on resume Pavel Rojtberg
2015-09-13 12:04 ` [PATCH 0/6] Input: xpad: updates and refactoring Pavel Rojtberg
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).