From fbea2d8dc6c2de65de8a452100d8cf76734418f4 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 30 May 2025 16:14:16 +0300 Subject: [PATCH] ASoC: SOF: ipc4-topology: Always validate the input audio format on fmt init Even if there is a single format supported by the module on it's input, it must be validated that it is matching with the reference parameters. The DAI copier's DAI side reference is adjusted to the formats it supports, but modules deep within the path might have incorrect configuration in topology (single format which is not matching with the previous module's output for example). This should be reported as errors and not silently accepted. Signed-off-by: Peter Ujfalusi --- sound/soc/sof/ipc4-topology.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index 3ac61739312455..68091f8bbc6e0c 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -1566,7 +1566,6 @@ static int sof_ipc4_init_input_audio_fmt(struct snd_sof_dev *sdev, u32 channels; u32 rate; u32 type; - bool single_format; int sample_valid_bits; int sample_type; int i = 0; @@ -1576,10 +1575,6 @@ static int sof_ipc4_init_input_audio_fmt(struct snd_sof_dev *sdev, return -EINVAL; } - single_format = sof_ipc4_is_single_format(sdev, pin_fmts, pin_fmts_size); - if (single_format) - goto in_fmt; - sample_valid_bits = sof_ipc4_get_valid_bits(sdev, params); if (sample_valid_bits < 0) return sample_valid_bits; @@ -1604,16 +1599,15 @@ static int sof_ipc4_init_input_audio_fmt(struct snd_sof_dev *sdev, type = sof_ipc4_fmt_cfg_to_type(fmt->fmt_cfg); if (params_rate(params) == rate && params_channels(params) == channels && sample_valid_bits == valid_bits && sample_type == type) - break; + goto in_fmt; } - if (i == pin_fmts_size) { - dev_err(sdev->dev, - "%s: Unsupported audio format: %uHz, %ubit, %u channels, type: %d\n", - __func__, params_rate(params), sample_valid_bits, - params_channels(params), sample_type); - return -EINVAL; - } + dev_err(sdev->dev, + "%s: Unsupported audio format: %uHz, %ubit, %u channels, type: %d\n", + __func__, params_rate(params), sample_valid_bits, + params_channels(params), sample_type); + + return -EINVAL; in_fmt: /* copy input format */