hid-tivo.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * HID driver for TiVo Slide Bluetooth remote
  4. *
  5. * Copyright (c) 2011 Jarod Wilson <jarod@redhat.com>
  6. * based on the hid-topseed driver, which is in turn, based on hid-cherry...
  7. */
  8. /*
  9. */
  10. #include <linux/device.h>
  11. #include <linux/hid.h>
  12. #include <linux/module.h>
  13. #include "hid-ids.h"
  14. #define HID_UP_TIVOVENDOR 0xffff0000
  15. #define tivo_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
  16. EV_KEY, (c))
  17. static int tivo_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  18. struct hid_field *field, struct hid_usage *usage,
  19. unsigned long **bit, int *max)
  20. {
  21. switch (usage->hid & HID_USAGE_PAGE) {
  22. case HID_UP_TIVOVENDOR:
  23. switch (usage->hid & HID_USAGE) {
  24. /* TiVo button */
  25. case 0x3d: tivo_map_key_clear(KEY_MEDIA); break;
  26. /* Live TV */
  27. case 0x3e: tivo_map_key_clear(KEY_TV); break;
  28. /* Red thumbs down */
  29. case 0x41: tivo_map_key_clear(KEY_KPMINUS); break;
  30. /* Green thumbs up */
  31. case 0x42: tivo_map_key_clear(KEY_KPPLUS); break;
  32. default:
  33. return 0;
  34. }
  35. break;
  36. case HID_UP_CONSUMER:
  37. switch (usage->hid & HID_USAGE) {
  38. /* Enter/Last (default mapping: KEY_LAST) */
  39. case 0x083: tivo_map_key_clear(KEY_ENTER); break;
  40. /* Info (default mapping: KEY_PROPS) */
  41. case 0x209: tivo_map_key_clear(KEY_INFO); break;
  42. default:
  43. return 0;
  44. }
  45. break;
  46. default:
  47. return 0;
  48. }
  49. /* This means we found a matching mapping here, else, look in the
  50. * standard hid mappings in hid-input.c */
  51. return 1;
  52. }
  53. static const struct hid_device_id tivo_devices[] = {
  54. /* TiVo Slide Bluetooth remote, pairs with a Broadcom dongle */
  55. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_BT) },
  56. { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE) },
  57. { HID_USB_DEVICE(USB_VENDOR_ID_TIVO, USB_DEVICE_ID_TIVO_SLIDE_PRO) },
  58. { }
  59. };
  60. MODULE_DEVICE_TABLE(hid, tivo_devices);
  61. static struct hid_driver tivo_driver = {
  62. .name = "tivo_slide",
  63. .id_table = tivo_devices,
  64. .input_mapping = tivo_input_mapping,
  65. };
  66. module_hid_driver(tivo_driver);
  67. MODULE_LICENSE("GPL");
  68. MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");