Skip to content

Commit 5c35b40

Browse files
buf: use API for sink iteration in components
this commit changes all components to use comp_dev_for_each_consumer for iteration through bsink_list pipeline code, like module adapter or ipc helpers was omitted intentionally Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
1 parent f5db20a commit 5c35b40

File tree

10 files changed

+32
-62
lines changed

10 files changed

+32
-62
lines changed

src/audio/copier/copier.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,15 +455,13 @@ static int copier_copy_to_sinks(struct copier_data *cd, struct comp_dev *dev,
455455
struct comp_buffer *src_c,
456456
struct comp_copy_limits *processed_data)
457457
{
458-
struct list_item *sink_list;
459458
struct comp_buffer *sink;
460459
int ret = 0;
461460

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

466-
sink = container_of(sink_list, struct comp_buffer, source_list);
467465
sink_dev = sink->sink;
468466
processed_data->sink_bytes = 0;
469467
if (sink_dev->state == COMP_STATE_ACTIVE) {
@@ -1066,14 +1064,14 @@ static int copier_bind(struct processing_module *mod, void *data)
10661064
const uint32_t src_queue_id = bu->extension.r.src_queue;
10671065
struct copier_data *cd = module_get_private_data(mod);
10681066
struct comp_dev *dev = mod->dev;
1069-
struct list_item *list;
10701067

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

10741071
/* update sink format */
1075-
list_for_item(list, &dev->bsink_list) {
1076-
struct comp_buffer *buffer = container_of(list, struct comp_buffer, source_list);
1072+
struct comp_buffer *buffer;
1073+
1074+
comp_dev_for_each_consumer(dev, buffer) {
10771075
uint32_t id = IPC4_SRC_QUEUE_ID(buf_get_id(buffer));
10781076

10791077
if (src_queue_id == id) {

src/audio/copier/copier_generic.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev,
6262
struct sof_ipc_stream_params *params)
6363
{
6464
struct comp_buffer *sink;
65-
struct list_item *sink_list;
6665

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

8281
/* update each sink format */
83-
list_for_item(sink_list, &dev->bsink_list) {
82+
comp_dev_for_each_consumer(dev, sink) {
8483
int j;
85-
86-
sink = container_of(sink_list, struct comp_buffer, source_list);
87-
8884
j = IPC4_SINK_QUEUE_ID(buf_get_id(sink));
8985

9086
ipc4_update_buffer_format(sink, &cd->out_fmt[j]);

src/audio/crossover/crossover.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,13 @@ static int crossover_assign_sinks(struct processing_module *mod,
100100
struct sof_crossover_config *config = cd->config;
101101
struct comp_dev *dev = mod->dev;
102102
struct comp_buffer *sink;
103-
struct list_item *sink_list;
104103
int num_sinks = 0;
105104
int i;
106105
int j = 0;
107106

108-
list_for_item(sink_list, &dev->bsink_list) {
107+
comp_dev_for_each_consumer(dev, sink) {
109108
unsigned int sink_id, state;
110109

111-
sink = container_of(sink_list, struct comp_buffer, source_list);
112110
sink_id = crossover_get_sink_id(cd, buffer_pipeline_id(sink), j);
113111
state = sink->sink->state;
114112
if (state != dev->state) {
@@ -529,7 +527,6 @@ static int crossover_prepare(struct processing_module *mod,
529527
struct comp_data *cd = module_get_private_data(mod);
530528
struct comp_dev *dev = mod->dev;
531529
struct comp_buffer *source, *sink;
532-
struct list_item *sink_list;
533530
int channels;
534531
int ret = 0;
535532

@@ -546,8 +543,7 @@ static int crossover_prepare(struct processing_module *mod,
546543
channels = audio_stream_get_channels(&source->stream);
547544

548545
/* Validate frame format and buffer size of sinks */
549-
list_for_item(sink_list, &dev->bsink_list) {
550-
sink = container_of(sink_list, struct comp_buffer, source_list);
546+
comp_dev_for_each_consumer(dev, sink) {
551547
if (cd->source_format != audio_stream_get_frm_fmt(&sink->stream)) {
552548
comp_err(dev, "crossover_prepare(): Source fmt %d and sink fmt %d are different.",
553549
cd->source_format, audio_stream_get_frm_fmt(&sink->stream));

src/audio/crossover/crossover_ipc3.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,13 @@ int crossover_check_sink_assign(struct processing_module *mod,
3737
{
3838
struct comp_dev *dev = mod->dev;
3939
struct comp_buffer *sink;
40-
struct list_item *sink_list;
4140
int num_assigned_sinks = 0;
4241
uint8_t assigned_sinks[SOF_CROSSOVER_MAX_STREAMS] = {0};
4342
int i;
4443

45-
list_for_item(sink_list, &dev->bsink_list) {
44+
comp_dev_for_each_consumer(dev, sink) {
4645
unsigned int pipeline_id;
4746

48-
sink = container_of(sink_list, struct comp_buffer, source_list);
4947
pipeline_id = buffer_pipeline_id(sink);
5048

5149
i = crossover_get_stream_index(mod, config, pipeline_id);

src/audio/crossover/crossover_ipc4.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ void crossover_params(struct processing_module *mod)
111111
{
112112
struct sof_ipc_stream_params *params = mod->stream_params;
113113
struct comp_buffer *sinkb, *sourceb;
114-
struct list_item *sink_list;
115114
struct comp_dev *dev = mod->dev;
116115

117116
comp_dbg(dev, "crossover_params()");
@@ -122,8 +121,7 @@ void crossover_params(struct processing_module *mod)
122121
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
123122
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);
124123

125-
list_for_item(sink_list, &dev->bsink_list) {
126-
sinkb = container_of(sink_list, struct comp_buffer, source_list);
124+
comp_dev_for_each_consumer(dev, sinkb) {
127125
ipc4_update_buffer_format(sinkb, &mod->priv.cfg.base_cfg.audio_fmt);
128126
}
129127
}

src/audio/dai-zephyr.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,16 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
269269

270270
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
271271
#if CONFIG_IPC_MAJOR_4
272-
struct list_item *sink_list;
273272
/*
274273
* copy from local buffer to all sinks that are not gateway buffers
275274
* using the right PCM converter function.
276275
*/
277-
list_for_item(sink_list, &dev->bsink_list) {
276+
struct comp_buffer *sink;
277+
278+
comp_dev_for_each_consumer(dev, sink) {
278279
struct comp_dev *sink_dev;
279-
struct comp_buffer *sink;
280280
int j;
281281

282-
sink = container_of(sink_list, struct comp_buffer, source_list);
283-
284282
if (sink == dd->dma_buffer)
285283
continue;
286284

@@ -319,20 +317,18 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
319317
ret = stream_copy_from_no_consume(dd->dma_buffer, dd->local_buffer,
320318
dd->process, bytes, dd->chmap);
321319
#if CONFIG_IPC_MAJOR_4
322-
struct list_item *sink_list;
323320
/* Skip in case of endpoint DAI devices created by the copier */
324321
if (converter) {
325322
/*
326323
* copy from DMA buffer to all sink buffers using the right PCM converter
327324
* function
328325
*/
329-
list_for_item(sink_list, &dev->bsink_list) {
326+
struct comp_buffer *sink;
327+
328+
comp_dev_for_each_consumer(dev, sink) {
330329
struct comp_dev *sink_dev;
331-
struct comp_buffer *sink;
332330
int j;
333331

334-
sink = container_of(sink_list, struct comp_buffer, source_list);
335-
336332
/* this has been handled above already */
337333
if (sink == dd->local_buffer)
338334
continue;
@@ -1592,17 +1588,16 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
15921588
sink_frames = free_bytes / audio_stream_frame_bytes(&dd->dma_buffer->stream);
15931589
frames = MIN(src_frames, sink_frames);
15941590

1595-
struct list_item *sink_list;
15961591
/*
15971592
* In the case of playback DAI's with multiple sink buffers, compute the
15981593
* minimum number of frames based on the DMA avail_bytes and the free
15991594
* samples in all active sink buffers.
16001595
*/
1601-
list_for_item(sink_list, &dev->bsink_list) {
1596+
struct comp_buffer *sink;
1597+
1598+
comp_dev_for_each_consumer(dev, sink) {
16021599
struct comp_dev *sink_dev;
1603-
struct comp_buffer *sink;
16041600

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

16081603
if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE &&
@@ -1613,8 +1608,6 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
16131608
}
16141609
}
16151610
} else {
1616-
struct list_item *sink_list;
1617-
16181611
src_frames = avail_bytes / audio_stream_frame_bytes(&dd->dma_buffer->stream);
16191612

16201613
/*
@@ -1630,11 +1623,11 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
16301623
* minimum number of samples based on the DMA avail_bytes and the free
16311624
* samples in all active sink buffers.
16321625
*/
1633-
list_for_item(sink_list, &dev->bsink_list) {
1626+
struct comp_buffer *sink;
1627+
1628+
comp_dev_for_each_consumer(dev, sink) {
16341629
struct comp_dev *sink_dev;
1635-
struct comp_buffer *sink;
16361630

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

16401633
if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE &&

src/audio/kpb.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ static int kpb_bind(struct comp_dev *dev, void *data)
328328
{
329329
struct comp_data *kpb = comp_get_drvdata(dev);
330330
struct ipc4_module_bind_unbind *bu;
331-
struct list_item *blist;
332331
int buf_id;
333332
int ret = 0;
334333

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

347-
list_for_item(blist, &dev->bsink_list) {
348-
struct comp_buffer *sink = container_of(blist, struct comp_buffer, source_list);
347+
comp_dev_for_each_consumer(dev, sink) {
349348
int sink_buf_id;
350349

351350
if (!sink->sink) {
@@ -858,10 +857,9 @@ static int kpb_prepare(struct comp_dev *dev)
858857
* NOTE! We assume here that channel selector component device
859858
* is connected to the KPB sinks as well as host device.
860859
*/
861-
struct list_item *blist;
860+
struct comp_buffer *sink;
862861

863-
list_for_item(blist, &dev->bsink_list) {
864-
struct comp_buffer *sink = container_of(blist, struct comp_buffer, source_list);
862+
comp_dev_for_each_consumer(dev, sink) {
865863
enum sof_comp_type type;
866864

867865
if (!sink->sink) {
@@ -888,13 +886,11 @@ static int kpb_prepare(struct comp_dev *dev)
888886
* If OBS is not equal to IBS it means that KPB will work in micselector mode.
889887
*/
890888
if (kpb->ipc4_cfg.base_cfg.ibs != kpb->ipc4_cfg.base_cfg.obs) {
891-
struct list_item *sink_list;
892889
uint32_t sink_id;
893890

894-
list_for_item(sink_list, &dev->bsink_list) {
895-
struct comp_buffer *sink =
896-
container_of(sink_list, struct comp_buffer, source_list);
891+
struct comp_buffer *sink;
897892

893+
comp_dev_for_each_consumer(dev, sink) {
898894
sink_id = buf_get_id(sink);
899895

900896
if (sink_id == 0)

src/audio/mux/mux.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ static int demux_process(struct processing_module *mod,
233233
{
234234
struct comp_data *cd = module_get_private_data(mod);
235235
struct comp_dev *dev = mod->dev;
236-
struct list_item *clist;
237236
struct comp_buffer *sink;
238237
struct audio_stream *sinks_stream[MUX_MAX_STREAMS] = { NULL };
239238
struct mux_look_up *look_ups[MUX_MAX_STREAMS] = { NULL };
@@ -245,8 +244,7 @@ static int demux_process(struct processing_module *mod,
245244
comp_dbg(dev, "demux_process()");
246245

247246
/* align sink streams with their respective configurations */
248-
list_for_item(clist, &dev->bsink_list) {
249-
sink = container_of(clist, struct comp_buffer, source_list);
247+
comp_dev_for_each_consumer(dev, sink) {
250248
if (sink->sink->state == dev->state) {
251249
i = get_stream_index(dev, cd, buffer_pipeline_id(sink));
252250
/* return if index wrong */

src/audio/selector/selector.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,6 @@ static void set_selector_params(struct processing_module *mod,
644644
const struct sof_selector_ipc4_config *sel_cfg = &cd->sel_ipc4_cfg;
645645
const struct ipc4_audio_format *out_fmt = NULL;
646646
struct comp_buffer *src_buf;
647-
struct list_item *sink_list;
648647
int i;
649648

650649
if (cd->sel_ipc4_cfg.init_payload_fmt == IPC4_SEL_INIT_PAYLOAD_BASE_WITH_EXT)
@@ -664,10 +663,9 @@ static void set_selector_params(struct processing_module *mod,
664663
params->chmap[i] = (out_fmt->ch_map >> i * 4) & 0xf;
665664

666665
/* update each sink format */
667-
list_for_item(sink_list, &dev->bsink_list) {
668-
struct comp_buffer *sink_buf =
669-
container_of(sink_list, struct comp_buffer, source_list);
666+
struct comp_buffer *sink_buf;
670667

668+
comp_dev_for_each_consumer(dev, sink_buf) {
671669
ipc4_update_buffer_format(sink_buf, out_fmt);
672670
audio_stream_set_channels(&sink_buf->stream, params->channels);
673671
audio_stream_set_rate(&sink_buf->stream, params->rate);

src/probe/probe.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ static bool probe_purpose_needs_ext_dma(uint32_t purpose)
10611061
static struct comp_buffer *ipc4_get_buffer(struct ipc_comp_dev *dev, probe_point_id_t probe_point)
10621062
{
10631063
struct comp_buffer *buf;
1064-
struct list_item *sink_list, *source_list;
1064+
struct list_item *source_list;
10651065
unsigned int queue_id;
10661066

10671067
switch (probe_point.fields.type) {
@@ -1075,8 +1075,7 @@ static struct comp_buffer *ipc4_get_buffer(struct ipc_comp_dev *dev, probe_point
10751075
}
10761076
break;
10771077
case PROBE_TYPE_OUTPUT:
1078-
list_for_item(sink_list, &dev->cd->bsink_list) {
1079-
buf = container_of(sink_list, struct comp_buffer, source_list);
1078+
comp_dev_for_each_consumer(dev->cd, buf) {
10801079
queue_id = IPC4_SINK_QUEUE_ID(buf_get_id(buf));
10811080

10821081
if (queue_id == probe_point.fields.index)

0 commit comments

Comments
 (0)