Skip to content

Commit 56ecc16

Browse files
ranj063broonie
authored andcommitted
ASoC: SOF: ipc4-topology: Fix the output reference params for SRC
For playback, the SRC sink rate must be configured based on the requested output format which is restricted to only handle DAI's that support a single audio format for now. For capture, the SRC module should convert the rate to match the rate requested by the PCM hw_params. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20230821113629.5017-3-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent ef24388 commit 56ecc16

1 file changed

Lines changed: 30 additions & 10 deletions

File tree

sound/soc/sof/ipc4-topology.c

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,19 +1839,39 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
18391839
struct sof_ipc4_src *src = swidget->private;
18401840
struct sof_ipc4_available_audio_format *available_fmt = &src->available_fmt;
18411841
struct sof_ipc4_audio_format *out_audio_fmt;
1842-
struct sof_ipc4_audio_format *in_fmt;
1842+
struct sof_ipc4_audio_format *in_audio_fmt;
18431843
u32 out_ref_rate, out_ref_channels, out_ref_valid_bits;
1844-
int ret, output_format_index;
1844+
int output_format_index, input_format_index;
18451845

1846-
ret = sof_ipc4_init_input_audio_fmt(sdev, swidget, &src->base_config,
1847-
pipeline_params, available_fmt);
1848-
if (ret < 0)
1849-
return ret;
1846+
input_format_index = sof_ipc4_init_input_audio_fmt(sdev, swidget, &src->base_config,
1847+
pipeline_params, available_fmt);
1848+
if (input_format_index < 0)
1849+
return input_format_index;
18501850

1851-
in_fmt = &available_fmt->input_pin_fmts[ret].audio_fmt;
1852-
out_ref_rate = in_fmt->sampling_frequency;
1853-
out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(in_fmt->fmt_cfg);
1854-
out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(in_fmt->fmt_cfg);
1851+
/*
1852+
* For playback, the SRC sink rate will be configured based on the requested output
1853+
* format, which is restricted to only deal with DAI's with a single format for now.
1854+
*/
1855+
if (dir == SNDRV_PCM_STREAM_PLAYBACK && available_fmt->num_output_formats > 1) {
1856+
dev_err(sdev->dev, "Invalid number of output formats: %d for SRC %s\n",
1857+
available_fmt->num_output_formats, swidget->widget->name);
1858+
return -EINVAL;
1859+
}
1860+
1861+
/*
1862+
* SRC does not perform format conversion, so the output channels and valid bit depth must
1863+
* be the same as that of the input.
1864+
*/
1865+
in_audio_fmt = &available_fmt->input_pin_fmts[input_format_index].audio_fmt;
1866+
out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(in_audio_fmt->fmt_cfg);
1867+
out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(in_audio_fmt->fmt_cfg);
1868+
1869+
/*
1870+
* For capture, the SRC module should convert the rate to match the rate requested by the
1871+
* PCM hw_params. Set the reference params based on the fe_params unconditionally as it
1872+
* will be ignored for playback anyway.
1873+
*/
1874+
out_ref_rate = params_rate(fe_params);
18551875

18561876
output_format_index = sof_ipc4_init_output_audio_fmt(sdev, &src->base_config,
18571877
available_fmt, out_ref_rate,

0 commit comments

Comments
 (0)