From 50be05b9509dbb322dc9eee65a9bb38af4e34a20 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 25 Aug 2017 20:15:40 +0100 Subject: [PATCH] pipeline: params: Use correct host side comp when installing params. Some components have multiple sources/sink and the correct host side component must be used when installing params. Make sure the correct component is used here by tracking the previous component and passing it to the params installation. Signed-off-by: Liam Girdwood --- src/audio/pipeline.c | 36 +++++++++++++++++------------- src/include/reef/audio/component.h | 14 ++---------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/audio/pipeline.c b/src/audio/pipeline.c index f213dc43c..4327254f7 100644 --- a/src/audio/pipeline.c +++ b/src/audio/pipeline.c @@ -311,7 +311,8 @@ int pipeline_buffer_connect(struct pipeline *p, /* call op on all downstream components - locks held by caller */ static int component_op_downstream(struct op_data *op_data, - struct comp_dev *start, struct comp_dev *current) + struct comp_dev *start, struct comp_dev *current, + struct comp_dev *previous) { struct list_item *clist; int err = 0; @@ -328,8 +329,8 @@ static int component_op_downstream(struct op_data *op_data, return 0; /* send params to the component */ - if (current != start) - comp_install_params(current, SOF_IPC_STREAM_PLAYBACK); + if (current != start && previous != NULL) + comp_install_params(current, previous); err = comp_params(current); break; case COMP_OPS_CMD: @@ -375,7 +376,8 @@ static int component_op_downstream(struct op_data *op_data, if (!buffer->connected) continue; - err = component_op_downstream(op_data, start, buffer->sink); + err = component_op_downstream(op_data, start, buffer->sink, + current); if (err < 0) break; } @@ -385,7 +387,8 @@ static int component_op_downstream(struct op_data *op_data, /* call op on all upstream components - locks held by caller */ static int component_op_upstream(struct op_data *op_data, - struct comp_dev *start, struct comp_dev *current) + struct comp_dev *start, struct comp_dev *current, + struct comp_dev *previous) { struct list_item *clist; int err = 0; @@ -402,8 +405,8 @@ static int component_op_upstream(struct op_data *op_data, return 0; /* send params to the component */ - if (current != start) - comp_install_params(current, SOF_IPC_STREAM_CAPTURE); + if (current != start && previous != NULL) + comp_install_params(current, previous); err = comp_params(current); break; case COMP_OPS_CMD: @@ -446,7 +449,8 @@ static int component_op_upstream(struct op_data *op_data, if (!buffer->connected) continue; - err = component_op_upstream(op_data, start, buffer->source); + err = component_op_upstream(op_data, start, buffer->source, + current); if (err < 0) break; } @@ -514,7 +518,7 @@ int pipeline_prepare(struct pipeline *p, struct comp_dev *dev) if (dev->params.direction == SOF_IPC_STREAM_PLAYBACK) { /* first of all prepare the pipeline */ - ret = component_op_downstream(&op_data, dev, dev); + ret = component_op_downstream(&op_data, dev, dev, NULL); if (ret < 0) goto out; @@ -535,7 +539,7 @@ int pipeline_prepare(struct pipeline *p, struct comp_dev *dev) ret = -EIO; } else { - ret = component_op_upstream(&op_data, dev, dev); + ret = component_op_upstream(&op_data, dev, dev, NULL); } out: @@ -561,10 +565,10 @@ int pipeline_cmd(struct pipeline *p, struct comp_dev *host, int cmd, if (host->params.direction == SOF_IPC_STREAM_PLAYBACK) { /* send cmd downstream from host to DAI */ - ret = component_op_downstream(&op_data, host, host); + ret = component_op_downstream(&op_data, host, host, NULL); } else { /* send cmd upstream from host to DAI */ - ret = component_op_upstream(&op_data, host, host); + ret = component_op_upstream(&op_data, host, host, NULL); } if (ret < 0) @@ -604,10 +608,10 @@ int pipeline_params(struct pipeline *p, struct comp_dev *host, if (host->params.direction == SOF_IPC_STREAM_PLAYBACK) { /* send params downstream from host to DAI */ - ret = component_op_downstream(&op_data, host, host); + ret = component_op_downstream(&op_data, host, host, NULL); } else { /* send params upstream from host to DAI */ - ret = component_op_upstream(&op_data, host, host); + ret = component_op_upstream(&op_data, host, host, NULL); } if (ret < 0) @@ -632,10 +636,10 @@ int pipeline_reset(struct pipeline *p, struct comp_dev *host) if (host->params.direction == SOF_IPC_STREAM_PLAYBACK) { /* send reset downstream from host to DAI */ - ret = component_op_downstream(&op_data, host, host); + ret = component_op_downstream(&op_data, host, host, NULL); } else { /* send reset upstream from host to DAI */ - ret = component_op_upstream(&op_data, host, host); + ret = component_op_upstream(&op_data, host, host, NULL); } if (ret < 0) diff --git a/src/include/reef/audio/component.h b/src/include/reef/audio/component.h index 2e76a86b9..e73a22a09 100644 --- a/src/include/reef/audio/component.h +++ b/src/include/reef/audio/component.h @@ -327,19 +327,9 @@ static inline int comp_buffer_reset(struct comp_dev *dev) * playback and upstream on capture. */ static inline void comp_install_params(struct comp_dev *dev, - enum sof_ipc_stream_direction direction) + struct comp_dev *previous) { - struct comp_buffer *buffer; - - if (direction == SOF_IPC_STREAM_PLAYBACK) { - buffer = list_first_item(&dev->bsource_list, - struct comp_buffer, sink_list); - dev->params = buffer->source->params; - } else { - buffer = list_first_item(&dev->bsink_list, - struct comp_buffer, source_list); - dev->params = buffer->sink->params; - } + dev->params = previous->params; } static inline uint32_t comp_frame_bytes(struct comp_dev *dev)