Skip to content

Commit

Permalink
x_source_list completed with some opens
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinszkudlinski committed Sep 11, 2024
1 parent bfa1d27 commit c4b3d68
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 48 deletions.
8 changes: 5 additions & 3 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,20 +1067,22 @@ 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, Xsource_list);
struct comp_buffer *buffer = comp_dev_get_first_data_consumer(dev);

while (buffer) {
uint32_t id = IPC4_SRC_QUEUE_ID(buf_get_id(buffer));

if (src_queue_id == id) {
ipc4_update_buffer_format(buffer, &cd->out_fmt[id]);
return 0;
}

buffer = comp_dev_get_next_data_consumer(dev, buffer);
}

comp_err(dev, "No sink buffer found for src_queue = %u", src_queue_id);
Expand Down
14 changes: 8 additions & 6 deletions src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ static int kpb_bind(struct comp_dev *dev, void *data)
{
struct comp_data *kpb = comp_get_drvdata(dev);
struct ipc4_module_bind_unbind *bu;
struct list_item *blist;
int buf_id;
int ret = 0;

Expand All @@ -343,9 +342,9 @@ static int kpb_bind(struct comp_dev *dev, void *data)
* (Detector/MicSel has one input pin). To properly connect KPB sink
* with Detector source we're looking for buffer with id=0.
*/
struct comp_buffer *sink = comp_dev_get_first_data_consumer(dev);

list_for_item(blist, &dev->bsink_list) {
struct comp_buffer *sink = container_of(blist, struct comp_buffer, Xsource_list);
while (sink) {
int sink_buf_id;

if (!sink->Xsink) {
Expand All @@ -361,6 +360,8 @@ static int kpb_bind(struct comp_dev *dev, void *data)
else
kpb->host_sink = sink;
}

sink = comp_dev_get_next_data_consumer(dev, sink);
}

return ret;
Expand Down Expand Up @@ -858,10 +859,9 @@ static int kpb_prepare(struct comp_dev *dev)
* NOTE! We assume here that channel selector component device
* is connected to the KPB sinks as well as host device.
*/
struct list_item *blist;
struct comp_buffer *sink = comp_dev_get_first_data_consumer(dev);

list_for_item(blist, &dev->bsink_list) {
struct comp_buffer *sink = container_of(blist, struct comp_buffer, Xsource_list);
while (sink) {
enum sof_comp_type type;

if (!sink->Xsink) {
Expand All @@ -882,6 +882,8 @@ static int kpb_prepare(struct comp_dev *dev)
default:
break;
}

sink = comp_dev_get_next_data_consumer(dev, sink);
}
#else
/* Update number of sel_sink channels.
Expand Down
25 changes: 14 additions & 11 deletions src/audio/module_adapter/module_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ static void module_adapter_process_output(struct comp_dev *dev)
if (i == j) {
struct comp_buffer *source;

sink = container_of(blist, struct comp_buffer, Xsource_list);
sink = container_of(blist, struct comp_buffer, Xsource_list); //msz ???
source = container_of(_blist, struct comp_buffer, Xsink_list);

module_copy_samples(dev, source, sink,
Expand Down Expand Up @@ -785,7 +785,6 @@ static int module_adapter_audio_stream_type_copy(struct comp_dev *dev)
struct comp_buffer *sources[PLATFORM_MAX_STREAMS];
struct comp_buffer *sinks[PLATFORM_MAX_STREAMS];
struct processing_module *mod = comp_mod(dev);
struct list_item *blist;
uint32_t num_input_buffers, num_output_buffers;
int ret, i = 0;

Expand All @@ -797,11 +796,12 @@ static int module_adapter_audio_stream_type_copy(struct comp_dev *dev)
return module_adapter_audio_stream_copy_1to1(dev);

/* acquire all sink and source buffers */
list_for_item(blist, &dev->bsink_list) {
struct comp_buffer *sink;
struct comp_buffer *sink = comp_dev_get_first_data_consumer(dev);

sink = container_of(blist, struct comp_buffer, Xsource_list);
while (sink) {
sinks[i++] = sink;

sink = comp_dev_get_next_data_consumer(dev, sink);
}
num_output_buffers = i;
if (num_output_buffers > mod->max_sinks) {
Expand All @@ -810,6 +810,8 @@ static int module_adapter_audio_stream_type_copy(struct comp_dev *dev)
}

i = 0;
struct list_item *blist;

list_for_item(blist, &dev->bsource_list) {
struct comp_buffer *source;

Expand Down Expand Up @@ -910,16 +912,16 @@ static int module_adapter_copy_ring_buffers(struct comp_dev *dev)
* DP module processing itself will take place in DP thread
* This is an adapter, to be removed when pipeline2.0 is ready
*/
struct processing_module *mod = comp_mod(dev);
struct comp_buffer *buffer;
struct list_item *blist;
struct processing_module *mod = comp_mod(dev);
int err;

list_for_item(blist, &dev->bsource_list) {
/* input - we need to copy data from audio_stream (as source)
* to ring_buffer (as sink)
*/
struct comp_buffer *buffer =
container_of(blist, struct comp_buffer, Xsink_list);
buffer = container_of(blist, struct comp_buffer, Xsink_list);
err = audio_buffer_sync_secondary_buffer(&buffer->audio_buffer, UINT_MAX);

if (err) {
Expand All @@ -931,7 +933,8 @@ static int module_adapter_copy_ring_buffers(struct comp_dev *dev)
if (mod->dp_startup_delay)
return 0;

list_for_item(blist, &dev->bsink_list) {
buffer = comp_dev_get_first_data_consumer(dev);
while(buffer) {
/* output - we need to copy data from ring_buffer (as source)
* to audio_stream (as sink)
*
Expand All @@ -944,8 +947,6 @@ static int module_adapter_copy_ring_buffers(struct comp_dev *dev)
*
* FIX: copy only the following module's IBS in each LL cycle
*/
struct comp_buffer *buffer =
container_of(blist, struct comp_buffer, Xsource_list);
struct sof_source *following_mod_data_source =
audio_buffer_get_source(&buffer->audio_buffer);

Expand All @@ -957,6 +958,8 @@ static int module_adapter_copy_ring_buffers(struct comp_dev *dev)
comp_err(dev, "DP to LL copy error status: %d", err);
return err;
}

buffer = comp_dev_get_next_data_consumer(dev, buffer);
}
return 0;
}
Expand Down
9 changes: 5 additions & 4 deletions src/audio/module_adapter/module_adapter_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,18 @@ int module_adapter_cmd(struct comp_dev *dev, int cmd, void *data, int max_data_s
int module_adapter_sink_src_prepare(struct comp_dev *dev)
{
struct processing_module *mod = comp_mod(dev);
struct list_item *blist;
int ret;
int i;

/* acquire all sink and source buffers, get handlers to sink/source API */
i = 0;
list_for_item(blist, &dev->bsink_list) {
struct comp_buffer *sink_buffer =
container_of(blist, struct comp_buffer, Xsource_list);
struct comp_buffer *sink_buffer = comp_dev_get_first_data_consumer(dev);

while (sink_buffer) {
mod->sinks[i] = audio_buffer_get_sink(&sink_buffer->audio_buffer);
i++;

sink_buffer = comp_dev_get_next_data_consumer(dev, sink_buffer);
}
mod->num_of_sinks = i;

Expand Down
8 changes: 5 additions & 3 deletions src/audio/module_adapter/module_adapter_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,13 @@ static bool module_adapter_multi_sink_source_prepare(struct comp_dev *dev)

/* acquire all sink and source buffers, get handlers to sink/source API */
i = 0;
list_for_item(blist, &dev->bsink_list) {
struct comp_buffer *sink_buffer =
container_of(blist, struct comp_buffer, Xsource_list);
struct comp_buffer *sink_buffer = comp_dev_get_first_data_consumer(dev);

while (sink_buffer) {
mod->sinks[i] = audio_buffer_get_sink(&sink_buffer->audio_buffer);
i++;

sink_buffer = comp_dev_get_next_data_consumer(dev, sink_buffer);
}
mod->num_of_sinks = i;

Expand Down
9 changes: 5 additions & 4 deletions src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ static int demux_process(struct processing_module *mod,
{
struct comp_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;
struct list_item *clist;
struct comp_buffer *sink;
struct audio_stream *sinks_stream[MUX_MAX_STREAMS] = { NULL };
struct mux_look_up *look_ups[MUX_MAX_STREAMS] = { NULL };
Expand All @@ -245,8 +244,8 @@ static int demux_process(struct processing_module *mod,
comp_dbg(dev, "demux_process()");

/* align sink streams with their respective configurations */
list_for_item(clist, &dev->bsink_list) {
sink = container_of(clist, struct comp_buffer, Xsource_list);
sink = comp_dev_get_first_data_consumer(dev);
while (sink) {
if (sink->Xsink->state == dev->state) {
i = get_stream_index(dev, cd, buffer_pipeline_id(sink));
/* return if index wrong */
Expand All @@ -257,6 +256,8 @@ static int demux_process(struct processing_module *mod,
look_ups[i] = get_lookup_table(dev, cd, buffer_pipeline_id(sink));
sinks_stream[i] = &sink->stream;
}

sink = comp_dev_get_next_data_consumer(dev, sink);
}

/* if there are no sinks active, then sinks[] is also empty */
Expand Down Expand Up @@ -449,7 +450,7 @@ static int demux_trigger(struct processing_module *mod, int cmd)
*/
if (cmd == COMP_TRIGGER_PRE_START) {
list_for_item(li, &mod->dev->bsink_list) {
b = container_of(li, struct comp_buffer, Xsource_list);
b = container_of(li, struct comp_buffer, Xsource_list); //msz ?????
if (b->Xsink->pipeline != mod->dev->pipeline)
audio_stream_set_overrun(&b->stream, true);
}
Expand Down
3 changes: 1 addition & 2 deletions src/ipc/ipc-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ int ipc_comp_free(struct ipc *ipc, uint32_t comp_id)
}

list_for_item_safe(clist, tmp, &icd->cd->bsink_list) {
struct comp_buffer *buffer = container_of(clist, struct comp_buffer, Xsource_list);

struct comp_buffer *buffer = container_of(clist, struct comp_buffer, Xsource_list); //msz ???
buffer->Xsource = NULL;
/* Also if it isn't shared - we are about to modify uncached data */
dcache_writeback_invalidate_region(uncache_to_cache(buffer),
Expand Down
11 changes: 4 additions & 7 deletions src/ipc/ipc3/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,14 @@ struct ipc_cmd_hdr *mailbox_validate(void)
/* check if a pipeline is hostless when walking downstream */
static bool is_hostless_downstream(struct comp_dev *current)
{
struct list_item *clist;

/* check if current is a HOST comp */
if (current->ipc_config.type == SOF_COMP_HOST ||
current->ipc_config.type == SOF_COMP_SG_HOST)
return false;

/* check if the pipeline has a HOST comp downstream */
list_for_item(clist, &current->bsink_list) {
struct comp_buffer *buffer;

buffer = container_of(clist, struct comp_buffer, Xsource_list);

struct comp_buffer *buffer = comp_dev_get_first_data_consumer(dev);
while (buffer) {
/* don't go downstream if this component is not connected */
if (!buffer->Xsink)
continue;
Expand All @@ -160,6 +155,8 @@ static bool is_hostless_downstream(struct comp_dev *current)
/* return if there's a host comp downstream */
if (!is_hostless_downstream(buffer->Xsink))
return false;

buffer = comp_dev_get_next_data_consumer(dev, sink);
}

return true;
Expand Down
19 changes: 14 additions & 5 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ static inline int ipc_comp_free_remote(struct comp_dev *dev)
return idc_send_msg(&msg, IDC_BLOCKING);
}

__attribute__((optimize("-O0")))
static int ipc_pipeline_module_free(uint32_t pipeline_id)
{
struct ipc *ipc = ipc_get();
Expand All @@ -286,19 +287,24 @@ static int ipc_pipeline_module_free(uint32_t pipeline_id)
icd = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_COMPONENT, pipeline_id, IPC_COMP_ALL);
while (icd) {
struct list_item *list, *_list;
struct comp_buffer *buffer;
struct comp_buffer *buffer = comp_dev_get_first_data_consumer(icd->cd);

/* free sink buffer allocated by current component in bind function */
list_for_item_safe(list, _list, &icd->cd->bsink_list) {
while (buffer) {
/* save next buffer pointer, as the buffer will be removed from list */
struct comp_buffer *next_buffer =
comp_dev_get_next_data_consumer(icd->cd, buffer);

struct comp_dev *sink;

buffer = container_of(list, struct comp_buffer, Xsource_list);
pipeline_disconnect(icd->cd, buffer, PPL_CONN_DIR_COMP_TO_BUFFER);
sink = buffer->Xsink;

/* free the buffer only when the sink module has also been disconnected */
if (!sink)
buffer_free(buffer);

buffer = next_buffer;
}

/* free source buffer allocated by current component in bind function */
Expand Down Expand Up @@ -697,14 +703,17 @@ int ipc_comp_disconnect(struct ipc *ipc, ipc_pipe_comp_connect *_connect)
return ipc4_process_on_core(src->ipc_config.core, false);

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, Xsource_list);
struct comp_buffer *buf = comp_dev_get_first_data_consumer(src);

while (buf) {
bool found = buf_get_id(buf) == buffer_id;

if (found) {
buffer = buf;
break;
}

buf = comp_dev_get_next_data_consumer(src, buf);
}

if (!buffer)
Expand Down
6 changes: 4 additions & 2 deletions src/probe/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,12 +1075,14 @@ static struct comp_buffer *ipc4_get_buffer(struct ipc_comp_dev *dev, probe_point
}
break;
case PROBE_TYPE_OUTPUT:
list_for_item(sink_list, &dev->cd->bsink_list) {
buf = container_of(sink_list, struct comp_buffer, Xsource_list);
buf = comp_dev_get_first_data_consumer(dev->cd);
while(buf) {
queue_id = IPC4_SINK_QUEUE_ID(buf_get_id(buf));

if (queue_id == probe_point.fields.index)
return buf;

buf = comp_dev_get_next_data_consumer(dev->cd, buf);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/cmocka/src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static inline struct comp_buffer *create_test_sink(struct comp_dev *dev,

/* set bsink list */
if (dev)
list_item_append(&buffer->Xsource_list, &dev->bsink_list);
list_item_append(&buffer->Xsource_list, &dev->bsink_list); //msz

/* alloc sink and set default parameters */
buffer->Xsink = calloc(1, sizeof(struct comp_dev));
Expand Down

0 comments on commit c4b3d68

Please sign in to comment.