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