hid-jabra.c 1.6 KB

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