Message ID | 20231017200109.11407-22-quic_wcheng@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4370914vqb; Tue, 17 Oct 2023 13:04:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFN6beZX1QVbgGRU/sDzFumFHm6FY7MPv4iCGyber5cRjYJlyOLh3/ybACcYrjFd4997v7Y X-Received: by 2002:a05:6a20:d80d:b0:163:ab09:193e with SMTP id iv13-20020a056a20d80d00b00163ab09193emr3193096pzb.1.1697573072803; Tue, 17 Oct 2023 13:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697573072; cv=none; d=google.com; s=arc-20160816; b=xAQqp+peF/921j3ZbTXMfD0/c77zStkAupgmPtmDzxT5ZvQsAs32h9NLIOJdrCKPHb /iTuuJYraDvn9SqMIc4S8GI3VCHc7SrU4LPGgg9JOFN3tbwOMWbiT05f3I2vknqGfUCD xYlxXuA0u+hx/7fGePa8n8aH1EXrd2RbdLbbcteSucBtadlm2wtfywSKuWVTB9FNuyGd 0aQtBPkjLBy4REV3sKS3GlYtQ6UuqRqSA4jXvvg7Zo9eBkDwsIwhlPJKt0AiR25rjkbw decTqFVOj0lUPv0cEK96v6n6bmmyF4S8qSm0GUFNlBUligShdwPn4oC+Mow69aTauf39 8XWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Shqo9s0lYRwfd+WgaNXsqGc7coVeRQUHUyu7Rj3csx0=; fh=ASZxE/GudOQkGCAz0d02NHHSpg4iNHYOcDWl1imlof0=; b=TyUFKHVFhZDnI3dW6nR4Cmj4XcOyfTBY1eDGo4M1lJxVHpQijwyqzIyTywKXcGKq1j 8RwFFK8bLNKOMUdbUoF+JYnX1pfPOU9IsccCA/BOKfxis/grM9gLlrILOqNjEp3JqEYj J0DDgfaogGaAslPwIZR4JHgucfJoczXDtE0o5Opcx/UnWyr2ZrYXjnvYCfJytSz7mpbL Z5sHwy/EVXOc244SsvI7AjBtF279DJKXgOZJVjVJx6Fk5XrEUGJLK2/0sFSnPdbGAUJF SLEFrQbcuN80ptpuYZytiD/hK7EUOsrlpyNOnyt/OHN+rZuNY444ZQi1LIL3ELGoO4mr blPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jhYdP2bS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id m16-20020a170902db1000b001c755810f7esi2666291plx.499.2023.10.17.13.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 13:04:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=jhYdP2bS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id A80EE80DCCA2; Tue, 17 Oct 2023 13:04:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344466AbjJQUDy (ORCPT <rfc822;dexuan.linux@gmail.com> + 21 others); Tue, 17 Oct 2023 16:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235117AbjJQUCI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 17 Oct 2023 16:02:08 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67EBA129; Tue, 17 Oct 2023 13:01:53 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39HDDlT1009936; Tue, 17 Oct 2023 20:01:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=Shqo9s0lYRwfd+WgaNXsqGc7coVeRQUHUyu7Rj3csx0=; b=jhYdP2bSa0fPqo9XRDkHLnPosihRotDmzVPMtN9hi3Xgl20wPsreZ28BweFagfcd31yA yP4wAGAqwJIM2sqW03BjqzjB8mMgr7uN0gofFHUGB1uS6iVQnC2f4pgXtTF+ig04huq0 KBZzOajguRF4X82reW2ISshx6IxBAL7alzYySzZwIl0AxCeGPer9jsHNep4kHNyUq35z So5yNf4IxXQrD6H0mKTayj7jDVa2n4sGwUajeC7izmtxFJN9Wu/FNAPpTcr9M4IHuS0Z 74oUdOL9RUoCDCKzDICuOQdhetJ0pOlfifJsmYMQjozW2vC+0LtS4kTPXxHWa2Mal8ug Vg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tsnej9qj1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Oct 2023 20:01:26 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39HK1P3U018697 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Oct 2023 20:01:25 GMT Received: from hu-wcheng-lv.qualcomm.com (10.49.16.6) 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; Tue, 17 Oct 2023 13:01:25 -0700 From: Wesley Cheng <quic_wcheng@quicinc.com> To: <mathias.nyman@intel.com>, <gregkh@linuxfoundation.org>, <lgirdwood@gmail.com>, <broonie@kernel.org>, <perex@perex.cz>, <tiwai@suse.com>, <agross@kernel.org>, <andersson@kernel.org>, <konrad.dybcio@linaro.org>, <robh+dt@kernel.org>, <krzysztof.kozlowski+dt@linaro.org>, <conor+dt@kernel.org>, <srinivas.kandagatla@linaro.org>, <bgoswami@quicinc.com>, <Thinh.Nguyen@synopsys.com> CC: <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <alsa-devel@alsa-project.org>, <linux-arm-msm@vger.kernel.org>, <devicetree@vger.kernel.org>, Wesley Cheng <quic_wcheng@quicinc.com> Subject: [PATCH v9 21/34] ASoC: usb: Add PCM format check API for USB backend Date: Tue, 17 Oct 2023 13:00:56 -0700 Message-ID: <20231017200109.11407-22-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231017200109.11407-1-quic_wcheng@quicinc.com> References: <20231017200109.11407-1-quic_wcheng@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) 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-GUID: SVF9sih1d-q6cJ4BYBtetbINXPX5d87M X-Proofpoint-ORIG-GUID: SVF9sih1d-q6cJ4BYBtetbINXPX5d87M 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-17_03,2023-10-17_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 bulkscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 phishscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310170169 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 17 Oct 2023 13:04:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780034382007030524 X-GMAIL-MSGID: 1780034382007030524 |
Series |
Introduce QC USB SND audio offloading support
|
|
Commit Message
Wesley Cheng
Oct. 17, 2023, 8 p.m. UTC
Introduce a check for if a particular PCM format is supported by the USB
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 <quic_wcheng@quicinc.com>
---
include/sound/soc-usb.h | 3 +++
sound/soc/soc-usb.c | 13 +++++++++++++
2 files changed, 16 insertions(+)
Comments
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 ... > 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 <quic_wcheng@quicinc.com> > --- > 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.
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 <quic_wcheng@quicinc.com> >> --- >> 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
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); + /** * snd_soc_usb_add_port() - Add a USB backend port * @dev: USB backend device