Skip to content

Commit

Permalink
buffer: Move pipeline_id down into stream params
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
andyross committed Jun 7, 2024
1 parent 96610c5 commit 0b4b349
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/audio/crossover/crossover.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
6 changes: 3 additions & 3 deletions src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mux/mux_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/include/module/audio/audio_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 6 additions & 2 deletions src/include/sof/audio/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions src/ipc/ipc-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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:
Expand Down

0 comments on commit 0b4b349

Please sign in to comment.