hid-ite.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /* ITE8595 USB kbd ctlr, with Synaptics touchpad connected to it. */
  39. { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
  40. USB_VENDOR_ID_SYNAPTICS,
  41. USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012) },
  42. { }
  43. };
  44. MODULE_DEVICE_TABLE(hid, ite_devices);
  45. static struct hid_driver ite_driver = {
  46. .name = "itetech",
  47. .id_table = ite_devices,
  48. .event = ite_event,
  49. };
  50. module_hid_driver(ite_driver);
  51. MODULE_LICENSE("GPL");