Skip to content

Commit fe836c7

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: ipc4-topology: Use correct queue_id for requesting input pin format
It is incorrect to request the input pin format of the destination widget using the output pin index of the source module as the indexes are not necessarily matching. moduleA.out_pin1 can be connected to moduleB.in_pin0 for example. Use the dst_queue_id to request the input format of the destination module. This bug remained unnoticed likely because in nocodec topologies we don't have process modules after a module copier, thus the pin/queue index is ignored. For the process module case, the code was likely have been tested in a controlled way where all the pin/queue/format properties were present to work. Update the debug prints to have better information. Reviewed-by: Kai Vehmanen <[email protected]> Reviewed-by: Ranjani Sridharan <[email protected]> Reviewed-by: Bard Liao <[email protected]> Signed-off-by: Peter Ujfalusi <[email protected]> Signed-off-by: Pierre-Louis Bossart <[email protected]> Cc: [email protected] # v6.8+ Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 4ae814d commit fe836c7

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

sound/soc/sof/ipc4-topology.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,7 +2869,7 @@ static void sof_ipc4_put_queue_id(struct snd_sof_widget *swidget, int queue_id,
28692869
static int sof_ipc4_set_copier_sink_format(struct snd_sof_dev *sdev,
28702870
struct snd_sof_widget *src_widget,
28712871
struct snd_sof_widget *sink_widget,
2872-
int sink_id)
2872+
struct snd_sof_route *sroute)
28732873
{
28742874
struct sof_ipc4_copier_config_set_sink_format format;
28752875
const struct sof_ipc_ops *iops = sdev->ipc->ops;
@@ -2878,9 +2878,6 @@ static int sof_ipc4_set_copier_sink_format(struct snd_sof_dev *sdev,
28782878
struct sof_ipc4_fw_module *fw_module;
28792879
struct sof_ipc4_msg msg = {{ 0 }};
28802880

2881-
dev_dbg(sdev->dev, "%s set copier sink %d format\n",
2882-
src_widget->widget->name, sink_id);
2883-
28842881
if (WIDGET_IS_DAI(src_widget->id)) {
28852882
struct snd_sof_dai *dai = src_widget->private;
28862883

@@ -2891,13 +2888,15 @@ static int sof_ipc4_set_copier_sink_format(struct snd_sof_dev *sdev,
28912888

28922889
fw_module = src_widget->module_info;
28932890

2894-
format.sink_id = sink_id;
2891+
format.sink_id = sroute->src_queue_id;
28952892
memcpy(&format.source_fmt, &src_config->audio_fmt, sizeof(format.source_fmt));
28962893

2897-
pin_fmt = sof_ipc4_get_input_pin_audio_fmt(sink_widget, sink_id);
2894+
pin_fmt = sof_ipc4_get_input_pin_audio_fmt(sink_widget, sroute->dst_queue_id);
28982895
if (!pin_fmt) {
2899-
dev_err(sdev->dev, "Unable to get pin %d format for %s",
2900-
sink_id, sink_widget->widget->name);
2896+
dev_err(sdev->dev,
2897+
"Failed to get input audio format of %s:%d for output of %s:%d\n",
2898+
sink_widget->widget->name, sroute->dst_queue_id,
2899+
src_widget->widget->name, sroute->src_queue_id);
29012900
return -EINVAL;
29022901
}
29032902

@@ -2955,15 +2954,17 @@ static int sof_ipc4_route_setup(struct snd_sof_dev *sdev, struct snd_sof_route *
29552954
sroute->src_queue_id = sof_ipc4_get_queue_id(src_widget, sink_widget,
29562955
SOF_PIN_TYPE_OUTPUT);
29572956
if (sroute->src_queue_id < 0) {
2958-
dev_err(sdev->dev, "failed to get queue ID for source widget: %s\n",
2957+
dev_err(sdev->dev,
2958+
"failed to get src_queue_id ID from source widget %s\n",
29592959
src_widget->widget->name);
29602960
return sroute->src_queue_id;
29612961
}
29622962

29632963
sroute->dst_queue_id = sof_ipc4_get_queue_id(src_widget, sink_widget,
29642964
SOF_PIN_TYPE_INPUT);
29652965
if (sroute->dst_queue_id < 0) {
2966-
dev_err(sdev->dev, "failed to get queue ID for sink widget: %s\n",
2966+
dev_err(sdev->dev,
2967+
"failed to get dst_queue_id ID from sink widget %s\n",
29672968
sink_widget->widget->name);
29682969
sof_ipc4_put_queue_id(src_widget, sroute->src_queue_id,
29692970
SOF_PIN_TYPE_OUTPUT);
@@ -2972,10 +2973,11 @@ static int sof_ipc4_route_setup(struct snd_sof_dev *sdev, struct snd_sof_route *
29722973

29732974
/* Pin 0 format is already set during copier module init */
29742975
if (sroute->src_queue_id > 0 && WIDGET_IS_COPIER(src_widget->id)) {
2975-
ret = sof_ipc4_set_copier_sink_format(sdev, src_widget, sink_widget,
2976-
sroute->src_queue_id);
2976+
ret = sof_ipc4_set_copier_sink_format(sdev, src_widget,
2977+
sink_widget, sroute);
29772978
if (ret < 0) {
2978-
dev_err(sdev->dev, "failed to set sink format for %s source queue ID %d\n",
2979+
dev_err(sdev->dev,
2980+
"failed to set sink format for source %s:%d\n",
29792981
src_widget->widget->name, sroute->src_queue_id);
29802982
goto out;
29812983
}

0 commit comments

Comments
 (0)