From d25b64950e3b1acf5de9c5217771be5ef8b56328 Mon Sep 17 00:00:00 2001 From: Krzysztof Frydryk Date: Tue, 26 Jul 2022 08:42:28 +0200 Subject: [PATCH] ipc4: set pipeline components dir based on source component Prefer to use source components direction, rather than dai direction when setting pipeline components direction. Accept first direction set in pipeline. This properly handles host_copier -> module -> host_copier pipelines. Signed-off-by: Krzysztof Frydryk --- src/ipc/ipc4/handler.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/ipc/ipc4/handler.c b/src/ipc/ipc4/handler.c index 3c974cd99..f8fcdcb99 100644 --- a/src/ipc/ipc4/handler.c +++ b/src/ipc/ipc4/handler.c @@ -393,19 +393,32 @@ static int ipc_wait_for_compound_msg(void) static int update_dir_to_pipeline_component(uint32_t *ppl_id, uint32_t count) { struct ipc_comp_dev *icd; - struct comp_dev *dai; + struct ipc_comp_dev *pipe; + struct comp_dev *dir_src = NULL; struct list_item *clist; struct ipc *ipc; uint32_t i; ipc = ipc_get(); - /* only dai has direction based on gateway type */ - dai = pipeline_get_dai_comp(ppl_id[0]); - /* skip host copier to host copier case */ - if (!dai) { - tr_info(&ipc_tr, "no dai is found"); - return 0; + for (i = 0; i < count; i++) { + pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, ppl_id[i]); + if (!pipe) { + tr_info(&ipc_tr, "ppl_id %u: no pipeline is found", ppl_id[i]); + continue; + } + + if (pipe->pipeline->source_comp->direction_set) { + dir_src = pipe->pipeline->source_comp; + break; + } else if (pipe->pipeline->sink_comp->direction_set) { + dir_src = pipe->pipeline->sink_comp; + break; + } + } + if (!dir_src) { + tr_err(&ipc_tr, "no direction source in pipeline"); + return IPC4_INVALID_RESOURCE_STATE; } /* set direction to the component in the pipeline array */ @@ -427,7 +440,7 @@ static int update_dir_to_pipeline_component(uint32_t *ppl_id, uint32_t count) if (dev->direction_set) break; - icd->cd->direction = dai->direction; + icd->cd->direction = dir_src->direction; break; } }