Skip to contentSkip to conversation

Input: xpad - Move Xbox 360 magic packet sending

PATCH In review Vicki Pfau 2 participants 3 messages May 2, 2023 – Jun 6, 2023

Subsystems (2)
lore
Share & tools
lore

Vicki Pfau

author
#0 lore raw

PATCH v2 1/1 Input: xpad - Move Xbox 360 magic packet sending

This moves the sending of the magic packet introduced in db7220c48d8d from xpad_probe to xpad_start_input to ensure that xpad->dev->dev exists in the event that an error occurs. This should also fix issues with suspend that may occur with some controllers.

Fixes db7220c48d8d ("Input: xpad - fix support for some third-party controllers")
Reported-by [email protected]
---
 drivers/input/joystick/xpad.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/input/joystick/xpad.c +21 -0
index 50ecff681b89..40abea92c393 100644
@@ -1720,6 +1720,27 @@ static int xpad_start_input(struct usb_xpad *xpad)
 			return error;
 		}
 	}
+	if (xpad->xtype == XTYPE_XBOX360) {
+		/*
+		 * Some third-party controllers Xbox 360-style controllers
+		 * require this message to finish initialization.
+		*/
+		u8 dummy[20];
+
+		error = usb_control_msg_recv(xpad->udev, 0,
+					     /* bRequest */ 0x01,
+					     /* bmRequestType */
+					     USB_TYPE_VENDOR | USB_DIR_IN |
+						USB_RECIP_INTERFACE,
+					     /* wValue */ 0x100,
+					     /* wIndex */ 0x00,
+					     dummy, sizeof(dummy),
+					     25, GFP_KERNEL);
+		if (error)
+			dev_warn(&xpad->dev->dev,
+				 "unable to receive magic message: %d\n",
+				 error);
+	}
 
 	return 0;
 }
Signature · 1 line
2.40.1
author
#1 lore raw
Quoted 36 lines · Vicki Pfau

This moves the sending of the magic packet introduced in db7220c48d8d from xpad_probe to xpad_start_input to ensure that xpad->dev->dev exists in the event that an error occurs. This should also fix issues with suspend that may occur with some controllers.

Fixes db7220c48d8d ("Input: xpad - fix support for some third-party controllers")
Reported-by [email protected]
---
 drivers/input/joystick/xpad.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/input/joystick/xpad.c +14 -0
index 50ecff681b89..40abea92c393 100644
@@ -1720,6 +1720,27 @@ static int xpad_start_input(struct usb_xpad *xpad)
 			return error;
 		}
 	}
+	if (xpad->xtype == XTYPE_XBOX360) {
+		/*
+		 * Some third-party controllers Xbox 360-style controllers
+		 * require this message to finish initialization.
+		*/
+		u8 dummy[20];
+
+		error = usb_control_msg_recv(xpad->udev, 0,
+					     /* bRequest */ 0x01,
+					     /* bmRequestType */
+					     USB_TYPE_VENDOR | USB_DIR_IN |
+						USB_RECIP_INTERFACE,
+					     /* wValue */ 0x100,
+					     /* wIndex */ 0x00,

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

Quoted 10 lines
drivers/input/joystick/xpad.c +7 -0
+					     dummy, sizeof(dummy),
+					     25, GFP_KERNEL);
+		if (error)
+			dev_warn(&xpad->dev->dev,
+				 "unable to receive magic message: %d\n",
+				 error);
+	}
 
 	return 0;
 }

It's been a month and this fixed version of the patch never got any replies. Did it just get overlooked? Or does the fact that the old version got reverted mean I need to change the description in some capacity?

maintainer
#2 lore raw

Hi Vicki,

Quoted 45 lines · Vicki Pfau
Quoted 44 lines · Vicki Pfau

This moves the sending of the magic packet introduced in db7220c48d8d from xpad_probe to xpad_start_input to ensure that xpad->dev->dev exists in the event that an error occurs. This should also fix issues with suspend that may occur with some controllers.

Fixes db7220c48d8d ("Input: xpad - fix support for some third-party controllers")
Reported-by [email protected]
---
 drivers/input/joystick/xpad.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/input/joystick/xpad.c +21 -0
index 50ecff681b89..40abea92c393 100644
@@ -1720,6 +1720,27 @@ static int xpad_start_input(struct usb_xpad *xpad)
 			return error;
 		}
 	}
+	if (xpad->xtype == XTYPE_XBOX360) {
+		/*
+		 * Some third-party controllers Xbox 360-style controllers
+		 * require this message to finish initialization.
+		*/
+		u8 dummy[20];
+
+		error = usb_control_msg_recv(xpad->udev, 0,
+					     /* bRequest */ 0x01,
+					     /* bmRequestType */
+					     USB_TYPE_VENDOR | USB_DIR_IN |
+						USB_RECIP_INTERFACE,
+					     /* wValue */ 0x100,
+					     /* wIndex */ 0x00,
+					     dummy, sizeof(dummy),
+					     25, GFP_KERNEL);
+		if (error)
+			dev_warn(&xpad->dev->dev,
+				 "unable to receive magic message: %d\n",
+				 error);
+	}
 
Quoted 7 lines

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

Quoted 2 lines
drivers/input/joystick/xpad.c +0 -0
 	return 0;
 }

It's been a month and this fixed version of the patch never got any replies. Did it just get overlooked? Or does the fact that the old version got reverted mean I need to change the description in some capacity?

Yes, because the original patch was reverted you need to adjust the patch/description and resubmit as a new patch.

Thanks.

Signature · 1 line
Dmitry