Re: [PATCH v24 17/34] ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6

From: Pierre-Louis Bossart
Date: Thu Aug 01 2024 - 05:15:09 EST





> +static int q6usb_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params,
> + struct snd_soc_dai *dai)
> +{
> + 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);
> + struct q6afe_port *q6usb_afe;
> + struct snd_soc_usb_device *sdev;
> + int ret;
> +
> + /* No active chip index */
> + if (list_empty(&data->devices))
> + return -EINVAL;
> +
> + mutex_lock(&data->mutex);
> + sdev = list_last_entry(&data->devices, struct snd_soc_usb_device, list);
> +
> + q6usb_afe = q6afe_port_get_from_id(cpu_dai->dev, USB_RX);
> + if (IS_ERR(q6usb_afe))
> + goto out;
> +
> + /* Notify audio DSP about the devices being offloaded */
> + ret = afe_port_send_usb_dev_param(q6usb_afe, sdev->card_idx,
> + sdev->pcm_idx);
> +
> +out:
> + mutex_unlock(&data->mutex);
> +
> + return ret;
> +}

Humm, multiple questions here

a) is this intentional that the params are not used in a hw_params routine?

b) if yes, could this be replaced by a .prepare callback

c) along the same lines as b), is suspend-resume during playback
supported? Usually this is handled with a .prepare callback to restore
connections.
> +
> +static const struct snd_soc_dai_ops q6usb_ops = {
> + .hw_params = q6usb_hw_params,
> +};