From patchwork Mon Dec 24 02:35:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liangshengjun X-Patchwork-Id: 10742019 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 D372A13A4 for ; Mon, 24 Dec 2018 02:35:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7D8E28829 for ; Mon, 24 Dec 2018 02:35:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A805328A3E; Mon, 24 Dec 2018 02:35:35 +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 943A928829 for ; Mon, 24 Dec 2018 02:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726565AbeLXCf1 convert rfc822-to-8bit (ORCPT ); Sun, 23 Dec 2018 21:35:27 -0500 Received: from szxga03-in.huawei.com ([45.249.212.189]:6521 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726361AbeLXCf1 (ORCPT ); Sun, 23 Dec 2018 21:35:27 -0500 Received: from DGGEMM403-HUB.china.huawei.com (unknown [172.30.72.56]) by Forcepoint Email with ESMTP id 7A65CBD9F3973; Mon, 24 Dec 2018 10:35:22 +0800 (CST) Received: from DGGEMM424-HUB.china.huawei.com (10.1.198.41) by DGGEMM403-HUB.china.huawei.com (10.3.20.211) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 24 Dec 2018 10:35:24 +0800 Received: from DGGEMM510-MBS.china.huawei.com ([169.254.11.150]) by dggemm424-hub.china.huawei.com ([10.1.198.41]) with mapi id 14.03.0415.000; Mon, 24 Dec 2018 10:35:17 +0800 From: liangshengjun To: Felipe Balbi , Greg Kroah-Hartman , Paul Elder , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Jiangheng , Caizhiyong 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+4CADpmHag Date: Mon, 24 Dec 2018 02:35:16 +0000 Message-ID: <84923CA334DF85428B9ADCEC0F3CE864055B6976@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(+) 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; -- 2.7.4 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 = { };