From a62b7cf1c3f73e3209222d5362a66389e7ae68bf Mon Sep 17 00:00:00 2001 From: Marcin Szkudlinski Date: Thu, 2 Nov 2023 15:33:22 +0100 Subject: [PATCH] buf: move buffer/stream ID to runtime_stream_params runtime_stream_params is a container for all parameters of a stream Add an API call to retrieve it Signed-off-by: Marcin Szkudlinski --- src/audio/copier/copier.c | 6 +++--- src/audio/copier/copier_generic.c | 2 +- src/audio/dai-zephyr.c | 4 ++-- .../google/google_rtc_audio_processing.c | 3 ++- src/audio/kpb.c | 4 ++-- src/audio/mixin_mixout/mixin_mixout.c | 4 ++-- src/audio/mux/mux.c | 2 +- src/audio/pipeline/pipeline-graph.c | 8 ++++---- src/audio/rtnr/rtnr.c | 3 ++- src/include/sof/audio/audio_stream.h | 1 + src/include/sof/audio/buffer.h | 19 +++++++++---------- src/ipc/ipc-helper.c | 2 +- src/ipc/ipc4/helper.c | 2 +- src/probe/probe.c | 4 ++-- src/samples/audio/smart_amp_test_ipc4.c | 6 ++++-- 15 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/audio/copier/copier.c b/src/audio/copier/copier.c index adeeae8c3dc4..d2c69daecc7d 100644 --- a/src/audio/copier/copier.c +++ b/src/audio/copier/copier.c @@ -405,7 +405,7 @@ static int do_conversion_copy(struct comp_dev *dev, comp_get_copy_limits(src, sink, processed_data); - i = IPC4_SINK_QUEUE_ID(sink->id); + i = IPC4_SINK_QUEUE_ID(buf_get_id(sink)); if (i >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT) return -EINVAL; buffer_stream_invalidate(src, processed_data->source_bytes); @@ -483,7 +483,7 @@ static int copier_module_copy(struct processing_module *mod, uint32_t samples; int sink_queue_id; - sink_queue_id = IPC4_SINK_QUEUE_ID(sink_c->id); + sink_queue_id = IPC4_SINK_QUEUE_ID(buf_get_id(sink_c)); if (sink_queue_id >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT) return -EINVAL; @@ -668,7 +668,7 @@ static int copier_set_sink_fmt(struct comp_dev *dev, const void *data, sink = container_of(sink_list, struct comp_buffer, source_list); - sink_id = IPC4_SINK_QUEUE_ID(sink->id); + sink_id = IPC4_SINK_QUEUE_ID(buf_get_id(sink)); if (sink_id == sink_fmt->sink_id) { ipc4_update_buffer_format(sink, &sink_fmt->sink_fmt); break; diff --git a/src/audio/copier/copier_generic.c b/src/audio/copier/copier_generic.c index c4991363eb7f..8c3a3278c7d1 100644 --- a/src/audio/copier/copier_generic.c +++ b/src/audio/copier/copier_generic.c @@ -85,7 +85,7 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev, sink = container_of(sink_list, struct comp_buffer, source_list); - j = IPC4_SINK_QUEUE_ID(sink->id); + j = IPC4_SINK_QUEUE_ID(buf_get_id(sink)); ipc4_update_buffer_format(sink, &cd->out_fmt[j]); } diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 33d0f3922df3..569bb37f1566 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -284,7 +284,7 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, sink_dev = sink->sink; - j = IPC4_SINK_QUEUE_ID(sink->id); + j = IPC4_SINK_QUEUE_ID(buf_get_id(sink)); if (j >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT) { comp_err(dev, "Sink queue ID: %d >= max output pin count: %d\n", @@ -1644,7 +1644,7 @@ int dai_zephyr_unbind(struct dai_data *dd, struct comp_dev *dev, void *data) buf_id = IPC4_COMP_ID(bu->extension.r.src_queue, bu->extension.r.dst_queue); if (dd && dd->local_buffer) { - if (dd->local_buffer->id == buf_id) { + if (buf_get_id(dd->local_buffer) == buf_id) { comp_dbg(dev, "dai_zephyr_unbind: local_buffer %x unbound", buf_id); dd->local_buffer = NULL; } diff --git a/src/audio/google/google_rtc_audio_processing.c b/src/audio/google/google_rtc_audio_processing.c index ec480fc1dcfc..fcf403a1f8bc 100644 --- a/src/audio/google/google_rtc_audio_processing.c +++ b/src/audio/google/google_rtc_audio_processing.c @@ -561,7 +561,8 @@ static int google_rtc_audio_processing_prepare(struct processing_module *mod, struct comp_buffer *source = container_of(source_buffer_list_item, struct comp_buffer, sink_list); #if CONFIG_IPC_MAJOR_4 - if (IPC4_SINK_QUEUE_ID(source->id) == SOF_AEC_FEEDBACK_QUEUE_ID) { + if (IPC4_SINK_QUEUE_ID(buf_get_id(source)) == + SOF_AEC_FEEDBACK_QUEUE_ID) { #else if (source->source->pipeline->pipeline_id != dev->pipeline->pipeline_id) { #endif diff --git a/src/audio/kpb.c b/src/audio/kpb.c index 48bc6bd3eeec..a7ef3c1e2a45 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -357,7 +357,7 @@ static int kpb_bind(struct comp_dev *dev, void *data) break; } - sink_buf_id = sink->id; + sink_buf_id = buf_get_id(sink); if (sink_buf_id == buf_id) { if (sink_buf_id == 0) @@ -903,7 +903,7 @@ static int kpb_prepare(struct comp_dev *dev) audio_stream_init_alignment_constants(byte_align, frame_align_req, &sink->stream); - sink_id = sink->id; + sink_id = buf_get_id(sink); if (sink_id == 0) audio_stream_set_channels(&sink->stream, kpb->num_of_sel_mic); diff --git a/src/audio/mixin_mixout/mixin_mixout.c b/src/audio/mixin_mixout/mixin_mixout.c index 9af1205008d4..29ff2ca48faf 100644 --- a/src/audio/mixin_mixout/mixin_mixout.c +++ b/src/audio/mixin_mixout/mixin_mixout.c @@ -302,7 +302,7 @@ static int mixin_process(struct processing_module *mod, unused_in_between_buf_c = container_of(output_buffers[i].data, struct comp_buffer, stream); mixout = unused_in_between_buf_c->sink; - sink_id = IPC4_SRC_QUEUE_ID(unused_in_between_buf_c->id); + sink_id = IPC4_SRC_QUEUE_ID(buf_get_id(unused_in_between_buf_c)); active_mixouts[i] = mixout; sinks_ids[i] = sink_id; @@ -570,7 +570,7 @@ static int mixin_params(struct processing_module *mod) /* Applying channel remapping may produce sink stream with channel count * different from source channel count. */ - sink_id = IPC4_SRC_QUEUE_ID(sink->id); + sink_id = IPC4_SRC_QUEUE_ID(buf_get_id(sink)); if (sink_id >= MIXIN_MAX_SINKS) { comp_err(dev, "Sink index out of range: %u, max sink count: %u", (uint32_t)sink_id, MIXIN_MAX_SINKS); diff --git a/src/audio/mux/mux.c b/src/audio/mux/mux.c index 92d278a22186..de16ee754c98 100644 --- a/src/audio/mux/mux.c +++ b/src/audio/mux/mux.c @@ -315,7 +315,7 @@ static void set_mux_params(struct processing_module *mod) source = container_of(source_list, struct comp_buffer, sink_list); audio_stream_init_alignment_constants(byte_align, frame_align_req, &source->stream); - j = source->id; + j = buf_get_id(source); cd->config.streams[j].pipeline_id = source->pipeline_id; if (j == BASE_CFG_QUEUED_ID) audio_fmt = &cd->md.base_cfg.audio_fmt; diff --git a/src/audio/pipeline/pipeline-graph.c b/src/audio/pipeline/pipeline-graph.c index 82fe49bbed20..02191a6f5b0a 100644 --- a/src/audio/pipeline/pipeline-graph.c +++ b/src/audio/pipeline/pipeline-graph.c @@ -181,9 +181,9 @@ int pipeline_connect(struct comp_dev *comp, struct comp_buffer *buffer, uint32_t flags; if (dir == PPL_CONN_DIR_COMP_TO_BUFFER) - comp_info(comp, "connect buffer %d as sink", buffer->id); + comp_info(comp, "connect buffer %d as sink", buf_get_id(buffer)); else - comp_info(comp, "connect buffer %d as source", buffer->id); + comp_info(comp, "connect buffer %d as source", buf_get_id(buffer)); irq_local_disable(flags); @@ -202,9 +202,9 @@ void pipeline_disconnect(struct comp_dev *comp, struct comp_buffer *buffer, int uint32_t flags; if (dir == PPL_CONN_DIR_COMP_TO_BUFFER) - comp_dbg(comp, "disconnect buffer %d as sink", buffer->id); + comp_dbg(comp, "disconnect buffer %d as sink", buf_get_id(buffer)); else - comp_dbg(comp, "disconnect buffer %d as source", buffer->id); + comp_dbg(comp, "disconnect buffer %d as source", buf_get_id(buffer)); irq_local_disable(flags); diff --git a/src/audio/rtnr/rtnr.c b/src/audio/rtnr/rtnr.c index 49db44eac1cb..7db70e4425ac 100644 --- a/src/audio/rtnr/rtnr.c +++ b/src/audio/rtnr/rtnr.c @@ -780,7 +780,8 @@ static int rtnr_copy(struct comp_dev *dev) /* Process integer multiple of RTNR internal block length */ frames = frames & ~RTNR_BLK_LENGTH_MASK; - comp_dbg(dev, "rtnr_copy() source->id: %d, frames = %d", source->id, frames); + comp_dbg(dev, "rtnr_copy() source_id: %d, frames = %d", buf_get_id(source), + frames); if (frames) { source_bytes = frames * audio_stream_frame_bytes(&source->stream); diff --git a/src/include/sof/audio/audio_stream.h b/src/include/sof/audio/audio_stream.h index 75060b0e1ef3..4243c25f8350 100644 --- a/src/include/sof/audio/audio_stream.h +++ b/src/include/sof/audio/audio_stream.h @@ -40,6 +40,7 @@ * TODO: compressed formats */ struct sof_audio_stream_params { + uint32_t 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 568a121db575..e636771f9f93 100644 --- a/src/include/sof/audio/buffer.h +++ b/src/include/sof/audio/buffer.h @@ -47,7 +47,7 @@ extern struct tr_ctx buffer_tr; #define trace_buf_get_id(buf_ptr) ((buf_ptr)->pipeline_id) /** \brief Retrieves subid (comp id) from the buffer */ -#define trace_buf_get_subid(buf_ptr) ((buf_ptr)->id) +#define buf_get_id(buf_ptr) ((buf_ptr)->stream.runtime_stream_params.id) #if defined(__ZEPHYR__) && defined(CONFIG_ZEPHYR_LOG) @@ -58,36 +58,36 @@ extern struct tr_ctx buffer_tr; #endif #define buf_err(buf_ptr, __e, ...) LOG_ERR(__BUF_FMT __e, trace_buf_get_id(buf_ptr), \ - trace_buf_get_subid(buf_ptr), ##__VA_ARGS__) + buf_get_id(buf_ptr), ##__VA_ARGS__) #define buf_warn(buf_ptr, __e, ...) LOG_WRN(__BUF_FMT __e, trace_buf_get_id(buf_ptr), \ - trace_buf_get_subid(buf_ptr), ##__VA_ARGS__) + buf_get_id(buf_ptr), ##__VA_ARGS__) #define buf_info(buf_ptr, __e, ...) LOG_INF(__BUF_FMT __e, trace_buf_get_id(buf_ptr), \ - trace_buf_get_subid(buf_ptr), ##__VA_ARGS__) + buf_get_id(buf_ptr), ##__VA_ARGS__) #define buf_dbg(buf_ptr, __e, ...) LOG_DBG(__BUF_FMT __e, trace_buf_get_id(buf_ptr), \ - trace_buf_get_subid(buf_ptr), ##__VA_ARGS__) + buf_get_id(buf_ptr), ##__VA_ARGS__) #else /** \brief Trace error message from buffer */ #define buf_err(buf_ptr, __e, ...) \ trace_dev_err(trace_buf_get_tr_ctx, trace_buf_get_id, \ - trace_buf_get_subid, \ + buf_get_id, \ (__sparse_force const struct comp_buffer *)buf_ptr, \ __e, ##__VA_ARGS__) /** \brief Trace warning message from buffer */ #define buf_warn(buf_ptr, __e, ...) \ trace_dev_warn(trace_buf_get_tr_ctx, trace_buf_get_id, \ - trace_buf_get_subid, \ + buf_get_id, \ (__sparse_force const struct comp_buffer *)buf_ptr, \ __e, ##__VA_ARGS__) /** \brief Trace info message from buffer */ #define buf_info(buf_ptr, __e, ...) \ trace_dev_info(trace_buf_get_tr_ctx, trace_buf_get_id, \ - trace_buf_get_subid, \ + buf_get_id, \ (__sparse_force const struct comp_buffer *)buf_ptr, \ __e, ##__VA_ARGS__) @@ -97,7 +97,7 @@ extern struct tr_ctx buffer_tr; #else #define buf_dbg(buf_ptr, __e, ...) \ trace_dev_dbg(trace_buf_get_tr_ctx, trace_buf_get_id, \ - trace_buf_get_subid, \ + buf_get_id, \ (__sparse_force const struct comp_buffer *)buf_ptr, \ __e, ##__VA_ARGS__) #endif @@ -139,7 +139,6 @@ struct comp_buffer { struct audio_stream stream; /* configuration */ - uint32_t id; uint32_t pipeline_id; uint32_t caps; uint32_t core; diff --git a/src/ipc/ipc-helper.c b/src/ipc/ipc-helper.c index 44983f6e6f95..dc18f8467c76 100644 --- a/src/ipc/ipc-helper.c +++ b/src/ipc/ipc-helper.c @@ -47,7 +47,7 @@ struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared buffer = buffer_alloc(desc->size, desc->caps, desc->flags, PLATFORM_DCACHE_ALIGN, is_shared); if (buffer) { - buffer->id = desc->comp.id; + buffer->stream.runtime_stream_params.id = desc->comp.id; buffer->pipeline_id = desc->comp.pipeline_id; buffer->core = desc->comp.core; diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index c40ca308c21e..4006ce82be8d 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -614,7 +614,7 @@ int ipc_comp_disconnect(struct ipc *ipc, ipc_pipe_comp_connect *_connect) buffer_id = IPC4_COMP_ID(bu->extension.r.src_queue, bu->extension.r.dst_queue); list_for_item(sink_list, &src->bsink_list) { struct comp_buffer *buf = container_of(sink_list, struct comp_buffer, source_list); - bool found = buf->id == buffer_id; + bool found = buf_get_id(buf) == buffer_id; if (found) { buffer = buf; diff --git a/src/probe/probe.c b/src/probe/probe.c index 933cea584f6d..1e24331698eb 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -1073,7 +1073,7 @@ static struct comp_buffer *ipc4_get_buffer(struct ipc_comp_dev *dev, probe_point case PROBE_TYPE_INPUT: list_for_item(source_list, &dev->cd->bsource_list) { buf = container_of(source_list, struct comp_buffer, sink_list); - queue_id = IPC4_SRC_QUEUE_ID(buf->id); + queue_id = IPC4_SRC_QUEUE_ID(buf_get_id(buf)); if (queue_id == probe_point.fields.index) return buf; @@ -1082,7 +1082,7 @@ static struct comp_buffer *ipc4_get_buffer(struct ipc_comp_dev *dev, probe_point case PROBE_TYPE_OUTPUT: list_for_item(sink_list, &dev->cd->bsink_list) { buf = container_of(sink_list, struct comp_buffer, source_list); - queue_id = IPC4_SINK_QUEUE_ID(buf->id); + queue_id = IPC4_SINK_QUEUE_ID(buf_get_id(buf)); if (queue_id == probe_point.fields.index) return buf; diff --git a/src/samples/audio/smart_amp_test_ipc4.c b/src/samples/audio/smart_amp_test_ipc4.c index 616920543197..d09a8f9a9720 100644 --- a/src/samples/audio/smart_amp_test_ipc4.c +++ b/src/samples/audio/smart_amp_test_ipc4.c @@ -289,7 +289,8 @@ static int smart_amp_process(struct processing_module *mod, for (i = 0; i < num_input_buffers; i++) { buf = container_of(input_buffers[i].data, struct comp_buffer, stream); - if (IPC4_SINK_QUEUE_ID(buf->id) == SOF_SMART_AMP_FEEDBACK_QUEUE_ID) { + if (IPC4_SINK_QUEUE_ID(buf_get_id(buf)) == + SOF_SMART_AMP_FEEDBACK_QUEUE_ID) { fb_input = &input_buffers[i]; fb_buf_c = buf; } else { @@ -356,7 +357,8 @@ static int smart_amp_prepare(struct processing_module *mod, source_buffer = container_of(blist, struct comp_buffer, sink_list); audio_stream_init_alignment_constants(1, 1, &source_buffer->stream); - if (IPC4_SINK_QUEUE_ID(source_buffer->id) == SOF_SMART_AMP_FEEDBACK_QUEUE_ID) { + if (IPC4_SINK_QUEUE_ID(buf_get_id(source_buffer)) == + SOF_SMART_AMP_FEEDBACK_QUEUE_ID) { audio_stream_set_channels(&source_buffer->stream, sad->config.feedback_channels); audio_stream_set_rate(&source_buffer->stream,