Skip to content

Commit c4f5689

Browse files
committed
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 <andyross@google.com>
1 parent 25c6206 commit c4f5689

8 files changed

Lines changed: 23 additions & 21 deletions

File tree

src/audio/crossover/crossover.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int crossover_assign_sinks(struct processing_module *mod,
111111
unsigned int sink_id, state;
112112

113113
sink = container_of(sink_list, struct comp_buffer, source_list);
114-
sink_id = crossover_get_sink_id(cd, sink->pipeline_id, j);
114+
sink_id = crossover_get_sink_id(cd, buffer_pipeline_id(sink), j);
115115
state = sink->sink->state;
116116
if (state != dev->state) {
117117
j++;

src/audio/crossover/crossover_ipc3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int crossover_check_sink_assign(struct processing_module *mod,
4646
unsigned int pipeline_id;
4747

4848
sink = container_of(sink_list, struct comp_buffer, source_list);
49-
pipeline_id = sink->pipeline_id;
49+
pipeline_id = buffer_pipeline_id(sink);
5050

5151
i = crossover_get_stream_index(mod, config, pipeline_id);
5252
if (i < 0) {

src/audio/mux/mux.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ static int demux_process(struct processing_module *mod,
248248
list_for_item(clist, &dev->bsink_list) {
249249
sink = container_of(clist, struct comp_buffer, source_list);
250250
if (sink->sink->state == dev->state) {
251-
i = get_stream_index(dev, cd, sink->pipeline_id);
251+
i = get_stream_index(dev, cd, buffer_pipeline_id(sink));
252252
/* return if index wrong */
253253
if (i < 0) {
254254
return i;
255255
}
256256

257-
look_ups[i] = get_lookup_table(dev, cd, sink->pipeline_id);
257+
look_ups[i] = get_lookup_table(dev, cd, buffer_pipeline_id(sink));
258258
sinks_stream[i] = &sink->stream;
259259
}
260260
}
@@ -310,7 +310,7 @@ static int mux_process(struct processing_module *mod,
310310
else
311311
frames = input_buffers[j].size;
312312

313-
i = get_stream_index(dev, cd, source->pipeline_id);
313+
i = get_stream_index(dev, cd, buffer_pipeline_id(source));
314314
/* return if index wrong */
315315
if (i < 0) {
316316
return i;

src/audio/mux/mux_ipc4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static void set_mux_params(struct processing_module *mod)
114114
{
115115
source = container_of(source_list, struct comp_buffer, sink_list);
116116
j = buf_get_id(source);
117-
cd->config.streams[j].pipeline_id = source->pipeline_id;
117+
cd->config.streams[j].pipeline_id = buffer_pipeline_id(source);
118118
if (j == BASE_CFG_QUEUED_ID)
119119
audio_fmt = &cd->md.base_cfg.audio_fmt;
120120
else

src/include/module/audio/audio_stream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121
struct sof_audio_stream_params {
2222
uint32_t id;
23+
uint32_t pipeline_id;
2324
enum sof_ipc_frame frame_fmt; /**< Sample data format */
2425
enum sof_ipc_frame valid_sample_fmt;
2526

src/include/sof/audio/buffer.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ extern struct tr_ctx buffer_tr;
4343
/** \brief Retrieves trace context from the buffer */
4444
#define trace_buf_get_tr_ctx(buf_ptr) (&(buf_ptr)->tctx)
4545

46-
/** \brief Retrieves id (pipe id) from the buffer */
47-
#define trace_buf_get_id(buf_ptr) ((buf_ptr)->pipeline_id)
48-
4946
/** \brief Retrieves subid (comp id) from the buffer */
5047
#define buf_get_id(buf_ptr) ((buf_ptr)->stream.runtime_stream_params.id)
5148

@@ -57,36 +54,36 @@ extern struct tr_ctx buffer_tr;
5754
#define __BUF_FMT "buf:%u.%u "
5855
#endif
5956

60-
#define buf_err(buf_ptr, __e, ...) LOG_ERR(__BUF_FMT __e, trace_buf_get_id(buf_ptr), \
57+
#define buf_err(buf_ptr, __e, ...) LOG_ERR(__BUF_FMT __e, buffer_pipeline_id(buf_ptr), \
6158
buf_get_id(buf_ptr), ##__VA_ARGS__)
6259

63-
#define buf_warn(buf_ptr, __e, ...) LOG_WRN(__BUF_FMT __e, trace_buf_get_id(buf_ptr), \
60+
#define buf_warn(buf_ptr, __e, ...) LOG_WRN(__BUF_FMT __e, buffer_pipeline_id(buf_ptr), \
6461
buf_get_id(buf_ptr), ##__VA_ARGS__)
6562

66-
#define buf_info(buf_ptr, __e, ...) LOG_INF(__BUF_FMT __e, trace_buf_get_id(buf_ptr), \
63+
#define buf_info(buf_ptr, __e, ...) LOG_INF(__BUF_FMT __e, buffer_pipeline_id(buf_ptr), \
6764
buf_get_id(buf_ptr), ##__VA_ARGS__)
6865

69-
#define buf_dbg(buf_ptr, __e, ...) LOG_DBG(__BUF_FMT __e, trace_buf_get_id(buf_ptr), \
66+
#define buf_dbg(buf_ptr, __e, ...) LOG_DBG(__BUF_FMT __e, buffer_pipeline_id(buf_ptr), \
7067
buf_get_id(buf_ptr), ##__VA_ARGS__)
7168

7269
#else
7370
/** \brief Trace error message from buffer */
7471
#define buf_err(buf_ptr, __e, ...) \
75-
trace_dev_err(trace_buf_get_tr_ctx, trace_buf_get_id, \
72+
trace_dev_err(trace_buf_get_tr_ctx, buffer_pipeline_id, \
7673
buf_get_id, \
7774
(__sparse_force const struct comp_buffer *)buf_ptr, \
7875
__e, ##__VA_ARGS__)
7976

8077
/** \brief Trace warning message from buffer */
8178
#define buf_warn(buf_ptr, __e, ...) \
82-
trace_dev_warn(trace_buf_get_tr_ctx, trace_buf_get_id, \
79+
trace_dev_warn(trace_buf_get_tr_ctx, buffer_pipeline_id, \
8380
buf_get_id, \
8481
(__sparse_force const struct comp_buffer *)buf_ptr, \
8582
__e, ##__VA_ARGS__)
8683

8784
/** \brief Trace info message from buffer */
8885
#define buf_info(buf_ptr, __e, ...) \
89-
trace_dev_info(trace_buf_get_tr_ctx, trace_buf_get_id, \
86+
trace_dev_info(trace_buf_get_tr_ctx, buffer_pipeline_id, \
9087
buf_get_id, \
9188
(__sparse_force const struct comp_buffer *)buf_ptr, \
9289
__e, ##__VA_ARGS__)
@@ -96,7 +93,7 @@ extern struct tr_ctx buffer_tr;
9693
#define buf_dbg(buf_ptr, __e, ...)
9794
#else
9895
#define buf_dbg(buf_ptr, __e, ...) \
99-
trace_dev_dbg(trace_buf_get_tr_ctx, trace_buf_get_id, \
96+
trace_dev_dbg(trace_buf_get_tr_ctx, buffer_pipeline_id, \
10097
buf_get_id, \
10198
(__sparse_force const struct comp_buffer *)buf_ptr, \
10299
__e, ##__VA_ARGS__)
@@ -139,7 +136,6 @@ struct comp_buffer {
139136
struct audio_stream stream;
140137

141138
/* configuration */
142-
uint32_t pipeline_id;
143139
uint32_t caps;
144140
uint32_t core;
145141
struct tr_ctx tctx; /* trace settings */
@@ -276,6 +272,11 @@ static inline struct comp_dev *buffer_get_comp(struct comp_buffer *buffer, int d
276272
return comp;
277273
}
278274

275+
static inline uint32_t buffer_pipeline_id(const struct comp_buffer *buffer)
276+
{
277+
return buffer->stream.runtime_stream_params.pipeline_id;
278+
}
279+
279280
static inline void buffer_reset_pos(struct comp_buffer *buffer, void *data)
280281
{
281282
/* reset rw pointers and avail/free bytes counters */

src/ipc/ipc-helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared
6464
is_shared);
6565
if (buffer) {
6666
buffer->stream.runtime_stream_params.id = desc->comp.id;
67-
buffer->pipeline_id = desc->comp.pipeline_id;
67+
buffer->stream.runtime_stream_params.pipeline_id = desc->comp.pipeline_id;
6868
buffer->core = desc->comp.core;
6969

7070
memcpy_s(&buffer->tctx, sizeof(struct tr_ctx),
@@ -80,7 +80,7 @@ int32_t ipc_comp_pipe_id(const struct ipc_comp_dev *icd)
8080
case COMP_TYPE_COMPONENT:
8181
return dev_comp_pipe_id(icd->cd);
8282
case COMP_TYPE_BUFFER:
83-
return icd->cb->pipeline_id;
83+
return buffer_pipeline_id(icd->cb);
8484
case COMP_TYPE_PIPELINE:
8585
return icd->pipeline->pipeline_id;
8686
default:

tools/testbench/testbench.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static void test_pipeline_free_comps(int pipeline_id)
163163
icd->id);
164164
break;
165165
case COMP_TYPE_BUFFER:
166-
if (icd->cb->pipeline_id != pipeline_id)
166+
if (buffer_pipeline_id(icd->cb) != pipeline_id)
167167
break;
168168
err = ipc_buffer_free(sof_get()->ipc, icd->id);
169169
if (err)

0 commit comments

Comments
 (0)