add the hub subclass code
[AROS.git] / compiler / include / devices / usb.h
blobe7f8aa858b0732375511d9ed925e186b4c32107a
1 #ifndef DEVICES_USB_H
2 #define DEVICES_USB_H
3 /*
4 ** $VER: usb.h 2.0 (15.12.07)
5 **
6 ** usb definitions include file
7 **
8 ** (C) Copyright 2002-2007 Chris Hodges
9 ** All Rights Reserved
12 #include <exec/types.h>
14 #if defined(__GNUC__)
15 # pragma pack(1)
16 #endif
18 /* Flags for bmRequestType */
19 #define URTF_OUT 0x00 /* direction: host to device */
20 #define URTF_IN 0x80 /* direction: device to host */
21 #define URTF_STANDARD 0x00 /* type: usb standard request */
22 #define URTF_CLASS 0x20 /* type: class request */
23 #define URTF_VENDOR 0x40 /* type: vendor specific request */
24 #define URTF_DEVICE 0x00 /* target: device */
25 #define URTF_INTERFACE 0x01 /* target: interface */
26 #define URTF_ENDPOINT 0x02 /* target: endpoint */
27 #define URTF_OTHER 0x03 /* target: other */
29 /* Usb Standard Requests (only for URTF_STANDARD) */
30 #define USR_GET_STATUS 0x00
31 #define USR_CLEAR_FEATURE 0x01
32 #define USR_SET_FEATURE 0x03
33 #define USR_SET_ADDRESS 0x05
34 #define USR_GET_DESCRIPTOR 0x06
35 #define USR_SET_DESCRIPTOR 0x07
36 #define USR_GET_CONFIGURATION 0x08
37 #define USR_SET_CONFIGURATION 0x09
38 #define USR_GET_INTERFACE 0x0a
39 #define USR_SET_INTERFACE 0x0b
40 #define USR_SYNCH_FRAME 0x0c
42 #ifdef AROS_USB30_CODE
43 #define USR_SET_SEL 0x30
44 #define USR_SET_ISOCH_DELAY 0x31
45 #endif
47 /* Usb Standard Feature Selectors */
48 #define UFS_DEVICE_REMOTE_WAKEUP 0x01 /* Recipient: Device */
49 #define UFS_ENDPOINT_HALT 0x00 /* Recipient: Endpoint */
50 #define UFS_TEST_MODE 0x02 /* Recipient: Device */
52 /* Usb GetStatus() data bits (LE-UWORD) */
53 #define U_GSB_SELF_POWERED 8
54 #define U_GSB_REMOTE_WAKEUP 9
56 #define U_GSF_SELF_POWERED (1<<U_GSB_SELF_POWERED)
57 #define U_GSF_REMOTE_WAKEUP (1<<U_GSB_REMOTE_WAKEUP)
59 /* Usb Descriptor Types */
60 #define UDT_DEVICE 0x01
61 #define UDT_CONFIGURATION 0x02
62 #define UDT_STRING 0x03
63 #define UDT_INTERFACE 0x04
64 #define UDT_ENDPOINT 0x05
66 #define UDT_DEVICE_QUALIFIER 0x06
67 #define UDT_OTHERSPEED_QUALIFIER 0x07
68 #define UDT_INTERFACE_POWER 0x08
69 #define UDT_OTG 0x09
70 #define UDT_DEBUG 0x0a
71 #define UDT_INTERFACE_ASSOCIATION 0x0b
72 #define UDT_SECURITY 0x0c
73 #define UDT_ENCRYPTION_TYPE 0x0e
74 #define UDT_BOS 0x0f
75 #define UDT_DEVICE_CAPABILITY 0x10
76 #define UDT_WIRELESS_EP_COMP 0x11 /* Wireless endpoint companion descriptor */
78 /* common class specific descriptors */
79 #define UDT_CS_UNDEFINED 0x20
80 #define UDT_CS_DEVICE 0x21
81 #define UDT_CS_CONFIGURATION 0x22
82 #define UDT_CS_STRING 0x23
83 #define UDT_CS_INTERFACE 0x24
84 #define UDT_CS_ENDPOINT 0x25
86 /* SMARTCARD class specific descriptors */
87 #define UDT_CCID 0x21 /* Smart card CCID functional descriptor */
89 /* Device Wire Adapter class specific descriptors */
90 #define UDT_WIREADAPTER_CLASS 0x21 /* Wire Adapter class descriptor */
91 #define UDT_WIREADAPTER_RPIPE 0x22 /* Wire Adapter RPipe descriptor */
92 #define UDT_RADIO_CONTROL_IF 0x23 /* Radio Control Interface Class descriptor */
94 /* Format of 8-bytes setup packet */
95 struct UsbSetupData
97 UBYTE bmRequestType; /* Request type and direction */
98 UBYTE bRequest; /* Request identifier */
99 UWORD wValue; /* request specific value, little endian! */
100 UWORD wIndex; /* request specific index, little endian! */
101 UWORD wLength; /* length of data to transfer, little endian! */
104 /* Usb Standard Device Descriptor */
105 struct UsbStdDevDesc
107 UBYTE bLength; /* Size of this descriptor in bytes */
108 UBYTE bDescriptorType; /* UDT_DEVICE Descriptor Type */
109 UWORD bcdUSB; /* USB Specification Release Number */
110 UBYTE bDeviceClass; /* Class code (assigned by the USB). */
111 UBYTE bDeviceSubClass; /* Subclass code (assigned by the USB). */
112 UBYTE bDeviceProtocol; /* Protocol code (assigned by the USB). */
113 UBYTE bMaxPacketSize0; /* Maximum packet size for endpoint zero (only 8, 16, 32, or 64 are valid) */
114 UWORD idVendor; /* Vendor ID (assigned by the USB) */
115 UWORD idProduct; /* Product ID (assigned by the manufacturer) */
116 UWORD bcdDevice; /* Device release number in binary-coded decimal */
117 UBYTE iManufacturer; /* Index of string descriptor describing manufacturer */
118 UBYTE iProduct; /* Index of string descriptor describing product */
119 UBYTE iSerialNumber; /* Index of string descriptor describing the device's serial number */
120 UBYTE bNumConfigurations; /* Number of possible configurations */
123 /* Usb Standard Configuration Descriptor */
124 struct UsbStdCfgDesc
126 UBYTE bLength; /* Size of this descriptor in bytes */
127 UBYTE bDescriptorType; /* UDT_CONFIGURATION Descriptor Type */
128 UWORD wTotalLength; /* Total length of data returned for this configuration. */
129 UBYTE bNumInterfaces; /* Number of interfaces supported by this configuration. */
130 UBYTE bConfigurationValue; /* Value to use as an argument to the SetConfiguration() request */
131 UBYTE iConfiguration; /* Index of string descriptor describing this configuration */
132 UBYTE bmAttributes; /* Configuration characteristics */
133 UBYTE bMaxPower; /* Maximum power consumption of the USB device (2mA units) */
136 /* Flags for bmAttributes */
137 #define USCAF_ONE 0x80
138 #define USCAF_SELF_POWERED 0x40
139 #define USCAF_REMOTE_WAKEUP 0x20
141 struct UsbStdIfDesc
143 UBYTE bLength; /* Size of this descriptor in bytes */
144 UBYTE bDescriptorType; /* UDT_INTERFACE Descriptor Type */
145 UBYTE bInterfaceNumber; /* Number of interface. */
146 UBYTE bAlternateSetting; /* Value used to select alternate setting */
147 UBYTE bNumEndpoints; /* Number of endpoints used by this interface (excluding endpoint zero). */
148 UBYTE bInterfaceClass; /* Class code (assigned by the USB). */
149 UBYTE bInterfaceSubClass; /* Subclass code (assigned by the USB). */
150 UBYTE bInterfaceProtocol; /* Protocol code (assigned by the USB). */
151 UBYTE iInterface; /* Index of string descriptor describing this interface */
154 /* Usb Standard Endpoint Descriptor */
156 struct UsbStdEPDesc
158 UBYTE bLength; /* Size of this descriptor in bytes */
159 UBYTE bDescriptorType; /* UDT_ENDPOINT Descriptor Type */
160 UBYTE bEndpointAddress; /* The address of the endpoint on the USB, MSB holds direction */
161 UBYTE bmAttributes; /* TransferType (00=Control, 01=Iso, 10=Bulk, 11=Interrupt */
162 UWORD wMaxPacketSize; /* Maximum packet size this endpoint is capable of sending or receiving */
163 UBYTE bInterval; /* Interval for polling endpoint for data transfers in ms */
166 /* Usb Standard String Descriptors */
167 struct UsbStdStrDesc
169 UBYTE bLength; /* Size of this descriptor in bytes */
170 UBYTE bDescriptorType; /* UDT_STRING Descriptor Type */
171 UWORD bString[1]; /* UNICODE encoded string */
174 /* Flags for bmAttributes */
175 #define USEAF_CONTROL 0x00
176 #define USEAF_ISOCHRONOUS 0x01
177 #define USEAF_BULK 0x02
178 #define USEAF_INTERRUPT 0x03
180 /* Flags for Synchronization Type (already shifted right by 2) */
181 #define USEAF_NOSYNC 0x00
182 #define USEAF_ASYNC 0x01
183 #define USEAF_ADAPTIVE 0x02
184 #define USEAF_SYNC 0x03
186 /* Flags for Usage Type (already shifted right by 2) */
187 #define USEAF_DATA 0x00
188 #define USEAF_FEEDBACK 0x01
189 #define USEAF_IMPLFEEDBACK 0x02
191 /* Standard classes */
192 #define AUDIO_CLASSCODE 0x01
193 #define CDCCTRL_CLASSCODE 0x02
194 #define CDCDATA_CLASSCODE 0x0a
195 #define HID_CLASSCODE 0x03
196 #define PHYSICAL_CLASSCODE 0x05
197 #define STILLIMG_CLASSCODE 0x06
198 #define PRINTER_CLASSCODE 0x07
199 #define MASSSTORE_CLASSCODE 0x08
200 #define HUB_CLASSCODE 0x09
201 #define HUB_SUBCLASS 0x00
202 #define SMARTCARD_CLASSCODE 0x0b
203 #define SECURITY_CLASSCODE 0x0d
204 #define VIDEO_CLASSCODE 0x0e
205 #define BLUETOOTH_CLASSCODE 0xe0
206 #define MISC_CLASSCODE 0xef
207 #define FWUPGRADE_CLASSCODE 0xfe
208 #define VENDOR_CLASSCODE 0xff
210 /* Misc Subclasses */
211 #define MISC_COMMON_SUBCLASS 0x02
213 /* Misc Subclass Common protocols */
214 #define MISC_PROTO_WUSB_WAMP 0x02 /* Wire Adapter Multifunction Peripheral */
216 /* Bluetooth subclasses */
217 #define BLUETOOTH_RF_SUBCLASS 0x01
218 #define BLUETOOTH_WUSB_SUBCLASS 0x02 /* Wireless USB Wire Adapter */
220 /* Bluetooth RF protocols */
221 #define BLUETOOTH_PROTO_PRG 0x01
222 #define BLUETOOTH_PROTO_UWB 0x02 /* UWB Radio Control Interface Programming Interface */
224 /* Wireless WUSB protocols */
225 #define BLUETOOTH_PROTO_HWA 0x01 /* Host Wire Adapter Control */
227 #if defined(__GNUC__)
228 # pragma pack()
229 #endif
231 #endif /* DEVICES_USB_H */