hidraw.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef _HIDRAW_H
  2. #define _HIDRAW_H
  3. /*
  4. * Copyright (c) 2007 Jiri Kosina
  5. */
  6. /*
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms and conditions of the GNU General Public License,
  9. * version 2, as published by the Free Software Foundation.
  10. *
  11. * You should have received a copy of the GNU General Public License along with
  12. * this program; if not, write to the Free Software Foundation, Inc.,
  13. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. */
  15. #include <linux/hid.h>
  16. #include <linux/types.h>
  17. struct hidraw_report_descriptor {
  18. __u32 size;
  19. __u8 value[HID_MAX_DESCRIPTOR_SIZE];
  20. };
  21. struct hidraw_devinfo {
  22. __u32 bustype;
  23. __s16 vendor;
  24. __s16 product;
  25. };
  26. /* ioctl interface */
  27. #define HIDIOCGRDESCSIZE _IOR('H', 0x01, int)
  28. #define HIDIOCGRDESC _IOR('H', 0x02, struct hidraw_report_descriptor)
  29. #define HIDIOCGRAWINFO _IOR('H', 0x03, struct hidraw_devinfo)
  30. #define HIDIOCGRAWNAME(len) _IOC(_IOC_READ, 'H', 0x04, len)
  31. #define HIDIOCGRAWPHYS(len) _IOC(_IOC_READ, 'H', 0x05, len)
  32. /* The first byte of SFEATURE and GFEATURE is the report number */
  33. #define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len)
  34. #define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)
  35. #define HIDRAW_FIRST_MINOR 0
  36. #define HIDRAW_MAX_DEVICES 64
  37. /* number of reports to buffer */
  38. #define HIDRAW_BUFFER_SIZE 64
  39. /* kernel-only API declarations */
  40. #ifdef __KERNEL__
  41. struct hidraw {
  42. unsigned int minor;
  43. int exist;
  44. int open;
  45. wait_queue_head_t wait;
  46. struct hid_device *hid;
  47. struct device *dev;
  48. struct list_head list;
  49. };
  50. struct hidraw_report {
  51. __u8 *value;
  52. int len;
  53. };
  54. struct hidraw_list {
  55. struct hidraw_report buffer[HIDRAW_BUFFER_SIZE];
  56. int head;
  57. int tail;
  58. struct fasync_struct *fasync;
  59. struct hidraw *hidraw;
  60. struct list_head node;
  61. struct mutex read_mutex;
  62. };
  63. #ifdef CONFIG_HIDRAW
  64. int hidraw_init(void);
  65. void hidraw_exit(void);
  66. int hidraw_report_event(struct hid_device *, u8 *, int);
  67. int hidraw_connect(struct hid_device *);
  68. void hidraw_disconnect(struct hid_device *);
  69. #else
  70. static inline int hidraw_init(void) { return 0; }
  71. static inline void hidraw_exit(void) { }
  72. static inline int hidraw_report_event(struct hid_device *hid, u8 *data, int len) { return 0; }
  73. static inline int hidraw_connect(struct hid_device *hid) { return -1; }
  74. static inline void hidraw_disconnect(struct hid_device *hid) { }
  75. #endif
  76. #endif
  77. #endif