Linux 4.18.10
[linux/fpc-iii.git] / drivers / hid / hid-jabra.c
blob1f52daf14426ea9e92d744b2744309dd89dd5cc7
1 /*
2 * Jabra USB HID Driver
4 * Copyright (c) 2017 Niels Skou Olsen <nolsen@jabra.com>
5 */
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.
14 #include <linux/hid.h>
15 #include <linux/module.h>
17 #include "hid-ids.h"
19 #define HID_UP_VENDOR_DEFINED_MIN 0xff000000
20 #define HID_UP_VENDOR_DEFINED_MAX 0xffff0000
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)
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);
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");
39 /* Ignore vendor defined usages, default map standard usages */
40 return is_vendor_defined ? -1 : 0;
43 static const struct hid_device_id jabra_devices[] = {
44 { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, HID_ANY_ID) },
45 { }
47 MODULE_DEVICE_TABLE(hid, jabra_devices);
49 static struct hid_driver jabra_driver = {
50 .name = "jabra",
51 .id_table = jabra_devices,
52 .input_mapping = jabra_input_mapping,
54 module_hid_driver(jabra_driver);
56 MODULE_AUTHOR("Niels Skou Olsen <nolsen@jabra.com>");
57 MODULE_DESCRIPTION("Jabra USB HID Driver");
58 MODULE_LICENSE("GPL");