Skip to contentSkip to conversation

hid: asus: add xg mobile 2023 external hardware support

PATCH Applied Denis Benato 3 participants 8 messages Feb 16 – Oct 26 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 hid: asus: add xg mobile 2023 external hardware support

XG mobile stations have the 0x5a endpoint and has to be initialized:
add them to hid-asus.

---
 drivers/hid/hid-asus.c | 3 +++
 drivers/hid/hid-ids.h  | 1 +
 2 files changed, 4 insertions(+)
drivers/hid/hid-asus.c +3 -0
index 1b9793f7c07e..52efbf75a994 100644
@@ -1483,6 +1483,9 @@ static const struct hid_device_id asus_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
 	    USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X),
 	  QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_ROG_ALLY_XPAD },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
+	    USB_DEVICE_ID_ASUSTEK_XGM_2023),
+	},
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
 	    USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD),
 	  QUIRK_ROG_CLAYMORE_II_KEYBOARD },
drivers/hid/hid-ids.h +1 -0
index 3e299a30dcde..4ab7640b119a 100644
@@ -229,6 +229,7 @@
 #define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X		0x1b4c
 #define USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD	0x196b
 #define USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD	0x1869
+#define USB_DEVICE_ID_ASUSTEK_XGM_2023	0x1a9a
 
 #define USB_VENDOR_ID_ATEN		0x0557
 #define USB_DEVICE_ID_ATEN_UC100KM	0x2004
Signature · 1 line
2.53.0
#1 lore raw

PATCH 2/2 hid: asus: always fully initialize devices

ASUS has more devices other than laptop keyboards which needs to be initializated: the init sequence is the same as keyboards.

ID1 and ID2 are USB report IDs that are correctly enumerated:
send init commands to all devices that supports those reports IDs.

---
 drivers/hid/hid-asus.c | 46 ++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 11 deletions(-)
drivers/hid/hid-asus.c +35 -11
index 52efbf75a994..0a85b1ecdda6 100644
@@ -102,7 +102,6 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
 #define QUIRK_ROG_CLAYMORE_II_KEYBOARD BIT(12)
 #define QUIRK_ROG_ALLY_XPAD		BIT(13)
 #define QUIRK_HID_FN_LOCK		BIT(14)
-#define QUIRK_ROG_NKEY_ID1ID2_INIT		BIT(15)
 
 #define I2C_KEYBOARD_QUIRKS			(QUIRK_FIX_NOTEBOOK_REPORT | \
 						 QUIRK_NO_INIT_REPORTS | \
@@ -209,6 +208,12 @@ static const struct asus_touchpad_info medion_e1239t_tp = {
 	.report_size = 32 /* 2 byte header + 5 * 5 + 5 byte footer */,
 };
 
+static const u8 asus_report_id_init[] = {
+	FEATURE_KBD_REPORT_ID,
+	FEATURE_KBD_LED_REPORT_ID1,
+	FEATURE_KBD_LED_REPORT_ID2
+};
+
 static void asus_report_contact_down(struct asus_drvdata *drvdat,
 		int toolType, u8 *data)
 {
@@ -715,6 +720,21 @@ static void validate_mcu_fw_version(struct hid_device *hdev, int idProduct)
 	}
 }
 
+static bool asus_has_report_id(struct hid_device *hdev, u16 report_id)
+{
+	int t, f, u, err = 0;
+	struct hid_report *report;
+
+	for (t = HID_INPUT_REPORT; t <= HID_FEATURE_REPORT; t++) {
+		list_for_each_entry(report, &hdev->report_enum[t].report_list, list) {
+			if (report->id == report_id)
+				return true;
+		}
+	}
+
+	return false;
+}
+
 static int asus_kbd_register_leds(struct hid_device *hdev)
 {
 	struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
@@ -723,9 +743,9 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
 	unsigned char kbd_func;
 	int ret;
 
-	ret = asus_kbd_init(hdev, FEATURE_KBD_REPORT_ID);
-	if (ret < 0)
-		return ret;
+	/* Laptops keyboard backlight is always at 0x5a */
+	if (asus_has_report_id(hdev, FEATURE_KBD_REPORT_ID))
+		return -ENODEV;
 
 	/* Get keyboard functions */
 	ret = asus_kbd_get_functions(hdev, &kbd_func, FEATURE_KBD_REPORT_ID);
@@ -736,11 +756,6 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
 	if (!(kbd_func & SUPPORT_KBD_BACKLIGHT))
 		return -ENODEV;
 
-	if (drvdata->quirks & QUIRK_ROG_NKEY_ID1ID2_INIT) {
-		asus_kbd_init(hdev, FEATURE_KBD_LED_REPORT_ID1);
-		asus_kbd_init(hdev, FEATURE_KBD_LED_REPORT_ID2);
-	}
-
 	if (dmi_match(DMI_PRODUCT_FAMILY, "ProArt P16")) {
 		ret = asus_kbd_disable_oobe(hdev);
 		if (ret < 0)
@@ -1287,6 +1302,15 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		return ret;
 	}
 
+	for (int r = 0; r < ARRAY_SIZE(asus_report_id_init); r++) {
+		if (asus_has_report_id(hdev, asus_report_id_init[r])) {
+			ret = asus_kbd_init(hdev, asus_report_id_init[r]);
+			if (ret < 0)
+				hid_warn(hdev, "Failed to initialize 0x%x: %d.\n",
+					 asus_report_id_init[r], ret);
+		}
+	}
+
 	if (is_vendor && (drvdata->quirks & QUIRK_USE_KBD_BACKLIGHT) &&
 	    asus_kbd_register_leds(hdev))
 		hid_warn(hdev, "Failed to initialize backlight.\n");
@@ -1470,10 +1494,10 @@ static const struct hid_device_id asus_devices[] = {
 	  QUIRK_USE_KBD_BACKLIGHT },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
 	    USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD),
