From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
To: lgirdwood@gmail.com, broonie@kernel.org
Cc: linux-sound@vger.kernel.org, kai.vehmanen@linux.intel.com,
yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev,
liam.r.girdwood@intel.com
Subject: [PATCH 2/3] ASoC: SOF: ipc4-topology: Correct the process module's output lookup
Date: Thu, 30 Jul 2026 15:17:28 +0300 [thread overview]
Message-ID: <20260730121729.18673-3-peter.ujfalusi@linux.intel.com> (raw)
In-Reply-To: <20260730121729.18673-1-peter.ujfalusi@linux.intel.com>
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>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com>
---
sound/soc/sof/ipc4-topology.c | 66 +++++++++++++++++++++++++----------
1 file changed, 47 insertions(+), 19 deletions(-)
diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c
index df002e69d2a7..6f9f5325a50b 100644
--- a/sound/soc/sof/ipc4-topology.c
+++ b/sound/soc/sof/ipc4-topology.c
@@ -2863,39 +2863,69 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
if (available_fmt->num_output_formats) {
struct sof_ipc4_audio_format *in_fmt;
struct sof_ipc4_pin_format *pin_fmt;
- u32 out_ref_rate, out_ref_channels;
- int out_ref_valid_bits, out_ref_type;
+ u32 ref_rate, ref_channels;
+ int ref_valid_bits, ref_type;
if (available_fmt->num_input_formats) {
+ /*
+ * The process module can change parameters and their operation
+ * depends on the direction:
+ * Playback: typically they have single output format. This is
+ * to 'force' the conversion from input to output.
+ * Use the input format as reference since the single
+ * format is going to be picked.
+ * Capture: typically they have multiple output formats to
+ * convert from dai (input) to FE (output) parameters.
+ * Use the input format as base and replace the param
+ * which is changed by the module with the FE parameter
+ * Reason: we can have module which changes the
+ * parameters in path, we cannot use the full
+ * FE param set for the module output lookup.
+ */
in_fmt = &available_fmt->input_pin_fmts[input_fmt_index].audio_fmt;
- out_ref_rate = in_fmt->sampling_frequency;
- out_ref_channels =
+ ref_rate = in_fmt->sampling_frequency;
+ ref_channels =
SOF_IPC4_AUDIO_FORMAT_CFG_CHANNELS_COUNT(in_fmt->fmt_cfg);
- out_ref_valid_bits =
+ ref_valid_bits =
SOF_IPC4_AUDIO_FORMAT_CFG_V_BIT_DEPTH(in_fmt->fmt_cfg);
- out_ref_type = sof_ipc4_fmt_cfg_to_type(in_fmt->fmt_cfg);
+ ref_type = sof_ipc4_fmt_cfg_to_type(in_fmt->fmt_cfg);
} else {
/* for modules without input formats, use FE params as reference */
- out_ref_rate = params_rate(fe_params);
- out_ref_channels = params_channels(fe_params);
+ ref_rate = params_rate(fe_params);
+ ref_channels = params_channels(fe_params);
ret = sof_ipc4_get_sample_type(sdev, fe_params);
if (ret < 0)
return ret;
- out_ref_type = (u32)ret;
+ ref_type = (u32)ret;
- out_ref_valid_bits = sof_ipc4_get_valid_bits(sdev, fe_params);
- if (out_ref_valid_bits < 0)
- return out_ref_valid_bits;
+ ref_valid_bits = sof_ipc4_get_valid_bits(sdev, fe_params);
+ if (ref_valid_bits < 0)
+ return ref_valid_bits;
}
+ if (dir == SNDRV_PCM_STREAM_CAPTURE) {
+ if (available_fmt->changed_params & BIT(SNDRV_PCM_HW_PARAM_RATE))
+ ref_rate = params_rate(fe_params);
+ if (available_fmt->changed_params & BIT(SNDRV_PCM_HW_PARAM_CHANNELS))
+ ref_channels = params_channels(fe_params);
+ if (available_fmt->changed_params & BIT(SNDRV_PCM_HW_PARAM_FORMAT)) {
+ ref_valid_bits = sof_ipc4_get_valid_bits(sdev, fe_params);
+ if (ref_valid_bits < 0)
+ return ref_valid_bits;
+
+ ref_type = sof_ipc4_get_sample_type(sdev, fe_params);
+ if (ref_type < 0)
+ return ref_type;
+ }
+ }
output_fmt_index = sof_ipc4_init_output_audio_fmt(sdev, swidget,
&process->base_config,
available_fmt,
- out_ref_rate,
- out_ref_channels,
- out_ref_valid_bits,
- out_ref_type);
+ ref_rate,
+ ref_channels,
+ ref_valid_bits,
+ ref_type);
if (output_fmt_index < 0)
return output_fmt_index;
@@ -2909,9 +2939,7 @@ static int sof_ipc4_prepare_process_module(struct snd_sof_widget *swidget,
/* modify the pipeline params with the output format */
ret = sof_ipc4_update_hw_params(sdev, pipeline_params,
&process->output_format,
- BIT(SNDRV_PCM_HW_PARAM_FORMAT) |
- BIT(SNDRV_PCM_HW_PARAM_CHANNELS) |
- BIT(SNDRV_PCM_HW_PARAM_RATE));
+ available_fmt->changed_params);
if (ret)
return ret;
}
--
2.55.0
next prev parent reply other threads:[~2026-07-30 12:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 12:17 [PATCH 0/3] ASoC: SOF: ipc4-topology: Pipeline params improvements Peter Ujfalusi
2026-07-30 12:17 ` [PATCH 1/3] ASoC: SOF: ipc4-topology: Store the params change between input/output of a module Peter Ujfalusi
2026-07-30 12:17 ` Peter Ujfalusi [this message]
2026-07-30 12:17 ` [PATCH 3/3] ASoC: SOF: ipc4-topology: Update the pipeline_params of prepared modules Peter Ujfalusi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260730121729.18673-3-peter.ujfalusi@linux.intel.com \
--to=peter.ujfalusi@linux.intel.com \
--cc=broonie@kernel.org \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=liam.r.girdwood@intel.com \
--cc=linux-sound@vger.kernel.org \
--cc=pierre-louis.bossart@linux.dev \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.