Skip to content

Commit fed2436

Browse files
committed
ASoC: SOF: ipc4-topology: Update the pipeline_params of prepared modules
If the module in path has been already prepared on a branch type of topology, where the branching happens downstream: A1--> A2 ---> B1 --> B2 ... B-branch |-> C1 --> C2 ... C-branch In this case if B-branch is started then A1/A2 is prepared, but when C-branch starts we still need to refine the parameters up to C1 to arrive with a correct params to configure C1. This branching can happen with copiers process modules. Signed-off-by: Peter Ujfalusi <[email protected]>
1 parent 3d555f8 commit fed2436

File tree

2 files changed

+91
-5
lines changed

2 files changed

+91
-5
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 90 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,10 +2007,57 @@ static void sof_ipc4_host_config(struct snd_sof_dev *sdev, struct snd_sof_widget
20072007
}
20082008

20092009
static int
2010-
sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
2011-
struct snd_pcm_hw_params *fe_params,
2012-
struct snd_sof_platform_stream_params *platform_params,
2013-
struct snd_pcm_hw_params *pipeline_params, int dir)
2010+
sof_ipc4_copier_module_update_params(struct snd_sof_widget *swidget,
2011+
struct snd_pcm_hw_params *pipeline_params)
2012+
{
2013+
struct snd_soc_component *scomp = swidget->scomp;
2014+
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
2015+
struct sof_ipc4_copier_data *copier_data;
2016+
struct sof_ipc4_copier *ipc4_copier;
2017+
2018+
switch (swidget->id) {
2019+
case snd_soc_dapm_aif_in:
2020+
case snd_soc_dapm_aif_out:
2021+
case snd_soc_dapm_buffer:
2022+
ipc4_copier = swidget->private;
2023+
copier_data = &ipc4_copier->data;
2024+
break;
2025+
case snd_soc_dapm_dai_in:
2026+
case snd_soc_dapm_dai_out:
2027+
{
2028+
struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget;
2029+
struct sof_ipc4_pipeline *pipeline = pipe_widget->private;
2030+
struct snd_sof_dai *dai;
2031+
2032+
if (pipeline->use_chain_dma)
2033+
return 0;
2034+
2035+
dai = swidget->private;
2036+
2037+
ipc4_copier = (struct sof_ipc4_copier *)dai->private;
2038+
copier_data = &ipc4_copier->data;
2039+
2040+
break;
2041+
}
2042+
default:
2043+
dev_err(sdev->dev, "unsupported type %d for copier %s",
2044+
swidget->id, swidget->widget->name);
2045+
return -EINVAL;
2046+
}
2047+
2048+
/* modify the input params for the next widget */
2049+
return sof_ipc4_update_hw_params(sdev, pipeline_params,
2050+
&copier_data->out_format,
2051+
BIT(SNDRV_PCM_HW_PARAM_FORMAT) |
2052+
BIT(SNDRV_PCM_HW_PARAM_CHANNELS) |
2053+
BIT(SNDRV_PCM_HW_PARAM_RATE));
2054+
}
2055+
2056+
static int
2057+
_sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
2058+
struct snd_pcm_hw_params *fe_params,
2059+
struct snd_sof_platform_stream_params *platform_params,
2060+
struct snd_pcm_hw_params *pipeline_params, int dir)
20142061
{
20152062
struct sof_ipc4_available_audio_format *available_fmt;
20162063
struct snd_soc_component *scomp = swidget->scomp;
@@ -2463,6 +2510,21 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
24632510
return 0;
24642511
}
24652512

2513+
static int
2514+
sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
2515+
struct snd_pcm_hw_params *fe_params,
2516+
struct snd_sof_platform_stream_params *platform_params,
2517+
struct snd_pcm_hw_params *pipeline_params, int dir)
2518+
{
2519+
if (swidget->prepared)
2520+
return sof_ipc4_copier_module_update_params(swidget,
2521+
pipeline_params);
2522+
2523+
return _sof_ipc4_prepare_copier_module(swidget, fe_params,
2524+
platform_params, pipeline_params,
2525+
dir);
2526+
}
2527+
24662528
static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget,
24672529
struct snd_pcm_hw_params *fe_params,
24682530
struct snd_sof_platform_stream_params *platform_params,
@@ -2476,6 +2538,10 @@ static int sof_ipc4_prepare_gain_module(struct snd_sof_widget *swidget,
24762538
u32 out_ref_rate, out_ref_channels, out_ref_valid_bits, out_ref_type;
24772539
int input_fmt_index, output_fmt_index;
24782540

2541+
/* This cannot happen */
2542+
if (unlikely(swidget->prepared))
2543+
return 0;
2544+
24792545
input_fmt_index = sof_ipc4_init_input_audio_fmt(sdev, swidget,
24802546
&gain->data.base_config,
24812547
pipeline_params,
@@ -2521,6 +2587,10 @@ static int sof_ipc4_prepare_mixer_module(struct snd_sof_widget *swidget,
25212587
u32 out_ref_rate, out_ref_channels, out_ref_valid_bits, out_ref_type;
25222588
int input_fmt_index, output_fmt_index;
25232589

2590+
/* Already prepared, nothing to do */
2591+
if (swidget->prepared)
2592+
return 0;
2593+
25242594
input_fmt_index = sof_ipc4_init_input_audio_fmt(sdev, swidget,
25252595
&mixer->base_config,
25262596
pipeline_params,
@@ -2567,6 +2637,10 @@ static int sof_ipc4_prepare_src_module(struct snd_sof_widget *swidget,
25672637
u32 out_ref_rate, out_ref_channels, out_ref_valid_bits, out_ref_type;
25682638
int output_fmt_index, input_fmt_index;
25692639

2640+
/* This cannot happen */
2641+
if (unlikely(swidget->prepared))
2642+
return 0;
2643+
25702644
input_fmt_index = sof_ipc4_init_input_audio_fmt(sdev, swidget,
25712645
&src->data.base_config,
25722646
pipeline_params,
@@ -2718,6 +2792,18 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27182792
int input_fmt_index = 0;
27192793
int ret;
27202794

2795+
if (swidget->prepared) {
2796+
if (!available_fmt->num_output_formats)
2797+
return 0;
2798+
2799+
/* modify the pipeline params with the output format */
2800+
return sof_ipc4_update_hw_params(sdev, pipeline_params,
2801+
&process->output_format,
2802+
BIT(SNDRV_PCM_HW_PARAM_FORMAT) |
2803+
BIT(SNDRV_PCM_HW_PARAM_CHANNELS) |
2804+
BIT(SNDRV_PCM_HW_PARAM_RATE));
2805+
}
2806+
27212807
input_fmt_index = sof_ipc4_init_input_audio_fmt(sdev, swidget,
27222808
&process->base_config,
27232809
pipeline_params,

sound/soc/sof/sof-audio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ sof_prepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget
458458
if (!widget_ops)
459459
return 0;
460460

461-
if (!swidget || !widget_ops[widget->id].ipc_prepare || swidget->prepared)
461+
if (!swidget || !widget_ops[widget->id].ipc_prepare)
462462
goto sink_prepare;
463463

464464
/* prepare the source widget */

0 commit comments

Comments
 (0)