Skip to content

Commit 578c136

Browse files
marcinszkudlinskikv2019i
authored andcommitted
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 718df51 commit 578c136

10 files changed

Lines changed: 32 additions & 62 deletions

File tree

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
@@ -271,18 +271,16 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
271271

272272
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
273273
#if CONFIG_IPC_MAJOR_4
274-
struct list_item *sink_list;
275274
/*
276275
* copy from local buffer to all sinks that are not gateway buffers
277276
* using the right PCM converter function.
278277
*/
279-
list_for_item(sink_list, &dev->bsink_list) {
278+
struct comp_buffer *sink;
279+
280+
comp_dev_for_each_consumer(dev, sink) {
280281
struct comp_dev *sink_dev;
281-
struct comp_buffer *sink;
282282
int j;
283283

284-
sink = container_of(sink_list, struct comp_buffer, source_list);
285-
286284
if (sink == dd->dma_buffer)
287285
continue;
288286

@@ -321,20 +319,18 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes,
321319
ret = stream_copy_from_no_consume(dd->dma_buffer, dd->local_buffer,
322320
dd->process, bytes, dd->chmap);
323321
#if CONFIG_IPC_MAJOR_4
324-
struct list_item *sink_list;
325322
/* Skip in case of endpoint DAI devices created by the copier */
326323
if (converter) {
327324
/*
328325
* copy from DMA buffer to all sink buffers using the right PCM converter
329326
* function
330327
*/
331-
list_for_item(sink_list, &dev->bsink_list) {
328+
struct comp_buffer *sink;
329+
330+
comp_dev_for_each_consumer(dev, sink) {
332331
struct comp_dev *sink_dev;
333-
struct comp_buffer *sink;
334332
int j;
335333

336-
sink = container_of(sink_list, struct comp_buffer, source_list);
337-
338334
/* this has been handled above already */
339335
if (sink == dd->local_buffer)
340336
continue;
@@ -1644,17 +1640,16 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
16441640
sink_frames = free_bytes / audio_stream_frame_bytes(&dd->dma_buffer->stream);
16451641
frames = MIN(src_frames, sink_frames);
16461642

1647-
struct list_item *sink_list;
16481643
/*
16491644
* In the case of playback DAI's with multiple sink buffers, compute the
16501645
* minimum number of frames based on the DMA avail_bytes and the free
16511646
* samples in all active sink buffers.
16521647
*/
1653-
list_for_item(sink_list, &dev->bsink_list) {
1648+
struct comp_buffer *sink;
1649+
1650+
comp_dev_for_each_consumer(dev, sink) {
16541651
struct comp_dev *sink_dev;
1655-
struct comp_buffer *sink;
16561652

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

16601655
if (sink_dev && sink_dev->state == COMP_STATE_ACTIVE &&
@@ -1665,8 +1660,6 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
16651660
}
16661661
}
16671662
} else {
1668-
struct list_item *sink_list;
1669-
16701663
src_frames = avail_bytes / audio_stream_frame_bytes(&dd->dma_buffer->stream);
16711664

16721665
/*
@@ -1682,11 +1675,11 @@ int dai_common_copy(struct dai_data *dd, struct comp_dev *dev, pcm_converter_fun
16821675
* minimum number of samples based on the DMA avail_bytes and the free
16831676
* samples in all active sink buffers.
16841677
*/
1685-
list_for_item(sink_list, &dev->bsink_list) {
1678+
struct comp_buffer *sink;
1679+
1680+
comp_dev_for_each_consumer(dev, sink) {
16861681
struct comp_dev *sink_dev;
1687-
struct comp_buffer *sink;
16881682

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

16921685
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
@@ -231,7 +231,6 @@ static int demux_process(struct processing_module *mod,
231231
{
232232
struct comp_data *cd = module_get_private_data(mod);
233233
struct comp_dev *dev = mod->dev;
234-
struct list_item *clist;
235234
struct comp_buffer *sink;
236235
struct audio_stream *sinks_stream[MUX_MAX_STREAMS] = { NULL };
237236
struct mux_look_up *look_ups[MUX_MAX_STREAMS] = { NULL };
@@ -243,8 +242,7 @@ static int demux_process(struct processing_module *mod,
243242
comp_dbg(dev, "demux_process()");
244243

245244
/* align sink streams with their respective configurations */
246-
list_for_item(clist, &dev->bsink_list) {
247-
sink = container_of(clist, struct comp_buffer, source_list);
245+
comp_dev_for_each_consumer(dev, sink) {
248246
if (sink->sink->state == dev->state) {
249247
i = get_stream_index(dev, cd, buffer_pipeline_id(sink));
250248
/* return if index wrong */

src/audio/selector/selector.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,6 @@ static void set_selector_params(struct processing_module *mod,
638638
const struct sof_selector_ipc4_config *sel_cfg = &cd->sel_ipc4_cfg;
639639
const struct ipc4_audio_format *out_fmt = NULL;
640640
struct comp_buffer *src_buf;
641-
struct list_item *sink_list;
642641
int i;
643642

644643
if (cd->sel_ipc4_cfg.init_payload_fmt == IPC4_SEL_INIT_PAYLOAD_BASE_WITH_EXT)
@@ -658,10 +657,9 @@ static void set_selector_params(struct processing_module *mod,
658657
params->chmap[i] = (out_fmt->ch_map >> i * 4) & 0xf;
659658

660659
/* update each sink format */
661-
list_for_item(sink_list, &dev->bsink_list) {
662-
struct comp_buffer *sink_buf =
663-
container_of(sink_list, struct comp_buffer, source_list);
660+
struct comp_buffer *sink_buf;
664661

662+
comp_dev_for_each_consumer(dev, sink_buf) {
665663
ipc4_update_buffer_format(sink_buf, out_fmt);
666664
audio_stream_set_channels(&sink_buf->stream, params->channels);
667665
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)