Message ID | 20240208231406.27397-33-quic_wcheng@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-58824-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp516222dyd; Thu, 8 Feb 2024 15:30:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWk6G7np1B+jJs+pS2tAsBUq0D5DwMLLPv4QvQ7/GPKsohx19+HAqp/u2hLZeS7XYiXukVQPIAbNiwwS7K1Mm5iPjEBRg== X-Google-Smtp-Source: AGHT+IEMZshIPZzOqFja/prkPF8rzAEuZ2IPbl/D19reXsheP4WWgNwyzprydbdyGKlneRZEZVMq X-Received: by 2002:a05:6a00:2d1c:b0:6e0:8718:eac2 with SMTP id fa28-20020a056a002d1c00b006e08718eac2mr104529pfb.23.1707435038104; Thu, 08 Feb 2024 15:30:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707435038; cv=pass; d=google.com; s=arc-20160816; b=Jg7ZUaC/3cdUgpx8nSE+0y5OpZlPFfxTVhq2K8+ZoZo0jpCJvDJKWwd5giz6gbe4Ke 0GccoNPLNGQOBGjydNZ907hzeUMZPYBUbShAwhL0jSz6G7TsJGLSBU9pC0s+3YlUuG0G vEtsL29WT9V8qfnIHdl7X+cz7FgfA0T8/tY6utFoGIAuXuI1BCfrJ1UZ8/IWlwnXA3B7 lk7laNYuqjN31jA+12eDD2H6+e89gJuf55FIBg9wtsOMZFLJtRmUIMWga5ZkIZgpKt7Y Zixa9bjqDElJG4/NXWHYcoKxhziv5yAiDGF1+3vnJgIwWbZX4z5nVHCmGx+wNCLL0lvt Gvqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o+wRszxk0RVAQ49EubcS3o6BAod/YEpz+w8A12Os+Eg=; fh=DCOgySnvkUhutDZ6l+uRTbsPYEa/DfkPJ0GjZwidHdI=; b=eO84N52Z2CCkyEcdZmqzCqUFdGnB6ZZCI724eKX2cadfk3WZVQJQym80mMNs6DLpLC ITGqQlKMiFKxOh0Wk5x0J1eadUhCIVuzFgSE5hMXcWdd7d0GliFLeHVdsPC+RydbWinF 6sTcEO9Ls0XacNKp9b70iQqxRjXgeRT/GWYG/djs6xVz4a/3kAej3OQVXvME5W2dGnWD YX7cTEMC68uyzwsdkLGegs4HxQsHt5D8tZSqPD7/MpnHTVQnnS6NLmOyIPUTDoicKe0e JzEJEjjnQ58CQN5DmkWLVU+V3/4fA7vCISSQ8CER0WoKCZ1Xz22+ZAoWWRhJX6DdF/jx bMkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=RbsmGQXF; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-58824-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58824-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=2; AJvYcCUZAEYoQHoC+tQ4Izu2GmBLBQu5bvOshaJVuImgqOUpIw76Arg1Zv/moyyLKy72OgQoVg4eLoM4IxMaINKQZA686NolsQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q8-20020aa79828000000b006ddce4f37c0si481283pfl.285.2024.02.08.15.30.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 15:30:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58824-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=RbsmGQXF; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-58824-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58824-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 004AB281CE9 for <ouuuleilei@gmail.com>; Thu, 8 Feb 2024 23:28:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB86660DD3; Thu, 8 Feb 2024 23:15:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="RbsmGQXF" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58BA450267; Thu, 8 Feb 2024 23:14:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707434082; cv=none; b=lgVw8S1+4r1ydNq8qHtVgC9Xy7YHOfIS3vRUjOxp9X1K9RoYR40j8m/fDcRGqH+mbtV50c9nnlVsC+zMDDmmYcOzDXB5VogYWY3kTI+mJhm7Jp+cVLfutcNx7i+FJmcet6zYpZS58N2DgJIpEdJBdKL62LwLR/vIF0TQrlQ6s5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707434082; c=relaxed/simple; bh=NETfvnw1ab2cyP+I0JYT3vCjGI4smKavYXYp7OlXQfg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lfkv0VdWa0EYUerzs6Zf+OsOalABZ2hGO5zopv5Z4sGnaNbJAHKcD68HDsOOsoyp1L8QEL/VNeog2v4saSDBKnCrXaDa9lE1akDIGhhBovteODoJTiaTUdCfHn5PNvjWULSloXk1veRVsTkBJ6GKRCJtXpgubSzHaV3bTn12z7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=RbsmGQXF; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 418MhkpW026726; Thu, 8 Feb 2024 23:14:26 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=o+wRszxk0RVAQ49EubcS 3o6BAod/YEpz+w8A12Os+Eg=; b=RbsmGQXFVzmjoNLNl5ewYhHHaLuLmMw9BHfE ooxs8MEytIb2nGVBsjAdwPpI3fShZJ/6MIeCsCBjxechY3l5K99Eafgp/r6yLBs0 9n2+eZUnZANST2cqYj4LzgGYYzeNehNAh7w9sL98OyGyFBcZgv6v+nsCHMJuIZQ8 6Pv8dCS2yKpmFqazAGUPAjTOrXw6SAWf0l0NNEZVMVzXjKTgkC77SwZbc4ByvIeP ekOak0UuXK6vjI6A3kSz7if+H8zJyb0w3q/VQvJjTw/FrLAgGw5a3hqEBHt00t8y aeni2EcKyUxLcAgAM3XgBq5GriIQBxPwOI4fPEbWpQc6n6myQw== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3w4pavjs0c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 23:14:25 +0000 (GMT) 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 418NEO0H013170 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 8 Feb 2024 23:14:24 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.40; Thu, 8 Feb 2024 15:14:24 -0800 From: Wesley Cheng <quic_wcheng@quicinc.com> To: <srinivas.kandagatla@linaro.org>, <mathias.nyman@intel.com>, <perex@perex.cz>, <conor+dt@kernel.org>, <corbet@lwn.net>, <lgirdwood@gmail.com>, <andersson@kernel.org>, <krzysztof.kozlowski+dt@linaro.org>, <gregkh@linuxfoundation.org>, <Thinh.Nguyen@synopsys.com>, <broonie@kernel.org>, <bgoswami@quicinc.com>, <tiwai@suse.com>, <robh+dt@kernel.org>, <konrad.dybcio@linaro.org> CC: <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>, <linux-sound@vger.kernel.org>, <linux-usb@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>, <linux-doc@vger.kernel.org>, <alsa-devel@alsa-project.org>, Wesley Cheng <quic_wcheng@quicinc.com> Subject: [PATCH v14 32/53] ALSA: usb-audio: Check for support for requested audio format Date: Thu, 8 Feb 2024 15:13:45 -0800 Message-ID: <20240208231406.27397-33-quic_wcheng@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240208231406.27397-1-quic_wcheng@quicinc.com> References: <20240208231406.27397-1-quic_wcheng@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) 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: Ks6BwNx3ChFFUf7KjWAN8kNc42jvynxW X-Proofpoint-GUID: Ks6BwNx3ChFFUf7KjWAN8kNc42jvynxW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_11,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 bulkscore=0 adultscore=0 clxscore=1015 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402080131 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790375402314776206 X-GMAIL-MSGID: 1790375402314776206 |
Series |
Introduce QC USB SND audio offloading support
|
|
Commit Message
Wesley Cheng
Feb. 8, 2024, 11:13 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 when playback is
initiated by the ASoC USB backend path.
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
---
sound/usb/card.c | 31 +++++++++++++++++++++++++++++++
sound/usb/card.h | 11 +++++++++++
2 files changed, 42 insertions(+)
Comments
On Fri, 09 Feb 2024 00:13:45 +0100, 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 when playback is > initiated by the ASoC USB backend path. > > Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> > --- > sound/usb/card.c | 31 +++++++++++++++++++++++++++++++ > sound/usb/card.h | 11 +++++++++++ > 2 files changed, 42 insertions(+) > > diff --git a/sound/usb/card.c b/sound/usb/card.c > index 7dc8007ba839..1ad99a462038 100644 > --- a/sound/usb/card.c > +++ b/sound/usb/card.c > @@ -155,6 +155,37 @@ 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; > + struct snd_usb_stream *as; > + > + /* > + * Register mutex is held when populating and clearing usb_chip > + * array. > + */ > + guard(mutex)(®ister_mutex); > + chip = usb_chip[card_idx]; > + > + if (chip && enable[card_idx]) { > + list_for_each_entry(as, &chip->pcm_list, list) { > + subs = &as->substream[direction]; > + if (snd_usb_find_substream_format(subs, params)) > + return as; > + } > + } > + > + 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 02e4ea898db5..ed4a664e24e5 100644 > --- a/sound/usb/card.h > +++ b/sound/usb/card.h > @@ -217,4 +217,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) */ The usefulness of ifdef guard here is doubtful, IMO. This header is only for USB-audio driver enablement, and not seen as generic helpers. So, just add the new function declarations without dummy definitions. thanks, Takashi
Hi Takashi, On 2/9/2024 2:42 AM, Takashi Iwai wrote: > On Fri, 09 Feb 2024 00:13:45 +0100, > 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 when playback is >> initiated by the ASoC USB backend path. >> >> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> >> --- >> sound/usb/card.c | 31 +++++++++++++++++++++++++++++++ >> sound/usb/card.h | 11 +++++++++++ >> 2 files changed, 42 insertions(+) >> >> diff --git a/sound/usb/card.c b/sound/usb/card.c >> index 7dc8007ba839..1ad99a462038 100644 >> --- a/sound/usb/card.c >> +++ b/sound/usb/card.c >> @@ -155,6 +155,37 @@ 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; >> + struct snd_usb_stream *as; >> + >> + /* >> + * Register mutex is held when populating and clearing usb_chip >> + * array. >> + */ >> + guard(mutex)(®ister_mutex); >> + chip = usb_chip[card_idx]; >> + >> + if (chip && enable[card_idx]) { >> + list_for_each_entry(as, &chip->pcm_list, list) { >> + subs = &as->substream[direction]; >> + if (snd_usb_find_substream_format(subs, params)) >> + return as; >> + } >> + } >> + >> + 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 02e4ea898db5..ed4a664e24e5 100644 >> --- a/sound/usb/card.h >> +++ b/sound/usb/card.h >> @@ -217,4 +217,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) */ > > The usefulness of ifdef guard here is doubtful, IMO. This header is > only for USB-audio driver enablement, and not seen as generic > helpers. So, just add the new function declarations without dummy > definitions. > Got it, will remove it. We also have a dependency in place for the qc_audio_offload driver and SND USB AUDIO in the Kconfig. Thanks Wesley Cheng
Hi Takashi, On 2/9/2024 1:34 PM, Wesley Cheng wrote: > Hi Takashi, > > On 2/9/2024 2:42 AM, Takashi Iwai wrote: >> On Fri, 09 Feb 2024 00:13:45 +0100, >> 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 when playback is >>> initiated by the ASoC USB backend path. >>> >>> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> >>> --- >>> sound/usb/card.c | 31 +++++++++++++++++++++++++++++++ >>> sound/usb/card.h | 11 +++++++++++ >>> 2 files changed, 42 insertions(+) >>> >>> diff --git a/sound/usb/card.c b/sound/usb/card.c >>> index 7dc8007ba839..1ad99a462038 100644 >>> --- a/sound/usb/card.c >>> +++ b/sound/usb/card.c >>> @@ -155,6 +155,37 @@ 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; >>> + struct snd_usb_stream *as; >>> + >>> + /* >>> + * Register mutex is held when populating and clearing usb_chip >>> + * array. >>> + */ >>> + guard(mutex)(®ister_mutex); >>> + chip = usb_chip[card_idx]; >>> + >>> + if (chip && enable[card_idx]) { >>> + list_for_each_entry(as, &chip->pcm_list, list) { >>> + subs = &as->substream[direction]; >>> + if (snd_usb_find_substream_format(subs, params)) >>> + return as; >>> + } >>> + } >>> + >>> + 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 02e4ea898db5..ed4a664e24e5 100644 >>> --- a/sound/usb/card.h >>> +++ b/sound/usb/card.h >>> @@ -217,4 +217,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) */ >> >> The usefulness of ifdef guard here is doubtful, IMO. This header is >> only for USB-audio driver enablement, and not seen as generic >> helpers. So, just add the new function declarations without dummy >> definitions. >> > > Got it, will remove it. We also have a dependency in place for the > qc_audio_offload driver and SND USB AUDIO in the Kconfig. > Looking at this again after trying some mixed Kconfig settings. These declarations aren't specific for USB-audio. They are helpers that are exposed to soc usb, so that it can do some basic verification with soc usb before allowing the enable stream to continue. Since the ASoC layer doesn't have insight on what audio profiles are supported by the usb device, this API will ensure that the request profile is supported. Issues are seen when we disable SND USB audio config and enable the ASoC parts. Thanks Wesley Cheng
On Sat, 17 Feb 2024 00:42:18 +0100, Wesley Cheng wrote: > > Hi Takashi, > > On 2/9/2024 1:34 PM, Wesley Cheng wrote: > > Hi Takashi, > > > > On 2/9/2024 2:42 AM, Takashi Iwai wrote: > >> On Fri, 09 Feb 2024 00:13:45 +0100, > >> 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 when playback is > >>> initiated by the ASoC USB backend path. > >>> > >>> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> > >>> --- > >>> sound/usb/card.c | 31 +++++++++++++++++++++++++++++++ > >>> sound/usb/card.h | 11 +++++++++++ > >>> 2 files changed, 42 insertions(+) > >>> > >>> diff --git a/sound/usb/card.c b/sound/usb/card.c > >>> index 7dc8007ba839..1ad99a462038 100644 > >>> --- a/sound/usb/card.c > >>> +++ b/sound/usb/card.c > >>> @@ -155,6 +155,37 @@ 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; > >>> + struct snd_usb_stream *as; > >>> + > >>> + /* > >>> + * Register mutex is held when populating and clearing usb_chip > >>> + * array. > >>> + */ > >>> + guard(mutex)(®ister_mutex); > >>> + chip = usb_chip[card_idx]; > >>> + > >>> + if (chip && enable[card_idx]) { > >>> + list_for_each_entry(as, &chip->pcm_list, list) { > >>> + subs = &as->substream[direction]; > >>> + if (snd_usb_find_substream_format(subs, params)) > >>> + return as; > >>> + } > >>> + } > >>> + > >>> + 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 02e4ea898db5..ed4a664e24e5 100644 > >>> --- a/sound/usb/card.h > >>> +++ b/sound/usb/card.h > >>> @@ -217,4 +217,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) */ > >> > >> The usefulness of ifdef guard here is doubtful, IMO. This header is > >> only for USB-audio driver enablement, and not seen as generic > >> helpers. So, just add the new function declarations without dummy > >> definitions. > >> > > > > Got it, will remove it. We also have a dependency in place for the > > qc_audio_offload driver and SND USB AUDIO in the Kconfig. > > > > Looking at this again after trying some mixed Kconfig settings. These > declarations aren't specific for USB-audio. They are helpers that are > exposed to soc usb, so that it can do some basic verification with soc > usb before allowing the enable stream to continue. Then rather the question is why snd-soc-usb calls those functions *unconditionally*. No matter whether we have dependencies in Kconfig, calling the function means that the callee shall be drug when the corresponding code is running. If it were generic core API stuff such as power-management or ACPI, it'd make sense to define dummy functions without the enablement, as many code may have optional calls. If the API is enabled, it's anyway in the core. If not, it's optional. That'll be fine. OTOH, the stuff you're calling certainly belongs to snd-usb-audio. Even if the call is really optional, it means that you'll have a hard dependency when snd-usb-audio is built, no matter whether you need or not. > Since the ASoC > layer doesn't have insight on what audio profiles are supported by the > usb device, this API will ensure that the request profile is > supported. > > Issues are seen when we disable SND USB audio config and enable the > ASoC parts. If snd-usb-audio is disabled, what snd-soc-usb would serve at all? Does it still make sense to keep it enabled? That said, the statement above (building snd-soc-usb without snd-usb-audio) looks already dubious; isn't it better to have a proper dependency in Kconfig, instead? thanks, Takashi
Hi Takashi, On 2/17/2024 2:08 AM, Takashi Iwai wrote: > On Sat, 17 Feb 2024 00:42:18 +0100, > Wesley Cheng wrote: >> >> Hi Takashi, >> >> On 2/9/2024 1:34 PM, Wesley Cheng wrote: >>> Hi Takashi, >>> >>> On 2/9/2024 2:42 AM, Takashi Iwai wrote: >>>> On Fri, 09 Feb 2024 00:13:45 +0100, >>>> 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 when playback is >>>>> initiated by the ASoC USB backend path. >>>>> >>>>> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> >>>>> --- >>>>> sound/usb/card.c | 31 +++++++++++++++++++++++++++++++ >>>>> sound/usb/card.h | 11 +++++++++++ >>>>> 2 files changed, 42 insertions(+) >>>>> >>>>> diff --git a/sound/usb/card.c b/sound/usb/card.c >>>>> index 7dc8007ba839..1ad99a462038 100644 >>>>> --- a/sound/usb/card.c >>>>> +++ b/sound/usb/card.c >>>>> @@ -155,6 +155,37 @@ 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; >>>>> + struct snd_usb_stream *as; >>>>> + >>>>> + /* >>>>> + * Register mutex is held when populating and clearing usb_chip >>>>> + * array. >>>>> + */ >>>>> + guard(mutex)(®ister_mutex); >>>>> + chip = usb_chip[card_idx]; >>>>> + >>>>> + if (chip && enable[card_idx]) { >>>>> + list_for_each_entry(as, &chip->pcm_list, list) { >>>>> + subs = &as->substream[direction]; >>>>> + if (snd_usb_find_substream_format(subs, params)) >>>>> + return as; >>>>> + } >>>>> + } >>>>> + >>>>> + 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 02e4ea898db5..ed4a664e24e5 100644 >>>>> --- a/sound/usb/card.h >>>>> +++ b/sound/usb/card.h >>>>> @@ -217,4 +217,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) */ >>>> >>>> The usefulness of ifdef guard here is doubtful, IMO. This header is >>>> only for USB-audio driver enablement, and not seen as generic >>>> helpers. So, just add the new function declarations without dummy >>>> definitions. >>>> >>> >>> Got it, will remove it. We also have a dependency in place for the >>> qc_audio_offload driver and SND USB AUDIO in the Kconfig. >>> >> >> Looking at this again after trying some mixed Kconfig settings. These >> declarations aren't specific for USB-audio. They are helpers that are >> exposed to soc usb, so that it can do some basic verification with soc >> usb before allowing the enable stream to continue. > > Then rather the question is why snd-soc-usb calls those functions > *unconditionally*. No matter whether we have dependencies in Kconfig, > calling the function means that the callee shall be drug when the > corresponding code is running. > > If it were generic core API stuff such as power-management or ACPI, > it'd make sense to define dummy functions without the enablement, as > many code may have optional calls. If the API is enabled, it's anyway > in the core. If not, it's optional. That'll be fine. > > OTOH, the stuff you're calling certainly belongs to snd-usb-audio. > Even if the call is really optional, it means that you'll have a hard > dependency when snd-usb-audio is built, no matter whether you need or > not. > >> Since the ASoC >> layer doesn't have insight on what audio profiles are supported by the >> usb device, this API will ensure that the request profile is >> supported. >> >> Issues are seen when we disable SND USB audio config and enable the >> ASoC parts. > > If snd-usb-audio is disabled, what snd-soc-usb would serve at all? > Does it still make sense to keep it enabled? > That said, the statement above (building snd-soc-usb without > snd-usb-audio) looks already dubious; isn't it better to have a proper > dependency in Kconfig, instead? > Ok, took a look at it a bit more and should have gotten all the dependencies addressed through Kconfigs. Thanks for the review comments and feedback. Thanks Wesley Cheng
diff --git a/sound/usb/card.c b/sound/usb/card.c index 7dc8007ba839..1ad99a462038 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -155,6 +155,37 @@ 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; + struct snd_usb_stream *as; + + /* + * Register mutex is held when populating and clearing usb_chip + * array. + */ + guard(mutex)(®ister_mutex); + chip = usb_chip[card_idx]; + + if (chip && enable[card_idx]) { + list_for_each_entry(as, &chip->pcm_list, list) { + subs = &as->substream[direction]; + if (snd_usb_find_substream_format(subs, params)) + return as; + } + } + + 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 02e4ea898db5..ed4a664e24e5 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -217,4 +217,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 */