3 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
6 * Copyright (c) 2007-2008 Daniel Drake. All rights reserved.
7 * Copyright (c) 2001 Johannes Erdfelt. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * NOTE: This file contains the definition of some standard USB
33 * structures. All structures which name ends by *DECODED use host byte
38 * NOTE: This file uses a lot of macros. If you want to see what the
39 * macros become when they are expanded then run the following
40 * commands from your shell:
42 * cpp libusb20_desc.h > temp.h
47 #ifndef _LIBUSB20_DESC_H_
48 #define _LIBUSB20_DESC_H_
50 #ifndef LIBUSB_GLOBAL_INCLUDE_FILE
63 #define LIBUSB20__NOT(...) __VA_ARGS__
64 #define LIBUSB20_NOT(arg) LIBUSB20__NOT(LIBUSB20_YES arg(() LIBUSB20_NO))
65 #define LIBUSB20_YES(...) __VA_ARGS__
66 #define LIBUSB20_NO(...)
67 #define LIBUSB20_END(...) __VA_ARGS__
68 #define LIBUSB20_MAX(a,b) (((a) > (b)) ? (a) : (b))
69 #define LIBUSB20_MIN(a,b) (((a) < (b)) ? (a) : (b))
71 #define LIBUSB20_ADD_BYTES(ptr,off) \
72 ((void *)(((const uint8_t *)(ptr)) + (off) - ((const uint8_t *)0)))
74 /* basic message elements */
81 LIBUSB20_ME_MAX, /* used to indicate end */
84 /* basic message element modifiers */
86 LIBUSB20_ME_IS_UNSIGNED = 0x00,
87 LIBUSB20_ME_IS_SIGNED = 0x80,
88 LIBUSB20_ME_MASK = 0x7F,
92 LIBUSB20_ME_IS_RAW, /* structure excludes length field
93 * (hardcoded value) */
94 LIBUSB20_ME_IS_ENCODED, /* structure includes length field */
95 LIBUSB20_ME_IS_EMPTY, /* no structure */
96 LIBUSB20_ME_IS_DECODED, /* structure is recursive */
99 /* basic helper structures and macros */
101 #define LIBUSB20_ME_STRUCT_ALIGN sizeof(void *)
103 struct libusb20_me_struct {
104 void *ptr; /* data pointer */
105 uint16_t len; /* defaults to zero */
106 uint16_t type; /* defaults to LIBUSB20_ME_IS_EMPTY */
107 } __aligned(LIBUSB20_ME_STRUCT_ALIGN);
109 struct libusb20_me_format {
110 const uint8_t *format; /* always set */
111 const char *desc; /* optionally set */
112 const char *fields; /* optionally set */
115 #define LIBUSB20_ME_STRUCT(n, field, arg, ismeta) \
116 ismeta ( LIBUSB20_ME_STRUCT, 1, 0, ) \
117 LIBUSB20_NOT(ismeta) ( struct libusb20_me_struct field; )
119 #define LIBUSB20_ME_STRUCT_ARRAY(n, field, arg, ismeta) \
120 ismeta ( LIBUSB20_ME_STRUCT , (arg) & 0xFF, \
121 ((arg) / 0x100) & 0xFF, ) \
122 LIBUSB20_NOT(ismeta) ( struct libusb20_me_struct field [arg]; )
124 #define LIBUSB20_ME_INTEGER(n, field, ismeta, un, u, bits, a, size) \
125 ismeta ( LIBUSB20_ME_INT##bits | \
126 LIBUSB20_ME_IS_##un##SIGNED , \
127 (size) & 0xFF, ((size) / 0x100) & 0xFF, ) \
128 LIBUSB20_NOT(ismeta) ( u##int##bits##_t \
129 __aligned((bits) / 8) field a; )
131 #define LIBUSB20_ME_UINT8_T(n, field, arg, ismeta) \
132 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 8, , 1)
134 #define LIBUSB20_ME_UINT8_ARRAY_T(n, field, arg, ismeta) \
135 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 8, [arg], arg)
137 #define LIBUSB20_ME_SINT8_T(n, field, arg, ismeta) \
138 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 8, , 1)
140 #define LIBUSB20_ME_SINT8_ARRAY_T(n, field, arg, ismeta) \
141 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 8, [arg], arg)
143 #define LIBUSB20_ME_UINT16_T(n, field, arg, ismeta) \
144 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 16, , 1)
146 #define LIBUSB20_ME_UINT16_ARRAY_T(n, field, arg, ismeta) \
147 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 16, [arg], arg)
149 #define LIBUSB20_ME_SINT16_T(n, field, arg, ismeta) \
150 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 16, , 1)
152 #define LIBUSB20_ME_SINT16_ARRAY_T(n, field, arg, ismeta) \
153 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 16, [arg], arg)
155 #define LIBUSB20_ME_UINT32_T(n, field, arg, ismeta) \
156 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 32, , 1)
158 #define LIBUSB20_ME_UINT32_ARRAY_T(n, field, arg, ismeta) \
159 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 32, [arg], arg)
161 #define LIBUSB20_ME_SINT32_T(n, field, arg, ismeta) \
162 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 32, , 1)
164 #define LIBUSB20_ME_SINT32_ARRAY_T(n, field, arg, ismeta) \
165 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 32, [arg], arg)
167 #define LIBUSB20_ME_UINT64_T(n, field, arg, ismeta) \
168 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 64, , 1)
170 #define LIBUSB20_ME_UINT64_ARRAY_T(n, field, arg, ismeta) \
171 LIBUSB20_ME_INTEGER(n, field, ismeta, UN, u, 64, [arg], arg)
173 #define LIBUSB20_ME_SINT64_T(n, field, arg, ismeta) \
174 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 64, , 1)
176 #define LIBUSB20_ME_SINT64_ARRAY_T(n, field, arg, ismeta) \
177 LIBUSB20_ME_INTEGER(n, field, ismeta,,, 64, [arg], arg)
179 #define LIBUSB20_MAKE_DECODED_FIELD(n, type, field, arg) \
180 LIBUSB20_ME_##type (n, field, arg, LIBUSB20_NO)
182 #define LIBUSB20_MAKE_STRUCT(name) \
183 extern const struct libusb20_me_format \
185 struct name##_DECODED { \
186 const struct libusb20_me_format *name##_FORMAT; \
187 name (LIBUSB20_MAKE_DECODED_FIELD,) \
190 #define LIBUSB20_MAKE_STRUCT_FORMAT(name) \
191 const struct libusb20_me_format \
192 name##_FORMAT[1] = {{ \
193 .format = LIBUSB20_MAKE_FORMAT(name), \
198 #define LIBUSB20_MAKE_FORMAT_SUB(n, type, field, arg) \
199 LIBUSB20_ME_##type (n, field, arg, LIBUSB20_YES)
201 #define LIBUSB20_MAKE_FORMAT(what) (const uint8_t []) \
202 { what (LIBUSB20_MAKE_FORMAT_SUB, ) LIBUSB20_ME_MAX, 0, 0 }
204 #define LIBUSB20_INIT(what, ptr) do { \
205 memset(ptr, 0, sizeof(*(ptr))); \
206 (ptr)->what##_FORMAT = what##_FORMAT; \
209 #define LIBUSB20_DEVICE_DESC(m,n) \
210 m(n, UINT8_T, bLength, ) \
211 m(n, UINT8_T, bDescriptorType, ) \
212 m(n, UINT16_T, bcdUSB, ) \
213 m(n, UINT8_T, bDeviceClass, ) \
214 m(n, UINT8_T, bDeviceSubClass, ) \
215 m(n, UINT8_T, bDeviceProtocol, ) \
216 m(n, UINT8_T, bMaxPacketSize0, ) \
217 m(n, UINT16_T, idVendor, ) \
218 m(n, UINT16_T, idProduct, ) \
219 m(n, UINT16_T, bcdDevice, ) \
220 m(n, UINT8_T, iManufacturer, ) \
221 m(n, UINT8_T, iProduct, ) \
222 m(n, UINT8_T, iSerialNumber, ) \
223 m(n, UINT8_T, bNumConfigurations, ) \
225 LIBUSB20_MAKE_STRUCT(LIBUSB20_DEVICE_DESC);
227 #define LIBUSB20_ENDPOINT_DESC(m,n) \
228 m(n, UINT8_T, bLength, ) \
229 m(n, UINT8_T, bDescriptorType, ) \
230 m(n, UINT8_T, bEndpointAddress, ) \
231 m(n, UINT8_T, bmAttributes, ) \
232 m(n, UINT16_T, wMaxPacketSize, ) \
233 m(n, UINT8_T, bInterval, ) \
234 m(n, UINT8_T, bRefresh, ) \
235 m(n, UINT8_T, bSynchAddress, ) \
237 LIBUSB20_MAKE_STRUCT(LIBUSB20_ENDPOINT_DESC);
239 #define LIBUSB20_INTERFACE_DESC(m,n) \
240 m(n, UINT8_T, bLength, ) \
241 m(n, UINT8_T, bDescriptorType, ) \
242 m(n, UINT8_T, bInterfaceNumber, ) \
243 m(n, UINT8_T, bAlternateSetting, ) \
244 m(n, UINT8_T, bNumEndpoints, ) \
245 m(n, UINT8_T, bInterfaceClass, ) \
246 m(n, UINT8_T, bInterfaceSubClass, ) \
247 m(n, UINT8_T, bInterfaceProtocol, ) \
248 m(n, UINT8_T, iInterface, ) \
250 LIBUSB20_MAKE_STRUCT(LIBUSB20_INTERFACE_DESC);
252 #define LIBUSB20_CONFIG_DESC(m,n) \
253 m(n, UINT8_T, bLength, ) \
254 m(n, UINT8_T, bDescriptorType, ) \
255 m(n, UINT16_T, wTotalLength, ) \
256 m(n, UINT8_T, bNumInterfaces, ) \
257 m(n, UINT8_T, bConfigurationValue, ) \
258 m(n, UINT8_T, iConfiguration, ) \
259 m(n, UINT8_T, bmAttributes, ) \
260 m(n, UINT8_T, bMaxPower, ) \
262 LIBUSB20_MAKE_STRUCT(LIBUSB20_CONFIG_DESC);
264 #define LIBUSB20_CONTROL_SETUP(m,n) \
265 m(n, UINT8_T, bmRequestType, ) \
266 m(n, UINT8_T, bRequest, ) \
267 m(n, UINT16_T, wValue, ) \
268 m(n, UINT16_T, wIndex, ) \
269 m(n, UINT16_T, wLength, ) \
271 LIBUSB20_MAKE_STRUCT(LIBUSB20_CONTROL_SETUP);
273 #define LIBUSB20_SS_ENDPT_COMP_DESC(m,n) \
274 m(n, UINT8_T, bLength, ) \
275 m(n, UINT8_T, bDescriptorType, ) \
276 m(n, UINT8_T, bMaxBurst, ) \
277 m(n, UINT8_T, bmAttributes, ) \
278 m(n, UINT16_T, wBytesPerInterval, ) \
280 LIBUSB20_MAKE_STRUCT(LIBUSB20_SS_ENDPT_COMP_DESC);
282 #define LIBUSB20_USB_20_DEVCAP_DESC(m,n) \
283 m(n, UINT8_T, bLength, ) \
284 m(n, UINT8_T, bDescriptorType, ) \
285 m(n, UINT8_T, bDevCapabilityType, ) \
286 m(n, UINT32_T, bmAttributes, ) \
288 LIBUSB20_MAKE_STRUCT(LIBUSB20_USB_20_DEVCAP_DESC);
290 #define LIBUSB20_SS_USB_DEVCAP_DESC(m,n) \
291 m(n, UINT8_T, bLength, ) \
292 m(n, UINT8_T, bDescriptorType, ) \
293 m(n, UINT8_T, bDevCapabilityType, ) \
294 m(n, UINT8_T, bmAttributes, ) \
295 m(n, UINT16_T, wSpeedSupported, ) \
296 m(n, UINT8_T, bFunctionalitySupport, ) \
297 m(n, UINT8_T, bU1DevExitLat, ) \
298 m(n, UINT16_T, wU2DevExitLat, ) \
300 LIBUSB20_MAKE_STRUCT(LIBUSB20_SS_USB_DEVCAP_DESC);
302 #define LIBUSB20_BOS_DESCRIPTOR(m,n) \
303 m(n, UINT8_T, bLength, ) \
304 m(n, UINT8_T, bDescriptorType, ) \
305 m(n, UINT16_T, wTotalLength, ) \
306 m(n, UINT8_T, bNumDeviceCapabilities, ) \
308 LIBUSB20_MAKE_STRUCT(LIBUSB20_BOS_DESCRIPTOR);
310 /* standard USB stuff */
313 * Device and/or Interface Class codes */
314 enum libusb20_class_code {
315 /** In the context of a \ref LIBUSB20_DEVICE_DESC "device
316 * descriptor", this bDeviceClass value indicates that each
317 * interface specifies its own class information and all
318 * interfaces operate independently.
320 LIBUSB20_CLASS_PER_INTERFACE = 0,
323 LIBUSB20_CLASS_AUDIO = 1,
325 /** Communications class */
326 LIBUSB20_CLASS_COMM = 2,
328 /** Human Interface Device class */
329 LIBUSB20_CLASS_HID = 3,
331 /** Printer dclass */
332 LIBUSB20_CLASS_PRINTER = 7,
334 /** Picture transfer protocol class */
335 LIBUSB20_CLASS_PTP = 6,
337 /** Mass storage class */
338 LIBUSB20_CLASS_MASS_STORAGE = 8,
341 LIBUSB20_CLASS_HUB = 9,
344 LIBUSB20_CLASS_DATA = 10,
346 /** Class is vendor-specific */
347 LIBUSB20_CLASS_VENDOR_SPEC = 0xff,
351 * Descriptor types as defined by the USB specification. */
352 enum libusb20_descriptor_type {
353 /** Device descriptor. See LIBUSB20_DEVICE_DESC. */
354 LIBUSB20_DT_DEVICE = 0x01,
356 /** Configuration descriptor. See LIBUSB20_CONFIG_DESC. */
357 LIBUSB20_DT_CONFIG = 0x02,
359 /** String descriptor */
360 LIBUSB20_DT_STRING = 0x03,
362 /** Interface descriptor. See LIBUSB20_INTERFACE_DESC. */
363 LIBUSB20_DT_INTERFACE = 0x04,
365 /** Endpoint descriptor. See LIBUSB20_ENDPOINT_DESC. */
366 LIBUSB20_DT_ENDPOINT = 0x05,
368 /** HID descriptor */
369 LIBUSB20_DT_HID = 0x21,
371 /** HID report descriptor */
372 LIBUSB20_DT_REPORT = 0x22,
374 /** Physical descriptor */
375 LIBUSB20_DT_PHYSICAL = 0x23,
377 /** Hub descriptor */
378 LIBUSB20_DT_HUB = 0x29,
380 /** Binary Object Store, BOS */
381 LIBUSB20_DT_BOS = 0x0f,
383 /** Device Capability */
384 LIBUSB20_DT_DEVICE_CAPABILITY = 0x10,
386 /** SuperSpeed endpoint companion */
387 LIBUSB20_DT_SS_ENDPOINT_COMPANION = 0x30,
391 * Device capability types as defined by the USB specification. */
392 enum libusb20_device_capability_type {
393 LIBUSB20_WIRELESS_USB_DEVICE_CAPABILITY = 0x1,
394 LIBUSB20_USB_2_0_EXTENSION_DEVICE_CAPABILITY = 0x2,
395 LIBUSB20_SS_USB_DEVICE_CAPABILITY = 0x3,
396 LIBUSB20_CONTAINER_ID_DEVICE_CAPABILITY = 0x4,
399 /* Descriptor sizes per descriptor type */
400 #define LIBUSB20_DT_DEVICE_SIZE 18
401 #define LIBUSB20_DT_CONFIG_SIZE 9
402 #define LIBUSB20_DT_INTERFACE_SIZE 9
403 #define LIBUSB20_DT_ENDPOINT_SIZE 7
404 #define LIBUSB20_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
405 #define LIBUSB20_DT_HUB_NONVAR_SIZE 7
406 #define LIBUSB20_DT_SS_ENDPOINT_COMPANION_SIZE 6
407 #define LIBUSB20_DT_BOS_SIZE 5
408 #define LIBUSB20_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE 7
409 #define LIBUSB20_SS_USB_DEVICE_CAPABILITY_SIZE 10
411 #define LIBUSB20_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
412 #define LIBUSB20_ENDPOINT_DIR_MASK 0x80
415 * Endpoint direction. Values for bit 7 of the
416 * \ref LIBUSB20_ENDPOINT_DESC::bEndpointAddress "endpoint address" scheme.
418 enum libusb20_endpoint_direction {
419 /** In: device-to-host */
420 LIBUSB20_ENDPOINT_IN = 0x80,
422 /** Out: host-to-device */
423 LIBUSB20_ENDPOINT_OUT = 0x00,
426 #define LIBUSB20_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */
429 * Endpoint transfer type. Values for bits 0:1 of the
430 * \ref LIBUSB20_ENDPOINT_DESC::bmAttributes "endpoint attributes" field.
432 enum libusb20_transfer_type {
433 /** Control endpoint */
434 LIBUSB20_TRANSFER_TYPE_CONTROL = 0,
436 /** Isochronous endpoint */
437 LIBUSB20_TRANSFER_TYPE_ISOCHRONOUS = 1,
440 LIBUSB20_TRANSFER_TYPE_BULK = 2,
442 /** Interrupt endpoint */
443 LIBUSB20_TRANSFER_TYPE_INTERRUPT = 3,
447 * Standard requests, as defined in table 9-3 of the USB2 specifications */
448 enum libusb20_standard_request {
449 /** Request status of the specific recipient */
450 LIBUSB20_REQUEST_GET_STATUS = 0x00,
452 /** Clear or disable a specific feature */
453 LIBUSB20_REQUEST_CLEAR_FEATURE = 0x01,
455 /* 0x02 is reserved */
457 /** Set or enable a specific feature */
458 LIBUSB20_REQUEST_SET_FEATURE = 0x03,
460 /* 0x04 is reserved */
462 /** Set device address for all future accesses */
463 LIBUSB20_REQUEST_SET_ADDRESS = 0x05,
465 /** Get the specified descriptor */
466 LIBUSB20_REQUEST_GET_DESCRIPTOR = 0x06,
468 /** Used to update existing descriptors or add new descriptors */
469 LIBUSB20_REQUEST_SET_DESCRIPTOR = 0x07,
471 /** Get the current device configuration value */
472 LIBUSB20_REQUEST_GET_CONFIGURATION = 0x08,
474 /** Set device configuration */
475 LIBUSB20_REQUEST_SET_CONFIGURATION = 0x09,
477 /** Return the selected alternate setting for the specified
479 LIBUSB20_REQUEST_GET_INTERFACE = 0x0A,
481 /** Select an alternate interface for the specified interface */
482 LIBUSB20_REQUEST_SET_INTERFACE = 0x0B,
484 /** Set then report an endpoint's synchronization frame */
485 LIBUSB20_REQUEST_SYNCH_FRAME = 0x0C,
487 /** Set U1 and U2 system exit latency */
488 LIBUSB20_REQUEST_SET_SEL = 0x30,
490 /** Set isochronous delay */
491 LIBUSB20_REQUEST_SET_ISOCH_DELAY = 0x31,
495 * Request type bits of the
496 * \ref libusb20_control_setup::bmRequestType "bmRequestType" field in
497 * control transfers. */
498 enum libusb20_request_type {
500 LIBUSB20_REQUEST_TYPE_STANDARD = (0x00 << 5),
503 LIBUSB20_REQUEST_TYPE_CLASS = (0x01 << 5),
506 LIBUSB20_REQUEST_TYPE_VENDOR = (0x02 << 5),
509 LIBUSB20_REQUEST_TYPE_RESERVED = (0x03 << 5),
513 * Recipient bits of the
514 * \ref libusb20_control_setup::bmRequestType "bmRequestType" field in
515 * control transfers. Values 4 through 31 are reserved. */
516 enum libusb20_request_recipient {
518 LIBUSB20_RECIPIENT_DEVICE = 0x00,
521 LIBUSB20_RECIPIENT_INTERFACE = 0x01,
524 LIBUSB20_RECIPIENT_ENDPOINT = 0x02,
527 LIBUSB20_RECIPIENT_OTHER = 0x03,
530 #define LIBUSB20_ISO_SYNC_TYPE_MASK 0x0C
533 * Synchronization type for isochronous endpoints. Values for bits 2:3
534 * of the \ref LIBUSB20_ENDPOINT_DESC::bmAttributes "bmAttributes"
535 * field in LIBUSB20_ENDPOINT_DESC.
537 enum libusb20_iso_sync_type {
538 /** No synchronization */
539 LIBUSB20_ISO_SYNC_TYPE_NONE = 0,
542 LIBUSB20_ISO_SYNC_TYPE_ASYNC = 1,
545 LIBUSB20_ISO_SYNC_TYPE_ADAPTIVE = 2,
548 LIBUSB20_ISO_SYNC_TYPE_SYNC = 3,
551 #define LIBUSB20_ISO_USAGE_TYPE_MASK 0x30
554 * Usage type for isochronous endpoints. Values for bits 4:5 of the
555 * \ref LIBUSB20_ENDPOINT_DESC::bmAttributes "bmAttributes" field in
556 * LIBUSB20_ENDPOINT_DESC.
558 enum libusb20_iso_usage_type {
560 LIBUSB20_ISO_USAGE_TYPE_DATA = 0,
562 /** Feedback endpoint */
563 LIBUSB20_ISO_USAGE_TYPE_FEEDBACK = 1,
565 /** Implicit feedback Data endpoint */
566 LIBUSB20_ISO_USAGE_TYPE_IMPLICIT = 2,
569 struct libusb20_endpoint {
570 struct LIBUSB20_ENDPOINT_DESC_DECODED desc;
571 struct libusb20_me_struct extra;
572 } __aligned(sizeof(void *));
574 struct libusb20_interface {
575 struct LIBUSB20_INTERFACE_DESC_DECODED desc;
576 struct libusb20_me_struct extra;
577 struct libusb20_interface *altsetting;
578 struct libusb20_endpoint *endpoints;
579 uint8_t num_altsetting;
580 uint8_t num_endpoints;
581 } __aligned(sizeof(void *));
583 struct libusb20_config {
584 struct LIBUSB20_CONFIG_DESC_DECODED desc;
585 struct libusb20_me_struct extra;
586 struct libusb20_interface *interface;
587 uint8_t num_interface;
588 } __aligned(sizeof(void *));
590 uint8_t libusb20_me_get_1(const struct libusb20_me_struct *ie, uint16_t offset);
591 uint16_t libusb20_me_get_2(const struct libusb20_me_struct *ie, uint16_t offset);
592 uint16_t libusb20_me_encode(void *ptr, uint16_t len, const void *pd);
593 uint16_t libusb20_me_decode(const void *ptr, uint16_t len, void *pd);
594 const uint8_t *libusb20_desc_foreach(const struct libusb20_me_struct *pdesc, const uint8_t *psubdesc);
595 struct libusb20_config *libusb20_parse_config_desc(const void *config_desc);
605 #endif /* _LIBUSB20_DESC_H_ */