hid-ite.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * HID driver for some ITE "special" devices
  3. * Copyright (c) 2017 Hans de Goede <hdegoede@redhat.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  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 ite_event(struct hid_device *hdev, struct hid_field *field,
  15. struct hid_usage *usage, __s32 value)
  16. {
  17. struct input_dev *input;
  18. if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput)
  19. return 0;
  20. input = field->hidinput->input;
  21. /*
  22. * The ITE8595 always reports 0 as value for the rfkill button. Luckily
  23. * it is the only button in its report, and it sends a report on
  24. * release only, so receiving a report means the button was pressed.
  25. */
  26. if (usage->hid == HID_GD_RFKILL_BTN) {
  27. input_event(input, EV_KEY, KEY_RFKILL, 1);
  28. input_sync(input);
  29. input_event(input, EV_KEY, KEY_RFKILL, 0);
  30. input_sync(input);
  31. return 1;
  32. }
  33. return 0;
  34. }
  35. static const struct hid_device_id ite_devices[] = {
  36. { HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE8595) },
  37. { HID_USB_DEVICE(USB_VENDOR_ID_258A, USB_DEVICE_ID_258A_6A88) },
  38. { }
  39. };
  40. MODULE_DEVICE_TABLE(hid, ite_devices);
  41. static struct hid_driver ite_driver = {
  42. .name = "itetech",
  43. .id_table = ite_devices,
  44. .event = ite_event,
  45. };
  46. module_hid_driver(ite_driver);
  47. MODULE_LICENSE("GPL");