usbdevice_fs.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /*****************************************************************************/
  3. /*
  4. * usbdevice_fs.h -- USB device file system.
  5. *
  6. * Copyright (C) 2000
  7. * Thomas Sailer ([email protected])
  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 as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. *
  23. * History:
  24. * 0.1 04.01.2000 Created
  25. */
  26. /*****************************************************************************/
  27. #ifndef _UAPI_LINUX_USBDEVICE_FS_H
  28. #define _UAPI_LINUX_USBDEVICE_FS_H
  29. #include <linux/types.h>
  30. #include <linux/magic.h>
  31. /* --------------------------------------------------------------------- */
  32. /* usbdevfs ioctl codes */
  33. struct usbdevfs_ctrltransfer {
  34. __u8 bRequestType;
  35. __u8 bRequest;
  36. __u16 wValue;
  37. __u16 wIndex;
  38. __u16 wLength;
  39. __u32 timeout; /* in milliseconds */
  40. void __user *data;
  41. };
  42. struct usbdevfs_bulktransfer {
  43. unsigned int ep;
  44. unsigned int len;
  45. unsigned int timeout; /* in milliseconds */
  46. void __user *data;
  47. };
  48. struct usbdevfs_setinterface {
  49. unsigned int interface;
  50. unsigned int altsetting;
  51. };
  52. struct usbdevfs_disconnectsignal {
  53. unsigned int signr;
  54. void __user *context;
  55. };
  56. #define USBDEVFS_MAXDRIVERNAME 255
  57. struct usbdevfs_getdriver {
  58. unsigned int interface;
  59. char driver[USBDEVFS_MAXDRIVERNAME + 1];
  60. };
  61. struct usbdevfs_connectinfo {
  62. unsigned int devnum;
  63. unsigned char slow;
  64. };
  65. struct usbdevfs_conninfo_ex {
  66. __u32 size; /* Size of the structure from the kernel's */
  67. /* point of view. Can be used by userspace */
  68. /* to determine how much data can be */
  69. /* used/trusted. */
  70. __u32 busnum; /* USB bus number, as enumerated by the */
  71. /* kernel, the device is connected to. */
  72. __u32 devnum; /* Device address on the bus. */
  73. __u32 speed; /* USB_SPEED_* constants from ch9.h */
  74. __u8 num_ports; /* Number of ports the device is connected */
  75. /* to on the way to the root hub. It may */
  76. /* be bigger than size of 'ports' array so */
  77. /* userspace can detect overflows. */
  78. __u8 ports[7]; /* List of ports on the way from the root */
  79. /* hub to the device. Current limit in */
  80. /* USB specification is 7 tiers (root hub, */
  81. /* 5 intermediate hubs, device), which */
  82. /* gives at most 6 port entries. */
  83. };
  84. #define USBDEVFS_URB_SHORT_NOT_OK 0x01
  85. #define USBDEVFS_URB_ISO_ASAP 0x02
  86. #define USBDEVFS_URB_BULK_CONTINUATION 0x04
  87. #define USBDEVFS_URB_NO_FSBR 0x20 /* Not used */
  88. #define USBDEVFS_URB_ZERO_PACKET 0x40
  89. #define USBDEVFS_URB_NO_INTERRUPT 0x80
  90. #define USBDEVFS_URB_TYPE_ISO 0
  91. #define USBDEVFS_URB_TYPE_INTERRUPT 1
  92. #define USBDEVFS_URB_TYPE_CONTROL 2
  93. #define USBDEVFS_URB_TYPE_BULK 3
  94. struct usbdevfs_iso_packet_desc {
  95. unsigned int length;
  96. unsigned int actual_length;
  97. unsigned int status;
  98. };
  99. struct usbdevfs_urb {
  100. unsigned char type;
  101. unsigned char endpoint;
  102. int status;
  103. unsigned int flags;
  104. void __user *buffer;
  105. int buffer_length;
  106. int actual_length;
  107. int start_frame;
  108. union {
  109. int number_of_packets; /* Only used for isoc urbs */
  110. unsigned int stream_id; /* Only used with bulk streams */
  111. };
  112. int error_count;
  113. unsigned int signr; /* signal to be sent on completion,
  114. or 0 if none should be sent. */
  115. void __user *usercontext;
  116. struct usbdevfs_iso_packet_desc iso_frame_desc[];
  117. };
  118. /* ioctls for talking directly to drivers */
  119. struct usbdevfs_ioctl {
  120. int ifno; /* interface 0..N ; negative numbers reserved */
  121. int ioctl_code; /* MUST encode size + direction of data so the
  122. * macros in <asm/ioctl.h> give correct values */
  123. void __user *data; /* param buffer (in, or out) */
  124. };
  125. /* You can do most things with hubs just through control messages,
  126. * except find out what device connects to what port. */
  127. struct usbdevfs_hub_portinfo {
  128. char nports; /* number of downstream ports in this hub */
  129. char port [127]; /* e.g. port 3 connects to device 27 */
  130. };
  131. /* System and bus capability flags */
  132. #define USBDEVFS_CAP_ZERO_PACKET 0x01
  133. #define USBDEVFS_CAP_BULK_CONTINUATION 0x02
  134. #define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04
  135. #define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08
  136. #define USBDEVFS_CAP_REAP_AFTER_DISCONNECT 0x10
  137. #define USBDEVFS_CAP_MMAP 0x20
  138. #define USBDEVFS_CAP_DROP_PRIVILEGES 0x40
  139. #define USBDEVFS_CAP_CONNINFO_EX 0x80
  140. #define USBDEVFS_CAP_SUSPEND 0x100
  141. /* USBDEVFS_DISCONNECT_CLAIM flags & struct */
  142. /* disconnect-and-claim if the driver matches the driver field */
  143. #define USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER 0x01
  144. /* disconnect-and-claim except when the driver matches the driver field */
  145. #define USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER 0x02
  146. struct usbdevfs_disconnect_claim {
  147. unsigned int interface;
  148. unsigned int flags;
  149. char driver[USBDEVFS_MAXDRIVERNAME + 1];
  150. };
  151. struct usbdevfs_streams {
  152. unsigned int num_streams; /* Not used by USBDEVFS_FREE_STREAMS */
  153. unsigned int num_eps;
  154. unsigned char eps[];
  155. };
  156. /*
  157. * USB_SPEED_* values returned by USBDEVFS_GET_SPEED are defined in
  158. * linux/usb/ch9.h
  159. */
  160. #define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer)
  161. #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
  162. #define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer)
  163. #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
  164. #define USBDEVFS_RESETEP _IOR('U', 3, unsigned int)
  165. #define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface)
  166. #define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int)
  167. #define USBDEVFS_GETDRIVER _IOW('U', 8, struct usbdevfs_getdriver)
  168. #define USBDEVFS_SUBMITURB _IOR('U', 10, struct usbdevfs_urb)
  169. #define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32)
  170. #define USBDEVFS_DISCARDURB _IO('U', 11)
  171. #define USBDEVFS_REAPURB _IOW('U', 12, void *)
  172. #define USBDEVFS_REAPURB32 _IOW('U', 12, __u32)
  173. #define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *)
  174. #define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32)
  175. #define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal)
  176. #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
  177. #define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int)
  178. #define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
  179. #define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo)
  180. #define USBDEVFS_IOCTL _IOWR('U', 18, struct usbdevfs_ioctl)
  181. #define USBDEVFS_IOCTL32 _IOWR('U', 18, struct usbdevfs_ioctl32)
  182. #define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo)
  183. #define USBDEVFS_RESET _IO('U', 20)
  184. #define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int)
  185. #define USBDEVFS_DISCONNECT _IO('U', 22)
  186. #define USBDEVFS_CONNECT _IO('U', 23)
  187. #define USBDEVFS_CLAIM_PORT _IOR('U', 24, unsigned int)
  188. #define USBDEVFS_RELEASE_PORT _IOR('U', 25, unsigned int)
  189. #define USBDEVFS_GET_CAPABILITIES _IOR('U', 26, __u32)
  190. #define USBDEVFS_DISCONNECT_CLAIM _IOR('U', 27, struct usbdevfs_disconnect_claim)
  191. #define USBDEVFS_ALLOC_STREAMS _IOR('U', 28, struct usbdevfs_streams)
  192. #define USBDEVFS_FREE_STREAMS _IOR('U', 29, struct usbdevfs_streams)
  193. #define USBDEVFS_DROP_PRIVILEGES _IOW('U', 30, __u32)
  194. #define USBDEVFS_GET_SPEED _IO('U', 31)
  195. /*
  196. * Returns struct usbdevfs_conninfo_ex; length is variable to allow
  197. * extending size of the data returned.
  198. */
  199. #define USBDEVFS_CONNINFO_EX(len) _IOC(_IOC_READ, 'U', 32, len)
  200. #define USBDEVFS_FORBID_SUSPEND _IO('U', 33)
  201. #define USBDEVFS_ALLOW_SUSPEND _IO('U', 34)
  202. #define USBDEVFS_WAIT_FOR_RESUME _IO('U', 35)
  203. #endif /* _UAPI_LINUX_USBDEVICE_FS_H */