grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / devs / USB / include / usb_core.h
blob22284a92d824b446e36df44f670cb048e0273d7a
1 #ifndef USB_CORE_H_
2 #define USB_CORE_H_
4 /* $Id$ */
6 #include <inttypes.h>
8 #include <exec/types.h>
9 #include <exec/ports.h>
10 #include <aros/macros.h>
12 typedef enum {
13 RET_ERROR = 0,
14 RET_OK,
15 } USBRetVal;
17 typedef struct {
18 struct Message pm_Message;
19 void *pm_Pipe;
20 USBRetVal pm_RetVal;
21 } USBMessage;
23 typedef struct {
24 uint8_t bmRequestType;
25 uint8_t bRequest;
26 uint16_t wValue;
27 uint16_t wIndex;
28 uint16_t wLength;
29 } __attribute__((packed)) USBDevice_Request;
31 #define UT_WRITE 0x00
32 #define UT_READ 0x80
33 #define UT_STANDARD 0x00
34 #define UT_CLASS 0x20
35 #define UT_VENDOR 0x40
36 #define UT_DEVICE 0x00
37 #define UT_INTERFACE 0x01
38 #define UT_ENDPOINT 0x02
39 #define UT_OTHER 0x03
41 #define UT_READ_DEVICE (UT_READ | UT_STANDARD | UT_DEVICE)
42 #define UT_READ_INTERFACE (UT_READ | UT_STANDARD | UT_INTERFACE)
43 #define UT_READ_ENDPOINT (UT_READ | UT_STANDARD | UT_ENDPOINT)
44 #define UT_WRITE_DEVICE (UT_WRITE | UT_STANDARD | UT_DEVICE)
45 #define UT_WRITE_INTERFACE (UT_WRITE | UT_STANDARD | UT_INTERFACE)
46 #define UT_WRITE_ENDPOINT (UT_WRITE | UT_STANDARD | UT_ENDPOINT)
47 #define UT_READ_CLASS_DEVICE (UT_READ | UT_CLASS | UT_DEVICE)
48 #define UT_READ_CLASS_INTERFACE (UT_READ | UT_CLASS | UT_INTERFACE)
49 #define UT_READ_CLASS_OTHER (UT_READ | UT_CLASS | UT_OTHER)
50 #define UT_READ_CLASS_ENDPOINT (UT_READ | UT_CLASS | UT_ENDPOINT)
51 #define UT_WRITE_CLASS_DEVICE (UT_WRITE | UT_CLASS | UT_DEVICE)
52 #define UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE)
53 #define UT_WRITE_CLASS_OTHER (UT_WRITE | UT_CLASS | UT_OTHER)
54 #define UT_WRITE_CLASS_ENDPOINT (UT_WRITE | UT_CLASS | UT_ENDPOINT)
55 #define UT_READ_VENDOR_DEVICE (UT_READ | UT_VENDOR | UT_DEVICE)
56 #define UT_READ_VENDOR_INTERFACE (UT_READ | UT_VENDOR | UT_INTERFACE)
57 #define UT_READ_VENDOR_OTHER (UT_READ | UT_VENDOR | UT_OTHER)
58 #define UT_READ_VENDOR_ENDPOINT (UT_READ | UT_VENDOR | UT_ENDPOINT)
59 #define UT_WRITE_VENDOR_DEVICE (UT_WRITE | UT_VENDOR | UT_DEVICE)
60 #define UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE)
61 #define UT_WRITE_VENDOR_OTHER (UT_WRITE | UT_VENDOR | UT_OTHER)
62 #define UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT)
64 /* Requests */
65 #define UR_GET_STATUS 0x00
66 #define UR_CLEAR_FEATURE 0x01
67 #define UR_SET_FEATURE 0x03
68 #define UR_SET_ADDRESS 0x05
69 #define UR_GET_DESCRIPTOR 0x06
70 #define UDESC_DEVICE 0x01
71 #define UDESC_CONFIG 0x02
72 #define UDESC_STRING 0x03
73 #define UDESC_INTERFACE 0x04
74 #define UDESC_ENDPOINT 0x05
75 #define UDESC_DEVICE_QUALIFIER 0x06
76 #define UDESC_OTHER_SPEED_CONFIGURATION 0x07
77 #define UDESC_INTERFACE_POWER 0x08
78 #define UDESC_OTG 0x09
79 #define UDESC_CS_DEVICE 0x21 /* class specific */
80 #define UDESC_CS_CONFIG 0x22
81 #define UDESC_CS_STRING 0x23
82 #define UDESC_CS_INTERFACE 0x24
83 #define UDESC_CS_ENDPOINT 0x25
84 #define UDESC_HUB 0x29
85 #define UR_SET_DESCRIPTOR 0x07
86 #define UR_GET_CONFIG 0x08
87 #define UR_SET_CONFIG 0x09
88 #define UR_GET_INTERFACE 0x0a
89 #define UR_SET_INTERFACE 0x0b
90 #define UR_SYNCH_FRAME 0x0c
92 /* Feature numbers */
93 #define UF_ENDPOINT_HALT 0
94 #define UF_DEVICE_REMOTE_WAKEUP 1
95 #define UF_TEST_MODE 2
97 #define USB_MAX_IPACKET 8 /* maximum size of the initial packet */
99 #define USB_2_MAX_CTRL_PACKET 64
100 #define USB_2_MAX_BULK_PACKET 512
102 typedef struct {
103 uint8_t bLength;
104 uint8_t bDescriptorType;
105 uint8_t bDescriptorSubtype;
106 } __attribute__((packed)) usb_descriptor_t;
108 typedef struct {
109 uint8_t bLength;
110 uint8_t bDescriptorType;
111 uint16_t bcdUSB;
112 #define UD_USB_2_0 0x0200
113 #define UD_IS_USB2(d) (AROS_LE2WORD((d)->bcdUSB) >= UD_USB_2_0)
114 uint8_t bDeviceClass;
115 uint8_t bDeviceSubClass;
116 uint8_t bDeviceProtocol;
117 uint8_t bMaxPacketSize;
118 /* The fields below are not part of the initial descriptor. */
119 uint16_t idVendor;
120 uint16_t idProduct;
121 uint16_t bcdDevice;
122 uint8_t iManufacturer;
123 uint8_t iProduct;
124 uint8_t iSerialNumber;
125 uint8_t bNumConfigurations;
126 } __attribute__((packed)) usb_device_descriptor_t;
127 #define USB_DEVICE_DESCRIPTOR_SIZE 18
129 typedef struct {
130 uint8_t bLength;
131 uint8_t bDescriptorType;
132 uint16_t wTotalLength;
133 uint8_t bNumInterface;
134 uint8_t bConfigurationValue;
135 uint8_t iConfiguration;
136 uint8_t bmAttributes;
137 #define UC_BUS_POWERED 0x80
138 #define UC_SELF_POWERED 0x40
139 #define UC_REMOTE_WAKEUP 0x20
140 uint8_t bMaxPower; /* max current in 2 mA units */
141 #define UC_POWER_FACTOR 2
142 } __attribute__((packed)) usb_config_descriptor_t;
143 #define USB_CONFIG_DESCRIPTOR_SIZE 9
145 typedef struct {
146 uint8_t bLength;
147 uint8_t bDescriptorType;
148 uint8_t bInterfaceNumber;
149 uint8_t bAlternateSetting;
150 uint8_t bNumEndpoints;
151 uint8_t bInterfaceClass;
152 uint8_t bInterfaceSubClass;
153 uint8_t bInterfaceProtocol;
154 uint8_t iInterface;
155 } __attribute__((packed)) usb_interface_descriptor_t;
156 #define USB_INTERFACE_DESCRIPTOR_SIZE 9
158 typedef struct {
159 uint8_t bLength;
160 uint8_t bDescriptorType;
161 uint8_t bEndpointAddress;
162 #define UE_GET_DIR(a) ((a) & 0x80)
163 #define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7))
164 #define UE_DIR_IN 0x80
165 #define UE_DIR_OUT 0x00
166 #define UE_ADDR 0x0f
167 #define UE_GET_ADDR(a) ((a) & UE_ADDR)
168 uint8_t bmAttributes;
169 #define UE_XFERTYPE 0x03
170 #define UE_CONTROL 0x00
171 #define UE_ISOCHRONOUS 0x01
172 #define UE_BULK 0x02
173 #define UE_INTERRUPT 0x03
174 #define UE_GET_XFERTYPE(a) ((a) & UE_XFERTYPE)
175 #define UE_ISO_TYPE 0x0c
176 #define UE_ISO_ASYNC 0x04
177 #define UE_ISO_ADAPT 0x08
178 #define UE_ISO_SYNC 0x0c
179 #define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE)
180 uint16_t wMaxPacketSize;
181 uint8_t bInterval;
182 } __attribute__((packed)) usb_endpoint_descriptor_t;
183 #define USB_ENDPOINT_DESCRIPTOR_SIZE 7
185 typedef struct {
186 uint8_t bLength;
187 uint8_t bDescriptorType;
188 uint16_t bString[127];
189 } __attribute__((packed)) usb_string_descriptor_t;
190 #define USB_MAX_STRING_LEN 128
191 #define USB_LANGUAGE_TABLE 0 /* # of the string language id table */
193 /* Hub specific request */
194 #define UR_GET_BUS_STATE 0x02
195 #define UR_CLEAR_TT_BUFFER 0x08
196 #define UR_RESET_TT 0x09
197 #define UR_GET_TT_STATE 0x0a
198 #define UR_STOP_TT 0x0b
200 /* Hub features */
201 #define UHF_C_HUB_LOCAL_POWER 0
202 #define UHF_C_HUB_OVER_CURRENT 1
203 #define UHF_PORT_CONNECTION 0
204 #define UHF_PORT_ENABLE 1
205 #define UHF_PORT_SUSPEND 2
206 #define UHF_PORT_OVER_CURRENT 3
207 #define UHF_PORT_RESET 4
208 #define UHF_PORT_POWER 8
209 #define UHF_PORT_LOW_SPEED 9
210 #define UHF_C_PORT_CONNECTION 16
211 #define UHF_C_PORT_ENABLE 17
212 #define UHF_C_PORT_SUSPEND 18
213 #define UHF_C_PORT_OVER_CURRENT 19
214 #define UHF_C_PORT_RESET 20
215 #define UHF_PORT_TEST 21
216 #define UHF_PORT_INDICATOR 22
218 typedef struct {
219 uint8_t bDescLength;
220 uint8_t bDescriptorType;
221 uint8_t bNbrPorts;
222 uint16_t wHubCharacteristics;
223 #define UHD_PWR 0x0003
224 #define UHD_PWR_GANGED 0x0000
225 #define UHD_PWR_INDIVIDUAL 0x0001
226 #define UHD_PWR_NO_SWITCH 0x0002
227 #define UHD_COMPOUND 0x0004
228 #define UHD_OC 0x0018
229 #define UHD_OC_GLOBAL 0x0000
230 #define UHD_OC_INDIVIDUAL 0x0008
231 #define UHD_OC_NONE 0x0010
232 #define UHD_TT_THINK 0x0060
233 #define UHD_TT_THINK_8 0x0000
234 #define UHD_TT_THINK_16 0x0020
235 #define UHD_TT_THINK_24 0x0040
236 #define UHD_TT_THINK_32 0x0060
237 #define UHD_PORT_IND 0x0080
238 uint8_t bPwrOn2PwrGood; /* delay in 2 ms units */
239 #define UHD_PWRON_FACTOR 2
240 uint8_t bHubContrCurrent;
241 uint8_t DeviceRemovable[32]; /* max 255 ports */
242 #define UHD_NOT_REMOV(desc, i) \
243 (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
244 /* deprecated */ uint8_t PortPowerCtrlMask[1];
245 } __attribute__((packed)) usb_hub_descriptor_t;
246 #define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */
248 typedef struct {
249 uint8_t bLength;
250 uint8_t bDescriptorType;
251 uint16_t bcdUSB;
252 uint8_t bDeviceClass;
253 uint8_t bDeviceSubClass;
254 uint8_t bDeviceProtocol;
255 uint8_t bMaxPacketSize0;
256 uint8_t bNumConfigurations;
257 uint8_t bReserved;
258 } __attribute__((packed)) usb_device_qualifier_t;
259 #define USB_DEVICE_QUALIFIER_SIZE 10
261 typedef struct {
262 uint8_t bLength;
263 uint8_t bDescriptorType;
264 uint8_t bmAttributes;
265 #define UOTG_SRP 0x01
266 #define UOTG_HNP 0x02
267 } __attribute__((packed)) usb_otg_descriptor_t;
269 /* OTG feature selectors */
270 #define UOTG_B_HNP_ENABLE 3
271 #define UOTG_A_HNP_SUPPORT 4
272 #define UOTG_A_ALT_HNP_SUPPORT 5
274 typedef struct {
275 uint16_t wStatus;
276 /* Device status flags */
277 #define UDS_SELF_POWERED 0x0001
278 #define UDS_REMOTE_WAKEUP 0x0002
279 /* Endpoint status flags */
280 #define UES_HALT 0x0001
281 } __attribute__((packed)) usb_status_t;
283 typedef struct {
284 uint16_t wHubStatus;
285 #define UHS_LOCAL_POWER 0x0001
286 #define UHS_OVER_CURRENT 0x0002
287 uint16_t wHubChange;
288 } __attribute__((packed)) usb_hub_status_t;
290 typedef struct {
291 uint16_t wPortStatus;
292 #define UPS_CURRENT_CONNECT_STATUS 0x0001
293 #define UPS_PORT_ENABLED 0x0002
294 #define UPS_SUSPEND 0x0004
295 #define UPS_OVERCURRENT_INDICATOR 0x0008
296 #define UPS_RESET 0x0010
297 #define UPS_PORT_POWER 0x0100
298 #define UPS_LOW_SPEED 0x0200
299 #define UPS_HIGH_SPEED 0x0400
300 #define UPS_PORT_TEST 0x0800
301 #define UPS_PORT_INDICATOR 0x1000
302 uint16_t wPortChange;
303 #define UPS_C_CONNECT_STATUS 0x0001
304 #define UPS_C_PORT_ENABLED 0x0002
305 #define UPS_C_SUSPEND 0x0004
306 #define UPS_C_OVERCURRENT_INDICATOR 0x0008
307 #define UPS_C_PORT_RESET 0x0010
308 } __attribute__((packed)) usb_port_status_t;
310 /* Device class codes */
311 #define UDCLASS_IN_INTERFACE 0x00
312 #define UDCLASS_COMM 0x02
313 #define UDCLASS_HUB 0x09
314 #define UDSUBCLASS_HUB 0x00
315 #define UDPROTO_FSHUB 0x00
316 #define UDPROTO_HSHUBSTT 0x01
317 #define UDPROTO_HSHUBMTT 0x02
318 #define UDCLASS_DIAGNOSTIC 0xdc
319 #define UDCLASS_WIRELESS 0xe0
320 #define UDSUBCLASS_RF 0x01
321 #define UDPROTO_BLUETOOTH 0x01
322 #define UDCLASS_VENDOR 0xff
324 /* Interface class codes */
325 #define UICLASS_UNSPEC 0x00
327 #define UICLASS_AUDIO 0x01
328 #define UISUBCLASS_AUDIOCONTROL 1
329 #define UISUBCLASS_AUDIOSTREAM 2
330 #define UISUBCLASS_MIDISTREAM 3
332 #define UICLASS_CDC 0x02 /* communication */
333 #define UISUBCLASS_DIRECT_LINE_CONTROL_MODEL 1
334 #define UISUBCLASS_ABSTRACT_CONTROL_MODEL 2
335 #define UISUBCLASS_TELEPHONE_CONTROL_MODEL 3
336 #define UISUBCLASS_MULTICHANNEL_CONTROL_MODEL 4
337 #define UISUBCLASS_CAPI_CONTROLMODEL 5
338 #define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
339 #define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7
340 #define UIPROTO_CDC_AT 1
342 #define UICLASS_HID 0x03
343 #define UISUBCLASS_BOOT 1
344 #define UIPROTO_BOOT_KEYBOARD 1
346 #define UICLASS_PHYSICAL 0x05
348 #define UICLASS_IMAGE 0x06
350 #define UICLASS_PRINTER 0x07
351 #define UISUBCLASS_PRINTER 1
352 #define UIPROTO_PRINTER_UNI 1
353 #define UIPROTO_PRINTER_BI 2
354 #define UIPROTO_PRINTER_1284 3
356 #define UICLASS_MASS 0x08
357 #define UISUBCLASS_RBC 1
358 #define UISUBCLASS_SFF8020I 2
359 #define UISUBCLASS_QIC157 3
360 #define UISUBCLASS_UFI 4
361 #define UISUBCLASS_SFF8070I 5
362 #define UISUBCLASS_SCSI 6
363 #define UIPROTO_MASS_CBI_I 0
364 #define UIPROTO_MASS_CBI 1
365 #define UIPROTO_MASS_BBB_OLD 2 /* Not in the spec anymore */
366 #define UIPROTO_MASS_BBB 80 /* 'P' for the Iomega Zip drive */
368 #define UICLASS_HUB 0x09
369 #define UISUBCLASS_HUB 0
370 #define UIPROTO_FSHUB 0
371 #define UIPROTO_HSHUBSTT 0 /* Yes, same as previous */
372 #define UIPROTO_HSHUBMTT 1
374 #define UICLASS_CDC_DATA 0x0a
375 #define UISUBCLASS_DATA 0
376 #define UIPROTO_DATA_ISDNBRI 0x30 /* Physical iface */
377 #define UIPROTO_DATA_HDLC 0x31 /* HDLC */
378 #define UIPROTO_DATA_TRANSPARENT 0x32 /* Transparent */
379 #define UIPROTO_DATA_Q921M 0x50 /* Management for Q921 */
380 #define UIPROTO_DATA_Q921 0x51 /* Data for Q921 */
381 #define UIPROTO_DATA_Q921TM 0x52 /* TEI multiplexer for Q921 */
382 #define UIPROTO_DATA_V42BIS 0x90 /* Data compression */
383 #define UIPROTO_DATA_Q931 0x91 /* Euro-ISDN */
384 #define UIPROTO_DATA_V120 0x92 /* V.24 rate adaption */
385 #define UIPROTO_DATA_CAPI 0x93 /* CAPI 2.0 commands */
386 #define UIPROTO_DATA_HOST_BASED 0xfd /* Host based driver */
387 #define UIPROTO_DATA_PUF 0xfe /* see Prot. Unit Func. Desc.*/
388 #define UIPROTO_DATA_VENDOR 0xff /* Vendor specific */
390 #define UICLASS_SMARTCARD 0x0b
392 /*#define UICLASS_FIRM_UPD 0x0c*/
394 #define UICLASS_SECURITY 0x0d
396 #define UICLASS_DIAGNOSTIC 0xdc
398 #define UICLASS_WIRELESS 0xe0
399 #define UISUBCLASS_RF 0x01
400 #define UIPROTO_BLUETOOTH 0x01
402 #define UICLASS_APPL_SPEC 0xfe
403 #define UISUBCLASS_FIRMWARE_DOWNLOAD 1
404 #define UISUBCLASS_IRDA 2
405 #define UIPROTO_IRDA 0
407 #define UICLASS_VENDOR 0xff
410 #define USB_HUB_MAX_DEPTH 5
413 * Minimum time a device needs to be powered down to go through
414 * a power cycle. XXX Are these time in the spec?
416 #define USB_POWER_DOWN_TIME 200 /* ms */
417 #define USB_PORT_POWER_DOWN_TIME 100 /* ms */
419 #if 0
420 /* These are the values from the spec. */
421 #define USB_PORT_RESET_DELAY 10 /* ms */
422 #define USB_PORT_ROOT_RESET_DELAY 50 /* ms */
423 #define USB_PORT_RESET_RECOVERY 10 /* ms */
424 #define USB_PORT_POWERUP_DELAY 100 /* ms */
425 #define USB_SET_ADDRESS_SETTLE 2 /* ms */
426 #define USB_RESUME_DELAY (20*5) /* ms */
427 #define USB_RESUME_WAIT 10 /* ms */
428 #define USB_RESUME_RECOVERY 10 /* ms */
429 #define USB_EXTRA_POWER_UP_TIME 0 /* ms */
430 #else
431 /* Allow for marginal (i.e. non-conforming) devices. */
432 #define USB_PORT_RESET_DELAY 50 /* ms */
433 #define USB_PORT_ROOT_RESET_DELAY 250 /* ms */
434 #define USB_PORT_RESET_RECOVERY 250 /* ms */
435 #define USB_PORT_POWERUP_DELAY 300 /* ms */
436 #define USB_SET_ADDRESS_SETTLE 10 /* ms */
437 #define USB_RESUME_DELAY (50*5) /* ms */
438 #define USB_RESUME_WAIT 50 /* ms */
439 #define USB_RESUME_RECOVERY 50 /* ms */
440 #define USB_EXTRA_POWER_UP_TIME 20 /* ms */
441 #endif
443 #define USB_MIN_POWER 100 /* mA */
444 #define USB_MAX_POWER 500 /* mA */
446 #define USB_BUS_RESET_DELAY 100 /* ms XXX?*/
449 #define USB_UNCONFIG_NO 0
450 #define USB_UNCONFIG_INDEX (-1)
452 #if 0
453 /*** ioctl() related stuff ***/
455 struct usb_ctl_request {
456 int ucr_addr;
457 usb_device_request_t ucr_request;
458 void *ucr_data;
459 int ucr_flags;
460 #define USBD_SHORT_XFER_OK 0x04 /* allow short reads */
461 int ucr_actlen; /* actual length transferred */
464 struct usb_alt_interface {
465 int uai_config_index;
466 int uai_interface_index;
467 int uai_alt_no;
470 #define USB_CURRENT_CONFIG_INDEX (-1)
471 #define USB_CURRENT_ALT_INDEX (-1)
473 struct usb_config_desc {
474 int ucd_config_index;
475 usb_config_descriptor_t ucd_desc;
478 struct usb_interface_desc {
479 int uid_config_index;
480 int uid_interface_index;
481 int uid_alt_index;
482 usb_interface_descriptor_t uid_desc;
485 struct usb_endpoint_desc {
486 int ued_config_index;
487 int ued_interface_index;
488 int ued_alt_index;
489 int ued_endpoint_index;
490 usb_endpoint_descriptor_t ued_desc;
493 struct usb_full_desc {
494 int ufd_config_index;
495 u_int ufd_size;
496 u_char *ufd_data;
499 struct usb_string_desc {
500 int usd_string_index;
501 int usd_language_id;
502 usb_string_descriptor_t usd_desc;
505 struct usb_ctl_report_desc {
506 int ucrd_size;
507 u_char ucrd_data[1024]; /* filled data size will vary */
510 typedef struct { u_int32_t cookie; } usb_event_cookie_t;
512 #define USB_MAX_DEVNAMES 4
513 #define USB_MAX_DEVNAMELEN 16
514 struct usb_device_info {
515 u_int8_t udi_bus;
516 u_int8_t udi_addr; /* device address */
517 usb_event_cookie_t udi_cookie;
518 char udi_product[USB_MAX_STRING_LEN];
519 char udi_vendor[USB_MAX_STRING_LEN];
520 char udi_release[8];
521 u_int16_t udi_productNo;
522 u_int16_t udi_vendorNo;
523 u_int16_t udi_releaseNo;
524 u_int8_t udi_class;
525 u_int8_t udi_subclass;
526 u_int8_t udi_protocol;
527 u_int8_t udi_config;
528 u_int8_t udi_speed;
529 #define USB_SPEED_LOW 1
530 #define USB_SPEED_FULL 2
531 #define USB_SPEED_HIGH 3
532 int udi_power; /* power consumption in mA, 0 if selfpowered */
533 int udi_nports;
534 char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
535 u_int8_t udi_ports[16];/* hub only: addresses of devices on ports */
536 #define USB_PORT_ENABLED 0xff
537 #define USB_PORT_SUSPENDED 0xfe
538 #define USB_PORT_POWERED 0xfd
539 #define USB_PORT_DISABLED 0xfc
542 struct usb_ctl_report {
543 int ucr_report;
544 u_char ucr_data[1024]; /* filled data size will vary */
547 struct usb_device_stats {
548 u_long uds_requests[4]; /* indexed by transfer type UE_* */
551 /* Events that can be read from /dev/usb */
552 struct usb_event {
553 int ue_type;
554 #define USB_EVENT_CTRLR_ATTACH 1
555 #define USB_EVENT_CTRLR_DETACH 2
556 #define USB_EVENT_DEVICE_ATTACH 3
557 #define USB_EVENT_DEVICE_DETACH 4
558 #define USB_EVENT_DRIVER_ATTACH 5
559 #define USB_EVENT_DRIVER_DETACH 6
560 #define USB_EVENT_IS_ATTACH(n) ((n) == USB_EVENT_CTRLR_ATTACH || (n) == USB_EVENT_DEVICE_ATTACH || (n) == USB_EVENT_DRIVER_ATTACH)
561 #define USB_EVENT_IS_DETACH(n) ((n) == USB_EVENT_CTRLR_DETACH || (n) == USB_EVENT_DEVICE_DETACH || (n) == USB_EVENT_DRIVER_DETACH)
562 struct timespec ue_time;
563 union {
564 struct {
565 int ue_bus;
566 } ue_ctrlr;
567 struct usb_device_info ue_device;
568 struct {
569 usb_event_cookie_t ue_cookie;
570 char ue_devname[16];
571 } ue_driver;
572 } u;
575 /* USB controller */
576 #define USB_REQUEST _IOWR('U', 1, struct usb_ctl_request)
577 #define USB_SETDEBUG _IOW ('U', 2, int)
578 #define USB_DISCOVER _IO ('U', 3)
579 #define USB_DEVICEINFO _IOWR('U', 4, struct usb_device_info)
580 #define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats)
582 /* Generic HID device */
583 #define USB_GET_REPORT_DESC _IOR ('U', 21, struct usb_ctl_report_desc)
584 #define USB_SET_IMMED _IOW ('U', 22, int)
585 #define USB_GET_REPORT _IOWR('U', 23, struct usb_ctl_report)
586 #define USB_SET_REPORT _IOW ('U', 24, struct usb_ctl_report)
587 #define USB_GET_REPORT_ID _IOR ('U', 25, int)
589 /* Generic USB device */
590 #define USB_GET_CONFIG _IOR ('U', 100, int)
591 #define USB_SET_CONFIG _IOW ('U', 101, int)
592 #define USB_GET_ALTINTERFACE _IOWR('U', 102, struct usb_alt_interface)
593 #define USB_SET_ALTINTERFACE _IOWR('U', 103, struct usb_alt_interface)
594 #define USB_GET_NO_ALT _IOWR('U', 104, struct usb_alt_interface)
595 #define USB_GET_DEVICE_DESC _IOR ('U', 105, usb_device_descriptor_t)
596 #define USB_GET_CONFIG_DESC _IOWR('U', 106, struct usb_config_desc)
597 #define USB_GET_INTERFACE_DESC _IOWR('U', 107, struct usb_interface_desc)
598 #define USB_GET_ENDPOINT_DESC _IOWR('U', 108, struct usb_endpoint_desc)
599 #define USB_GET_FULL_DESC _IOWR('U', 109, struct usb_full_desc)
600 #define USB_GET_STRING_DESC _IOWR('U', 110, struct usb_string_desc)
601 #define USB_DO_REQUEST _IOWR('U', 111, struct usb_ctl_request)
602 #define USB_GET_DEVICEINFO _IOR ('U', 112, struct usb_device_info)
603 #define USB_SET_SHORT_XFER _IOW ('U', 113, int)
604 #define USB_SET_TIMEOUT _IOW ('U', 114, int)
606 /* Modem device */
607 #define USB_GET_CM_OVER_DATA _IOR ('U', 130, int)
608 #define USB_SET_CM_OVER_DATA _IOW ('U', 131, int)
610 #endif /* IOCTL stuff */
612 #endif /*USB_CORE_H_*/