xref: /linux/drivers/hid/hid-jabra.c (revision 63307d015b91e626c97bb82e88054af3d0b74643)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *  Jabra USB HID Driver
4  *
5  *  Copyright (c) 2017 Niels Skou Olsen <nolsen@jabra.com>
6  */
7 
8 /*
9  */
10 
11 #include <linux/hid.h>
12 #include <linux/module.h>
13 
14 #include "hid-ids.h"
15 
16 #define HID_UP_VENDOR_DEFINED_MIN	0xff000000
17 #define HID_UP_VENDOR_DEFINED_MAX	0xffff0000
18 
19 static int jabra_input_mapping(struct hid_device *hdev,
20 			       struct hid_input *hi,
21 			       struct hid_field *field,
22 			       struct hid_usage *usage,
23 			       unsigned long **bit, int *max)
24 {
25 	int is_vendor_defined =
26 		((usage->hid & HID_USAGE_PAGE) >= HID_UP_VENDOR_DEFINED_MIN &&
27 		 (usage->hid & HID_USAGE_PAGE) <= HID_UP_VENDOR_DEFINED_MAX);
28 
29 	dbg_hid("hid=0x%08x appl=0x%08x coll_idx=0x%02x usage_idx=0x%02x: %s\n",
30 		usage->hid,
31 		field->application,
32 		usage->collection_index,
33 		usage->usage_index,
34 		is_vendor_defined ? "ignored" : "defaulted");
35 
36 	/* Ignore vendor defined usages, default map standard usages */
37 	return is_vendor_defined ? -1 : 0;
38 }
39 
40 static const struct hid_device_id jabra_devices[] = {
41 	{ HID_USB_DEVICE(USB_VENDOR_ID_JABRA, HID_ANY_ID) },
42 	{ }
43 };
44 MODULE_DEVICE_TABLE(hid, jabra_devices);
45 
46 static struct hid_driver jabra_driver = {
47 	.name = "jabra",
48 	.id_table = jabra_devices,
49 	.input_mapping = jabra_input_mapping,
50 };
51 module_hid_driver(jabra_driver);
52 
53 MODULE_AUTHOR("Niels Skou Olsen <nolsen@jabra.com>");
54 MODULE_DESCRIPTION("Jabra USB HID Driver");
55 MODULE_LICENSE("GPL");
56