Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Hans de Goede | f1918be | 2017-05-10 17:12:53 +0200 | [diff] [blame] | 2 | /* |
| 3 | * HID driver for some ITE "special" devices |
| 4 | * Copyright (c) 2017 Hans de Goede <hdegoede@redhat.com> |
Hans de Goede | f1918be | 2017-05-10 17:12:53 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <linux/device.h> |
| 8 | #include <linux/input.h> |
| 9 | #include <linux/hid.h> |
| 10 | #include <linux/module.h> |
| 11 | |
| 12 | #include "hid-ids.h" |
| 13 | |
| 14 | static int ite_event(struct hid_device *hdev, struct hid_field *field, |
| 15 | struct hid_usage *usage, __s32 value) |
| 16 | { |
| 17 | struct input_dev *input; |
| 18 | |
| 19 | if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput) |
| 20 | return 0; |
| 21 | |
| 22 | input = field->hidinput->input; |
| 23 | |
| 24 | /* |
| 25 | * The ITE8595 always reports 0 as value for the rfkill button. Luckily |
| 26 | * it is the only button in its report, and it sends a report on |
| 27 | * release only, so receiving a report means the button was pressed. |
| 28 | */ |
| 29 | if (usage->hid == HID_GD_RFKILL_BTN) { |
| 30 | input_event(input, EV_KEY, KEY_RFKILL, 1); |
| 31 | input_sync(input); |
| 32 | input_event(input, EV_KEY, KEY_RFKILL, 0); |
| 33 | input_sync(input); |
| 34 | return 1; |
| 35 | } |
| 36 | |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | static const struct hid_device_id ite_devices[] = { |
| 41 | { HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE8595) }, |
Hans de Goede | 4050207 | 2018-11-26 11:52:18 +0100 | [diff] [blame] | 42 | { HID_USB_DEVICE(USB_VENDOR_ID_258A, USB_DEVICE_ID_258A_6A88) }, |
Hans de Goede | 8f18eca | 2019-11-19 15:57:11 +0100 | [diff] [blame] | 43 | /* ITE8595 USB kbd ctlr, with Synaptics touchpad connected to it. */ |
Hans de Goede | beae561 | 2020-02-01 12:56:48 +0100 | [diff] [blame] | 44 | { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, |
| 45 | USB_VENDOR_ID_SYNAPTICS, |
| 46 | USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012) }, |
Hans de Goede | f1918be | 2017-05-10 17:12:53 +0200 | [diff] [blame] | 47 | { } |
| 48 | }; |
| 49 | MODULE_DEVICE_TABLE(hid, ite_devices); |
| 50 | |
| 51 | static struct hid_driver ite_driver = { |
| 52 | .name = "itetech", |
| 53 | .id_table = ite_devices, |
| 54 | .event = ite_event, |
| 55 | }; |
| 56 | module_hid_driver(ite_driver); |
| 57 | |
| 58 | MODULE_LICENSE("GPL"); |