usbdevice_fs.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*****************************************************************************/
  2. /*
  3. * usbdevice_fs.h -- USB device file system.
  4. *
  5. * Copyright (C) 2000
  6. * Thomas Sailer (sailer@ife.ee.ethz.ch)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  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., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. *
  22. * History:
  23. * 0.1 04.01.2000 Created
  24. */
  25. /*****************************************************************************/
  26. #ifndef _LINUX_USBDEVICE_FS_H
  27. #define _LINUX_USBDEVICE_FS_H
  28. #include <linux/types.h>
  29. #include <linux/magic.h>
  30. /* --------------------------------------------------------------------- */
  31. /* usbdevfs ioctl codes */
  32. struct usbdevfs_ctrltransfer {
  33. __u8 bRequestType;
  34. __u8 bRequest;
  35. __u16 wValue;
  36. __u16 wIndex;
  37. __u16 wLength;
  38. __u32 timeout; /* in milliseconds */
  39. void __user *data;
  40. };
  41. struct usbdevfs_bulktransfer {
  42. unsigned int ep;
  43. unsigned int len;
  44. unsigned int timeout; /* in milliseconds */
  45. void __user *data;
  46. };
  47. struct usbdevfs_setinterface {
  48. unsigned int interface;
  49. unsigned int altsetting;
  50. };
  51. struct usbdevfs_disconnectsignal {
  52. unsigned int signr;
  53. void __user *context;
  54. };
  55. #define USBDEVFS_MAXDRIVERNAME 255
  56. struct usbdevfs_getdriver {
  57. unsigned int interface;
  58. char driver[USBDEVFS_MAXDRIVERNAME + 1];
  59. };
  60. struct usbdevfs_connectinfo {
  61. unsigned int devnum;
  62. unsigned char slow;
  63. };
  64. #define USBDEVFS_URB_SHORT_NOT_OK 0x01
  65. #define USBDEVFS_URB_ISO_ASAP 0x02
  66. #define USBDEVFS_URB_BULK_CONTINUATION 0x04
  67. #define USBDEVFS_URB_NO_FSBR 0x20
  68. #define USBDEVFS_URB_ZERO_PACKET 0x40
  69. #define USBDEVFS_URB_NO_INTERRUPT 0x80
  70. #define USBDEVFS_URB_TYPE_ISO 0
  71. #define USBDEVFS_URB_TYPE_INTERRUPT 1
  72. #define USBDEVFS_URB_TYPE_CONTROL 2
  73. #define USBDEVFS_URB_TYPE_BULK 3
  74. struct usbdevfs_iso_packet_desc {
  75. unsigned int length;
  76. unsigned int actual_length;
  77. unsigned int status;
  78. };
  79. struct usbdevfs_urb {
  80. unsigned char type;
  81. unsigned char endpoint;
  82. int status;
  83. unsigned int flags;
  84. void __user *buffer;
  85. int buffer_length;
  86. int actual_length;
  87. int start_frame;
  88. int number_of_packets;
  89. int error_count;
  90. unsigned int signr; /* signal to be sent on completion,
  91. or 0 if none should be sent. */
  92. void __user *usercontext;
  93. struct usbdevfs_iso_packet_desc iso_frame_desc[0];
  94. };
  95. /* ioctls for talking directly to drivers */
  96. struct usbdevfs_ioctl {
  97. int ifno; /* interface 0..N ; negative numbers reserved */
  98. int ioctl_code; /* MUST encode size + direction of data so the
  99. * macros in <asm/ioctl.h> give correct values */
  100. void __user *data; /* param buffer (in, or out) */
  101. };
  102. /* You can do most things with hubs just through control messages,
  103. * except find out what device connects to what port. */
  104. struct usbdevfs_hub_portinfo {
  105. char nports; /* number of downstream ports in this hub */
  106. char port [127]; /* e.g. port 3 connects to device 27 */
  107. };
  108. #ifdef __KERNEL__
  109. #ifdef CONFIG_COMPAT
  110. #include <linux/compat.h>
  111. struct usbdevfs_ctrltransfer32 {
  112. u8 bRequestType;
  113. u8 bRequest;
  114. u16 wValue;
  115. u16 wIndex;
  116. u16 wLength;
  117. u32 timeout; /* in milliseconds */
  118. compat_caddr_t data;
  119. };
  120. struct usbdevfs_bulktransfer32 {
  121. compat_uint_t ep;
  122. compat_uint_t len;
  123. compat_uint_t timeout; /* in milliseconds */
  124. compat_caddr_t data;
  125. };
  126. struct usbdevfs_disconnectsignal32 {
  127. compat_int_t signr;
  128. compat_caddr_t context;
  129. };
  130. struct usbdevfs_urb32 {
  131. unsigned char type;
  132. unsigned char endpoint;
  133. compat_int_t status;
  134. compat_uint_t flags;
  135. compat_caddr_t buffer;
  136. compat_int_t buffer_length;
  137. compat_int_t actual_length;
  138. compat_int_t start_frame;
  139. compat_int_t number_of_packets;
  140. compat_int_t error_count;
  141. compat_uint_t signr;
  142. compat_caddr_t usercontext; /* unused */
  143. struct usbdevfs_iso_packet_desc iso_frame_desc[0];
  144. };
  145. struct usbdevfs_ioctl32 {
  146. s32 ifno;
  147. s32 ioctl_code;
  148. compat_caddr_t data;
  149. };
  150. #endif
  151. #endif /* __KERNEL__ */
  152. #define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer)
  153. #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
  154. #define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer)
  155. #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
  156. #define USBDEVFS_RESETEP _IOR('U', 3, unsigned int)
  157. #define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface)
  158. #define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int)
  159. #define USBDEVFS_GETDRIVER _IOW('U', 8, struct usbdevfs_getdriver)
  160. #define USBDEVFS_SUBMITURB _IOR('U', 10, struct usbdevfs_urb)
  161. #define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32)
  162. #define USBDEVFS_DISCARDURB _IO('U', 11)
  163. #define USBDEVFS_REAPURB _IOW('U', 12, void *)
  164. #define USBDEVFS_REAPURB32 _IOW('U', 12, __u32)
  165. #define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *)
  166. #define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32)
  167. #define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal)
  168. #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
  169. #define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int)
  170. #define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
  171. #define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo)
  172. #define USBDEVFS_IOCTL _IOWR('U', 18, struct usbdevfs_ioctl)
  173. #define USBDEVFS_IOCTL32 _IOWR('U', 18, struct usbdevfs_ioctl32)
  174. #define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo)
  175. #define USBDEVFS_RESET _IO('U', 20)
  176. #define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int)
  177. #define USBDEVFS_DISCONNECT _IO('U', 22)
  178. #define USBDEVFS_CONNECT _IO('U', 23)
  179. #define USBDEVFS_CLAIM_PORT _IOR('U', 24, unsigned int)
  180. #define USBDEVFS_RELEASE_PORT _IOR('U', 25, unsigned int)
  181. #endif /* _LINUX_USBDEVICE_FS_H */