File: hid-evision.c

package info (click to toggle)
linux 6.17.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,735,112 kB
  • sloc: ansic: 26,688,265; asm: 271,225; sh: 147,407; python: 75,980; makefile: 57,304; perl: 36,943; xml: 19,562; cpp: 5,899; yacc: 4,909; lex: 2,943; awk: 1,556; sed: 29; ruby: 25
file content (54 lines) | stat: -rw-r--r-- 1,358 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  HID driver for EVision devices
 *  For now, only ignore bogus consumer reports
 *  sent after the keyboard has been configured
 *
 *  Copyright (c) 2022 Philippe Valembois
 */

#include <linux/device.h>
#include <linux/input.h>
#include <linux/hid.h>
#include <linux/module.h>

#include "hid-ids.h"

static int evision_input_mapping(struct hid_device *hdev, struct hid_input *hi,
		struct hid_field *field, struct hid_usage *usage,
		unsigned long **bit, int *max)
{
	if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
		return 0;

	/* Ignore key down event */
	if ((usage->hid & HID_USAGE) >> 8 == 0x05)
		return -1;
	/* Ignore key up event */
	if ((usage->hid & HID_USAGE) >> 8 == 0x06)
		return -1;

	switch (usage->hid & HID_USAGE) {
	/* Ignore configuration saved event */
	case 0x0401: return -1;
	/* Ignore reset event */
	case 0x0402: return -1;
	}
	return 0;
}

static const struct hid_device_id evision_devices[] = {
	{ HID_USB_DEVICE(USB_VENDOR_ID_EVISION, USB_DEVICE_ID_EVISION_ICL01) },
	{ }
};
MODULE_DEVICE_TABLE(hid, evision_devices);

static struct hid_driver evision_driver = {
	.name = "evision",
	.id_table = evision_devices,
	.input_mapping = evision_input_mapping,
};
module_hid_driver(evision_driver);

MODULE_DESCRIPTION("HID driver for EVision devices");
MODULE_LICENSE("GPL");