From 0b4b34928d53981d20a0241035c47b7514e5dd3e Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Tue, 4 Jun 2024 18:51:46 -0700 Subject: [PATCH] buffer: Move pipeline_id down into stream params The pipeline_id has historically been part of the comp_buffer struct, but that is being deprecated as a public API. So move it down into the contained sof_audio_stream_params struct where it can be found by new style sink/source code. Note that the actual value of the pipeline ID is a little ambiguous: on IPC3, the buffer is defined by the user in the .tplg file as part of a specific pipeline with a known ID. With IPC4 topology, the buffers are implicitly created and will be assigned the ID of their source (!) component. It is legal to define a connection across two pipelines, and there's no ability here to recover both pipeline IDs. Signed-off-by: Andy Ross --- src/audio/crossover/crossover.c | 2 +- src/audio/mux/mux.c | 6 +++--- src/audio/mux/mux_ipc4.c | 2 +- src/include/module/audio/audio_stream.h | 1 + src/include/sof/audio/buffer.h | 8 ++++++-- src/ipc/ipc-helper.c | 4 ++-- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/audio/crossover/crossover.c b/src/audio/crossover/crossover.c index 69135368671a..3cf6e6744709 100644 --- a/src/audio/crossover/crossover.c +++ b/src/audio/crossover/crossover.c @@ -111,7 +111,7 @@ static int crossover_assign_sinks(struct processing_module *mod, unsigned int sink_id, state; sink = container_of(sink_list, struct comp_buffer, source_list); - sink_id = crossover_get_sink_id(cd, sink->pipeline_id, j); + sink_id = crossover_get_sink_id(cd, buffer_pipeline_id(sink), j); state = sink->sink->state; if (state != dev->state) { j++; diff --git a/src/audio/mux/mux.c b/src/audio/mux/mux.c index a9e89afb9644..92fb98a93faa 100644 --- a/src/audio/mux/mux.c +++ b/src/audio/mux/mux.c @@ -248,13 +248,13 @@ static int demux_process(struct processing_module *mod, list_for_item(clist, &dev->bsink_list) { sink = container_of(clist, struct comp_buffer, source_list); if (sink->sink->state == dev->state) { - i = get_stream_index(dev, cd, sink->pipeline_id); + i = get_stream_index(dev, cd, buffer_pipeline_id(sink)); /* return if index wrong */ if (i < 0) { return i; } - look_ups[i] = get_lookup_table(dev, cd, sink->pipeline_id); + look_ups[i] = get_lookup_table(dev, cd, buffer_pipeline_id(sink)); sinks_stream[i] = &sink->stream; } } @@ -310,7 +310,7 @@ static int mux_process(struct processing_module *mod, else frames = input_buffers[j].size; - i = get_stream_index(dev, cd, source->pipeline_id); + i = get_stream_index(dev, cd, buffer_pipeline_id(source)); /* return if index wrong */ if (i < 0) { return i; diff --git a/src/audio/mux/mux_ipc4.c b/src/audio/mux/mux_ipc4.c index bf6e591665bc..a4edc218ab5d 100644 --- a/src/audio/mux/mux_ipc4.c +++ b/src/audio/mux/mux_ipc4.c @@ -114,7 +114,7 @@ static void set_mux_params(struct processing_module *mod) { source = container_of(source_list, struct comp_buffer, sink_list); j = buf_get_id(source); - cd->config.streams[j].pipeline_id = source->pipeline_id; + cd->config.streams[j].pipeline_id = buffer_pipeline_id(source); if (j == BASE_CFG_QUEUED_ID) audio_fmt = &cd->md.base_cfg.audio_fmt; else diff --git a/src/include/module/audio/audio_stream.h b/src/include/module/audio/audio_stream.h index 0941047a6395..5e30c2aab4a9 100644 --- a/src/include/module/audio/audio_stream.h +++ b/src/include/module/audio/audio_stream.h @@ -20,6 +20,7 @@ */ struct sof_audio_stream_params { uint32_t id; + uint32_t pipeline_id; enum sof_ipc_frame frame_fmt; /**< Sample data format */ enum sof_ipc_frame valid_sample_fmt; diff --git a/src/include/sof/audio/buffer.h b/src/include/sof/audio/buffer.h index 662e329c1027..e5904d8dbc53 100644 --- a/src/include/sof/audio/buffer.h +++ b/src/include/sof/audio/buffer.h @@ -44,7 +44,7 @@ extern struct tr_ctx buffer_tr; #define trace_buf_get_tr_ctx(buf_ptr) (&(buf_ptr)->tctx) /** \brief Retrieves id (pipe id) from the buffer */ -#define trace_buf_get_id(buf_ptr) ((buf_ptr)->pipeline_id) +#define trace_buf_get_id(buf_ptr) ((buf_ptr)->stream.runtime_stream_params.pipeline_id) /** \brief Retrieves subid (comp id) from the buffer */ #define buf_get_id(buf_ptr) ((buf_ptr)->stream.runtime_stream_params.id) @@ -139,7 +139,6 @@ struct comp_buffer { struct audio_stream stream; /* configuration */ - uint32_t pipeline_id; uint32_t caps; uint32_t core; struct tr_ctx tctx; /* trace settings */ @@ -276,6 +275,11 @@ static inline struct comp_dev *buffer_get_comp(struct comp_buffer *buffer, int d return comp; } +static inline uint32_t buffer_pipeline_id(const struct comp_buffer *buffer) +{ + return buffer->stream.runtime_stream_params.pipeline_id; +} + static inline void buffer_reset_pos(struct comp_buffer *buffer, void *data) { /* reset rw pointers and avail/free bytes counters */ diff --git a/src/ipc/ipc-helper.c b/src/ipc/ipc-helper.c index 305c3623d3b6..23a14fade8e4 100644 --- a/src/ipc/ipc-helper.c +++ b/src/ipc/ipc-helper.c @@ -64,7 +64,7 @@ struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared is_shared); if (buffer) { buffer->stream.runtime_stream_params.id = desc->comp.id; - buffer->pipeline_id = desc->comp.pipeline_id; + buffer->stream.runtime_stream_params.pipeline_id = desc->comp.pipeline_id; buffer->core = desc->comp.core; memcpy_s(&buffer->tctx, sizeof(struct tr_ctx), @@ -80,7 +80,7 @@ int32_t ipc_comp_pipe_id(const struct ipc_comp_dev *icd) case COMP_TYPE_COMPONENT: return dev_comp_pipe_id(icd->cd); case COMP_TYPE_BUFFER: - return icd->cb->pipeline_id; + return buffer_pipeline_id(icd->cb); case COMP_TYPE_PIPELINE: return icd->pipeline->pipeline_id; default: