diff options
| author | Tom Harwood <tomharwood@fastmail.fm> | 2012-07-06 11:05:04 -0400 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2012-07-12 06:34:43 -0400 |
| commit | ff9bf5a2eff6e726406bcc097e8a578822d38859 (patch) | |
| tree | c6f6c991d504732542c8552954e2235acc9a26d7 | |
| parent | 929578ab0339fe42bb3ceeaa2e6607189cddf70b (diff) | |
HID: Add driver for Holtek based keyboards with broken HID
Corrects two HID descriptor issues, which prevent some Holtek based
(USB ID 04d9:a055) keyboards from working. The error when not using
the driver is: generic-usb: probe ... failed with error -22 .
Signed-off-by: Tom Harwood <tomharwood@fastmail.fm>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
| -rw-r--r-- | drivers/hid/Kconfig | 6 | ||||
| -rw-r--r-- | drivers/hid/Makefile | 1 | ||||
| -rw-r--r-- | drivers/hid/hid-core.c | 1 | ||||
| -rw-r--r-- | drivers/hid/hid-holtek-kbd.c | 183 | ||||
| -rw-r--r-- | drivers/hid/hid-ids.h | 3 |
5 files changed, 192 insertions, 2 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index cbf0e0344e3e..8e439e290fc4 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
| @@ -200,10 +200,12 @@ config HID_EZKEY | |||
| 200 | Support for Ezkey BTC 8193 keyboard. | 200 | Support for Ezkey BTC 8193 keyboard. |
| 201 | 201 | ||
| 202 | config HID_HOLTEK | 202 | config HID_HOLTEK |
| 203 | tristate "Holtek On Line Grip based game controller support" | 203 | tristate "Holtek HID devices" |
| 204 | depends on USB_HID | 204 | depends on USB_HID |
| 205 | ---help--- | 205 | ---help--- |
| 206 | Say Y here if you have a Holtek On Line Grip based game controller. | 206 | Support for Holtek based devices: |
| 207 | - Holtek On Line Grip based game controller | ||
| 208 | - Trust GXT 18 Gaming Keyboard | ||
| 207 | 209 | ||
| 208 | config HOLTEK_FF | 210 | config HOLTEK_FF |
| 209 | bool "Holtek On Line Grip force feedback support" | 211 | bool "Holtek On Line Grip force feedback support" |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 05913c533ec5..2429ae7c58c0 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
| @@ -48,6 +48,7 @@ obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o | |||
| 48 | obj-$(CONFIG_HID_ELECOM) += hid-elecom.o | 48 | obj-$(CONFIG_HID_ELECOM) += hid-elecom.o |
| 49 | obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o | 49 | obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o |
| 50 | obj-$(CONFIG_HID_GYRATION) += hid-gyration.o | 50 | obj-$(CONFIG_HID_GYRATION) += hid-gyration.o |
| 51 | obj-$(CONFIG_HID_HOLTEK) += hid-holtek-kbd.o | ||
| 51 | obj-$(CONFIG_HID_HOLTEK) += hid-holtekff.o | 52 | obj-$(CONFIG_HID_HOLTEK) += hid-holtekff.o |
| 52 | obj-$(CONFIG_HID_HYPERV_MOUSE) += hid-hyperv.o | 53 | obj-$(CONFIG_HID_HYPERV_MOUSE) += hid-hyperv.o |
| 53 | obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o | 54 | obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index f69568032c04..ba1c3644e6ac 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
| @@ -1536,6 +1536,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
| 1536 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, | 1536 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, |
| 1537 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, | 1537 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, |
| 1538 | { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) }, | 1538 | { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK, USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP) }, |
| 1539 | { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD) }, | ||
| 1539 | { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, | 1540 | { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, |
| 1540 | { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, | 1541 | { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, |
| 1541 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, | 1542 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, |
diff --git a/drivers/hid/hid-holtek-kbd.c b/drivers/hid/hid-holtek-kbd.c new file mode 100644 index 000000000000..e0a5d1739fc3 --- /dev/null +++ b/drivers/hid/hid-holtek-kbd.c | |||
| @@ -0,0 +1,183 @@ | |||
| 1 | /* | ||
| 2 | * HID driver for Holtek keyboard | ||
| 3 | * Copyright (c) 2012 Tom Harwood | ||
| 4 | */ | ||
| 5 | |||
| 6 | /* | ||
| 7 | * This program is free software; you can redistribute it and/or modify it | ||
| 8 | * under the terms of the GNU General Public License as published by the Free | ||
| 9 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 10 | * any later version. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/device.h> | ||
| 14 | #include <linux/hid.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/usb.h> | ||
| 17 | |||
| 18 | #include "hid-ids.h" | ||
| 19 | #include "usbhid/usbhid.h" | ||
| 20 | |||
| 21 | /* Holtek based keyboards (USB ID 04d9:a055) have the following issues: | ||
| 22 | * - The report descriptor specifies an excessively large number of consumer | ||
| 23 | * usages (2^15), which is more than HID_MAX_USAGES. This prevents proper | ||
| 24 | * parsing of the report descriptor. | ||
| 25 | * - The report descriptor reports on caps/scroll/num lock key presses, but | ||
| 26 | * doesn't have an LED output usage block. | ||
| 27 | * | ||
| 28 | * The replacement descriptor below fixes the number of consumer usages, | ||
| 29 | * and provides an LED output usage block. LED output events are redirected | ||
| 30 | * to the boot interface. | ||
| 31 | */ | ||
| 32 | |||
| 33 | static __u8 holtek_kbd_rdesc_fixed[] = { | ||
| 34 | /* Original report descriptor, with reduced number of consumer usages */ | ||
| 35 | 0x05, 0x01, /* Usage Page (Desktop), */ | ||
| 36 | 0x09, 0x80, /* Usage (Sys Control), */ | ||
| 37 | 0xA1, 0x01, /* Collection (Application), */ | ||
| 38 | 0x85, 0x01, /* Report ID (1), */ | ||
| 39 | 0x19, 0x81, /* Usage Minimum (Sys Power Down), */ | ||
| 40 | 0x29, 0x83, /* Usage Maximum (Sys Wake Up), */ | ||
| 41 | 0x15, 0x00, /* Logical Minimum (0), */ | ||
| 42 | 0x25, 0x01, /* Logical Maximum (1), */ | ||
| 43 | 0x95, 0x03, /* Report Count (3), */ | ||
| 44 | 0x75, 0x01, /* Report Size (1), */ | ||
| 45 | 0x81, 0x02, /* Input (Variable), */ | ||
| 46 | 0x95, 0x01, /* Report Count (1), */ | ||
| 47 | 0x75, 0x05, /* Report Size (5), */ | ||
| 48 | 0x81, 0x01, /* Input (Constant), */ | ||
| 49 | 0xC0, /* End Collection, */ | ||
| 50 | 0x05, 0x0C, /* Usage Page (Consumer), */ | ||
| 51 | 0x09, 0x01, /* Usage (Consumer Control), */ | ||
| 52 | 0xA1, 0x01, /* Collection (Application), */ | ||
| 53 | 0x85, 0x02, /* Report ID (2), */ | ||
| 54 | 0x19, 0x00, /* Usage Minimum (00h), */ | ||
| 55 | 0x2A, 0xFF, 0x2F, /* Usage Maximum (0x2FFF), previously 0x7FFF */ | ||
| 56 | 0x15, 0x00, /* Logical Minimum (0), */ | ||
| 57 | 0x26, 0xFF, 0x2F, /* Logical Maximum (0x2FFF),previously 0x7FFF*/ | ||
| 58 | 0x95, 0x01, /* Report Count (1), */ | ||
| 59 | 0x75, 0x10, /* Report Size (16), */ | ||
| 60 | 0x81, 0x00, /* Input, */ | ||
| 61 | 0xC0, /* End Collection, */ | ||
| 62 | 0x05, 0x01, /* Usage Page (Desktop), */ | ||
| 63 | 0x09, 0x06, /* Usage (Keyboard), */ | ||
| 64 | 0xA1, 0x01, /* Collection (Application), */ | ||
| 65 | 0x85, 0x03, /* Report ID (3), */ | ||
| 66 | 0x95, 0x38, /* Report Count (56), */ | ||
| 67 | 0x75, 0x01, /* Report Size (1), */ | ||
| 68 | 0x15, 0x00, /* Logical Minimum (0), */ | ||
| 69 | 0x25, 0x01, /* Logical Maximum (1), */ | ||
| 70 | 0x05, 0x07, /* Usage Page (Keyboard), */ | ||
| 71 | 0x19, 0xE0, /* Usage Minimum (KB Leftcontrol), */ | ||
| 72 | 0x29, 0xE7, /* Usage Maximum (KB Right GUI), */ | ||
| 73 | 0x19, 0x00, /* Usage Minimum (None), */ | ||
| 74 | 0x29, 0x2F, /* Usage Maximum (KB Lboxbracket And Lbrace),*/ | ||
| 75 | 0x81, 0x02, /* Input (Variable), */ | ||
| 76 | 0xC0, /* End Collection, */ | ||
| 77 | 0x05, 0x01, /* Usage Page (Desktop), */ | ||
| 78 | 0x09, 0x06, /* Usage (Keyboard), */ | ||
| 79 | 0xA1, 0x01, /* Collection (Application), */ | ||
| 80 | 0x85, 0x04, /* Report ID (4), */ | ||
| 81 | 0x95, 0x38, /* Report Count (56), */ | ||
| 82 | 0x75, 0x01, /* Report Size (1), */ | ||
| 83 | 0x15, 0x00, /* Logical Minimum (0), */ | ||
| 84 | 0x25, 0x01, /* Logical Maximum (1), */ | ||
| 85 | 0x05, 0x07, /* Usage Page (Keyboard), */ | ||
| 86 | 0x19, 0x30, /* Usage Minimum (KB Rboxbracket And Rbrace),*/ | ||
| 87 | 0x29, 0x67, /* Usage Maximum (KP Equals), */ | ||
| 88 | 0x81, 0x02, /* Input (Variable), */ | ||
| 89 | 0xC0, /* End Collection */ | ||
| 90 | |||
| 91 | /* LED usage for the boot protocol interface */ | ||
| 92 | 0x05, 0x01, /* Usage Page (Desktop), */ | ||
| 93 | 0x09, 0x06, /* Usage (Keyboard), */ | ||
| 94 | 0xA1, 0x01, /* Collection (Application), */ | ||
| 95 | 0x05, 0x08, /* Usage Page (LED), */ | ||
| 96 | 0x19, 0x01, /* Usage Minimum (01h), */ | ||
| 97 | 0x29, 0x03, /* Usage Maximum (03h), */ | ||
| 98 | 0x15, 0x00, /* Logical Minimum (0), */ | ||
| 99 | 0x25, 0x01, /* Logical Maximum (1), */ | ||
| 100 | 0x75, 0x01, /* Report Size (1), */ | ||
| 101 | 0x95, 0x03, /* Report Count (3), */ | ||
| 102 | 0x91, 0x02, /* Output (Variable), */ | ||
| 103 | 0x95, 0x05, /* Report Count (5), */ | ||
| 104 | 0x91, 0x01, /* Output (Constant), */ | ||
| 105 | 0xC0, /* End Collection */ | ||
| 106 | }; | ||
| 107 | |||
| 108 | static __u8 *holtek_kbd_report_fixup(struct hid_device *hdev, __u8 *rdesc, | ||
| 109 | unsigned int *rsize) | ||
| 110 | { | ||
| 111 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); | ||
| 112 | |||
| 113 | if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { | ||
| 114 | rdesc = holtek_kbd_rdesc_fixed; | ||
| 115 | *rsize = sizeof(holtek_kbd_rdesc_fixed); | ||
| 116 | } | ||
| 117 | return rdesc; | ||
| 118 | } | ||
| 119 | |||
| 120 | static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type, | ||
| 121 | unsigned int code, | ||
| 122 | int value) | ||
| 123 | { | ||
| 124 | struct hid_device *hid = input_get_drvdata(dev); | ||
| 125 | struct usb_device *usb_dev = hid_to_usb_dev(hid); | ||
| 126 | |||
| 127 | /* Locate the boot interface, to receive the LED change events */ | ||
| 128 | struct usb_interface *boot_interface = usb_ifnum_to_if(usb_dev, 0); | ||
| 129 | |||
| 130 | struct hid_device *boot_hid = usb_get_intfdata(boot_interface); | ||
| 131 | struct hid_input *boot_hid_input = list_first_entry(&boot_hid->inputs, | ||
| 132 | struct hid_input, list); | ||
| 133 | |||
| 134 | return boot_hid_input->input->event(boot_hid_input->input, type, code, | ||
| 135 | value); | ||
| 136 | } | ||
| 137 | |||
| 138 | static int holtek_kbd_probe(struct hid_device *hdev, | ||
| 139 | const struct hid_device_id *id) | ||
| 140 | { | ||
| 141 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); | ||
| 142 | int ret = hid_parse(hdev); | ||
| 143 | |||
| 144 | if (!ret) | ||
| 145 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | ||
| 146 | |||
| 147 | if (!ret && intf->cur_altsetting->desc.bInterfaceNumber == 1) { | ||
| 148 | struct hid_input *hidinput; | ||
| 149 | list_for_each_entry(hidinput, &hdev->inputs, list) { | ||
| 150 | hidinput->input->event = holtek_kbd_input_event; | ||
| 151 | } | ||
| 152 | } | ||
| 153 | |||
| 154 | return ret; | ||
| 155 | } | ||
| 156 | |||
| 157 | static const struct hid_device_id holtek_kbd_devices[] = { | ||
| 158 | { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, | ||
| 159 | USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD) }, | ||
| 160 | { } | ||
| 161 | }; | ||
| 162 | MODULE_DEVICE_TABLE(hid, holtek_kbd_devices); | ||
| 163 | |||
| 164 | static struct hid_driver holtek_kbd_driver = { | ||
| 165 | .name = "holtek_kbd", | ||
| 166 | .id_table = holtek_kbd_devices, | ||
| 167 | .report_fixup = holtek_kbd_report_fixup, | ||
| 168 | .probe = holtek_kbd_probe | ||
| 169 | }; | ||
| 170 | |||
| 171 | static int __init holtek_kbd_init(void) | ||
| 172 | { | ||
| 173 | return hid_register_driver(&holtek_kbd_driver); | ||
| 174 | } | ||
| 175 | |||
| 176 | static void __exit holtek_kbd_exit(void) | ||
| 177 | { | ||
| 178 | hid_unregister_driver(&holtek_kbd_driver); | ||
| 179 | } | ||
| 180 | |||
| 181 | module_exit(holtek_kbd_exit); | ||
| 182 | module_init(holtek_kbd_init); | ||
| 183 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index c607e6f33953..a139d9619ad1 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
| @@ -404,6 +404,9 @@ | |||
| 404 | #define USB_VENDOR_ID_HOLTEK 0x1241 | 404 | #define USB_VENDOR_ID_HOLTEK 0x1241 |
| 405 | #define USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP 0x5015 | 405 | #define USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP 0x5015 |
| 406 | 406 | ||
| 407 | #define USB_VENDOR_ID_HOLTEK_ALT 0x04d9 | ||
| 408 | #define USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD 0xa055 | ||
| 409 | |||
| 407 | #define USB_VENDOR_ID_IMATION 0x0718 | 410 | #define USB_VENDOR_ID_IMATION 0x0718 |
| 408 | #define USB_DEVICE_ID_DISC_STAKKA 0xd000 | 411 | #define USB_DEVICE_ID_DISC_STAKKA 0xd000 |
| 409 | 412 | ||