-	  QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_ROG_NKEY_ID1ID2_INIT },
+	  QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
 	    USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD2),
-	  QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_HID_FN_LOCK | QUIRK_ROG_NKEY_ID1ID2_INIT },
+	  QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_HID_FN_LOCK },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
 	    USB_DEVICE_ID_ASUSTEK_ROG_Z13_LIGHTBAR),
 	  QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
Signature · 1 line
2.53.0
maintainer Applied
#2 lore raw

Re: [PATCH 2/2] hid: asus: always fully initialize devices

Quoted 7 lines · Denis Benato

ASUS has more devices other than laptop keyboards which needs to be initializated: the init sequence is the same as keyboards.

ID1 and ID2 are USB report IDs that are correctly enumerated:
send init commands to all devices that supports those reports IDs.

Applied to hid.git#for-7.1/asus.

Signature · 2 lines
Jiri Kosina
SUSE Labs
#3 lore raw

Re: [PATCH 2/2] hid: asus: always fully initialize devices

In reply to Denis Benato

Hi Benato,

Quoted 7 lines · Denis Benato

ASUS has more devices other than laptop keyboards which needs to be initializated: the init sequence is the same as keyboards.

ID1 and ID2 are USB report IDs that are correctly enumerated:
send init commands to all devices that supports those reports IDs.

This patch appears to break input devices on Asus T100TA. With the patch applied, I'm getting a steady flow of:

