mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
usb: gadget: f_uac1: add iad descriptor
According to the spec "USB Interface Association Descriptor Device Class Code and Use Model"[1], the Interface Association Descriptor (IAD) is needed for composite device which has multiple interfaces controlled independently of each other. Without the IAD, the device may not work as expected because the USB system software will not properly bind the interfaces with drivers (e.g UAC1 && UVC composite device not recognized in Win10). [1] https://www.usb.org/sites/default/files/iadclasscode_r10.pdf Change-Id: I446c771fe182bd556a054d9ae0ada1374442d1d0 Signed-off-by: William Wu <william.wu@rock-chips.com>
This commit is contained in:
@@ -48,6 +48,17 @@ static inline struct f_uac1 *func_to_uac1(struct usb_function *f)
|
||||
/* Number of streaming interfaces */
|
||||
#define F_AUDIO_NUM_INTERFACES 2
|
||||
|
||||
static struct usb_interface_assoc_descriptor iad_desc = {
|
||||
.bLength = sizeof(iad_desc),
|
||||
.bDescriptorType = USB_DT_INTERFACE_ASSOCIATION,
|
||||
|
||||
.bFirstInterface = 0,
|
||||
.bInterfaceCount = 3,
|
||||
.bFunctionClass = USB_CLASS_AUDIO,
|
||||
.bFunctionSubClass = USB_SUBCLASS_AUDIOSTREAMING,
|
||||
.bFunctionProtocol = UAC_VERSION_1,
|
||||
};
|
||||
|
||||
/* B.3.1 Standard AC Interface Descriptor */
|
||||
static struct usb_interface_descriptor ac_interface_desc = {
|
||||
.bLength = USB_DT_INTERFACE_SIZE,
|
||||
@@ -247,6 +258,7 @@ static struct uac_iso_endpoint_descriptor as_iso_in_desc = {
|
||||
};
|
||||
|
||||
static struct usb_descriptor_header *f_audio_desc[] = {
|
||||
(struct usb_descriptor_header *)&iad_desc,
|
||||
(struct usb_descriptor_header *)&ac_interface_desc,
|
||||
(struct usb_descriptor_header *)&ac_header_desc,
|
||||
|
||||
@@ -276,6 +288,7 @@ static struct usb_descriptor_header *f_audio_desc[] = {
|
||||
};
|
||||
|
||||
enum {
|
||||
STR_ASSOC,
|
||||
STR_AC_IF,
|
||||
STR_USB_OUT_IT,
|
||||
STR_USB_OUT_IT_CH_NAMES,
|
||||
@@ -290,6 +303,7 @@ enum {
|
||||
};
|
||||
|
||||
static struct usb_string strings_uac1[] = {
|
||||
[STR_ASSOC].s = "Source/Sink",
|
||||
[STR_AC_IF].s = "AC Interface",
|
||||
[STR_USB_OUT_IT].s = "Playback Input terminal",
|
||||
[STR_USB_OUT_IT_CH_NAMES].s = "Playback Channels",
|
||||
@@ -523,6 +537,8 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
us = usb_gstrings_attach(cdev, uac1_strings, ARRAY_SIZE(strings_uac1));
|
||||
if (IS_ERR(us))
|
||||
return PTR_ERR(us);
|
||||
|
||||
iad_desc.iFunction = us[STR_ASSOC].id;
|
||||
ac_interface_desc.iInterface = us[STR_AC_IF].id;
|
||||
usb_out_it_desc.iTerminal = us[STR_USB_OUT_IT].id;
|
||||
usb_out_it_desc.iChannelNames = us[STR_USB_OUT_IT_CH_NAMES].id;
|
||||
@@ -559,6 +575,7 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
status = usb_interface_id(c, f);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
iad_desc.bFirstInterface = status;
|
||||
ac_interface_desc.bInterfaceNumber = status;
|
||||
uac1->ac_intf = status;
|
||||
uac1->ac_alt = 0;
|
||||
|
||||
Reference in New Issue
Block a user