hid-logitech-dj.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #ifndef __HID_LOGITECH_DJ_H
  2. #define __HID_LOGITECH_DJ_H
  3. /*
  4. * HID driver for Logitech Unifying receivers
  5. *
  6. * Copyright (c) 2011 Logitech
  7. */
  8. /*
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <linux/kfifo.h>
  24. #define DJ_MAX_PAIRED_DEVICES 6
  25. #define DJ_MAX_NUMBER_NOTIFICATIONS 8
  26. #define DJ_RECEIVER_INDEX 0
  27. #define DJ_DEVICE_INDEX_MIN 1
  28. #define DJ_DEVICE_INDEX_MAX 6
  29. #define DJREPORT_SHORT_LENGTH 15
  30. #define DJREPORT_LONG_LENGTH 32
  31. #define REPORT_ID_DJ_SHORT 0x20
  32. #define REPORT_ID_DJ_LONG 0x21
  33. #define REPORT_TYPE_RFREPORT_FIRST 0x01
  34. #define REPORT_TYPE_RFREPORT_LAST 0x1F
  35. /* Command Switch to DJ mode */
  36. #define REPORT_TYPE_CMD_SWITCH 0x80
  37. #define CMD_SWITCH_PARAM_DEVBITFIELD 0x00
  38. #define CMD_SWITCH_PARAM_TIMEOUT_SECONDS 0x01
  39. #define TIMEOUT_NO_KEEPALIVE 0x00
  40. /* Command to Get the list of Paired devices */
  41. #define REPORT_TYPE_CMD_GET_PAIRED_DEVICES 0x81
  42. /* Device Paired Notification */
  43. #define REPORT_TYPE_NOTIF_DEVICE_PAIRED 0x41
  44. #define SPFUNCTION_MORE_NOTIF_EXPECTED 0x01
  45. #define SPFUNCTION_DEVICE_LIST_EMPTY 0x02
  46. #define DEVICE_PAIRED_PARAM_SPFUNCTION 0x00
  47. #define DEVICE_PAIRED_PARAM_EQUAD_ID_LSB 0x01
  48. #define DEVICE_PAIRED_PARAM_EQUAD_ID_MSB 0x02
  49. #define DEVICE_PAIRED_RF_REPORT_TYPE 0x03
  50. /* Device Un-Paired Notification */
  51. #define REPORT_TYPE_NOTIF_DEVICE_UNPAIRED 0x40
  52. /* Connection Status Notification */
  53. #define REPORT_TYPE_NOTIF_CONNECTION_STATUS 0x42
  54. #define CONNECTION_STATUS_PARAM_STATUS 0x00
  55. #define STATUS_LINKLOSS 0x01
  56. /* Error Notification */
  57. #define REPORT_TYPE_NOTIF_ERROR 0x7F
  58. #define NOTIF_ERROR_PARAM_ETYPE 0x00
  59. #define ETYPE_KEEPALIVE_TIMEOUT 0x01
  60. /* supported DJ HID && RF report types */
  61. #define REPORT_TYPE_KEYBOARD 0x01
  62. #define REPORT_TYPE_MOUSE 0x02
  63. #define REPORT_TYPE_CONSUMER_CONTROL 0x03
  64. #define REPORT_TYPE_SYSTEM_CONTROL 0x04
  65. #define REPORT_TYPE_MEDIA_CENTER 0x08
  66. #define REPORT_TYPE_LEDS 0x0E
  67. /* RF Report types bitfield */
  68. #define STD_KEYBOARD 0x00000002
  69. #define STD_MOUSE 0x00000004
  70. #define MULTIMEDIA 0x00000008
  71. #define POWER_KEYS 0x00000010
  72. #define MEDIA_CENTER 0x00000100
  73. #define KBD_LEDS 0x00004000
  74. struct dj_report {
  75. u8 report_id;
  76. u8 device_index;
  77. u8 report_type;
  78. u8 report_params[DJREPORT_SHORT_LENGTH - 3];
  79. };
  80. struct dj_receiver_dev {
  81. struct hid_device *hdev;
  82. struct dj_device *paired_dj_devices[DJ_MAX_PAIRED_DEVICES +
  83. DJ_DEVICE_INDEX_MIN];
  84. struct work_struct work;
  85. struct kfifo notif_fifo;
  86. spinlock_t lock;
  87. bool querying_devices;
  88. };
  89. struct dj_device {
  90. struct hid_device *hdev;
  91. struct dj_receiver_dev *dj_receiver_dev;
  92. u32 reports_supported;
  93. u8 device_index;
  94. };
  95. /**
  96. * is_dj_device - know if the given dj_device is not the receiver.
  97. * @dj_dev: the dj device to test
  98. *
  99. * This macro tests if a struct dj_device pointer is a device created
  100. * by the bus enumarator.
  101. */
  102. #define is_dj_device(dj_dev) \
  103. (&(dj_dev)->dj_receiver_dev->hdev->dev == (dj_dev)->hdev->dev.parent)
  104. #endif