Message ID | 20231017200109.11407-21-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 ib8csp4371185vqb; Tue, 17 Oct 2023 13:05:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGm3XU5aj5+pSeusf/9Blv870v3s/wqroW6GUxQzJFobv/9IKniK08rXzQIxeNwtMAdKpqG X-Received: by 2002:a05:6870:8a28:b0:1e1:e6ee:94b6 with SMTP id p40-20020a0568708a2800b001e1e6ee94b6mr4034032oaq.4.1697573100663; Tue, 17 Oct 2023 13:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697573100; cv=none; d=google.com; s=arc-20160816; b=g0n6qUwKVrmrYXOwcL0QXfjoeAm4hVag+A3v9BgOOJbV2SEzZByEW1NX28Su6pnPVu ucVnRZLPgCMQtvK8RYbmlxJMcZxbjLzP1qryif+qxaQqPEGd1FPf+P3GvLq/DrOWA3eQ iO14T2R5c4hlo3mZT8469JvKMcaxxsAOFP1qZj9p1jf59TS8DYG3gNKhj4ntJHblOgfy 4DP1JDgdi0PUBywIdik71fhWgz+DD9l9eFr+9+lDgyNkjcDDn3dw5j8Y991WEY3dC5DI 7MmukKt63NDU+4LPug5K0ZbmB9ON+zhbhR2EGY6dJXBTmuEE5IwB3VbeQy4T8QLfV73z oqSw== 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=dH3EZ3Jzl3/12IrSu0jI4GH3HGQtq5+vzpa4GA8M+f0=; fh=ASZxE/GudOQkGCAz0d02NHHSpg4iNHYOcDWl1imlof0=; b=EOGRxSlMEUNEuEPpSDoNjOFNqHknDe8p8Es01WFq2k7BZM3cUhyW7Ivv4Dev223Rr9 927tRR1Pgp47PYYO6MDWHSgW8CxF1nSG9RBKBB1CVL/mZ2VkmOJrJ7QWvGD2ofLDp/Gb 9u0PU+B/choe7gQY3w7dhz9TdT4cEOpRja5VLd7x52hOV8pk6E3Zq9yMKWun3IUrDtkt yXbZEBS5jTgudDuE0UT412T4bBX42rAS0z4KI8c9qBsWla34xpiMhFtPxKmO6jDdLl02 WWwpg3Ixacvr8W0UHVN1uJ/stGFO3GCxlj/nX1jkPHfqMyAMBQg+LpNhSzRu6n1cpY0R yT/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=CaHFkJvi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id bm9-20020a656e89000000b0057823b96685si500119pgb.681.2023.10.17.13.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 13:05:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=CaHFkJvi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 B0966801B818; Tue, 17 Oct 2023 13:04:57 -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 S1344579AbjJQUEi (ORCPT <rfc822;dexuan.linux@gmail.com> + 21 others); Tue, 17 Oct 2023 16:04:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344621AbjJQUD4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 17 Oct 2023 16:03:56 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB89910FD; Tue, 17 Oct 2023 13:02:16 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39HIBDEr026311; Tue, 17 Oct 2023 20:01:59 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=dH3EZ3Jzl3/12IrSu0jI4GH3HGQtq5+vzpa4GA8M+f0=; b=CaHFkJviym5w1PQGFxKRfDCFXDvdvxJmNhcRvQNkI63S3rJmX3iSmI9FXabFo3rXD56w fjoHjcFzRyza20kV00FA0uy0m3F83DqK9HZYpCDFbZzl472uN1UXHyL+f2lEkg3AvD8F w1qsnBpaWRxpEAwRX5IRrxGZFwenGm81ZuUFWSU5Ix89iwyIngmob2bvjahmxWW3Qmqw vqp/RBihIuqg2VhT7BwqSlPtyaI3orSjcTVzMH0wTxFLI7LrZ5WrI/JUMgZz6vK8rlRn ja+B7JETaA/wjPP3SO9tRmg0RwsEULpdDYKnq3xA576Bsr44tL89IHcrxRueyFUO2Bn3 hg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ts85fujf7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Oct 2023 20:01:59 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39HK1PsI004934 (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 20/34] ALSA: usb-audio: Check for support for requested audio format Date: Tue, 17 Oct 2023 13:00:55 -0700 Message-ID: <20231017200109.11407-21-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-ORIG-GUID: mc9sAtAFsen2WJ0X9Xwgf4PFIDiF-jb1 X-Proofpoint-GUID: mc9sAtAFsen2WJ0X9Xwgf4PFIDiF-jb1 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 adultscore=0 priorityscore=1501 phishscore=0 malwarescore=0 spamscore=0 mlxscore=0 bulkscore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310170170 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:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780034411527586670 X-GMAIL-MSGID: 1780034411527586670 |
Series |
Introduce QC USB SND audio offloading support
|
|
Commit Message
Wesley Cheng
Oct. 17, 2023, 8 p.m. UTC
Allow for checks on a specific USB audio device to see if a requested PCM
format is supported. This is needed for support for when playback is
initiated by the ASoC USB backend path.
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
---
sound/usb/card.c | 40 ++++++++++++++++++++++++++++++++++++++++
sound/usb/card.h | 11 +++++++++++
2 files changed, 51 insertions(+)
Comments
On 10/17/23 15:00, Wesley Cheng wrote: > Allow for checks on a specific USB audio device to see if a requested PCM > format is supported. This is needed for support for when playback is This is needed for support when playback is > initiated by the ASoC USB backend path. > > Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> > --- > sound/usb/card.c | 40 ++++++++++++++++++++++++++++++++++++++++ > sound/usb/card.h | 11 +++++++++++ > 2 files changed, 51 insertions(+) > > diff --git a/sound/usb/card.c b/sound/usb/card.c > index c0b312e264bf..88f431917c15 100644 > --- a/sound/usb/card.c > +++ b/sound/usb/card.c > @@ -162,6 +162,46 @@ int snd_usb_unregister_platform_ops(void) > } > EXPORT_SYMBOL_GPL(snd_usb_unregister_platform_ops); > > +/* > + * Checks to see if requested audio profile, i.e sample rate, # of > + * channels, etc... is supported by the substream associated to the > + * USB audio device. > + */ > +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, > + struct snd_pcm_hw_params *params, int direction) > +{ > + struct snd_usb_audio *chip; > + struct snd_usb_substream *subs = NULL; useless init? > + struct snd_usb_stream *as; > + const struct audioformat *fmt; > + > + /* > + * Register mutex is held when populating and clearing usb_chip > + * array. > + */ > + mutex_lock(®ister_mutex); > + chip = usb_chip[card_idx]; > + if (!chip) { > + mutex_unlock(®ister_mutex); > + return NULL; > + } > + > + if (enable[card_idx]) { > + list_for_each_entry(as, &chip->pcm_list, list) { > + subs = &as->substream[direction]; > + fmt = snd_usb_find_substream_format(subs, params); > + if (fmt) { > + mutex_unlock(®ister_mutex); > + return as; > + } > + } > + } > + mutex_unlock(®ister_mutex); > + > + return NULL; > +} > +EXPORT_SYMBOL_GPL(snd_usb_find_suppported_substream); > + > /* > * disconnect streams > * called from usb_audio_disconnect() > diff --git a/sound/usb/card.h b/sound/usb/card.h > index 2884912adc96..e26292363cf0 100644 > --- a/sound/usb/card.h > +++ b/sound/usb/card.h > @@ -216,4 +216,15 @@ struct snd_usb_platform_ops { > > int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops); > int snd_usb_unregister_platform_ops(void); > + > +#if IS_ENABLED(CONFIG_SND_USB_AUDIO) > +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, > + struct snd_pcm_hw_params *params, int direction); > +#else > +static struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, > + struct snd_pcm_hw_params *params, int direction) > +{ > + return NULL; > +} > +#endif /* IS_ENABLED(CONFIG_SND_USB_AUDIO) */ > #endif /* __USBAUDIO_CARD_H */
Hi Pierre, On 10/17/2023 3:29 PM, Pierre-Louis Bossart wrote: > > > On 10/17/23 15:00, Wesley Cheng wrote: >> Allow for checks on a specific USB audio device to see if a requested PCM >> format is supported. This is needed for support for when playback is > > This is needed for support when playback is > Will fix this typo >> initiated by the ASoC USB backend path. >> >> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> >> --- >> sound/usb/card.c | 40 ++++++++++++++++++++++++++++++++++++++++ >> sound/usb/card.h | 11 +++++++++++ >> 2 files changed, 51 insertions(+) >> >> diff --git a/sound/usb/card.c b/sound/usb/card.c >> index c0b312e264bf..88f431917c15 100644 >> --- a/sound/usb/card.c >> +++ b/sound/usb/card.c >> @@ -162,6 +162,46 @@ int snd_usb_unregister_platform_ops(void) >> } >> EXPORT_SYMBOL_GPL(snd_usb_unregister_platform_ops); >> >> +/* >> + * Checks to see if requested audio profile, i.e sample rate, # of >> + * channels, etc... is supported by the substream associated to the >> + * USB audio device. >> + */ >> +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, >> + struct snd_pcm_hw_params *params, int direction) >> +{ >> + struct snd_usb_audio *chip; >> + struct snd_usb_substream *subs = NULL; > > useless init? > Agreed. Thanks Wesley Cheng
diff --git a/sound/usb/card.c b/sound/usb/card.c index c0b312e264bf..88f431917c15 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -162,6 +162,46 @@ int snd_usb_unregister_platform_ops(void) } EXPORT_SYMBOL_GPL(snd_usb_unregister_platform_ops); +/* + * Checks to see if requested audio profile, i.e sample rate, # of + * channels, etc... is supported by the substream associated to the + * USB audio device. + */ +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, + struct snd_pcm_hw_params *params, int direction) +{ + struct snd_usb_audio *chip; + struct snd_usb_substream *subs = NULL; + struct snd_usb_stream *as; + const struct audioformat *fmt; + + /* + * Register mutex is held when populating and clearing usb_chip + * array. + */ + mutex_lock(®ister_mutex); + chip = usb_chip[card_idx]; + if (!chip) { + mutex_unlock(®ister_mutex); + return NULL; + } + + if (enable[card_idx]) { + list_for_each_entry(as, &chip->pcm_list, list) { + subs = &as->substream[direction]; + fmt = snd_usb_find_substream_format(subs, params); + if (fmt) { + mutex_unlock(®ister_mutex); + return as; + } + } + } + mutex_unlock(®ister_mutex); + + return NULL; +} +EXPORT_SYMBOL_GPL(snd_usb_find_suppported_substream); + /* * disconnect streams * called from usb_audio_disconnect() diff --git a/sound/usb/card.h b/sound/usb/card.h index 2884912adc96..e26292363cf0 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -216,4 +216,15 @@ struct snd_usb_platform_ops { int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops); int snd_usb_unregister_platform_ops(void); + +#if IS_ENABLED(CONFIG_SND_USB_AUDIO) +struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, + struct snd_pcm_hw_params *params, int direction); +#else +static struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx, + struct snd_pcm_hw_params *params, int direction) +{ + return NULL; +} +#endif /* IS_ENABLED(CONFIG_SND_USB_AUDIO) */ #endif /* __USBAUDIO_CARD_H */