summaryrefslogtreecommitdiffstats
path: root/sound/soc/sof/ipc4-topology.c
diff options
context:
space:
mode:
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>2023-05-15 13:33:29 +0300
committerMark Brown <broonie@kernel.org>2023-05-15 20:12:51 +0900
commit523042f63febca24cbf9cf83729044c3dbaa9706 (patch)
treeda6f83fe702261ce240564a00f35f3f371cf644e /sound/soc/sof/ipc4-topology.c
parent4c7873d60958ed1895b6552fb1e15fa2bbf06cad (diff)
downloadlinux-stable-523042f63febca24cbf9cf83729044c3dbaa9706.tar.gz
linux-stable-523042f63febca24cbf9cf83729044c3dbaa9706.tar.bz2
linux-stable-523042f63febca24cbf9cf83729044c3dbaa9706.zip
ASoC: SOF: ipc4-topology: Add a helper function for output format selection
Add a helper function to select the output format. 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-3-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org
Diffstat (limited to 'sound/soc/sof/ipc4-topology.c')
-rw-r--r--sound/soc/sof/ipc4-topology.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c
index 3e59551b2367..7c448342ff92 100644
--- a/sound/soc/sof/ipc4-topology.c
+++ b/sound/soc/sof/ipc4-topology.c
@@ -1028,6 +1028,26 @@ static int sof_ipc4_update_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_hw
return 0;
}
+static int sof_ipc4_init_output_audio_fmt(struct snd_sof_dev *sdev,
+ struct sof_ipc4_base_module_cfg *base_config,
+ struct sof_ipc4_available_audio_format *available_fmt,
+ int input_audio_format_index)
+{
+ int i;
+
+ /* pick the only available output format */
+ if (available_fmt->num_output_formats == 1)
+ i = 0;
+ else
+ i = input_audio_format_index;
+
+ if (available_fmt->num_output_formats && i < available_fmt->num_output_formats)
+ base_config->obs = available_fmt->output_pin_fmts[i].buffer_size;
+
+ /* Return the index of the chosen output format */
+ return i;
+}
+
static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev,
struct snd_sof_widget *swidget,
struct sof_ipc4_base_module_cfg *base_config,
@@ -1110,15 +1130,7 @@ in_fmt:
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)
- base_config->obs = available_fmt->output_pin_fmts[i].buffer_size;
-
- /* Return the index of the matched format */
- return i;
+ return sof_ipc4_init_output_audio_fmt(sdev, base_config, available_fmt, i);
}
static void sof_ipc4_unprepare_copier_module(struct snd_sof_widget *swidget)