Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline2.0: step3, make all components using API instead of direct access to bsink_list and bsource_list #9478

Merged
merged 5 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ static int aria_prepare(struct processing_module *mod,

comp_info(dev, "aria_prepare()");

source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
source = comp_dev_get_first_data_producer(dev);
aria_set_stream_params(source, mod);

sink = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
sink = comp_dev_get_first_data_consumer(dev);
aria_set_stream_params(sink, mod);

if (audio_stream_get_valid_fmt(&source->stream) != SOF_IPC_FRAME_S24_4LE ||
Expand Down
22 changes: 8 additions & 14 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,8 @@ static int asrc_params(struct processing_module *mod)
return -EINVAL;
}

sourceb = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer,
source_list);
sourceb = comp_dev_get_first_data_producer(dev);
sinkb = comp_dev_get_first_data_consumer(dev);

/* update the source/sink buffer formats. Sink rate will be modified below */
asrc_update_buffer_format(sourceb, cd);
Expand Down Expand Up @@ -452,7 +450,7 @@ static int asrc_dai_find(struct comp_dev *dev, struct comp_data *cd)
if (cd->mode == ASRC_OM_PUSH) {
/* In push mode check if sink component is DAI */
do {
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
sinkb = comp_dev_get_first_data_consumer(dev);

dev = sinkb->sink;

Expand All @@ -470,7 +468,7 @@ static int asrc_dai_find(struct comp_dev *dev, struct comp_data *cd)
} else {
/* In pull mode check if source component is DAI */
do {
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);

dev = sourceb->source;

Expand Down Expand Up @@ -545,10 +543,8 @@ static int asrc_prepare(struct processing_module *mod,
return ret;

/* SRC component will only ever have 1 source and 1 sink buffer */
sourceb = list_first_item(&dev->bsource_list,
struct comp_buffer, sink_list);
sinkb = list_first_item(&dev->bsink_list,
struct comp_buffer, source_list);
sourceb = comp_dev_get_first_data_producer(dev);
sinkb = comp_dev_get_first_data_consumer(dev);

/* get source data format and period bytes */
cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream);
Expand Down Expand Up @@ -796,10 +792,8 @@ static int asrc_process(struct processing_module *mod,
return ret;

/* asrc component needs 1 source and 1 sink buffer */
source = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
sink = list_first_item(&dev->bsink_list, struct comp_buffer,
source_list);
source = comp_dev_get_first_data_producer(dev);
sink = comp_dev_get_first_data_consumer(dev);

frames_src = audio_stream_get_avail_frames(source_s);
frames_snk = audio_stream_get_free_frames(sink_s);
Expand Down
3 changes: 1 addition & 2 deletions src/audio/codec/dts/dts.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ static int dts_effect_convert_sof_interface_result(struct comp_dev *dev,
static int dts_effect_populate_buffer_configuration(struct comp_dev *dev,
DtsSofInterfaceBufferConfiguration *buffer_config)
{
struct comp_buffer *source = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
struct comp_buffer *source = comp_dev_get_first_data_producer(dev);
const struct audio_stream *stream;
DtsSofInterfaceBufferLayout buffer_layout;
DtsSofInterfaceBufferFormat buffer_format;
Expand Down
16 changes: 7 additions & 9 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
return -EINVAL;
}

buffer = list_first_item(&dai_copier->bsource_list, struct comp_buffer, sink_list);
buffer = comp_dev_get_first_data_producer(dai_copier);
pipe_reg.stream_start_offset = posn.dai_posn +
latency * audio_stream_period_bytes(&buffer->stream, dev->frames);
pipe_reg.stream_end_offset = 0;
Expand All @@ -412,7 +412,7 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
return -EINVAL;
}

buffer = list_first_item(&dai_copier->bsource_list, struct comp_buffer, sink_list);
buffer = comp_dev_get_first_data_producer(dai_copier);
pipe_reg.stream_start_offset += latency *
audio_stream_period_bytes(&buffer->stream, dev->frames);
mailbox_sw_regs_write(cd->pipeline_reg_offset, &pipe_reg.stream_start_offset,
Expand Down Expand Up @@ -455,15 +455,13 @@ static int copier_copy_to_sinks(struct copier_data *cd, struct comp_dev *dev,
struct comp_buffer *src_c,
struct comp_copy_limits *processed_data)
{
struct list_item *sink_list;
struct comp_buffer *sink;
int ret = 0;

/* module copy, one source to multiple sink buffers */
list_for_item(sink_list, &dev->bsink_list) {
comp_dev_for_each_consumer(dev, sink) {
struct comp_dev *sink_dev;

sink = container_of(sink_list, struct comp_buffer, source_list);
sink_dev = sink->sink;
processed_data->sink_bytes = 0;
if (sink_dev->state == COMP_STATE_ACTIVE) {
Expand Down Expand Up @@ -563,7 +561,7 @@ static int copier_multi_endpoint_dai_copy(struct copier_data *cd, struct comp_de
return -EINVAL;
}

src = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
src = comp_dev_get_first_data_producer(dev);

/* gateway(s) on output */
ret = do_conversion_copy(dev, cd, src, cd->multi_endpoint_buffer, &processed_data);
Expand Down Expand Up @@ -1066,14 +1064,14 @@ static int copier_bind(struct processing_module *mod, void *data)
const uint32_t src_queue_id = bu->extension.r.src_queue;
struct copier_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;
struct list_item *list;

if (dev->ipc_config.id != src_id)
return 0; /* Another component is a data producer */

/* update sink format */
list_for_item(list, &dev->bsink_list) {
struct comp_buffer *buffer = container_of(list, struct comp_buffer, source_list);
struct comp_buffer *buffer;

comp_dev_for_each_consumer(dev, buffer) {
uint32_t id = IPC4_SRC_QUEUE_ID(buf_get_id(buffer));

if (src_queue_id == id) {
Expand Down
6 changes: 1 addition & 5 deletions src/audio/copier/copier_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
struct sof_ipc_stream_params *params)
{
struct comp_buffer *sink;
struct list_item *sink_list;

memset(params, 0, sizeof(*params));
params->direction = cd->direction;
Expand All @@ -80,11 +79,8 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
params->no_stream_position = 1;

/* update each sink format */
list_for_item(sink_list, &dev->bsink_list) {
comp_dev_for_each_consumer(dev, sink) {
int j;

sink = container_of(sink_list, struct comp_buffer, source_list);

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/copier/copier_ipcgtw.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ static inline struct comp_buffer *get_buffer(struct comp_dev *dev)
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
if (list_is_empty(&dev->bsink_list))
return NULL;
return list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
return comp_dev_get_first_data_consumer(dev);
}

assert(dev->direction == SOF_IPC_STREAM_CAPTURE);

if (list_is_empty(&dev->bsource_list))
return NULL;
return list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
return comp_dev_get_first_data_producer(dev);
}

int copier_ipcgtw_process(const struct ipc4_ipcgtw_cmd *cmd,
Expand Down
10 changes: 3 additions & 7 deletions src/audio/crossover/crossover.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,13 @@ static int crossover_assign_sinks(struct processing_module *mod,
struct sof_crossover_config *config = cd->config;
struct comp_dev *dev = mod->dev;
struct comp_buffer *sink;
struct list_item *sink_list;
int num_sinks = 0;
int i;
int j = 0;

list_for_item(sink_list, &dev->bsink_list) {
comp_dev_for_each_consumer(dev, sink) {
unsigned int sink_id, state;

sink = container_of(sink_list, struct comp_buffer, source_list);
sink_id = crossover_get_sink_id(cd, buffer_pipeline_id(sink), j);
state = sink->sink->state;
if (state != dev->state) {
Expand Down Expand Up @@ -529,7 +527,6 @@ static int crossover_prepare(struct processing_module *mod,
struct comp_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;
struct comp_buffer *source, *sink;
struct list_item *sink_list;
int channels;
int ret = 0;

Expand All @@ -539,15 +536,14 @@ static int crossover_prepare(struct processing_module *mod,

/* Crossover has a variable number of sinks */
mod->max_sinks = SOF_CROSSOVER_MAX_STREAMS;
source = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
source = comp_dev_get_first_data_producer(dev);

/* Get source data format */
cd->source_format = audio_stream_get_frm_fmt(&source->stream);
channels = audio_stream_get_channels(&source->stream);

/* Validate frame format and buffer size of sinks */
list_for_item(sink_list, &dev->bsink_list) {
sink = container_of(sink_list, struct comp_buffer, source_list);
comp_dev_for_each_consumer(dev, sink) {
if (cd->source_format != audio_stream_get_frm_fmt(&sink->stream)) {
comp_err(dev, "crossover_prepare(): Source fmt %d and sink fmt %d are different.",
cd->source_format, audio_stream_get_frm_fmt(&sink->stream));
Expand Down
4 changes: 1 addition & 3 deletions src/audio/crossover/crossover_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ int crossover_check_sink_assign(struct processing_module *mod,
{
struct comp_dev *dev = mod->dev;
struct comp_buffer *sink;
struct list_item *sink_list;
int num_assigned_sinks = 0;
uint8_t assigned_sinks[SOF_CROSSOVER_MAX_STREAMS] = {0};
int i;

list_for_item(sink_list, &dev->bsink_list) {
comp_dev_for_each_consumer(dev, sink) {
unsigned int pipeline_id;

sink = container_of(sink_list, struct comp_buffer, source_list);
pipeline_id = buffer_pipeline_id(sink);

i = crossover_get_stream_index(mod, config, pipeline_id);
Expand Down
6 changes: 2 additions & 4 deletions src/audio/crossover/crossover_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,17 @@ void crossover_params(struct processing_module *mod)
{
struct sof_ipc_stream_params *params = mod->stream_params;
struct comp_buffer *sinkb, *sourceb;
struct list_item *sink_list;
struct comp_dev *dev = mod->dev;

comp_dbg(dev, "crossover_params()");

ipc4_base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params);
component_set_nearest_period_frames(dev, params->rate);

sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sourceb = comp_dev_get_first_data_producer(dev);
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);

list_for_item(sink_list, &dev->bsink_list) {
sinkb = container_of(sink_list, struct comp_buffer, source_list);
comp_dev_for_each_consumer(dev, sinkb) {
ipc4_update_buffer_format(sinkb, &mod->priv.cfg.base_cfg.audio_fmt);
}
}
8 changes: 2 additions & 6 deletions src/audio/dai-legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,9 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev,
}

if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
dd->local_buffer = list_first_item(&dev->bsource_list,
struct comp_buffer,
sink_list);
dd->local_buffer = comp_dev_get_first_data_producer(dev);
else
dd->local_buffer = list_first_item(&dev->bsink_list,
struct comp_buffer,
source_list);
dd->local_buffer = comp_dev_get_first_data_consumer(dev);

/* check if already configured */
if (dev->state == COMP_STATE_PREPARE) {
Expand Down
45 changes: 16 additions & 29 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,18 +269,16 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,

if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
#if CONFIG_IPC_MAJOR_4
struct list_item *sink_list;
/*
* copy from local buffer to all sinks that are not gateway buffers
* using the right PCM converter function.
*/
list_for_item(sink_list, &dev->bsink_list) {
struct comp_buffer *sink;

comp_dev_for_each_consumer(dev, sink) {
struct comp_dev *sink_dev;
struct comp_buffer *sink;
int j;

sink = container_of(sink_list, struct comp_buffer, source_list);

if (sink == dd->dma_buffer)
continue;

Expand Down Expand Up @@ -319,20 +317,18 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
ret = stream_copy_from_no_consume(dd->dma_buffer, dd->local_buffer,
dd->process, bytes, dd->chmap);
#if CONFIG_IPC_MAJOR_4
struct list_item *sink_list;
/* Skip in case of endpoint DAI devices created by the copier */
if (converter) {
/*
* copy from DMA buffer to all sink buffers using the right PCM converter
* function
*/
list_for_item(sink_list, &dev->bsink_list) {
struct comp_buffer *sink;

comp_dev_for_each_consumer(dev, sink) {
struct comp_dev *sink_dev;
struct comp_buffer *sink;
int j;

sink = container_of(sink_list, struct comp_buffer, source_list);

/* this has been handled above already */
if (sink == dd->local_buffer)
continue;
Expand Down Expand Up @@ -852,11 +848,9 @@ static int dai_set_dma_buffer(struct dai_data *dd, struct comp_dev *dev,
comp_dbg(dev, "dai_set_dma_buffer()");

if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
dd->local_buffer = list_first_item(&dev->bsource_list, struct comp_buffer,
sink_list);
dd->local_buffer = comp_dev_get_first_data_producer(dev);
else
dd->local_buffer = list_first_item(&dev->bsink_list, struct comp_buffer,
source_list);
dd->local_buffer = comp_dev_get_first_data_consumer(dev);

/* check if already configured */
if (dev->state == COMP_STATE_PREPARE) {
Expand Down Expand Up @@ -1524,13 +1518,9 @@ static void set_new_local_buffer(struct dai_data *dd, struct comp_dev *dev)
uint32_t local_fmt;

if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
dd->local_buffer = list_first_item(&dev->bsource_list,
struct comp_buffer,
sink_list);
dd->local_buffer = comp_dev_get_first_data_producer(dev);
else
dd->local_buffer = list_first_item(&dev->bsink_list,
struct comp_buffer,
source_list);
dd->local_buffer = comp_dev_get_first_data_consumer(dev);

local_fmt = audio_stream_get_frm_fmt(&dd->local_buffer->stream);

Expand Down Expand Up @@ -1595,17 +1585,16 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
sink_frames = free_bytes / audio_stream_frame_bytes(&dd->dma_buffer->stream);
frames = MIN(src_frames, sink_frames);

struct list_item *sink_list;
/*
* In the case of playback DAI's with multiple sink buffers, compute the
* minimum number of frames based on the DMA avail_bytes and the free
* samples in all active sink buffers.
*/
list_for_item(sink_list, &dev->bsink_list) {
struct comp_buffer *sink;

comp_dev_for_each_consumer(dev, sink) {
struct comp_dev *sink_dev;
struct comp_buffer *sink;

sink = container_of(sink_list, struct comp_buffer, source_list);
sink_dev = sink->sink;

if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE &&
Expand All @@ -1616,8 +1605,6 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
}
}
} else {
struct list_item *sink_list;

src_frames = avail_bytes / audio_stream_frame_bytes(&dd->dma_buffer->stream);

/*
Expand All @@ -1633,11 +1620,11 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
* minimum number of samples based on the DMA avail_bytes and the free
* samples in all active sink buffers.
*/
list_for_item(sink_list, &dev->bsink_list) {
struct comp_buffer *sink;

comp_dev_for_each_consumer(dev, sink) {
struct comp_dev *sink_dev;
struct comp_buffer *sink;

sink = container_of(sink_list, struct comp_buffer, source_list);
sink_dev = sink->sink;

if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE &&
Expand Down
Loading
Loading