hid-logitech-dj.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_DEVICE_INDEX_MIN 1
  27. #define DJ_DEVICE_INDEX_MAX 6
  28. #define DJREPORT_SHORT_LENGTH 15
  29. #define DJREPORT_LONG_LENGTH 32
  30. #define REPORT_ID_DJ_SHORT 0x20
  31. #define REPORT_ID_DJ_LONG 0x21
  32. #define REPORT_TYPE_RFREPORT_FIRST 0x01
  33. #define REPORT_TYPE_RFREPORT_LAST 0x1F
  34. /* Command Switch to DJ mode */
  35. #define REPORT_TYPE_CMD_SWITCH 0x80
  36. #define CMD_SWITCH_PARAM_DEVBITFIELD 0x00
  37. #define CMD_SWITCH_PARAM_TIMEOUT_SECONDS 0x01
  38. #define TIMEOUT_NO_KEEPALIVE 0x00
  39. /* Command to Get the list of Paired devices */
  40. #define REPORT_TYPE_CMD_GET_PAIRED_DEVICES 0x81
  41. /* Device Paired Notification */
  42. #define REPORT_TYPE_NOTIF_DEVICE_PAIRED 0x41
  43. #define SPFUNCTION_MORE_NOTIF_EXPECTED 0x01
  44. #define SPFUNCTION_DEVICE_LIST_EMPTY 0x02
  45. #define DEVICE_PAIRED_PARAM_SPFUNCTION 0x00
  46. #define DEVICE_PAIRED_PARAM_EQUAD_ID_LSB 0x01
  47. #define DEVICE_PAIRED_PARAM_EQUAD_ID_MSB 0x02
  48. #define DEVICE_PAIRED_RF_REPORT_TYPE 0x03
  49. /* Device Un-Paired Notification */
  50. #define REPORT_TYPE_NOTIF_DEVICE_UNPAIRED 0x40
  51. /* Connection Status Notification */
  52. #define REPORT_TYPE_NOTIF_CONNECTION_STATUS 0x42
  53. #define CONNECTION_STATUS_PARAM_STATUS 0x00
  54. #define STATUS_LINKLOSS 0x01
  55. /* Error Notification */
  56. #define REPORT_TYPE_NOTIF_ERROR 0x7F
  57. #define NOTIF_ERROR_PARAM_ETYPE 0x00
  58. #define ETYPE_KEEPALIVE_TIMEOUT 0x01
  59. /* supported DJ HID && RF report types */
  60. #define REPORT_TYPE_KEYBOARD 0x01
  61. #define REPORT_TYPE_MOUSE 0x02
  62. #define REPORT_TYPE_CONSUMER_CONTROL 0x03
  63. #define REPORT_TYPE_SYSTEM_CONTROL 0x04
  64. #define REPORT_TYPE_MEDIA_CENTER 0x08
  65. #define REPORT_TYPE_LEDS 0x0E
  66. /* RF Report types bitfield */
  67. #define STD_KEYBOARD 0x00000002
  68. #define STD_MOUSE 0x00000004
  69. #define MULTIMEDIA 0x00000008
  70. #define POWER_KEYS 0x00000010
  71. #define MEDIA_CENTER 0x00000100
  72. #define KBD_LEDS 0x00004000
  73. struct dj_report {
  74. u8 report_id;
  75. u8 device_index;
  76. u8 report_type;
  77. u8 report_params[DJREPORT_SHORT_LENGTH - 3];
  78. };
  79. struct dj_receiver_dev {
  80. struct hid_device *hdev;
  81. struct dj_device *paired_dj_devices[DJ_MAX_PAIRED_DEVICES +
  82. DJ_DEVICE_INDEX_MIN];
  83. struct work_struct work;
  84. struct kfifo notif_fifo;
  85. spinlock_t lock;
  86. };
  87. struct dj_device {
  88. struct hid_device *hdev;
  89. struct dj_receiver_dev *dj_receiver_dev;
  90. u32 reports_supported;
  91. u8 device_index;
  92. };
  93. /**
  94. * is_dj_device - know if the given dj_device is not the receiver.
  95. * @dj_dev: the dj device to test
  96. *
  97. * This macro tests if a struct dj_device pointer is a device created
  98. * by the bus enumarator.
  99. */
  100. #define is_dj_device(dj_dev) \
  101. (&(dj_dev)->dj_receiver_dev->hdev->dev == (dj_dev)->hdev->dev.parent)
  102. #endif