HID: asus: Add T100CHI bluetooth keyboard dock special keys mapping
authorHans de Goede <hdegoede@redhat.com>
Sun, 2 Jul 2017 14:34:15 +0000 (16:34 +0200)
committerJiri Kosina <jkosina@suse.cz>
Thu, 20 Jul 2017 14:02:35 +0000 (16:02 +0200)
The Asus Transformer T100CHI comes with a Bluetooth keyboard dock which
uses the same 0xff31 Asus vendor HUT page as other Asus keyboards.

This commit adds its device-id to hid-asus and fixes an issue in the
descriptor of the 0xff31 Usage, which together fixes the special keys
on this keyboard not working.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-asus.c
drivers/hid/hid-core.c
drivers/hid/hid-ids.h

index b2501b64ab9d839b245cfd5d894bda26dec23f76..43fb4a331cf3f524a433336e83536992b51241c9 100644 (file)
@@ -65,6 +65,7 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
 #define QUIRK_NO_CONSUMER_USAGES       BIT(4)
 #define QUIRK_USE_KBD_BACKLIGHT                BIT(5)
 #define QUIRK_T100_KEYBOARD            BIT(6)
+#define QUIRK_T100CHI                  BIT(7)
 
 #define I2C_KEYBOARD_QUIRKS                    (QUIRK_FIX_NOTEBOOK_REPORT | \
                                                 QUIRK_NO_INIT_REPORTS | \
@@ -619,11 +620,34 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
                hid_info(hdev, "Fixing up Asus notebook report descriptor\n");
                rdesc[55] = 0xdd;
        }
+       /* For the T100TA keyboard dock */
        if (drvdata->quirks & QUIRK_T100_KEYBOARD &&
                 *rsize == 76 && rdesc[73] == 0x81 && rdesc[74] == 0x01) {
                hid_info(hdev, "Fixing up Asus T100 keyb report descriptor\n");
                rdesc[74] &= ~HID_MAIN_ITEM_CONSTANT;
        }
+       /* For the T100CHI keyboard dock */
+       if (drvdata->quirks & QUIRK_T100CHI &&
+                *rsize == 403 && rdesc[388] == 0x09 && rdesc[389] == 0x76) {
+               /*
+                * Change Usage (76h) to Usage Minimum (00h), Usage Maximum
+                * (FFh) and clear the flags in the Input() byte.
+                * Note the descriptor has a bogus 0 byte at the end so we
+                * only need 1 extra byte.
+                */
+               *rsize = 404;
+               rdesc = kmemdup(rdesc, *rsize, GFP_KERNEL);
+               if (!rdesc)
+                       return NULL;
+
+               hid_info(hdev, "Fixing up T100CHI keyb report descriptor\n");
+               memmove(rdesc + 392, rdesc + 390, 12);
+               rdesc[388] = 0x19;
+               rdesc[389] = 0x00;
+               rdesc[390] = 0x29;
+               rdesc[391] = 0xff;
+               rdesc[402] = 0x00;
+       }
 
        return rdesc;
 }
@@ -643,6 +667,9 @@ static const struct hid_device_id asus_devices[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_ASUS_AK1D) },
        { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) },
        { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) },
+       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK,
+               USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD), QUIRK_T100CHI },
+
        { }
 };
 MODULE_DEVICE_TABLE(hid, asus_devices);
index 6fd01a692197af4e70c9e1bb4bfd0bd8ffb4f348..e5e260f6124ea59aad0b410c55e7283923d0cff7 100644 (file)
@@ -1982,6 +1982,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T100_KEYBOARD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) },
        { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) },
+       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD) },
 #endif
 #if IS_ENABLED(CONFIG_HID_AUREAL)
        { HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) },
index 3d911bfd91cf1a8ea67c504f344ecba32acc603e..10935956f5c64e236e42d4e1f88e7b37ad52dfb5 100644 (file)
 #define USB_DEVICE_ID_ASUSTEK_LCM      0x1726
 #define USB_DEVICE_ID_ASUSTEK_LCM2     0x175b
 #define USB_DEVICE_ID_ASUSTEK_T100_KEYBOARD    0x17e0
+#define USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD 0x8502
 #define USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD     0x8585
 #define USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD     0x0101
 #define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1 0x1854