Skip to content

Commit 3c785a0

Browse files
jwrdegoedeJiri Kosina
authored andcommitted
HID: ite: Replace ABS_MISC 120/121 events with touchpad on/off keypresses
The usb-hid keyboard-dock for the Acer Switch 10 SW5-012 model declares an application and hid-usage page of 0x0088 for the INPUT(4) report which it sends. This reports contains 2 8-bit fields which are declared as HID_MAIN_ITEM_VARIABLE. The keyboard-touchpad combo never actually generates this report, except when the touchpad is toggled on/off with the Fn + F7 hotkey combo. The toggle on/off is handled inside the keyboard-dock, when the touchpad is toggled off it simply stops sending events. When the touchpad is toggled on/off an INPUT(4) report is generated with the first content byte set to 120/121, before this commit the kernel would report this as ABS_MISC 120/121 events. Patch the descriptor to replace the HID_MAIN_ITEM_VARIABLE with HID_MAIN_ITEM_RELATIVE (because no key-presss release events are send) and add mappings for the 0x00880078 and 0x00880079 usages to generate touchpad on/off key events when the touchpad is toggled on/off. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent b59f38d commit 3c785a0

1 file changed

Lines changed: 60 additions & 1 deletion

File tree

drivers/hid/hid-ite.c

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,48 @@
1111

1212
#include "hid-ids.h"
1313

14+
#define QUIRK_TOUCHPAD_ON_OFF_REPORT BIT(0)
15+
16+
static __u8 *ite_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize)
17+
{
18+
unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
19+
20+
if (quirks & QUIRK_TOUCHPAD_ON_OFF_REPORT) {
21+
if (*rsize == 188 && rdesc[162] == 0x81 && rdesc[163] == 0x02) {
22+
hid_info(hdev, "Fixing up ITE keyboard report descriptor\n");
23+
rdesc[163] = HID_MAIN_ITEM_RELATIVE;
24+
}
25+
}
26+
27+
return rdesc;
28+
}
29+
30+
static int ite_input_mapping(struct hid_device *hdev,
31+
struct hid_input *hi, struct hid_field *field,
32+
struct hid_usage *usage, unsigned long **bit,
33+
int *max)
34+
{
35+
36+
unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
37+
38+
if ((quirks & QUIRK_TOUCHPAD_ON_OFF_REPORT) &&
39+
(usage->hid & HID_USAGE_PAGE) == 0x00880000) {
40+
if (usage->hid == 0x00880078) {
41+
/* Touchpad on, userspace expects F22 for this */
42+
hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_F22);
43+
return 1;
44+
}
45+
if (usage->hid == 0x00880079) {
46+
/* Touchpad off, userspace expects F23 for this */
47+
hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_F23);
48+
return 1;
49+
}
50+
return -1;
51+
}
52+
53+
return 0;
54+
}
55+
1456
static int ite_event(struct hid_device *hdev, struct hid_field *field,
1557
struct hid_usage *usage, __s32 value)
1658
{
@@ -37,13 +79,27 @@ static int ite_event(struct hid_device *hdev, struct hid_field *field,
3779
return 0;
3880
}
3981

82+
static int ite_probe(struct hid_device *hdev, const struct hid_device_id *id)
83+
{
84+
int ret;
85+
86+
hid_set_drvdata(hdev, (void *)id->driver_data);
87+
88+
ret = hid_open_report(hdev);
89+
if (ret)
90+
return ret;
91+
92+
return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
93+
}
94+
4095
static const struct hid_device_id ite_devices[] = {
4196
{ HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE8595) },
4297
{ HID_USB_DEVICE(USB_VENDOR_ID_258A, USB_DEVICE_ID_258A_6A88) },
4398
/* ITE8595 USB kbd ctlr, with Synaptics touchpad connected to it. */
4499
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
45100
USB_VENDOR_ID_SYNAPTICS,
46-
USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012) },
101+
USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012),
102+
.driver_data = QUIRK_TOUCHPAD_ON_OFF_REPORT },
47103
/* ITE8910 USB kbd ctlr, with Synaptics touchpad connected to it. */
48104
{ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
49105
USB_VENDOR_ID_SYNAPTICS,
@@ -55,6 +111,9 @@ MODULE_DEVICE_TABLE(hid, ite_devices);
55111
static struct hid_driver ite_driver = {
56112
.name = "itetech",
57113
.id_table = ite_devices,
114+
.probe = ite_probe,
115+
.report_fixup = ite_report_fixup,
116+
.input_mapping = ite_input_mapping,
58117
.event = ite_event,
59118
};
60119
module_hid_driver(ite_driver);

0 commit comments

Comments
 (0)