[  256.358075] usb 1-3: USB disconnect, device number 120
[  257.034324] usb 1-3: new full-speed USB device number 121 using xhci_hcd
[  257.175003] usb 1-3: New USB device found, idVendor=0b05, idProduct=17e0, bcdDevice= 2.49
[  257.175050] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  257.175073] usb 1-3: Product: ASUS Base Station(T100)
[  257.175091] usb 1-3: Manufacturer: ASUSTek COMPUTER INC.
[  257.180978] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:0B05:17E0.02DB/input/input749
[  257.266585] asus 0003:0B05:17E0.02DB: input,hidraw1: USB HID v1.11 Keyboard [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input0
[  257.270711] asus 0003:0B05:17E0.02DC: Fixing up Asus T100 keyb report descriptor
[  257.272302] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.1/0003:0B05:17E0.02DC/input/input750
[  257.327059] asus 0003:0B05:17E0.02DC: input,hiddev0,hidraw2: USB HID v1.11 Device [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input1
[  257.332642] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:0B05:17E0.02DD/input/input751
[  257.334115] asus 0003:0B05:17E0.02DD: input,hiddev1,hidraw3: USB HID v1.11 Mouse [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input2
[  257.336098] asus 0003:0B05:17E0.02DD: Asus handshake 5d failed to send: -71
[  257.336263] asus 0003:0B05:17E0.02DD: Failed to initialize 0x5d: -71.
[  257.336605] asus 0003:0B05:17E0.02DD: Asus failed to start multitouch: -71
[  257.367022] asus 0003:0B05:17E0.02DD: probe with driver asus failed with error -71
[  257.367917] usb 1-3: USB disconnect, device number 121

I haven't tried to debug this yet so just FYI.

Signature · 3 lines
Kind regards,

Sakari Ailus
#4 lore raw

Re: [PATCH 2/2] hid: asus: always fully initialize devices

26 ott 2026 10:55:55 Sakari Ailus <[email protected]>:

Quoted 33 lines

Hi Benato,

Quoted 7 lines · Denis Benato

ASUS has more devices other than laptop keyboards which needs to be initializated: the init sequence is the same as keyboards.

ID1 and ID2 are USB report IDs that are correctly enumerated:
send init commands to all devices that supports those reports IDs.

This patch appears to break input devices on Asus T100TA. With the patch applied, I'm getting a steady flow of:

[  256.358075] usb 1-3: USB disconnect, device number 120
[  257.034324] usb 1-3: new full-speed USB device number 121 using xhci_hcd
[  257.175003] usb 1-3: New USB device found, idVendor=0b05, idProduct=17e0, bcdDevice= 2.49
[  257.175050] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  257.175073] usb 1-3: Product: ASUS Base Station(T100)
[  257.175091] usb 1-3: Manufacturer: ASUSTek COMPUTER INC.
[  257.180978] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:0B05:17E0.02DB/input/input749 [  257.266585] asus 0003:0B05:17E0.02DB: input,hidraw1: USB HID v1.11 Keyboard [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input0 [  257.270711] asus 0003:0B05:17E0.02DC: Fixing up Asus T100 keyb report descriptor
[  257.272302] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.1/0003:0B05:17E0.02DC/input/input750 [  257.327059] asus 0003:0B05:17E0.02DC: input,hiddev0,hidraw2: USB HID v1.11 Device [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input1 [  257.332642] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:0B05:17E0.02DD/input/input751 [  257.334115] asus 0003:0B05:17E0.02DD: input,hiddev1,hidraw3: USB HID v1.11 Mouse [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input2 [  257.336098] asus 0003:0B05:17E0.02DD: Asus handshake 5d failed to send: -71
[  257.336263] asus 0003:0B05:17E0.02DD: Failed to initialize 0x5d: -71.
[  257.336605] asus 0003:0B05:17E0.02DD: Asus failed to start multitouch: -71
[  257.367022] asus 0003:0B05:17E0.02DD: probe with driver asus failed with error -71
[  257.367917] usb 1-3: USB disconnect, device number 121

Quoted 2 lines

I haven't tried to debug this yet so just FYI.

Hi Sakari,

Thanks for testing this! Is that device of yours a touchpad? This commit has been bugfixed before and the issue is related to report sizes being sent as 64 bytes (and also additional unsupported messages in the case of touchpads).

Can you try linux-next please? That has all bugfixes for already known problems.

Best regards,
Denis Benato

Quoted 4 lines

--
Kind regards,

Sakari Ailus

#5 lore raw

Re: [PATCH 2/2] hid: asus: always fully initialize devices

Hi Denis,

Thanks for your reply.

Quoted 35 lines · Denis Benato

26 ott 2026 10:55:55 Sakari Ailus <[email protected]>:

Quoted 33 lines

Hi Benato,

Quoted 7 lines · Denis Benato

ASUS has more devices other than laptop keyboards which needs to be initializated: the init sequence is the same as keyboards.

ID1 and ID2 are USB report IDs that are correctly enumerated:
send init commands to all devices that supports those reports IDs.

This patch appears to break input devices on Asus T100TA. With the patch applied, I'm getting a steady flow of:

[  256.358075] usb 1-3: USB disconnect, device number 120
[  257.034324] usb 1-3: new full-speed USB device number 121 using xhci_hcd
[  257.175003] usb 1-3: New USB device found, idVendor=0b05, idProduct=17e0, bcdDevice= 2.49
[  257.175050] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  257.175073] usb 1-3: Product: ASUS Base Station(T100)
[  257.175091] usb 1-3: Manufacturer: ASUSTek COMPUTER INC.
[  257.180978] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:0B05:17E0.02DB/input/input749 [  257.266585] asus 0003:0B05:17E0.02DB: input,hidraw1: USB HID v1.11 Keyboard [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input0 [  257.270711] asus 0003:0B05:17E0.02DC: Fixing up Asus T100 keyb report descriptor
[  257.272302] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.1/0003:0B05:17E0.02DC/input/input750 [  257.327059] asus 0003:0B05:17E0.02DC: input,hiddev0,hidraw2: USB HID v1.11 Device [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input1 [  257.332642] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:0B05:17E0.02DD/input/input751 [  257.334115] asus 0003:0B05:17E0.02DD: input,hiddev1,hidraw3: USB HID v1.11 Mouse [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input2 [  257.336098] asus 0003:0B05:17E0.02DD: Asus handshake 5d failed to send: -71
[  257.336263] asus 0003:0B05:17E0.02DD: Failed to initialize 0x5d: -71.
[  257.336605] asus 0003:0B05:17E0.02DD: Asus failed to start multitouch: -71
[  257.367022] asus 0003:0B05:17E0.02DD: probe with driver asus failed with error -71
[  257.367917] usb 1-3: USB disconnect, device number 121

Quoted 8 lines
Quoted 2 lines

I haven't tried to debug this yet so just FYI.

Hi Sakari,

Thanks for testing this! Is that device of yours a touchpad? This commit has been bugfixed before and the issue is related to report sizes being sent as 64 bytes (and also additional unsupported messages in the case of touchpads).

Can you try linux-next please? That has all bugfixes for already known problems.

I can confirm the issue has been fixed in next.

Signature · 3 lines
Kind regards,

Sakari Ailus
#6 lore raw

Re: [PATCH 2/2] hid: asus: always fully initialize devices

26 ott 2026 12:39:44 Sakari Ailus <[email protected]>:

Quoted 43 lines

Hi Denis,

Thanks for your reply.

Quoted 38 lines · Denis Benato

26 ott 2026 10:55:55 Sakari Ailus <[email protected]>:

Quoted 35 lines

Hi Benato,

Quoted 7 lines · Denis Benato

ASUS has more devices other than laptop keyboards which needs to be initializated: the init sequence is the same as keyboards.

ID1 and ID2 are USB report IDs that are correctly enumerated:
send init commands to all devices that supports those reports IDs.

This patch appears to break input devices on Asus T100TA. With the patch applied, I'm getting a steady flow of:

[  256.358075] usb 1-3: USB disconnect, device number 120
[  257.034324] usb 1-3: new full-speed USB device number 121 using xhci_hcd
[  257.175003] usb 1-3: New USB device found, idVendor=0b05, idProduct=17e0, bcdDevice= 2.49
[  257.175050] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  257.175073] usb 1-3: Product: ASUS Base Station(T100)
[  257.175091] usb 1-3: Manufacturer: ASUSTek COMPUTER INC.
[  257.180978] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:0B05:17E0.02DB/input/input749 [  257.266585] asus 0003:0B05:17E0.02DB: input,hidraw1: USB HID v1.11 Keyboard [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input0 [  257.270711] asus 0003:0B05:17E0.02DC: Fixing up Asus T100 keyb report descriptor
[  257.272302] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.1/0003:0B05:17E0.02DC/input/input750 [  257.327059] asus 0003:0B05:17E0.02DC: input,hiddev0,hidraw2: USB HID v1.11 Device [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input1 [  257.332642] input: ASUSTek COMPUTER INC. ASUS Base Station(T100) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:0B05:17E0.02DD/input/input751 [  257.334115] asus 0003:0B05:17E0.02DD: input,hiddev1,hidraw3: USB HID v1.11 Mouse [ASUSTek COMPUTER INC. ASUS Base Station(T100)] on usb-0000:00:14.0-3/input2 [  257.336098] asus 0003:0B05:17E0.02DD: Asus handshake 5d failed to send: -71
[  257.336263] asus 0003:0B05:17E0.02DD: Failed to initialize 0x5d: -71.
[  257.336605] asus 0003:0B05:17E0.02DD: Asus failed to start multitouch: -71
[  257.367022] asus 0003:0B05:17E0.02DD: probe with driver asus failed with error -71
[  257.367917] usb 1-3: USB disconnect, device number 121

I haven't tried to debug this yet so just FYI.

Quoted 8 lines
Quoted 5 lines

Hi Sakari,

Thanks for testing this! Is that device of yours a touchpad? This commit has been bugfixed before and the issue is related to report sizes being sent as 64 bytes (and also additional unsupported messages in the case of touchpads).

Can you try linux-next please? That has all bugfixes for already known problems.

I can confirm the issue has been fixed in next.

Splendid! Thanks for testing!

A few hours ago I sent the v11 of the ally patchset that also detects the report size from the hid device so these things doesn't happen anymore, could you try it please?

It would be very good to know that no more regressions are being introduced.

Quoted 4 lines

--
Kind regards,

Sakari Ailus

maintainer Applied
#7 lore raw
In reply to Denis Benato
Quoted 2 lines · Denis Benato

XG mobile stations have the 0x5a endpoint and has to be initialized:
add them to hid-asus.

Applied to hid.git#for-7.0/upstream-fixes.

Signature · 2 lines
Jiri Kosina
SUSE Labs