diff --git a/subsys/usb/device/Kconfig b/subsys/usb/device/Kconfig index 20addc2f1c1..476f7400270 100644 --- a/subsys/usb/device/Kconfig +++ b/subsys/usb/device/Kconfig @@ -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" diff --git a/subsys/usb/device/class/Kconfig.cdc b/subsys/usb/device/class/Kconfig.cdc index af1d8aba398..7c748028023 100644 --- a/subsys/usb/device/class/Kconfig.cdc +++ b/subsys/usb/device/class/Kconfig.cdc @@ -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 diff --git a/subsys/usb/device/class/audio/Kconfig b/subsys/usb/device/class/audio/Kconfig index e38bf11f0d5..825f2580a50 100644 --- a/subsys/usb/device/class/audio/Kconfig +++ b/subsys/usb/device/class/audio/Kconfig @@ -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 diff --git a/subsys/usb/device/class/audio/audio.c b/subsys/usb/device/class/audio/audio.c index 637096052f7..dc7e15f08d8 100644 --- a/subsys/usb/device/class/audio/audio.c +++ b/subsys/usb/device/class/audio/audio.c @@ -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 */ diff --git a/subsys/usb/device/class/audio/usb_audio_internal.h b/subsys/usb/device/class/audio/usb_audio_internal.h index 1cf8a10702d..c0d5383577d 100644 --- a/subsys/usb/device/class/audio/usb_audio_internal.h +++ b/subsys/usb/device/class/audio/usb_audio_internal.h @@ -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); \ diff --git a/subsys/usb/device/class/cdc_acm.c b/subsys/usb/device/class/cdc_acm.c index ab14732440e..9262cd5cf78 100644 --- a/subsys/usb/device/class/cdc_acm.c +++ b/subsys/usb/device/class/cdc_acm.c @@ -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) \ { \ diff --git a/subsys/usb/device/class/netusb/Kconfig b/subsys/usb/device/class/netusb/Kconfig index 803322536e8..e358c9b9ac7 100644 --- a/subsys/usb/device/class/netusb/Kconfig +++ b/subsys/usb/device/class/netusb/Kconfig @@ -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. diff --git a/subsys/usb/device/class/netusb/function_ecm.c b/subsys/usb/device/class/netusb/function_ecm.c index b5eaa0dfd8d..256cf9b9d1e 100644 --- a/subsys/usb/device/class/netusb/function_ecm.c +++ b/subsys/usb/device/class/netusb/function_ecm.c @@ -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) = {