| 1 | /*
|
|---|
| 2 | * SPDX-FileCopyrightText: 2011 Vojtech Horky
|
|---|
| 3 | * SPDX-FileCopyrightText: 2013 Jan Vesely
|
|---|
| 4 | *
|
|---|
| 5 | * SPDX-License-Identifier: BSD-3-Clause
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /** @addtogroup libusbdev
|
|---|
| 9 | * @{
|
|---|
| 10 | */
|
|---|
| 11 | /** @file
|
|---|
| 12 | * USB device driver framework.
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | #ifndef LIBUSBDEV_ALTERNATE_IFACES_H_
|
|---|
| 16 | #define LIBUSBDEV_ALTERNATE_IFACES_H_
|
|---|
| 17 |
|
|---|
| 18 | #include <errno.h>
|
|---|
| 19 | #include <usb/descriptor.h>
|
|---|
| 20 | #include <stddef.h>
|
|---|
| 21 | #include <stdint.h>
|
|---|
| 22 |
|
|---|
| 23 | /** Wrapper for data related to alternate interface setting.
|
|---|
| 24 | * The pointers will typically point inside configuration descriptor and
|
|---|
| 25 | * thus you shall not deallocate them.
|
|---|
| 26 | */
|
|---|
| 27 | typedef struct {
|
|---|
| 28 | /** Interface descriptor. */
|
|---|
| 29 | const usb_standard_interface_descriptor_t *interface;
|
|---|
| 30 | /** Pointer to start of descriptor tree bound with this interface. */
|
|---|
| 31 | const uint8_t *nested_descriptors;
|
|---|
| 32 | /** Size of data pointed by nested_descriptors in bytes. */
|
|---|
| 33 | size_t nested_descriptors_size;
|
|---|
| 34 | } usb_alternate_interface_descriptors_t;
|
|---|
| 35 |
|
|---|
| 36 | /** Alternate interface settings. */
|
|---|
| 37 | typedef struct {
|
|---|
| 38 | /** Array of alternate interfaces descriptions. */
|
|---|
| 39 | usb_alternate_interface_descriptors_t *alternatives;
|
|---|
| 40 | /** Size of @c alternatives array. */
|
|---|
| 41 | size_t alternative_count;
|
|---|
| 42 | /** Index of currently selected one. */
|
|---|
| 43 | size_t current;
|
|---|
| 44 | } usb_alternate_interfaces_t;
|
|---|
| 45 |
|
|---|
| 46 | size_t usb_interface_count_alternates(const uint8_t *, size_t, uint8_t);
|
|---|
| 47 | errno_t usb_alternate_interfaces_init(usb_alternate_interfaces_t *,
|
|---|
| 48 | const uint8_t *, size_t, int);
|
|---|
| 49 | void usb_alternate_interfaces_deinit(usb_alternate_interfaces_t *);
|
|---|
| 50 |
|
|---|
| 51 | #endif
|
|---|
| 52 | /**
|
|---|
| 53 | * @}
|
|---|
| 54 | */
|
|---|