2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
5 * Copyright (c) 2007-2008 Daniel Drake. All rights reserved.
6 * Copyright (c) 2001 Johannes Erdfelt. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * NOTE: This file contains the definition of some standard USB
32 * structures. All structures which name ends by *DECODED use host byte
37 * NOTE: This file uses a lot of macros. If you want to see what the
38 * macros become when they are expanded then run the following
39 * commands from your shell:
41 * cpp libusb20_desc.h > temp.h
46 #ifndef _LIBUSB20_DESC_H_
47 #define _LIBUSB20_DESC_H_
49 #ifndef LIBUSB_GLOBAL_INCLUDE_FILE
62 #define LIBUSB20__NOT(...) __VA_ARGS__
63 #define LIBUSB20_NOT(arg) LIBUSB20__NOT(LIBUSB20_YES arg(() LIBUSB20_NO))
64 #define LIBUSB20_YES(...) __VA_ARGS__
65 #define LIBUSB20_NO(...)
66 #define LIBUSB20_END(...) __VA_ARGS__
67 #define LIBUSB20_MAX(a,b) (((a) > (b)) ? (a) : (b))
68 #define LIBUSB20_MIN(a,b) (((a) < (b)) ? (a) : (b))
70 #define LIBUSB20_ADD_BYTES(ptr,off) \
71 ((void *)(((const uint8_t *)(ptr)) + (off) - ((const uint8_t *)0)))
73 /* basic message elements */
80 LIBUSB20_ME_MAX, /* used to indicate end */
83 /* basic message element modifiers */
85 LIBUSB20_ME_IS_UNSIGNED = 0x00,
86 LIBUSB20_ME_IS_SIGNED = 0x80,
87 LIBUSB20_ME_MASK = 0x7F,
91 LIBUSB20_ME_IS_RAW, /* structure excludes length field
92 * (hardcoded value) */
93 LIBUSB20_ME_IS_ENCODED, /* structure includes length field */
94 LIBUSB20_ME_IS_EMPTY, /* no structure */
95 LIBUSB20_ME_IS_DECODED, /* structure is recursive */
98 /* basic helper structures and macros */
100 #define LIBUSB20_ME_STRUCT_ALIGN sizeof(void *)
102 struct libusb20_me_struct {
103 void *ptr; /* data pointer */
104 uint16_t len; /* defaults to zero */
105 uint16_t type; /* defaults to LIBUSB20_ME_IS_EMPTY */
106 } __aligned(LIBUSB20_ME_STRUCT_ALIGN);
108 struct libusb20_me_format {
109 const uint8_t *format; /* always set */
110 const char *desc; /* optionally set */
111 const char *fields; /* optionally set */
114 #define LIBUSB20_ME_STRUCT(n, field, arg, ismeta) \
115 ismeta ( LIBUSB20_ME_STRUCT, 1, 0, ) \
116 LIBUSB20_NOT(ismeta) ( struct libusb20_me_struct field; )
118 #define LIBUSB20_ME_STRUCT_ARRAY(n, field, arg, ismeta) \
119 ismeta ( LIBUSB20_ME_STRUCT , (arg) & 0xFF, \
120 ((arg) / 0x100) & 0xFF, ) \
121 LIBUSB20_NOT(ismeta) ( struct libusb20_me_struct field [arg]; )
123 #define LIBUSB20_ME_INTEGER(n, field, ismeta, un, u, bits, a, size) \
124 ismeta ( LIBUSB20_ME_INT##bits | \
125 LIBUSB20_ME_IS_##un##SIGNED , \
126 (size) & 0xFF, ((size) / 0x100) & 0xFF, ) \
127 LIBUSB20_NOT(ismeta) ( u##int##bits##_t \
128 __aligned((bits) / 8) field a; )
130 #define LIBUSB20_ME_UINT8_T(n, field, arg, ismeta) \
131 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 8, , 1)
133 #define LIBUSB20_ME_UINT8_ARRAY_T(n, field, arg, ismeta) \
134 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 8, [arg], arg)
136 #define LIBUSB20_ME_SINT8_T(n, field, arg, ismeta) \
137 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 8, , 1)
139 #define LIBUSB20_ME_SINT8_ARRAY_T(n, field, arg, ismeta) \
140 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 8, [arg], arg)
142 #define LIBUSB20_ME_UINT16_T(n, field, arg, ismeta) \
143 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 16, , 1)
145 #define LIBUSB20_ME_UINT16_ARRAY_T(n, field, arg, ismeta) \
146 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 16, [arg], arg)
148 #define LIBUSB20_ME_SINT16_T(n, field, arg, ismeta) \
149 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 16, , 1)
151 #define LIBUSB20_ME_SINT16_ARRAY_T(n, field, arg, ismeta) \
152 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 16, [arg], arg)
154 #define LIBUSB20_ME_UINT32_T(n, field, arg, ismeta) \
155 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 32, , 1)
157 #define LIBUSB20_ME_UINT32_ARRAY_T(n, field, arg, ismeta) \
158 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 32, [arg], arg)
160 #define LIBUSB20_ME_SINT32_T(n, field, arg, ismeta) \
161 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 32, , 1)
163 #define LIBUSB20_ME_SINT32_ARRAY_T(n, field, arg, ismeta) \
164 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 32, [arg], arg)
166 #define LIBUSB20_ME_UINT64_T(n, field, arg, ismeta) \
167 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 64, , 1)
169 #define LIBUSB20_ME_UINT64_ARRAY_T(n, field, arg, ismeta) \
170 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 64, [arg], arg)
172 #define LIBUSB20_ME_SINT64_T(n, field, arg, ismeta) \
173 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 64, , 1)
175 #define LIBUSB20_ME_SINT64_ARRAY_T(n, field, arg, ismeta) \
176 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 64, [arg], arg)
178 #define LIBUSB20_MAKE_DECODED_FIELD(n, type, field, arg) \
179 LIBUSB20_ME_##type (n, field, arg, LIBUSB20_NO)
181 #define LIBUSB20_MAKE_STRUCT(name) \
182 extern const struct libusb20_me_format \
184 struct name##_DECODED { \
185 const struct libusb20_me_format *name##_FORMAT; \
186 name (LIBUSB20_MAKE_DECODED_FIELD,) \
189 #define LIBUSB20_MAKE_STRUCT_FORMAT(name) \
190 const struct libusb20_me_format \
191 name##_FORMAT[1] = {{ \
192 .format = LIBUSB20_MAKE_FORMAT(name), \
197 #define LIBUSB20_MAKE_FORMAT_SUB(n, type, field, arg) \
198 LIBUSB20_ME_##type (n, field, arg, LIBUSB20_YES)
200 #define LIBUSB20_MAKE_FORMAT(what) (const uint8_t []) \
201 { what (LIBUSB20_MAKE_FORMAT_SUB, ) LIBUSB20_ME_MAX, 0, 0 }
203 #define LIBUSB20_INIT(what, ptr) do { \
204 memset(ptr, 0, sizeof(*(ptr))); \
205 (ptr)->what##_FORMAT = what##_FORMAT; \
208 #define LIBUSB20_DEVICE_DESC(m,n) \
209 m(n, UINT8_T, bLength, ) \
210 m(n, UINT8_T, bDescriptorType, ) \
211 m(n, UINT16_T, bcdUSB, ) \
212 m(n, UINT8_T, bDeviceClass, ) \
213 m(n, UINT8_T, bDeviceSubClass, ) \
214 m(n, UINT8_T, bDeviceProtocol, ) \
215 m(n, UINT8_T, bMaxPacketSize0, ) \
216 m(n, UINT16_T, idVendor, ) \
217 m(n, UINT16_T, idProduct, ) \
218 m(n, UINT16_T, bcdDevice, ) \
219 m(n, UINT8_T, iManufacturer, ) \
220 m(n, UINT8_T, iProduct, ) \
221 m(n, UINT8_T, iSerialNumber, ) \
222 m(n, UINT8_T, bNumConfigurations, ) \
224 LIBUSB20_MAKE_STRUCT(LIBUSB20_DEVICE_DESC);
226 #define LIBUSB20_ENDPOINT_DESC(m,n) \
227 m(n, UINT8_T, bLength, ) \
228 m(n, UINT8_T, bDescriptorType, ) \
229 m(n, UINT8_T, bEndpointAddress, ) \
230 m(n, UINT8_T, bmAttributes, ) \
231 m(n, UINT16_T, wMaxPacketSize, ) \
232 m(n, UINT8_T, bInterval, ) \
233 m(n, UINT8_T, bRefresh, ) \
234 m(n, UINT8_T, bSynchAddress, ) \
236 LIBUSB20_MAKE_STRUCT(LIBUSB20_ENDPOINT_DESC);
238 #define LIBUSB20_INTERFACE_DESC(m,n) \
239 m(n, UINT8_T, bLength, ) \
240 m(n, UINT8_T, bDescriptorType, ) \
241 m(n, UINT8_T, bInterfaceNumber, ) \
242 m(n, UINT8_T, bAlternateSetting, ) \
243 m(n, UINT8_T, bNumEndpoints, ) \
244 m(n, UINT8_T, bInterfaceClass, ) \
245 m(n, UINT8_T, bInterfaceSubClass, ) \
246 m(n, UINT8_T, bInterfaceProtocol, ) \
247 m(n, UINT8_T, iInterface, ) \
249 LIBUSB20_MAKE_STRUCT(LIBUSB20_INTERFACE_DESC);
251 #define LIBUSB20_CONFIG_DESC(m,n) \
252 m(n, UINT8_T, bLength, ) \
253 m(n, UINT8_T, bDescriptorType, ) \
254 m(n, UINT16_T, wTotalLength, ) \
255 m(n, UINT8_T, bNumInterfaces, ) \
256 m(n, UINT8_T, bConfigurationValue, ) \
257 m(n, UINT8_T, iConfiguration, ) \
258 m(n, UINT8_T, bmAttributes, ) \
259 m(n, UINT8_T, bMaxPower, ) \
261 LIBUSB20_MAKE_STRUCT(LIBUSB20_CONFIG_DESC);
263 #define LIBUSB20_CONTROL_SETUP(m,n) \
264 m(n, UINT8_T, bmRequestType, ) \
265 m(n, UINT8_T, bRequest, ) \
266 m(n, UINT16_T, wValue, ) \
267 m(n, UINT16_T, wIndex, ) \
268 m(n, UINT16_T, wLength, ) \
270 LIBUSB20_MAKE_STRUCT(LIBUSB20_CONTROL_SETUP);
272 #define LIBUSB20_SS_ENDPT_COMP_DESC(m,n) \
273 m(n, UINT8_T, bLength, ) \
274 m(n, UINT8_T, bDescriptorType, ) \
275 m(n, UINT8_T, bMaxBurst, ) \
276 m(n, UINT8_T, bmAttributes, ) \
277 m(n, UINT16_T, wBytesPerInterval, ) \
279 LIBUSB20_MAKE_STRUCT(LIBUSB20_SS_ENDPT_COMP_DESC);
281 #define LIBUSB20_USB_20_DEVCAP_DESC(m,n) \
282 m(n, UINT8_T, bLength, ) \
283 m(n, UINT8_T, bDescriptorType, ) \
284 m(n, UINT8_T, bDevCapabilityType, ) \
285 m(n, UINT32_T, bmAttributes, ) \
287 LIBUSB20_MAKE_STRUCT(LIBUSB20_USB_20_DEVCAP_DESC);
289 #define LIBUSB20_SS_USB_DEVCAP_DESC(m,n) \
290 m(n, UINT8_T, bLength, ) \
291 m(n, UINT8_T, bDescriptorType, ) \
292 m(n, UINT8_T, bDevCapabilityType, ) \
293 m(n, UINT8_T, bmAttributes, ) \
294 m(n, UINT16_T, wSpeedSupported, ) \
295 m(n, UINT8_T, bFunctionalitySupport, ) \
296 m(n, UINT8_T, bU1DevExitLat, ) \
297 m(n, UINT16_T, wU2DevExitLat, ) \
299 LIBUSB20_MAKE_STRUCT(LIBUSB20_SS_USB_DEVCAP_DESC);
301 #define LIBUSB20_BOS_DESCRIPTOR(m,n) \
302 m(n, UINT8_T, bLength, ) \
303 m(n, UINT8_T, bDescriptorType, ) \
304 m(n, UINT16_T, wTotalLength, ) \
305 m(n, UINT8_T, bNumDeviceCapabilities, ) \
307 LIBUSB20_MAKE_STRUCT(LIBUSB20_BOS_DESCRIPTOR);
309 /* standard USB stuff */
312 * Device and/or Interface Class codes */
313 enum libusb20_class_code {
314 /** In the context of a \ref LIBUSB20_DEVICE_DESC "device
315 * descriptor", this bDeviceClass value indicates that each
316 * interface specifies its own class information and all
317 * interfaces operate independently.
319 LIBUSB20_CLASS_PER_INTERFACE = 0,
322 LIBUSB20_CLASS_AUDIO = 1,
324 /** Communications class */
325 LIBUSB20_CLASS_COMM = 2,
327 /** Human Interface Device class */
328 LIBUSB20_CLASS_HID = 3,
330 /** Printer dclass */
331 LIBUSB20_CLASS_PRINTER = 7,
333 /** Picture transfer protocol class */
334 LIBUSB20_CLASS_PTP = 6,
336 /** Mass storage class */
337 LIBUSB20_CLASS_MASS_STORAGE = 8,
340 LIBUSB20_CLASS_HUB = 9,
343 LIBUSB20_CLASS_DATA = 10,
345 /** Class is vendor-specific */
346 LIBUSB20_CLASS_VENDOR_SPEC = 0xff,
350 * Descriptor types as defined by the USB specification. */
351 enum libusb20_descriptor_type {
352 /** Device descriptor. See LIBUSB20_DEVICE_DESC. */
353 LIBUSB20_DT_DEVICE = 0x01,
355 /** Configuration descriptor. See LIBUSB20_CONFIG_DESC. */
356 LIBUSB20_DT_CONFIG = 0x02,
358 /** String descriptor */
359 LIBUSB20_DT_STRING = 0x03,
361 /** Interface descriptor. See LIBUSB20_INTERFACE_DESC. */
362 LIBUSB20_DT_INTERFACE = 0x04,
364 /** Endpoint descriptor. See LIBUSB20_ENDPOINT_DESC. */
365 LIBUSB20_DT_ENDPOINT = 0x05,
367 /** HID descriptor */
368 LIBUSB20_DT_HID = 0x21,
370 /** HID report descriptor */
371 LIBUSB20_DT_REPORT = 0x22,
373 /** Physical descriptor */
374 LIBUSB20_DT_PHYSICAL = 0x23,
376 /** Hub descriptor */
377 LIBUSB20_DT_HUB = 0x29,
379 /** Binary Object Store, BOS */
380 LIBUSB20_DT_BOS = 0x0f,
382 /** Device Capability */
383 LIBUSB20_DT_DEVICE_CAPABILITY = 0x10,
385 /** SuperSpeed endpoint companion */
386 LIBUSB20_DT_SS_ENDPOINT_COMPANION = 0x30,
390 * Device capability types as defined by the USB specification. */
391 enum libusb20_device_capability_type {
392 LIBUSB20_WIRELESS_USB_DEVICE_CAPABILITY = 0x1,
393 LIBUSB20_USB_2_0_EXTENSION_DEVICE_CAPABILITY = 0x2,
394 LIBUSB20_SS_USB_DEVICE_CAPABILITY = 0x3,
395 LIBUSB20_CONTAINER_ID_DEVICE_CAPABILITY = 0x4,
398 /* Descriptor sizes per descriptor type */
399 #define LIBUSB20_DT_DEVICE_SIZE 18
400 #define LIBUSB20_DT_CONFIG_SIZE 9
401 #define LIBUSB20_DT_INTERFACE_SIZE 9
402 #define LIBUSB20_DT_ENDPOINT_SIZE 7
403 #define LIBUSB20_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
404 #define LIBUSB20_DT_HUB_NONVAR_SIZE 7
405 #define LIBUSB20_DT_SS_ENDPOINT_COMPANION_SIZE 6
406 #define LIBUSB20_DT_BOS_SIZE 5
407 #define LIBUSB20_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE 7
408 #define LIBUSB20_SS_USB_DEVICE_CAPABILITY_SIZE 10
410 #define LIBUSB20_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
411 #define LIBUSB20_ENDPOINT_DIR_MASK 0x80
414 * Endpoint direction. Values for bit 7 of the
415 * \ref LIBUSB20_ENDPOINT_DESC::bEndpointAddress "endpoint address" scheme.
417 enum libusb20_endpoint_direction {
418 /** In: device-to-host */
419 LIBUSB20_ENDPOINT_IN = 0x80,
421 /** Out: host-to-device */
422 LIBUSB20_ENDPOINT_OUT = 0x00,
425 #define LIBUSB20_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */
428 * Endpoint transfer type. Values for bits 0:1 of the
429 * \ref LIBUSB20_ENDPOINT_DESC::bmAttributes "endpoint attributes" field.
431 enum libusb20_transfer_type {
432 /** Control endpoint */
433 LIBUSB20_TRANSFER_TYPE_CONTROL = 0,
435 /** Isochronous endpoint */
436 LIBUSB20_TRANSFER_TYPE_ISOCHRONOUS = 1,
439 LIBUSB20_TRANSFER_TYPE_BULK = 2,
441 /** Interrupt endpoint */
442 LIBUSB20_TRANSFER_TYPE_INTERRUPT = 3,
446 * Standard requests, as defined in table 9-3 of the USB2 specifications */
447 enum libusb20_standard_request {
448 /** Request status of the specific recipient */
449 LIBUSB20_REQUEST_GET_STATUS = 0x00,
451 /** Clear or disable a specific feature */
452 LIBUSB20_REQUEST_CLEAR_FEATURE = 0x01,
454 /* 0x02 is reserved */
456 /** Set or enable a specific feature */
457 LIBUSB20_REQUEST_SET_FEATURE = 0x03,
459 /* 0x04 is reserved */
461 /** Set device address for all future accesses */
462 LIBUSB20_REQUEST_SET_ADDRESS = 0x05,
464 /** Get the specified descriptor */
465 LIBUSB20_REQUEST_GET_DESCRIPTOR = 0x06,
467 /** Used to update existing descriptors or add new descriptors */
468 LIBUSB20_REQUEST_SET_DESCRIPTOR = 0x07,
470 /** Get the current device configuration value */
471 LIBUSB20_REQUEST_GET_CONFIGURATION = 0x08,
473 /** Set device configuration */
474 LIBUSB20_REQUEST_SET_CONFIGURATION = 0x09,
476 /** Return the selected alternate setting for the specified
478 LIBUSB20_REQUEST_GET_INTERFACE = 0x0A,
480 /** Select an alternate interface for the specified interface */
481 LIBUSB20_REQUEST_SET_INTERFACE = 0x0B,
483 /** Set then report an endpoint's synchronization frame */
484 LIBUSB20_REQUEST_SYNCH_FRAME = 0x0C,
486 /** Set U1 and U2 system exit latency */
487 LIBUSB20_REQUEST_SET_SEL = 0x30,
489 /** Set isochronous delay */
490 LIBUSB20_REQUEST_SET_ISOCH_DELAY = 0x31,
494 * Request type bits of the
495 * \ref libusb20_control_setup::bmRequestType "bmRequestType" field in
496 * control transfers. */
497 enum libusb20_request_type {
499 LIBUSB20_REQUEST_TYPE_STANDARD = (0x00 << 5),
502 LIBUSB20_REQUEST_TYPE_CLASS = (0x01 << 5),
505 LIBUSB20_REQUEST_TYPE_VENDOR = (0x02 << 5),
508 LIBUSB20_REQUEST_TYPE_RESERVED = (0x03 << 5),
512 * Recipient bits of the
513 * \ref libusb20_control_setup::bmRequestType "bmRequestType" field in
514 * control transfers. Values 4 through 31 are reserved. */
515 enum libusb20_request_recipient {
517 LIBUSB20_RECIPIENT_DEVICE = 0x00,
520 LIBUSB20_RECIPIENT_INTERFACE = 0x01,
523 LIBUSB20_RECIPIENT_ENDPOINT = 0x02,
526 LIBUSB20_RECIPIENT_OTHER = 0x03,
529 #define LIBUSB20_ISO_SYNC_TYPE_MASK 0x0C
532 * Synchronization type for isochronous endpoints. Values for bits 2:3
533 * of the \ref LIBUSB20_ENDPOINT_DESC::bmAttributes "bmAttributes"
534 * field in LIBUSB20_ENDPOINT_DESC.
536 enum libusb20_iso_sync_type {
537 /** No synchronization */
538 LIBUSB20_ISO_SYNC_TYPE_NONE = 0,
541 LIBUSB20_ISO_SYNC_TYPE_ASYNC = 1,
544 LIBUSB20_ISO_SYNC_TYPE_ADAPTIVE = 2,
547 LIBUSB20_ISO_SYNC_TYPE_SYNC = 3,
550 #define LIBUSB20_ISO_USAGE_TYPE_MASK 0x30
553 * Usage type for isochronous endpoints. Values for bits 4:5 of the
554 * \ref LIBUSB20_ENDPOINT_DESC::bmAttributes "bmAttributes" field in
555 * LIBUSB20_ENDPOINT_DESC.
557 enum libusb20_iso_usage_type {
559 LIBUSB20_ISO_USAGE_TYPE_DATA = 0,
561 /** Feedback endpoint */
562 LIBUSB20_ISO_USAGE_TYPE_FEEDBACK = 1,
564 /** Implicit feedback Data endpoint */
565 LIBUSB20_ISO_USAGE_TYPE_IMPLICIT = 2,
568 struct libusb20_endpoint {
569 struct LIBUSB20_ENDPOINT_DESC_DECODED desc;
570 struct libusb20_me_struct extra;
571 } __aligned(sizeof(void *));
573 struct libusb20_interface {
574 struct LIBUSB20_INTERFACE_DESC_DECODED desc;
575 struct libusb20_me_struct extra;
576 struct libusb20_interface *altsetting;
577 struct libusb20_endpoint *endpoints;
578 uint8_t num_altsetting;
579 uint8_t num_endpoints;
580 } __aligned(sizeof(void *));
582 struct libusb20_config {
583 struct LIBUSB20_CONFIG_DESC_DECODED desc;
584 struct libusb20_me_struct extra;
585 struct libusb20_interface *interface;
586 uint8_t num_interface;
587 } __aligned(sizeof(void *));
589 uint8_t libusb20_me_get_1(const struct libusb20_me_struct *ie, uint16_t offset);
590 uint16_t libusb20_me_get_2(const struct libusb20_me_struct *ie, uint16_t offset);
591 uint16_t libusb20_me_encode(void *ptr, uint16_t len, const void *pd);
592 uint16_t libusb20_me_decode(const void *ptr, uint16_t len, void *pd);
593 const uint8_t *libusb20_desc_foreach(const struct libusb20_me_struct *pdesc, const uint8_t *psubdesc);
594 struct libusb20_config *libusb20_parse_config_desc(const void *config_desc);
604 #endif /* _LIBUSB20_DESC_H_ */