diff mbox series

Input: xpad - fix PowerA EnWired Controller guide button

Message ID 20221006221209.2016372-1-vi@endrift.com
State New
Headers show
Series Input: xpad - fix PowerA EnWired Controller guide button | expand

Commit Message

Vicki Pfau Oct. 6, 2022, 10:12 p.m. UTC
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.

Signed-off-by: Vicki Pfau <vi@endrift.com>
---
 drivers/input/joystick/xpad.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Mattijs Korpershoek Oct. 14, 2022, 1 p.m. UTC | #1
Hi Vicki,

Thank you for your patch.

On Thu, Oct 06, 2022 at 15:12, Vicki Pfau <vi@endrift.com> wrote:

> 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.
>
> Signed-off-by: Vicki Pfau <vi@endrift.com>
> ---
>  drivers/input/joystick/xpad.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index 18190b529bca..6449665d7b61 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c
> @@ -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.


> +		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.

> +			return error;
> +
>  		error = xpad_start_xbox_one(xpad);
>  		if (error) {
>  			usb_kill_urb(xpad->irq_in);
> -- 
> 2.38.0
Lyude Paul Feb. 25, 2023, 1:14 a.m. UTC | #2
Poke, Dmitry - any chance we could get this pushed?

On Thu, 2022-10-06 at 15:12 -0700, Vicki Pfau wrote:
> 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.
> 
> Signed-off-by: Vicki Pfau <vi@endrift.com>
> ---
>  drivers/input/joystick/xpad.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index 18190b529bca..6449665d7b61 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c
> @@ -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);
Dmitry Torokhov Feb. 25, 2023, 6:27 p.m. UTC | #3
Hi Lyude,

On Sat, Feb 25, 2023 at 02:14:27AM +0100, Lyude Paul wrote:
> Poke, Dmitry - any chance we could get this pushed?

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

Thanks.
Vicki Pfau Feb. 28, 2023, 12:32 a.m. UTC | #4
Hi Dmitry,

On 2/25/23 10:27, Dmitry Torokhov wrote:
> Hi Lyude,
> 
> On Sat, Feb 25, 2023 at 02:14:27AM +0100, Lyude Paul wrote:
>> 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/20230203022758.3982393-1-vi@endrift.com/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
diff mbox series

Patch

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 18190b529bca..6449665d7b61 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -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);