Commit a2e07c33 authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Mark Brown

ASoC: SOF: ipc4-topology: Move the call to init output format

In preparation for changing the logic for input/output format selection,
move the call to sof_ipc4_init_output_audio_fmt() into the individual
widget prepare ops.

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-4-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org
parent 523042f6
...@@ -1130,7 +1130,7 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, ...@@ -1130,7 +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);
} }
return sof_ipc4_init_output_audio_fmt(sdev, base_config, available_fmt, i); 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)
...@@ -1375,6 +1375,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, ...@@ -1375,6 +1375,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
int ipc_size, ret; int ipc_size, ret;
u32 deep_buffer_dma_ms = 0; u32 deep_buffer_dma_ms = 0;
u32 format_list_count; u32 format_list_count;
int output_fmt_index;
dev_dbg(sdev->dev, "copier %s, type %d", swidget->widget->name, swidget->id); dev_dbg(sdev->dev, "copier %s, type %d", swidget->widget->name, swidget->id);
...@@ -1518,6 +1519,9 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, ...@@ -1518,6 +1519,9 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
if (ret < 0) if (ret < 0)
return ret; return ret;
output_fmt_index = sof_ipc4_init_output_audio_fmt(sdev, &copier_data->base_config,
available_fmt, ret);
/* /*
* Set the output format. Current topology defines pin 0 input and output formats in pairs. * Set the output format. Current topology defines pin 0 input and output formats in pairs.
* This assumes that the pin 0 formats are defined before all other pins. * This assumes that the pin 0 formats are defined before all other pins.
...@@ -1525,10 +1529,11 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget, ...@@ -1525,10 +1529,11 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
* input format. This logic will need to be updated when the format definitions * input format. This logic will need to be updated when the format definitions
* in topology change. * in topology change.
*/ */
memcpy(&copier_data->out_format, &available_fmt->output_pin_fmts[ret].audio_fmt, memcpy(&copier_data->out_format,
&available_fmt->output_pin_fmts[output_fmt_index].audio_fmt,
sizeof(struct sof_ipc4_audio_format)); sizeof(struct sof_ipc4_audio_format));
dev_dbg(sdev->dev, "Output audio format for %s\n", swidget->widget->name); dev_dbg(sdev->dev, "Output audio format for %s\n", swidget->widget->name);
sof_ipc4_dbg_audio_format(sdev->dev, &available_fmt->output_pin_fmts[ret], 1); sof_ipc4_dbg_audio_format(sdev->dev, &available_fmt->output_pin_fmts[output_fmt_index], 1);
switch (swidget->id) { switch (swidget->id) {
case snd_soc_dapm_dai_in: case snd_soc_dapm_dai_in:
...@@ -1694,6 +1699,8 @@ static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget, ...@@ -1694,6 +1699,8 @@ static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget,
if (ret < 0) if (ret < 0)
return ret; return ret;
sof_ipc4_init_output_audio_fmt(sdev, &gain->base_config, available_fmt, ret);
/* update pipeline memory usage */ /* update pipeline memory usage */
sof_ipc4_update_pipeline_mem_usage(sdev, swidget, &gain->base_config); sof_ipc4_update_pipeline_mem_usage(sdev, swidget, &gain->base_config);
...@@ -1718,6 +1725,8 @@ static int sof_ipc4_prepare_mixer_module(struct snd_sof_widget *swidget, ...@@ -1718,6 +1725,8 @@ static int sof_ipc4_prepare_mixer_module(struct snd_sof_widget *swidget,
if (ret < 0) if (ret < 0)
return ret; return ret;
sof_ipc4_init_output_audio_fmt(sdev, &mixer->base_config, available_fmt, ret);
/* update pipeline memory usage */ /* update pipeline memory usage */
sof_ipc4_update_pipeline_mem_usage(sdev, swidget, &mixer->base_config); sof_ipc4_update_pipeline_mem_usage(sdev, swidget, &mixer->base_config);
...@@ -1743,6 +1752,8 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget, ...@@ -1743,6 +1752,8 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
if (ret < 0) if (ret < 0)
return ret; return ret;
sof_ipc4_init_output_audio_fmt(sdev, &src->base_config, available_fmt, ret);
/* update pipeline memory usage */ /* update pipeline memory usage */
sof_ipc4_update_pipeline_mem_usage(sdev, swidget, &src->base_config); sof_ipc4_update_pipeline_mem_usage(sdev, swidget, &src->base_config);
...@@ -1842,6 +1853,7 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget, ...@@ -1842,6 +1853,7 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
struct sof_ipc4_process *process = swidget->private; struct sof_ipc4_process *process = swidget->private;
struct sof_ipc4_available_audio_format *available_fmt = &process->available_fmt; struct sof_ipc4_available_audio_format *available_fmt = &process->available_fmt;
void *cfg = process->ipc_config_data; void *cfg = process->ipc_config_data;
int output_fmt_index;
int ret; int ret;
ret = sof_ipc4_init_audio_fmt(sdev, swidget, &process->base_config, ret = sof_ipc4_init_audio_fmt(sdev, swidget, &process->base_config,
...@@ -1851,10 +1863,15 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget, ...@@ -1851,10 +1863,15 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
if (ret < 0) if (ret < 0)
return ret; return ret;
output_fmt_index = sof_ipc4_init_output_audio_fmt(sdev, &process->base_config,
available_fmt, ret);
/* copy Pin 0 output format */ /* copy Pin 0 output format */
if (available_fmt->num_output_formats && ret < available_fmt->num_output_formats && if (available_fmt->num_output_formats &&
!available_fmt->output_pin_fmts[ret].pin_index) { output_fmt_index < available_fmt->num_output_formats &&
memcpy(&process->output_format, &available_fmt->output_pin_fmts[ret].audio_fmt, !available_fmt->output_pin_fmts[output_fmt_index].pin_index) {
memcpy(&process->output_format,
&available_fmt->output_pin_fmts[output_fmt_index].audio_fmt,
sizeof(struct sof_ipc4_audio_format)); sizeof(struct sof_ipc4_audio_format));
/* modify the pipeline params with the pin 0 output format */ /* modify the pipeline params with the pin 0 output format */
......
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