usb: device: clarify the impact of Kconfig option USB_COMPOSITE_DEVICE

Effectively, this option changes code triple in device descriptor.
Although the name is misleading, renaming it would again lead
to negative user experiences. Instead, clarify what the option does
and always select it where it is required.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
Johann Fischer 2023-07-06 18:08:20 +02:00 committed by Carles Cufí
parent 3945988ac1
commit 7bfec37247
8 changed files with 8 additions and 23 deletions

View File

@ -49,9 +49,11 @@ config USB_DEVICE_SN
Hardware Information Driver (HWINFO).
config USB_COMPOSITE_DEVICE
bool "Composite device driver"
bool "Use Interface Association Descriptor code triple"
help
Enable composite USB device driver.
This option modifies the code triple in the device descriptor
to signal that one of the functions has two or more interfaces and
uses the Interface Association Descriptor.
config USB_MAX_NUM_TRANSFERS
int "Set number of USB transfer data buffers"

View File

@ -6,6 +6,7 @@ menu "USB CDC ACM Class support"
config USB_CDC_ACM
bool "USB CDC ACM Class support"
default y
select USB_COMPOSITE_DEVICE
depends on SERIAL
depends on DT_HAS_ZEPHYR_CDC_ACM_UART_ENABLED
select SERIAL_HAS_DRIVER

View File

@ -6,6 +6,7 @@
config USB_DEVICE_AUDIO
bool "USB Audio Device Class Driver"
select EXPERIMENTAL
select USB_COMPOSITE_DEVICE
help
USB Audio Device Class driver.
Zephyr USB Audio Class is considered experimental

View File

@ -292,12 +292,10 @@ static void audio_interface_config(struct usb_desc_header *head,
struct usb_if_descriptor *iface = (struct usb_if_descriptor *)head;
struct cs_ac_if_descriptor *header;
#ifdef CONFIG_USB_COMPOSITE_DEVICE
struct usb_association_descriptor *iad =
(struct usb_association_descriptor *)
((char *)iface - sizeof(struct usb_association_descriptor));
iad->bFirstInterface = bInterfaceNumber;
#endif
fix_fu_descriptors(iface);
/* Audio Control Interface */

View File

@ -328,13 +328,8 @@ struct dev##_feature_unit_descriptor_##i { \
.iFunction = 0, \
}
#ifdef CONFIG_USB_COMPOSITE_DEVICE
#define USB_AUDIO_IAD_DECLARE struct usb_association_descriptor iad;
#define USB_AUDIO_IAD(if_cnt) .iad = INIT_IAD(USB_AUDIO_AUDIOCONTROL, if_cnt),
#else
#define USB_AUDIO_IAD_DECLARE
#define USB_AUDIO_IAD(if_cnt)
#endif
#define DECLARE_DESCRIPTOR(dev, i, ifaces) \
DECLARE_HEADER(dev, i, ifaces); \

View File

@ -80,9 +80,7 @@ LOG_MODULE_REGISTER(usb_cdc_acm, CONFIG_USB_CDC_ACM_LOG_LEVEL);
#define ACM_IN_EP_IDX 2
struct usb_cdc_acm_config {
#if (CONFIG_USB_COMPOSITE_DEVICE || CONFIG_CDC_ACM_IAD)
struct usb_association_descriptor iad_cdc;
#endif
struct usb_if_descriptor if0;
struct cdc_header_descriptor if0_header;
struct cdc_cm_descriptor if0_cm;
@ -437,9 +435,7 @@ static void cdc_interface_config(struct usb_desc_header *head,
desc->if0_union.bControlInterface = bInterfaceNumber;
desc->if1.bInterfaceNumber = bInterfaceNumber + 1;
desc->if0_union.bSubordinateInterface0 = bInterfaceNumber + 1;
#if (CONFIG_USB_COMPOSITE_DEVICE || CONFIG_CDC_ACM_IAD)
desc->iad_cdc.bFirstInterface = bInterfaceNumber;
#endif
}
/**
@ -1051,7 +1047,6 @@ static const struct uart_driver_api cdc_acm_driver_api = {
#endif /* CONFIG_UART_USE_RUNTIME_CONFIGURE */
};
#if (CONFIG_USB_COMPOSITE_DEVICE || CONFIG_CDC_ACM_IAD)
#define INITIALIZER_IAD \
.iad_cdc = { \
.bLength = sizeof(struct usb_association_descriptor), \
@ -1063,9 +1058,6 @@ static const struct uart_driver_api cdc_acm_driver_api = {
.bFunctionProtocol = 0, \
.iFunction = 0, \
},
#else
#define INITIALIZER_IAD
#endif
#define INITIALIZER_IF(iface_num, num_ep, class, subclass) \
{ \

View File

@ -12,6 +12,7 @@ config USB_DEVICE_NETWORK
config USB_DEVICE_NETWORK_ECM
bool "USB Ethernet Control Model (ECM) Networking device"
select USB_DEVICE_NETWORK
select USB_COMPOSITE_DEVICE
help
Ethernet Control Model (ECM) is a part of Communications Device
Class (CDC) USB protocol specified by USB-IF.
@ -27,6 +28,7 @@ config USB_DEVICE_NETWORK_EEM
config USB_DEVICE_NETWORK_RNDIS
bool "USB Remote NDIS (RNDIS) Networking device"
select USB_DEVICE_NETWORK
select USB_COMPOSITE_DEVICE
help
Remote NDIS (RNDIS) is commonly used Microsoft vendor protocol with
Specification available from Microsoft web site.

View File

@ -31,9 +31,7 @@ LOG_MODULE_REGISTER(usb_ecm, CONFIG_USB_DEVICE_NETWORK_LOG_LEVEL);
static uint8_t tx_buf[NET_ETH_MAX_FRAME_SIZE], rx_buf[NET_ETH_MAX_FRAME_SIZE];
struct usb_cdc_ecm_config {
#ifdef CONFIG_USB_COMPOSITE_DEVICE
struct usb_association_descriptor iad;
#endif
struct usb_if_descriptor if0;
struct cdc_header_descriptor if0_header;
struct cdc_union_descriptor if0_union;
@ -48,7 +46,6 @@ struct usb_cdc_ecm_config {
} __packed;
USBD_CLASS_DESCR_DEFINE(primary, 0) struct usb_cdc_ecm_config cdc_ecm_cfg = {
#ifdef CONFIG_USB_COMPOSITE_DEVICE
.iad = {
.bLength = sizeof(struct usb_association_descriptor),
.bDescriptorType = USB_DESC_INTERFACE_ASSOC,
@ -59,7 +56,6 @@ USBD_CLASS_DESCR_DEFINE(primary, 0) struct usb_cdc_ecm_config cdc_ecm_cfg = {
.bFunctionProtocol = 0,
.iFunction = 0,
},
#endif
/* Interface descriptor 0 */
/* CDC Communication interface */
.if0 = {
@ -422,9 +418,7 @@ static void ecm_interface_config(struct usb_desc_header *head,
cdc_ecm_cfg.if0_union.bSubordinateInterface0 = bInterfaceNumber + 1;
cdc_ecm_cfg.if1_0.bInterfaceNumber = bInterfaceNumber + 1;
cdc_ecm_cfg.if1_1.bInterfaceNumber = bInterfaceNumber + 1;
#ifdef CONFIG_USB_COMPOSITE_DEVICE
cdc_ecm_cfg.iad.bFirstInterface = bInterfaceNumber;
#endif
}
USBD_DEFINE_CFG_DATA(cdc_ecm_config) = {