1 // SPDX-License-Identifier: GPL-2.0-only
3 * HID driver for some ITE "special" devices
4 * Copyright (c) 2017 Hans de Goede <hdegoede@redhat.com>
7 #include <linux/device.h>
8 #include <linux/input.h>
10 #include <linux/module.h>
14 #define QUIRK_TOUCHPAD_ON_OFF_REPORT BIT(0)
16 static __u8 *ite_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize)
18 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
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;
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,
36 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
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);
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);
56 static int ite_event(struct hid_device *hdev, struct hid_field *field,
57 struct hid_usage *usage, __s32 value)
59 struct input_dev *input;
61 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput)
64 input = field->hidinput->input;
67 * The ITE8595 always reports 0 as value for the rfkill button. Luckily
68 * it is the only button in its report, and it sends a report on
69 * release only, so receiving a report means the button was pressed.
71 if (usage->hid == HID_GD_RFKILL_BTN) {
72 input_event(input, EV_KEY, KEY_RFKILL, 1);
74 input_event(input, EV_KEY, KEY_RFKILL, 0);
82 static int ite_probe(struct hid_device *hdev, const struct hid_device_id *id)
86 hid_set_drvdata(hdev, (void *)id->driver_data);
88 ret = hid_open_report(hdev);
92 return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
95 static const struct hid_device_id ite_devices[] = {
96 { HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE8595) },
97 { HID_USB_DEVICE(USB_VENDOR_ID_258A, USB_DEVICE_ID_258A_6A88) },
98 /* ITE8595 USB kbd ctlr, with Synaptics touchpad connected to it. */
99 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
100 USB_VENDOR_ID_SYNAPTICS,
101 USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012),
102 .driver_data = QUIRK_TOUCHPAD_ON_OFF_REPORT },
103 /* ITE8910 USB kbd ctlr, with Synaptics touchpad connected to it. */
104 { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
105 USB_VENDOR_ID_SYNAPTICS,
106 USB_DEVICE_ID_SYNAPTICS_ACER_ONE_S1003) },
109 MODULE_DEVICE_TABLE(hid, ite_devices);
111 static struct hid_driver ite_driver = {
113 .id_table = ite_devices,
115 .report_fixup = ite_report_fixup,
116 .input_mapping = ite_input_mapping,
119 module_hid_driver(ite_driver);
121 MODULE_LICENSE("GPL");