Skip to content

Commit 791b32e

Browse files
committed
ASoC: SOF: ipc4-topology: Correct the process module's output lookup
The process module can change different parameters in the audio path and this change has to be properly evaluated and applied. In case of playback we are converting from multiple input formats to a single format (or just passing through without change), the output format lookup must be based on the input format. In case of capture, we are converting from a single input format to a format which is to be passed to the FE, we need to use the input parameters and the FE parameters to be able to find the correct format: for those parameters that are modified by the module instance we need to use the FE parameter while for the rest we use the input parameters. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent bd7f52a commit 791b32e

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,23 +2750,53 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27502750
if (available_fmt->num_output_formats) {
27512751
struct sof_ipc4_audio_format *in_fmt;
27522752
struct sof_ipc4_pin_format *pin_fmt;
2753-
u32 out_ref_rate, out_ref_channels;
2754-
int out_ref_valid_bits, out_ref_type;
2753+
u32 ref_rate, ref_channels;
2754+
int ref_valid_bits, ref_type;
27552755

2756+
/*
2757+
* The process module can change parameters and their operation
2758+
* depends on the direction:
2759+
* Playback: typically they have single output format. This is
2760+
* to 'force' the conversion from input to output.
2761+
* Use the input format as reference since the single
2762+
* format is going to be picked.
2763+
* Capture: typically they have multiple output formats to
2764+
* convert from dai (input) to FE (output) parameters.
2765+
* Use the input format as base and replace the param
2766+
* which is changed by the module with the FE parameter
2767+
* Reason: we can have module which changes the
2768+
* parameters in path, we cannot use the full
2769+
* FE param set for the module output lookup.
2770+
*/
27562771
in_fmt = &available_fmt->input_pin_fmts[input_fmt_index].audio_fmt;
27572772

2758-
out_ref_rate = in_fmt->sampling_frequency;
2759-
out_ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(in_fmt->fmt_cfg);
2760-
out_ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(in_fmt->fmt_cfg);
2761-
out_ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(in_fmt->fmt_cfg);
2762-
2773+
ref_rate = in_fmt->sampling_frequency;
2774+
ref_channels = SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(in_fmt->fmt_cfg);
2775+
ref_valid_bits = SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(in_fmt->fmt_cfg);
2776+
ref_type = SOF_IPC4_AUDIO_FORMAT_CFG_SAMPLE_TYPE(in_fmt->fmt_cfg);
2777+
2778+
if (dir == SNDRV_PCM_STREAM_CAPTURE) {
2779+
if (available_fmt->changed_params & BIT(SNDRV_PCM_HW_PARAM_RATE))
2780+
ref_rate = params_rate(fe_params);
2781+
if (available_fmt->changed_params & BIT(SNDRV_PCM_HW_PARAM_CHANNELS))
2782+
ref_channels = params_channels(fe_params);
2783+
if (available_fmt->changed_params & BIT(SNDRV_PCM_HW_PARAM_FORMAT)) {
2784+
ref_valid_bits = sof_ipc4_get_valid_bits(sdev, fe_params);
2785+
if (ref_valid_bits < 0)
2786+
return ref_valid_bits;
2787+
2788+
ref_type = sof_ipc4_get_sample_type(sdev, fe_params);
2789+
if (ref_type < 0)
2790+
return ref_type;
2791+
}
2792+
}
27632793
output_fmt_index = sof_ipc4_init_output_audio_fmt(sdev, swidget,
27642794
&process->base_config,
27652795
available_fmt,
2766-
out_ref_rate,
2767-
out_ref_channels,
2768-
out_ref_valid_bits,
2769-
out_ref_type);
2796+
ref_rate,
2797+
ref_channels,
2798+
ref_valid_bits,
2799+
ref_type);
27702800
if (output_fmt_index < 0)
27712801
return output_fmt_index;
27722802

@@ -2780,9 +2810,7 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
27802810
/* modify the pipeline params with the output format */
27812811
ret = sof_ipc4_update_hw_params(sdev, pipeline_params,
27822812
&process->output_format,
2783-
BIT(SNDRV_PCM_HW_PARAM_FORMAT) |
2784-
BIT(SNDRV_PCM_HW_PARAM_CHANNELS) |
2785-
BIT(SNDRV_PCM_HW_PARAM_RATE));
2813+
available_fmt->changed_params);
27862814
if (ret)
27872815
return ret;
27882816
}

0 commit comments

Comments
 (0)