From patchwork Wed Dec 19 11:02:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liangshengjun X-Patchwork-Id: 10737061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC7EB14DE for ; Wed, 19 Dec 2018 11:02:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B185D2ACAE for ; Wed, 19 Dec 2018 11:02:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A59B22ACBA; Wed, 19 Dec 2018 11:02:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9495E2ACAE for ; Wed, 19 Dec 2018 11:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728428AbeLSLCb convert rfc822-to-8bit (ORCPT ); Wed, 19 Dec 2018 06:02:31 -0500 Received: from szxga02-in.huawei.com ([45.249.212.188]:6946 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728002AbeLSLCb (ORCPT ); Wed, 19 Dec 2018 06:02:31 -0500 Received: from DGGEMM405-HUB.china.huawei.com (unknown [172.30.72.54]) by Forcepoint Email with ESMTP id C869EA4E7F2CF; Wed, 19 Dec 2018 19:02:23 +0800 (CST) Received: from DGGEMM510-MBS.china.huawei.com ([169.254.11.150]) by DGGEMM405-HUB.china.huawei.com ([10.3.20.213]) with mapi id 14.03.0415.000; Wed, 19 Dec 2018 19:02:22 +0800 From: liangshengjun To: "balbi@kernel.org" CC: Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] usb: gadget: function: f_uac1 add interface assoc desc Thread-Topic: [PATCH] usb: gadget: function: f_uac1 add interface assoc desc Thread-Index: AdSXihVFnR/WgnXsQhWO9abAmF+4CA== Date: Wed, 19 Dec 2018 11:02:21 +0000 Message-ID: <84923CA334DF85428B9ADCEC0F3CE864055B49A6@dggemm510-mbs.china.huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.223.71] MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add f_uac1 interface association descriptor, make f_uac1 link other function(like f_uvc) is possible. Signed-off-by: Liang Shengjun --- drivers/usb/gadget/function/f_uac1.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c index 2746a92..28c1a78 100644 --- a/drivers/usb/gadget/function/f_uac1.c +++ b/drivers/usb/gadget/function/f_uac1.c @@ -48,6 +48,16 @@ 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 uac_iad = { + .bLength = sizeof(uac_iad), + .bDescriptorType = USB_DT_INTERFACE_ASSOCIATION, + .bFirstInterface = 0, + .bInterfaceCount = 3, + .bFunctionClass = USB_CLASS_AUDIO, + .bFunctionSubClass = 0, + .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 +257,7 @@ static struct uac_iso_endpoint_descriptor as_iso_in_desc = { }; static struct usb_descriptor_header *f_audio_desc[] = { + (struct usb_descriptor_header *)&uac_iad, (struct usb_descriptor_header *)&ac_interface_desc, (struct usb_descriptor_header *)&ac_header_desc, @@ -523,6 +534,7 @@ 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); + uac_iad.iFunction = us[STR_AC_IF].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 +571,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; + uac_iad.bFirstInterface = status; ac_interface_desc.bInterfaceNumber = status; uac1->ac_intf = status; uac1->ac_alt = 0;