1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2017 Niels Skou Olsen <nolsen@jabra.com>
11 #include <linux/hid.h>
12 #include <linux/module.h>
16 #define HID_UP_VENDOR_DEFINED_MIN 0xff000000
17 #define HID_UP_VENDOR_DEFINED_MAX 0xffff0000
19 static int jabra_input_mapping(struct hid_device *hdev,
21 struct hid_field *field,
22 struct hid_usage *usage,
23 unsigned long **bit, int *max)
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);
29 dbg_hid("hid=0x%08x appl=0x%08x coll_idx=0x%02x usage_idx=0x%02x: %s\n",
32 usage->collection_index,
34 is_vendor_defined ? "ignored" : "defaulted");
36 /* Ignore vendor defined usages, default map standard usages */
37 return is_vendor_defined ? -1 : 0;
40 static const struct hid_device_id jabra_devices[] = {
41 { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, HID_ANY_ID) },
44 MODULE_DEVICE_TABLE(hid, jabra_devices);
46 static struct hid_driver jabra_driver = {
48 .id_table = jabra_devices,
49 .input_mapping = jabra_input_mapping,
51 module_hid_driver(jabra_driver);
53 MODULE_AUTHOR("Niels Skou Olsen <nolsen@jabra.com>");
54 MODULE_DESCRIPTION("Jabra USB HID Driver");
55 MODULE_LICENSE("GPL");