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