Skip to content

Commit 648fea1

Browse files
Chao Songbroonie
Chao Song
authored andcommitted
ASoC: SOF: ipc4-topology: set copier output format for process module
The copier output pin 0 format is set with module instance initialization, format for additional copier output pin should be set before the pin is used. If a process module is connected to additional copier output pin, the copier output pin format should be set according to the corresponding input pin format of the process module. Signed-off-by: Chao Song <[email protected]> Co-developed-by: Ranjani Sridharan <[email protected]> Signed-off-by: Ranjani Sridharan <[email protected]> Reviewed-by: Péter Ujfalusi <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Reviewed-by: Bard Liao <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Signed-off-by: Peter Ujfalusi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent f9efae9 commit 648fea1

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

sound/soc/sof/ipc4-topology.c

+43-3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,37 @@ static void sof_ipc4_dbg_audio_format(struct device *dev, struct sof_ipc4_pin_fo
166166
}
167167
}
168168

169+
static const struct sof_ipc4_audio_format *
170+
sof_ipc4_get_input_pin_audio_fmt(struct snd_sof_widget *swidget, int pin_index)
171+
{
172+
struct sof_ipc4_base_module_cfg_ext *base_cfg_ext;
173+
struct sof_ipc4_process *process;
174+
int i;
175+
176+
if (swidget->id != snd_soc_dapm_effect) {
177+
struct sof_ipc4_base_module_cfg *base = swidget->private;
178+
179+
/* For non-process modules, base module config format is used for all input pins */
180+
return &base->audio_fmt;
181+
}
182+
183+
process = swidget->private;
184+
base_cfg_ext = process->base_config_ext;
185+
186+
/*
187+
* If there are multiple input formats available for a pin, the first available format
188+
* is chosen.
189+
*/
190+
for (i = 0; i < base_cfg_ext->num_input_pin_fmts; i++) {
191+
struct sof_ipc4_pin_format *pin_format = &base_cfg_ext->pin_formats[i];
192+
193+
if (pin_format->pin_index == pin_index)
194+
return &pin_format->audio_fmt;
195+
}
196+
197+
return NULL;
198+
}
199+
169200
/**
170201
* sof_ipc4_get_audio_fmt - get available audio formats from swidget->tuples
171202
* @scomp: pointer to pointer to SOC component
@@ -2049,9 +2080,9 @@ static int sof_ipc4_set_copier_sink_format(struct snd_sof_dev *sdev,
20492080
struct snd_sof_widget *sink_widget,
20502081
int sink_id)
20512082
{
2052-
struct sof_ipc4_base_module_cfg *sink_config = sink_widget->private;
2053-
struct sof_ipc4_base_module_cfg *src_config;
20542083
struct sof_ipc4_copier_config_set_sink_format format;
2084+
struct sof_ipc4_base_module_cfg *src_config;
2085+
const struct sof_ipc4_audio_format *pin_fmt;
20552086
struct sof_ipc4_fw_module *fw_module;
20562087
struct sof_ipc4_msg msg = {{ 0 }};
20572088
u32 header, extension;
@@ -2071,7 +2102,16 @@ static int sof_ipc4_set_copier_sink_format(struct snd_sof_dev *sdev,
20712102

20722103
format.sink_id = sink_id;
20732104
memcpy(&format.source_fmt, &src_config->audio_fmt, sizeof(format.source_fmt));
2074-
memcpy(&format.sink_fmt, &sink_config->audio_fmt, sizeof(format.sink_fmt));
2105+
2106+
pin_fmt = sof_ipc4_get_input_pin_audio_fmt(sink_widget, sink_id);
2107+
if (!pin_fmt) {
2108+
dev_err(sdev->dev, "Unable to get pin %d format for %s",
2109+
sink_id, sink_widget->widget->name);
2110+
return -EINVAL;
2111+
}
2112+
2113+
memcpy(&format.sink_fmt, pin_fmt, sizeof(format.sink_fmt));
2114+
20752115
msg.data_size = sizeof(format);
20762116
msg.data_ptr = &format;
20772117

0 commit comments

Comments
 (0)