cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

hid-jabra.c (1422B)


      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
     19static 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
     40static const struct hid_device_id jabra_devices[] = {
     41	{ HID_USB_DEVICE(USB_VENDOR_ID_JABRA, HID_ANY_ID) },
     42	{ }
     43};
     44MODULE_DEVICE_TABLE(hid, jabra_devices);
     45
     46static struct hid_driver jabra_driver = {
     47	.name = "jabra",
     48	.id_table = jabra_devices,
     49	.input_mapping = jabra_input_mapping,
     50};
     51module_hid_driver(jabra_driver);
     52
     53MODULE_AUTHOR("Niels Skou Olsen <nolsen@jabra.com>");
     54MODULE_DESCRIPTION("Jabra USB HID Driver");
     55MODULE_LICENSE("GPL");