hid-evision.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * HID driver for EVision devices
  4. * For now, only ignore bogus consumer reports
  5. * sent after the keyboard has been configured
  6. *
  7. * Copyright (c) 2022 Philippe Valembois
  8. */
  9. #include <linux/device.h>
  10. #include <linux/input.h>
  11. #include <linux/hid.h>
  12. #include <linux/module.h>
  13. #include "hid-ids.h"
  14. static int evision_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  15. struct hid_field *field, struct hid_usage *usage,
  16. unsigned long **bit, int *max)
  17. {
  18. if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
  19. return 0;
  20. /* Ignore key down event */
  21. if ((usage->hid & HID_USAGE) >> 8 == 0x05)
  22. return -1;
  23. /* Ignore key up event */
  24. if ((usage->hid & HID_USAGE) >> 8 == 0x06)
  25. return -1;
  26. switch (usage->hid & HID_USAGE) {
  27. /* Ignore configuration saved event */
  28. case 0x0401: return -1;
  29. /* Ignore reset event */
  30. case 0x0402: return -1;
  31. }
  32. return 0;
  33. }
  34. static const struct hid_device_id evision_devices[] = {
  35. { HID_USB_DEVICE(USB_VENDOR_ID_EVISION, USB_DEVICE_ID_EVISION_ICL01) },
  36. { }
  37. };
  38. MODULE_DEVICE_TABLE(hid, evision_devices);
  39. static struct hid_driver evision_driver = {
  40. .name = "evision",
  41. .id_table = evision_devices,
  42. .input_mapping = evision_input_mapping,
  43. };
  44. module_hid_driver(evision_driver);
  45. MODULE_DESCRIPTION("HID driver for EVision devices");
  46. MODULE_LICENSE("GPL");