Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp4054165rdg; Wed, 18 Oct 2023 13:36:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErGW6eM9kOBwWp7R4wLVlrRxs1lwwzTcXJQReNrbqfaeEFkfrMV27POfzIj7Y3Tg423BmL X-Received: by 2002:a05:6a21:9987:b0:17a:f2ed:e921 with SMTP id ve7-20020a056a21998700b0017af2ede921mr218583pzb.55.1697661366726; Wed, 18 Oct 2023 13:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697661366; cv=none; d=google.com; s=arc-20160816; b=W9qaJt8/KSYOGmyu8SHGLpcU+BzonkmU9R3Q0jA2e1Gw/Ef2aT45Ra43hgovcV+cJB l3HGru8VRpr0r096CFrjAZAaVB50aRSs9l/qKXUd4oifNCWJaxGm6dOhh0dFl7RNztjH jm4I0ZvzB3SUs0Cy6k4RUkUBu1rvHKuGG3wOY2Kexlc6Bm+w1QYswijCAvs2tMo80FQc +IpWhAD3oDj9RFyn71jEro81/CQk3Rf87a+oI51RnGasaLqR8GRkWpkpcV8grAXbThBY IZcW1ICU1hd77NkzsEfxOkzEQPbQ2NF9B3TDLiis2xCC59ro+OHrpr00rD8FI3uskbrP WRDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=D3VEipluic1dnj4xaArrQ04lPUUz9iyghjTrQJeu5aE=; fh=9+IEscr4WmNbE41gibPc+AZ0nx0+/tccCXbA5gmgnS8=; b=GfLGSavMj0N8dQssoEtzfuX3pbZ23PrEIKopbcU04ER4fSRbff2N7y3XTofnCQoCWq Zw7o/HNVBCP/iUi6HslUMsbSyqL1Vt8WwfFItI1wdoAe1Y6Bmy6S4c/z5Ehf1HQovUrg LA3hpX5ppYi5rQjMaL9xIMwLSJbg/t5HZQ4kNnjF7TI24yLknEaR4jVnoFKndJYdFJqd liyYF4dkZlWFLoklZ+0uxPIYL01xpdBUIADEIAqVFJjjI5wHhXvT2KAsuXUeiCZvdcnW mdU/ajXHDuv7wT+HBvJs1g1sFFXkQBC7QKmD8nD3rBI4BhuVN9VaZewQN1LpX72OOduY feHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=HYRGvFZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id d13-20020a170902cecd00b001c74876f029si688266plg.381.2023.10.18.13.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 13:36:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=HYRGvFZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4C5DB8037AB6; Wed, 18 Oct 2023 13:36:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231459AbjJRUfy (ORCPT + 99 others); Wed, 18 Oct 2023 16:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344773AbjJRUd4 (ORCPT ); Wed, 18 Oct 2023 16:33:56 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A70D1AA; Wed, 18 Oct 2023 13:33:43 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39IKXGjj008745; Wed, 18 Oct 2023 20:33:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=D3VEipluic1dnj4xaArrQ04lPUUz9iyghjTrQJeu5aE=; b=HYRGvFZRbv9ZGlNVYgJ0bbpCQaouRJDG5GUWgOJMv8bbGAA6WVtbowAcpNgL1UIXgMf/ y50Q2HXtqKrGtoRkoxHIGNsZg/KRUx82bSURxVn8GlnUD0hKAcef5jIg57jToidW83gF /23UwY9CiDh7BiNTTijZl9a34YGWQ7NBq3xASPduJKSoMFsA5GOq1lSfQ8TxdTEIYPQn cXWTcYUbJj4i8e1TttKiXXDIs5icR3UvmFXC1k1Os16QVfcmoYhq+/UkLdWcODIbv4VC rZDmGV+KbdLAT5Oy0EFnJMxKBjKtJNrYMdvFh2KPyoUOMlIul2f9XJ5ladpkYnZf9jwh fg== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ttb7ahrvw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Oct 2023 20:33:26 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39IKXPdM003412 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Oct 2023 20:33:25 GMT Received: from [10.110.123.255] (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Wed, 18 Oct 2023 13:33:24 -0700 Message-ID: <09bf52fe-0234-3fc6-1911-9d0f8217d8ad@quicinc.com> Date: Wed, 18 Oct 2023 13:33:24 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v9 21/34] ASoC: usb: Add PCM format check API for USB backend Content-Language: en-US To: Pierre-Louis Bossart , , , , , , , , , , , , , , , CC: , , , , References: <20231017200109.11407-1-quic_wcheng@quicinc.com> <20231017200109.11407-22-quic_wcheng@quicinc.com> From: Wesley Cheng In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: GnQCwHKt7WkSwgc5_0rgRzLNxfyB9Hpg X-Proofpoint-GUID: GnQCwHKt7WkSwgc5_0rgRzLNxfyB9Hpg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-18_18,2023-10-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 spamscore=0 suspectscore=0 clxscore=1015 mlxlogscore=727 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310180169 X-Spam-Status: No, score=-4.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 18 Oct 2023 13:36:03 -0700 (PDT) Hi Pierre, On 10/17/2023 3:33 PM, Pierre-Louis Bossart wrote: > > > On 10/17/23 15:00, Wesley Cheng wrote: >> Introduce a check for if a particular PCM format is supported by the USB > > Introduce a helper to check if a ... > Ack. >> audio device connected. If the USB audio device does not have an audio >> profile which can support the requested format, then notify the USB >> backend. >> >> Signed-off-by: Wesley Cheng >> --- >> include/sound/soc-usb.h | 3 +++ >> sound/soc/soc-usb.c | 13 +++++++++++++ >> 2 files changed, 16 insertions(+) >> >> diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h >> index 58c686f4f7ba..c6ddc055c4cd 100644 >> --- a/include/sound/soc-usb.h >> +++ b/include/sound/soc-usb.h >> @@ -37,6 +37,9 @@ struct snd_soc_usb { >> void *priv_data; >> }; >> >> +int snd_soc_usb_find_format(int card_idx, struct snd_pcm_hw_params *params, >> + int direction); >> + >> int snd_soc_usb_connect(struct device *usbdev, struct snd_soc_usb_device *sdev); >> int snd_soc_usb_disconnect(struct device *usbdev, struct snd_soc_usb_device *sdev); >> void *snd_soc_usb_find_priv_data(struct device *usbdev); >> diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c >> index 73b1bcc3b506..7407678a993e 100644 >> --- a/sound/soc/soc-usb.c >> +++ b/sound/soc/soc-usb.c >> @@ -63,6 +63,19 @@ void *snd_soc_usb_find_priv_data(struct device *dev) >> } >> EXPORT_SYMBOL_GPL(snd_soc_usb_find_priv_data); >> >> +int snd_soc_usb_find_format(int card_idx, struct snd_pcm_hw_params *params, >> + int direction) >> +{ >> + struct snd_usb_stream *as; >> + >> + as = snd_usb_find_suppported_substream(card_idx, params, direction); >> + if (!as) >> + return -EOPNOTSUPP; >> + >> + return 0; >> +} >> +EXPORT_SYMBOL_GPL(snd_soc_usb_find_format); > > Is this the right way to check for formats? > > formats are defined within the scope of an endpoint, and those endpoints > are themselves defined within the scope of an interface? > > I don't see a notion of endpoint here. Does this assume all endpoints > are valid, or maybe the existence of a single endpoint in a device? > > Confused. At least in terms of USB and USB UAC, formats are defined within an audio streaming interface descriptor, which will include multiple (up to 2) USB endpoints. Those endpoints will be described w/ both an audio streaming endpoint descriptor as well as a standard USB endpoint descriptor. The audio interface/format descriptors are the ones that carry the information about what formats are supported by the USB device. So this API finds a possible USB AS streaming descriptor on the device that matches the requested one. Endpoints will be opened subsequently when the audio stream is started, and an interface is enabled by sending a SET_INTERFACE control packet on the USB bus. Thanks Wesley Cheng