diff mbox series

[v24,34/34] ASoC: qcom: qdsp6: Ensure PCM format is supported by USB audio device

Message ID 20240801011730.4797-35-quic_wcheng@quicinc.com (mailing list archive)
State Superseded
Headers show
Series Introduce QC USB SND audio offloading support | expand

Commit Message

Wesley Cheng Aug. 1, 2024, 1:17 a.m. UTC
Check for if the PCM format is supported during the hw_params callback.  If
the profile is not supported then the userspace ALSA entity will receive an
error, and can take further action.

Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
---
 sound/soc/qcom/qdsp6/q6usb.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Pierre-Louis Bossart Aug. 1, 2024, 9:04 a.m. UTC | #1
On 8/1/24 03:17, Wesley Cheng wrote:
> Check for if the PCM format is supported during the hw_params callback.  If
> the profile is not supported then the userspace ALSA entity will receive an
> error, and can take further action.
> 
> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
> ---
>  sound/soc/qcom/qdsp6/q6usb.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/sound/soc/qcom/qdsp6/q6usb.c b/sound/soc/qcom/qdsp6/q6usb.c
> index d8f1bb4ec497..9a3fb3cb32b2 100644
> --- a/sound/soc/qcom/qdsp6/q6usb.c
> +++ b/sound/soc/qcom/qdsp6/q6usb.c
> @@ -52,6 +52,7 @@ static int q6usb_hw_params(struct snd_pcm_substream *substream,
>  	struct q6usb_port_data *data = dev_get_drvdata(dai->dev);
>  	struct snd_soc_pcm_runtime *rtd = substream->private_data;
>  	struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
> +	int direction = substream->stream;
>  	struct q6afe_port *q6usb_afe;
>  	struct snd_soc_usb_device *sdev;
>  	int ret;
> @@ -63,6 +64,10 @@ static int q6usb_hw_params(struct snd_pcm_substream *substream,
>  	mutex_lock(&data->mutex);
>  	sdev = list_last_entry(&data->devices, struct snd_soc_usb_device, list);
>  
> +	ret = snd_soc_usb_find_supported_format(sdev->chip_idx, params, direction);
> +	if (ret < 0)
> +		goto out;
> +
>  	q6usb_afe = q6afe_port_get_from_id(cpu_dai->dev, USB_RX);
>  	if (IS_ERR(q6usb_afe))
>  		goto out;

This patch and the previous patch 33 should be added before patch 17,
see comments there.
diff mbox series

Patch

diff --git a/sound/soc/qcom/qdsp6/q6usb.c b/sound/soc/qcom/qdsp6/q6usb.c
index d8f1bb4ec497..9a3fb3cb32b2 100644
--- a/sound/soc/qcom/qdsp6/q6usb.c
+++ b/sound/soc/qcom/qdsp6/q6usb.c
@@ -52,6 +52,7 @@  static int q6usb_hw_params(struct snd_pcm_substream *substream,
 	struct q6usb_port_data *data = dev_get_drvdata(dai->dev);
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
+	int direction = substream->stream;
 	struct q6afe_port *q6usb_afe;
 	struct snd_soc_usb_device *sdev;
 	int ret;
@@ -63,6 +64,10 @@  static int q6usb_hw_params(struct snd_pcm_substream *substream,
 	mutex_lock(&data->mutex);
 	sdev = list_last_entry(&data->devices, struct snd_soc_usb_device, list);
 
+	ret = snd_soc_usb_find_supported_format(sdev->chip_idx, params, direction);
+	if (ret < 0)
+		goto out;
+
 	q6usb_afe = q6afe_port_get_from_id(cpu_dai->dev, USB_RX);
 	if (IS_ERR(q6usb_afe))
 		goto out;