xref: /haiku/headers/os/drivers/USB_spec.h (revision d5cd5d63ff0ad395989db6cf4841a64d5b545d1d)
1 /*
2 ** USB_spec.h
3 **
4 ** Copyright 1999, Be Incorporated. All Rights Reserved.
5 **
6 ** This file contains structures and constants based on the USB Specification 1.1
7 **
8 */
9 
10 #ifndef _USB_SPEC_H
11 #define _USB_SPEC_H
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /* request types (target & direction) for  send_request() */
18 /* cf USB Spec Rev 1.1, table 9-2, p 183 */
19 #define USB_REQTYPE_DEVICE_IN         0x80
20 #define USB_REQTYPE_DEVICE_OUT        0x00
21 #define USB_REQTYPE_INTERFACE_IN      0x81
22 #define USB_REQTYPE_INTERFACE_OUT     0x01
23 #define USB_REQTYPE_ENDPOINT_IN       0x82
24 #define USB_REQTYPE_ENDPOINT_OUT      0x02
25 #define USB_REQTYPE_OTHER_OUT         0x03
26 #define USB_REQTYPE_OTHER_IN          0x83
27 
28 /* request types for send_request() */
29 /* cf USB Spec Rev 1.1, table 9-2, p 183 */
30 #define USB_REQTYPE_STANDARD          0x00
31 #define USB_REQTYPE_CLASS             0x20
32 #define USB_REQTYPE_VENDOR            0x40
33 #define USB_REQTYPE_RESERVED          0x60
34 #define USB_REQTYPE_MASK              0x9F
35 
36 /* standard request values for send_request() */
37 /* cf USB Spec Rev 1.1, table 9-4, p 187 */
38 #define USB_REQUEST_GET_STATUS           0
39 #define USB_REQUEST_CLEAR_FEATURE        1
40 #define USB_REQUEST_SET_FEATURE          3
41 #define USB_REQUEST_SET_ADDRESS          5
42 #define USB_REQUEST_GET_DESCRIPTOR       6
43 #define USB_REQUEST_SET_DESCRIPTOR       7
44 #define USB_REQUEST_GET_CONFIGURATION    8
45 #define USB_REQUEST_SET_CONFIGURATION    9
46 #define USB_REQUEST_GET_INTERFACE       10
47 #define USB_REQUEST_SET_INTERFACE       11
48 #define USB_REQUEST_SYNCH_FRAME         12
49 
50 /* used by {set,get}_descriptor() */
51 /* cf USB Spec Rev 1.1, table 9-5, p 187 */
52 #define USB_DESCRIPTOR_DEVICE            1
53 #define USB_DESCRIPTOR_CONFIGURATION     2
54 #define USB_DESCRIPTOR_STRING            3
55 #define USB_DESCRIPTOR_INTERFACE         4
56 #define USB_DESCRIPTOR_ENDPOINT          5
57 
58 /* used by {set,clear}_feature() */
59 /* cf USB Spec Rev 1.1, table 9-6, p 188 */
60 #define USB_FEATURE_DEVICE_REMOTE_WAKEUP	1
61 #define USB_FEATURE_ENDPOINT_HALT			0
62 
63 
64 
65 typedef struct {
66 	/* cf USB Spec Rev 1.1, table 9-7, p 197 */
67 	uint8 length;
68 	uint8 descriptor_type;          /* USB_DESCRIPTOR_DEVICE */
69 	uint16 usb_version;             /* USB_DESCRIPTOR_DEVICE_LENGTH */
70 	uint8 device_class;
71 	uint8 device_subclass;
72 	uint8 device_protocol;
73 	uint8 max_packet_size_0;
74 	uint16 vendor_id;
75 	uint16 product_id;
76 	uint16 device_version;
77 	uint8 manufacturer;
78 	uint8 product;
79 	uint8 serial_number;
80 	uint8 num_configurations;
81 } _PACKED usb_device_descriptor;
82 
83 typedef struct {
84 	/* cf USB Spec Rev 1.1, table 9-8, p 199 */
85 	uint8 length;
86 	uint8 descriptor_type;          /* USB_DESCRIPTOR_CONFIGURATION */
87 	uint16 total_length;            /* USB_DESCRIPTOR_CONFIGURATION_LENGTH */
88 	uint8 number_interfaces;
89 	uint8 configuration_value;
90 	uint8 configuration;
91 	uint8 attributes;
92 	uint8 max_power;
93 } _PACKED usb_configuration_descriptor;
94 
95 typedef struct {
96 	/* cf USB Spec Rev 1.1, table 9-9, p 202 */
97 	uint8 length;
98 	uint8 descriptor_type;          /* USB_DESCRIPTOR_INTERFACE */
99 	uint8 interface_number;         /* USB_DESCRIPTOR_INTERFACE_LENGTH  */
100 	uint8 alternate_setting;
101 	uint8 num_endpoints;
102 	uint8 interface_class;
103 	uint8 interface_subclass;
104 	uint8 interface_protocol;
105 	uint8 interface;
106 } _PACKED usb_interface_descriptor;
107 
108 typedef struct {
109 	/* cf USB Spec Rev 1.1, table 9-10, p 203 */
110 	uint8 length;
111 	uint8 descriptor_type;          /* USB_DESCRIPTOR_ENDPOINT */
112 	uint8 endpoint_address;         /* USB_DESCRIPTOR_ENDPOINT_LENGTH */
113 	uint8 attributes;
114 	uint16 max_packet_size;
115 	uint8 interval;
116 } _PACKED usb_endpoint_descriptor;
117 
118 typedef struct {
119 	/* cf USB Spec Rev 1.1, table 9-12, p 205 */
120 	uint8 length;                   /* USB_DESCRIPTOR_STRING */
121 	uint8 descriptor_type;
122 	uchar string[1];
123 } _PACKED usb_string_descriptor;
124 
125 typedef struct {
126 	uint8 length;
127 	uint8 descriptor_type;
128 	uint8 data[1];
129 } _PACKED usb_generic_descriptor;
130 
131 typedef union {
132 	usb_generic_descriptor generic;
133 	usb_device_descriptor device;
134 	usb_interface_descriptor interface;
135 	usb_endpoint_descriptor endpoint;
136 	usb_configuration_descriptor configuration;
137 	usb_string_descriptor string;
138 } usb_descriptor;
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif
145