Skip to contentSkip to conversation

Input: xpad - fix PowerA EnWired Controller guide button

PATCH In review Vicki Pfau 4 participants 5 messages Oct 6, 2022 – Feb 28, 2023

Subsystems (2)
lore
Share & tools
lore

Vicki Pfau

author
#0 lore raw

PATCH 1/1 Input: xpad - fix PowerA EnWired Controller guide button

Some Xbox One controllers require more complete versions of the controller start-up sequence used in official software in order to function properly. This patch adds a usb_set_interface call that matches official startup and nominally disabled the audio interface, which isn't supported in the xpad driver in the first place.

---
 drivers/input/joystick/xpad.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/input/joystick/xpad.c +7 -0
index 18190b529bca..6449665d7b61 100644
@@ -1509,6 +1509,13 @@ static int xpad_start_input(struct usb_xpad *xpad)
 		return -EIO;
 
 	if (xpad->xtype == XTYPE_XBOXONE) {
+		/* Explicitly disable the audio interface. This is needed for some
+		 * controllers, such as the PowerA Enhanced Wired Controller
+		 * for Series X|S (0x20d6:0x200e) to report the guide button */
+		error = usb_set_interface(xpad->udev, 1, 0);
+		if (error)
+			return error;
+
 		error = xpad_start_xbox_one(xpad);
 		if (error) {
 			usb_kill_urb(xpad->irq_in);
Signature · 1 line
2.38.0
#1 lore raw

Hi Vicki,

Thank you for your patch.

Quoted 16 lines · Vicki Pfau

Some Xbox One controllers require more complete versions of the controller start-up sequence used in official software in order to function properly. This patch adds a usb_set_interface call that matches official startup and nominally disabled the audio interface, which isn't supported in the xpad driver in the first place.

---
 drivers/input/joystick/xpad.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/input/joystick/xpad.c +0 -0
index 18190b529bca..6449665d7b61 100644

drivers/input/joystick/xpad.c static int xpad_start_input(struct usb_xpad *xpad) · line 1515

Quoted 7 lines
drivers/input/joystick/xpad.c +4 -0
@@ -1509,6 +1509,13 @@ static int xpad_start_input(struct usb_xpad *xpad)
 		return -EIO;
 
 	if (xpad->xtype == XTYPE_XBOXONE) {
+		/* Explicitly disable the audio interface. This is needed for some
+		 * controllers, such as the PowerA Enhanced Wired Controller
+		 * for Series X|S (0x20d6:0x200e) to report the guide button */
+		error = usb_set_interface(xpad->udev, 1, 0);

Can't we call this in probe() ?
It seems suspicious to be called here as the usb_set_interace() doc states:

"Also, drivers must not change altsettings while urbs are scheduled for endpoints in that interface;"

However, we just called usb_submit_urb() before. I'm not 100% sure but I think we are contradicting the documentation here.

drivers/input/joystick/xpad.c static int xpad_start_input(struct usb_xpad *xpad) · line 1516

Quoted 1 line
drivers/input/joystick/xpad.c +1 -0
+		if (error)

Shouldn't we call usb_kill_urb() here before returing the error? It seems that's what is done in the other error path below.

Quoted 7 lines
drivers/input/joystick/xpad.c +2 -0
+			return error;
+
 		error = xpad_start_xbox_one(xpad);
 		if (error) {
 			usb_kill_urb(xpad->irq_in);
Signature · 1 line
2.38.0
#2 lore raw
In reply to Vicki Pfau

Poke, Dmitry - any chance we could get this pushed?

Quoted 29 lines · Vicki Pfau

Some Xbox One controllers require more complete versions of the controller start-up sequence used in official software in order to function properly. This patch adds a usb_set_interface call that matches official startup and nominally disabled the audio interface, which isn't supported in the xpad driver in the first place.

---
 drivers/input/joystick/xpad.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/input/joystick/xpad.c +7 -0
index 18190b529bca..6449665d7b61 100644
@@ -1509,6 +1509,13 @@ static int xpad_start_input(struct usb_xpad *xpad)
 		return -EIO;
 
 	if (xpad->xtype == XTYPE_XBOXONE) {
+		/* Explicitly disable the audio interface. This is needed for some
+		 * controllers, such as the PowerA Enhanced Wired Controller
+		 * for Series X|S (0x20d6:0x200e) to report the guide button */
+		error = usb_set_interface(xpad->udev, 1, 0);
+		if (error)
+			return error;
+
 		error = xpad_start_xbox_one(xpad);
 		if (error) {
 			usb_kill_urb(xpad->irq_in);
Signature · 3 lines
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat
maintainer
#3 lore raw

Hi Lyude,

Quoted 1 line · Lyude Paul

Poke, Dmitry - any chance we could get this pushed?

I was waiting for Vicki to respond to Mattijs' comments...

Thanks.

Signature · 1 line
Dmitry
author
#4 lore raw

Hi Dmitry,

Quoted 9 lines · Dmitry Torokhov

Hi Lyude,

Quoted 1 line · Lyude Paul

Poke, Dmitry - any chance we could get this pushed?

I was waiting for Vicki to respond to Mattijs' comments...

Thanks.

I'm a little confused as to what's happened here. This appears to be the thread for the v1 of this patch, but the v2 appeared later in a separate series (https://lore.kernel.org/linux-input/[email protected]/T/#m98b35653c34a180e08cebb63b43b3690943f6e77) that was reviewed already. It moves the check into a separate function that will wind up properly freeing the URB if it fails. I tried moving it directly into probe, but that broke resume; it works properly when put in this function.

Vicki