[PATCH 3/6] HID: asus: add support for T3304 detachable keyboard

James Ye
2026-05-03T07:27:07Z

ASUSTek Computer, Inc. T3304 Soft Keyboard [0b05:1aad] is the detachable
keyboard of the ASUS Vivobook 13 Slate OLED (T3304). It presents as a
USB device with two interfaces: a keyboard and a pointing device
(touchpad).

Basic keyboard and full touchpad functionality work out-of-the-box with
hid-generic and hid-multitouch, but function key combos e.g. volume,
brightness control, home/end/pgup/pgdown require initialization.

Bind the keyboard interface to hid-asus for initialization. The
OEM-specific report descriptors required for this are present only on
the touchpad interface, not the keyboard, so a quirk is used to add the
required feature descriptor.

Signed-off-by: James Ye <jye836@gmail.com>
---
drivers/hid/hid-asus.c | 58 +++++++++++++++++++++++++++++++++++++++---
drivers/hid/hid-ids.h | 1 +
2 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index ef9d5eba4dc9..e4c97fddfaf1 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -99,6 +99,7 @@ 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_T3304_KEYBOARD BIT(15)

#define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \
QUIRK_NO_INIT_REPORTS | \
@@ -494,6 +495,14 @@ static int asus_kbd_init(struct hid_device *hdev, u8 report_id)
return ret;
}

+ struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
+
+ /* T3304 keyboard always replies with 16 0xff bytes. Don't check for
+ * acknowledgment.
+ */
+ if (drvdata->quirks & QUIRK_T3304_KEYBOARD)
+ return 0;
+
u8 *readbuf __free(kfree) = kzalloc(FEATURE_KBD_REPORT_SIZE, GFP_KERNEL);
if (!readbuf)
return -ENOMEM;
@@ -1312,10 +1321,12 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
hid_warn(hdev, "Failed to initialize backlight.\n");

/*
- * For ROG keyboards, skip rename for consistency and ->input check as
- * some devices do not have inputs.
+ * For ROG and T3304 keyboards, skip rename for consistency.
+ * For ROG keyboards, skip ->input check as some devices do not have
+ * inputs.
*/
- if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD)
+ if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD ||
+ drvdata->quirks & QUIRK_T3304_KEYBOARD)
return 0;

/*
@@ -1369,6 +1380,22 @@ static const __u8 asus_g752_fixed_rdesc[] = {
0x2A, 0xFF, 0x00, /* Usage Maximum (0xFF) */
};

+static const __u8 asus_t3304_fixed_rdesc[] = {
+ 0x06, 0x31, 0xff, // Usage Page (Vendor Usage Page 0xff31)
+ 0x09, 0x76, // Usage (Vendor Usage 0x76)
+ 0xa1, 0x01, // Collection (Application)
+ 0x05, 0xff, // Usage Page (Vendor Usage Page 0xff)
+ 0x85, 0x5a, // Report ID (90)
+ 0x19, 0x00, // Usage Minimum (0)
+ 0x2a, 0xff, 0x00, // Usage Maximum (255)
+ 0x15, 0x00, // Logical Minimum (0)
+ 0x26, 0xff, 0x00, // Logical Maximum (255)
+ 0x75, 0x08, // Report Size (8)
+ 0x95, 0x0f, // Report Count (15)
+ 0xb1, 0x02, // Feature (Data,Var,Abs)
+ 0xc0, // End Collection
+};
+
static const __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
@@ -1473,6 +1500,28 @@ static const __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
}
}

+ /* T3304 keyboard's vendor descriptors are on the touchpad interface,
+ * not the keyboard. But we need hid-multitouch to handle the touchpad,
+ * Add a descriptor with only the config report so that this driver can
+ * perform initialization.
+ */
+ if (drvdata->quirks & QUIRK_T3304_KEYBOARD) {
+ __u8 *new_rdesc;
+ size_t new_size = *rsize + sizeof(asus_t3304_fixed_rdesc);
+
+ new_rdesc = devm_kzalloc(&hdev->dev, new_size, GFP_KERNEL);
+ if (new_rdesc == NULL)
+ return rdesc;
+
+ hid_info(hdev, "Fixing up Asus T3304 keyboard report descriptor\n");
+ memcpy(new_rdesc, rdesc, *rsize);
+ memcpy(new_rdesc + *rsize, asus_t3304_fixed_rdesc,
+ sizeof(asus_t3304_fixed_rdesc));
+
+ *rsize = new_size;
+ rdesc = new_rdesc;
+ }
+
return rdesc;
}

@@ -1536,6 +1585,9 @@ static const struct hid_device_id asus_devices[] = {
QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD) },
+ { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
+ USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T3304_KEYBOARD),
+ QUIRK_T3304_KEYBOARD },
{ }
};
MODULE_DEVICE_TABLE(hid, asus_devices);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 0cf63742315b..ecf30e36a99d 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -219,6 +219,7 @@
#define USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD 0x8502
#define USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD 0x183d
#define USB_DEVICE_ID_ASUSTEK_T304_KEYBOARD 0x184a
+#define USB_DEVICE_ID_ASUSTEK_T3304_KEYBOARD 0x1aad
#define USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD 0x8585
#define USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD 0x0101
#define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1 0x1854
--
2.54.0