Commit 523042f6 authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Mark Brown

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
parent 4c7873d6
...@@ -1028,6 +1028,26 @@ static int sof_ipc4_update_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_hw ...@@ -1028,6 +1028,26 @@ static int sof_ipc4_update_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_hw
return 0; 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, static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev,
struct snd_sof_widget *swidget, struct snd_sof_widget *swidget,
struct sof_ipc4_base_module_cfg *base_config, struct sof_ipc4_base_module_cfg *base_config,
...@@ -1110,15 +1130,7 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, ...@@ -1110,15 +1130,7 @@ 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 */ return sof_ipc4_init_output_audio_fmt(sdev, base_config, available_fmt, i);
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;
} }
static void sof_ipc4_unprepare_copier_module(struct snd_sof_widget *swidget) static void sof_ipc4_unprepare_copier_module(struct snd_sof_widget *swidget)
......
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