Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: Add special driver for Jabra devices

Add a hid-jabra driver to the list of special drivers in hid-core. The
driver prevents vendor defined HID usages (FF00-FFFF) in Jabra devices
from being mapped to input events, that become unintended mouse events
in the X11 server.

Signed-off-by: Niels Skou Olsen <nolsen@jabra.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Niels Skou Olsen and committed by
Jiri Kosina
19ca2827 d5158e02

+73
+11
drivers/hid/Kconfig
··· 396 396 ---help--- 397 397 Support for ITE devices not fully compliant with HID standard. 398 398 399 + config HID_JABRA 400 + tristate "Jabra USB HID Driver" 401 + depends on HID 402 + ---help--- 403 + Support for Jabra USB HID devices. 404 + 405 + Prevents mapping of vendor defined HID usages to input events. Without 406 + this driver HID reports from Jabra devices may incorrectly be seen as 407 + mouse button events. 408 + Say M here if you may ever plug in a Jabra USB device. 409 + 399 410 config HID_TWINHAN 400 411 tristate "Twinhan IR remote control" 401 412 depends on HID
+1
drivers/hid/Makefile
··· 52 52 obj-$(CONFIG_HID_HYPERV_MOUSE) += hid-hyperv.o 53 53 obj-$(CONFIG_HID_ICADE) += hid-icade.o 54 54 obj-$(CONFIG_HID_ITE) += hid-ite.o 55 + obj-$(CONFIG_HID_JABRA) += hid-jabra.o 55 56 obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o 56 57 obj-$(CONFIG_HID_KEYTOUCH) += hid-keytouch.o 57 58 obj-$(CONFIG_HID_KYE) += hid-kye.o
+58
drivers/hid/hid-jabra.c
··· 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");
+3
drivers/hid/hid-quirks.c
··· 384 384 #if IS_ENABLED(CONFIG_HID_ICADE) 385 385 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ION, USB_DEVICE_ID_ICADE) }, 386 386 #endif 387 + #if IS_ENABLED(CONFIG_HID_JABRA) 388 + { HID_USB_DEVICE(USB_VENDOR_ID_JABRA, HID_ANY_ID) }, 389 + #endif 387 390 #if IS_ENABLED(CONFIG_HID_KENSINGTON) 388 391 { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, 389 392 #endif