Skip to content

Commit

Permalink
buf: move buffer/stream ID to runtime_stream_params
Browse files Browse the repository at this point in the history
runtime_stream_params is a container for all
parameters of a stream
Add an API call to retrieve it

Signed-off-by: Marcin Szkudlinski <[email protected]>
  • Loading branch information
marcinszkudlinski authored and kv2019i committed Nov 22, 2023
1 parent ee80da7 commit a62b7cf
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 33 deletions.
6 changes: 3 additions & 3 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/audio/copier/copier_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/audio/google/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/audio/mixin_mixout/mixin_mixout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/audio/pipeline/pipeline-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/audio/rtnr/rtnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/include/sof/audio/audio_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
19 changes: 9 additions & 10 deletions src/include/sof/audio/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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__)

Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ipc/ipc-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/probe/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/samples/audio/smart_amp_test_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a62b7cf

Please sign in to comment.