Commit 4c7873d6 authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Mark Brown

ASoC: SOF: ipc4-topology: Handle input/output audio format special case

When there is only one input/output format specified in topology, there
is no need to search for a matching format, simply pick the available
one. This is in preparation to modify and split the selection logic for
the input and output audio formats.

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
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com
Link: https://lore.kernel.org/r/20230515103336.16132-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org
parent 1946dda4
...@@ -1039,7 +1039,7 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, ...@@ -1039,7 +1039,7 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev,
u32 channels; u32 channels;
u32 rate; u32 rate;
int sample_valid_bits; int sample_valid_bits;
int i; int i = 0;
if (!pin_fmts) { if (!pin_fmts) {
dev_err(sdev->dev, "no reference formats for %s\n", swidget->widget->name); dev_err(sdev->dev, "no reference formats for %s\n", swidget->widget->name);
...@@ -1066,6 +1066,10 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, ...@@ -1066,6 +1066,10 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev,
return -EINVAL; return -EINVAL;
} }
/* pick the only available input format */
if (available_fmt->num_input_formats == 1)
goto in_fmt;
/* /*
* Search supported audio formats with pin index 0 to match rate, channels ,and * Search supported audio formats with pin index 0 to match rate, channels ,and
* sample_valid_bytes from runtime params * sample_valid_bytes from runtime params
...@@ -1093,6 +1097,7 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, ...@@ -1093,6 +1097,7 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev,
return -EINVAL; return -EINVAL;
} }
in_fmt:
/* copy input format */ /* copy input format */
if (available_fmt->num_input_formats && i < available_fmt->num_input_formats) { if (available_fmt->num_input_formats && i < available_fmt->num_input_formats) {
memcpy(&base_config->audio_fmt, &available_fmt->input_pin_fmts[i].audio_fmt, memcpy(&base_config->audio_fmt, &available_fmt->input_pin_fmts[i].audio_fmt,
...@@ -1105,6 +1110,10 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, ...@@ -1105,6 +1110,10 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev,
sof_ipc4_dbg_audio_format(sdev->dev, &available_fmt->input_pin_fmts[i], 1); sof_ipc4_dbg_audio_format(sdev->dev, &available_fmt->input_pin_fmts[i], 1);
} }
/* pick the only available output format */
if (available_fmt->num_output_formats == 1)
i = 0;
if (available_fmt->num_output_formats && i < available_fmt->num_output_formats) if (available_fmt->num_output_formats && i < available_fmt->num_output_formats)
base_config->obs = available_fmt->output_pin_fmts[i].buffer_size; base_config->obs = available_fmt->output_pin_fmts[i].buffer_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment