xref: /openbmc/linux/drivers/hid/hid-evision.c (revision e847c767)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *  HID driver for EVision devices
4  *  For now, only ignore bogus consumer reports
5  *  sent after the keyboard has been configured
6  *
7  *  Copyright (c) 2022 Philippe Valembois
8  */
9 
10 #include <linux/device.h>
11 #include <linux/input.h>
12 #include <linux/hid.h>
13 #include <linux/module.h>
14 
15 #include "hid-ids.h"
16 
17 static int evision_input_mapping(struct hid_device *hdev, struct hid_input *hi,
18 		struct hid_field *field, struct hid_usage *usage,
19 		unsigned long **bit, int *max)
20 {
21 	if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
22 		return 0;
23 
24 	/* Ignore key down event */
25 	if ((usage->hid & HID_USAGE) >> 8 == 0x05)
26 		return -1;
27 	/* Ignore key up event */
28 	if ((usage->hid & HID_USAGE) >> 8 == 0x06)
29 		return -1;
30 
31 	switch (usage->hid & HID_USAGE) {
32 	/* Ignore configuration saved event */
33 	case 0x0401: return -1;
34 	/* Ignore reset event */
35 	case 0x0402: return -1;
36 	}
37 	return 0;
38 }
39 
40 static const struct hid_device_id evision_devices[] = {
41 	{ HID_USB_DEVICE(USB_VENDOR_ID_EVISION, USB_DEVICE_ID_EVISION_ICL01) },
42 	{ }
43 };
44 MODULE_DEVICE_TABLE(hid, evision_devices);
45 
46 static struct hid_driver evision_driver = {
47 	.name = "evision",
48 	.id_table = evision_devices,
49 	.input_mapping = evision_input_mapping,
50 };
51 module_hid_driver(evision_driver);
52 
53 MODULE_LICENSE("GPL");
54