From nobody Sat Sep 21 22:45:51 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEB29CCA47D for ; Wed, 22 Jun 2022 08:58:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349115AbiFVI6T (ORCPT ); Wed, 22 Jun 2022 04:58:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbiFVI6Q (ORCPT ); Wed, 22 Jun 2022 04:58:16 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EEB8E34; Wed, 22 Jun 2022 01:58:07 -0700 (PDT) X-UUID: b768fae71ca547b7b5dd424f82c0d88c-20220622 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.6,REQID:c7be37e6-56a1-4dcb-953c-d51da3c76ffd,OB:0,LO B:0,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,RULE:Release_Ham,ACT ION:release,TS:100 X-CID-INFO: VERSION:1.1.6,REQID:c7be37e6-56a1-4dcb-953c-d51da3c76ffd,OB:0,LOB: 0,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,RULE:Spam_GS981B3D,ACT ION:quarantine,TS:100 X-CID-META: VersionHash:b14ad71,CLOUDID:190135ea-f7af-4e69-92ee-0fd74a0c286c,C OID:47c063911d5b,Recheck:0,SF:28|17|19|48,TC:nil,Content:0,EDM:-3,IP:nil,U RL:1,File:nil,QS:nil,BEC:nil,COL:0 X-UUID: b768fae71ca547b7b5dd424f82c0d88c-20220622 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1474948226; Wed, 22 Jun 2022 16:58:01 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Wed, 22 Jun 2022 16:58:00 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.3 via Frontend Transport; Wed, 22 Jun 2022 16:57:59 +0800 From: Chunfeng Yun To: Felipe Balbi CC: Greg Kroah-Hartman , Matthias Brugger , Pavel Hofman , Julian Scheel , xin lin , Yunhao Tian , Ruslan Bilovol , , , , , Eddie Hung , Chunfeng Yun Subject: [PATCH] usb: gadget: f_uac1: add IAD descriptor Date: Wed, 22 Jun 2022 16:57:57 +0800 Message-ID: <20220622085757.23437-1-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: xin lin Win10 can not enumerate composite device of UVC+UAC1+ADB without IAD descri= ptor in uac1.0, so add it. Signed-off-by: xin lin Signed-off-by: Chunfeng Yun --- drivers/usb/gadget/function/f_uac1.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/func= tion/f_uac1.c index 6f0e1d803dc2..8390207bc513 100644 --- a/drivers/usb/gadget/function/f_uac1.c +++ b/drivers/usb/gadget/function/f_uac1.c @@ -71,6 +71,17 @@ static inline struct f_uac1_opts *g_audio_to_uac1_opts(s= truct g_audio *audio) * ALSA_Playback -> IT_3 -> OT_4 -> USB-IN */ =20 +static struct usb_interface_assoc_descriptor iad_desc =3D { + .bLength =3D sizeof(iad_desc), + .bDescriptorType =3D USB_DT_INTERFACE_ASSOCIATION, + + .bFirstInterface =3D 0, + .bInterfaceCount =3D 3, + .bFunctionClass =3D USB_CLASS_AUDIO, + .bFunctionSubClass =3D 0, + .bFunctionProtocol =3D UAC_VERSION_1, +}; + /* B.3.1 Standard AC Interface Descriptor */ static struct usb_interface_descriptor ac_interface_desc =3D { .bLength =3D USB_DT_INTERFACE_SIZE, @@ -259,6 +270,7 @@ static struct uac_iso_endpoint_descriptor as_iso_in_des= c =3D { }; =20 static struct usb_descriptor_header *f_audio_desc[] =3D { + (struct usb_descriptor_header *)&iad_desc, (struct usb_descriptor_header *)&ac_interface_desc, (struct usb_descriptor_header *)&ac_header_desc, =20 @@ -293,6 +305,7 @@ static struct usb_descriptor_header *f_audio_desc[] =3D= { }; =20 enum { + STR_ASSOC, STR_AC_IF, STR_USB_OUT_IT, STR_USB_OUT_IT_CH_NAMES, @@ -310,6 +323,7 @@ enum { =20 static struct usb_string strings_uac1[] =3D { /* [STR_AC_IF].s =3D DYNAMIC, */ + [STR_ASSOC].s =3D "Source/Sink", [STR_USB_OUT_IT].s =3D "Playback Input terminal", [STR_USB_OUT_IT_CH_NAMES].s =3D "Playback Channels", [STR_IO_OUT_OT].s =3D "Playback Output terminal", @@ -1058,6 +1072,7 @@ static void setup_descriptor(struct f_uac1_opts *opts) as_out_header_desc.bTerminalLink =3D usb_out_it_desc.bTerminalID; as_in_header_desc.bTerminalLink =3D usb_in_ot_desc.bTerminalID; =20 + iad_desc.bInterfaceCount =3D 1; ac_header_desc->wTotalLength =3D cpu_to_le16(ac_header_desc->bLength); =20 if (EPIN_EN(opts)) { @@ -1068,6 +1083,7 @@ static void setup_descriptor(struct f_uac1_opts *opts) if (FUIN_EN(opts)) len +=3D in_feature_unit_desc->bLength; ac_header_desc->wTotalLength =3D cpu_to_le16(len); + iad_desc.bInterfaceCount++; } if (EPOUT_EN(opts)) { u16 len =3D le16_to_cpu(ac_header_desc->wTotalLength); @@ -1077,9 +1093,11 @@ static void setup_descriptor(struct f_uac1_opts *opt= s) if (FUOUT_EN(opts)) len +=3D out_feature_unit_desc->bLength; ac_header_desc->wTotalLength =3D cpu_to_le16(len); + iad_desc.bInterfaceCount++; } =20 i =3D 0; + f_audio_desc[i++] =3D USBDHDR(&iad_desc); f_audio_desc[i++] =3D USBDHDR(&ac_interface_desc); f_audio_desc[i++] =3D USBDHDR(ac_header_desc); =20 @@ -1217,6 +1235,7 @@ static int f_audio_bind(struct usb_configuration *c, = struct usb_function *f) } } =20 + iad_desc.iFunction =3D us[STR_ASSOC].id; ac_interface_desc.iInterface =3D us[STR_AC_IF].id; usb_out_it_desc.iTerminal =3D us[STR_USB_OUT_IT].id; usb_out_it_desc.iChannelNames =3D us[STR_USB_OUT_IT_CH_NAMES].id; @@ -1302,6 +1321,8 @@ static int f_audio_bind(struct usb_configuration *c, = struct usb_function *f) status =3D usb_interface_id(c, f); if (status < 0) goto err_free_fu; + + iad_desc.bFirstInterface =3D status; ac_interface_desc.bInterfaceNumber =3D status; uac1->ac_intf =3D status; uac1->ac_alt =3D 0; --=20 2.18.0