Skip to content

Commit 6e2cdc2

Browse files
ranj063plbossart
authored andcommitted
ASoC: SOF: Introduce struct snd_sof_pipeline
Introduce struct snd_sof_pipeline to save the information about pipelines including the pipeline widget, their status wrt how many PCM's are using them and whether they are complete or not. In struct snd_sof_widget, replace pipe_widget with spipe and remove complete. In struct snd_sof_pcm_stream_pipeline_list, replace pipe_widgets with pipelines. Update all users accordingly. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 783c737 commit 6e2cdc2

9 files changed

Lines changed: 114 additions & 70 deletions

File tree

‎sound/soc/sof/core.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
390390
INIT_LIST_HEAD(&sdev->pcm_list);
391391
INIT_LIST_HEAD(&sdev->kcontrol_list);
392392
INIT_LIST_HEAD(&sdev->widget_list);
393+
INIT_LIST_HEAD(&sdev->pipeline_list);
393394
INIT_LIST_HEAD(&sdev->dai_list);
394395
INIT_LIST_HEAD(&sdev->dai_link_list);
395396
INIT_LIST_HEAD(&sdev->route_list);

‎sound/soc/sof/intel/hda-dai.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static int ipc4_hda_dai_trigger(struct snd_pcm_substream *substream,
468468

469469
w = snd_soc_dai_get_widget(dai, substream->stream);
470470
swidget = w->dobj.private;
471-
pipe_widget = swidget->pipe_widget;
471+
pipe_widget = swidget->spipe->pipe_widget;
472472
pipeline = pipe_widget->private;
473473

474474
switch (cmd) {

‎sound/soc/sof/ipc3-topology.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,9 +2233,9 @@ static int sof_ipc3_set_up_all_pipelines(struct snd_sof_dev *sdev, bool verify)
22332233
return ret;
22342234
}
22352235

2236-
swidget->complete = sof_ipc3_complete_pipeline(sdev, swidget);
2237-
if (swidget->complete < 0)
2238-
return swidget->complete;
2236+
swidget->spipe->complete = sof_ipc3_complete_pipeline(sdev, swidget);
2237+
if (swidget->spipe->complete < 0)
2238+
return swidget->spipe->complete;
22392239
break;
22402240
default:
22412241
break;
@@ -2317,7 +2317,7 @@ static int sof_ipc3_tear_down_all_pipelines(struct snd_sof_dev *sdev, bool verif
23172317
if (!verify && !swidget->dynamic_pipeline_widget &&
23182318
SOF_FW_VER(v->major, v->minor, v->micro) < SOF_FW_VER(2, 2, 0)) {
23192319
swidget->use_count = 0;
2320-
swidget->complete = 0;
2320+
swidget->spipe->complete = 0;
23212321
continue;
23222322
}
23232323

‎sound/soc/sof/ipc4-pcm.c‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
6868
struct ipc4_pipeline_set_state_data *data;
6969
struct snd_sof_widget *pipe_widget;
7070
struct sof_ipc4_pipeline *pipeline;
71+
struct snd_sof_pipeline *spipe;
7172
struct snd_sof_pcm *spcm;
7273
int ret;
7374
int i, j;
@@ -79,7 +80,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
7980
pipeline_list = &spcm->stream[substream->stream].pipeline_list;
8081

8182
/* nothing to trigger if the list is empty */
82-
if (!pipeline_list->pipe_widgets)
83+
if (!pipeline_list->pipelines)
8384
return 0;
8485

8586
/* allocate memory for the pipeline data */
@@ -96,7 +97,8 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
9697
* sink->source would still be guaranteed for each fork independently.
9798
*/
9899
for (i = pipeline_list->count - 1; i >= 0; i--) {
99-
pipe_widget = pipeline_list->pipe_widgets[i];
100+
spipe = pipeline_list->pipelines[i];
101+
pipe_widget = spipe->pipe_widget;
100102
pipeline = pipe_widget->private;
101103
if (pipeline->state != state && !pipeline->skip_during_fe_trigger)
102104
data->pipeline_ids[data->count++] = pipe_widget->instance_id;
@@ -122,7 +124,8 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
122124
/* update PAUSED state for all pipelines that were just triggered */
123125
for (i = 0; i < data->count; i++) {
124126
for (j = 0; j < pipeline_list->count; j++) {
125-
pipe_widget = pipeline_list->pipe_widgets[j];
127+
spipe = pipeline_list->pipelines[j];
128+
pipe_widget = spipe->pipe_widget;
126129
pipeline = pipe_widget->private;
127130

128131
if (data->pipeline_ids[i] == pipe_widget->instance_id) {
@@ -146,7 +149,8 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
146149
/* update final state for all pipelines that were just triggered */
147150
for (i = 0; i < data->count; i++) {
148151
for (j = 0; j < pipeline_list->count; j++) {
149-
pipe_widget = pipeline_list->pipe_widgets[j];
152+
spipe = pipeline_list->pipelines[j];
153+
pipe_widget = spipe->pipe_widget;
150154
pipeline = pipe_widget->private;
151155

152156
if (data->pipeline_ids[i] == pipe_widget->instance_id) {
@@ -274,8 +278,8 @@ static void sof_ipc4_pcm_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm
274278

275279
for_each_pcm_streams(stream) {
276280
pipeline_list = &spcm->stream[stream].pipeline_list;
277-
kfree(pipeline_list->pipe_widgets);
278-
pipeline_list->pipe_widgets = NULL;
281+
kfree(pipeline_list->pipelines);
282+
pipeline_list->pipelines = NULL;
279283
}
280284
}
281285

@@ -289,10 +293,9 @@ static int sof_ipc4_pcm_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm
289293
pipeline_list = &spcm->stream[stream].pipeline_list;
290294

291295
/* allocate memory for max number of pipeline IDs */
292-
pipeline_list->pipe_widgets = kcalloc(ipc4_data->max_num_pipelines,
293-
sizeof(struct snd_sof_widget *),
294-
GFP_KERNEL);
295-
if (!pipeline_list->pipe_widgets) {
296+
pipeline_list->pipelines = kcalloc(ipc4_data->max_num_pipelines,
297+
sizeof(struct snd_sof_widget *), GFP_KERNEL);
298+
if (!pipeline_list->pipelines) {
296299
sof_ipc4_pcm_free(sdev, spcm);
297300
return -ENOMEM;
298301
}

‎sound/soc/sof/ipc4-topology.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ sof_ipc4_update_pipeline_mem_usage(struct snd_sof_dev *sdev, struct snd_sof_widg
833833

834834
total = SOF_IPC4_FW_PAGE(task_mem + queue_mem);
835835

836-
pipe_widget = swidget->pipe_widget;
836+
pipe_widget = swidget->spipe->pipe_widget;
837837
pipeline = pipe_widget->private;
838838
pipeline->mem_usage += total;
839839
}
@@ -947,7 +947,7 @@ static void sof_ipc4_unprepare_copier_module(struct snd_sof_widget *swidget)
947947
struct sof_ipc4_pipeline *pipeline;
948948

949949
/* reset pipeline memory usage */
950-
pipe_widget = swidget->pipe_widget;
950+
pipe_widget = swidget->spipe->pipe_widget;
951951
pipeline = pipe_widget->private;
952952
pipeline->mem_usage = 0;
953953

@@ -1114,7 +1114,7 @@ sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
11141114
struct snd_sof_widget *pipe_widget;
11151115
struct sof_ipc4_pipeline *pipeline;
11161116

1117-
pipe_widget = swidget->pipe_widget;
1117+
pipe_widget = swidget->spipe->pipe_widget;
11181118
pipeline = pipe_widget->private;
11191119
ipc4_copier = (struct sof_ipc4_copier *)swidget->private;
11201120
gtw_attr = ipc4_copier->gtw_attr;
@@ -1496,7 +1496,7 @@ static int sof_ipc4_control_setup(struct snd_sof_dev *sdev, struct snd_sof_contr
14961496

14971497
static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
14981498
{
1499-
struct snd_sof_widget *pipe_widget = swidget->pipe_widget;
1499+
struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget;
15001500
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
15011501
struct sof_ipc4_pipeline *pipeline;
15021502
struct sof_ipc4_msg *msg;
@@ -1815,7 +1815,7 @@ static int sof_ipc4_route_free(struct snd_sof_dev *sdev, struct snd_sof_route *s
18151815
* routes belonging to the same pipeline will be disconnected by the FW when the pipeline
18161816
* is freed. So avoid sending this IPC which will be ignored by the FW anyway.
18171817
*/
1818-
if (src_widget->pipe_widget == sink_widget->pipe_widget)
1818+
if (src_widget->spipe->pipe_widget == sink_widget->spipe->pipe_widget)
18191819
goto out;
18201820

18211821
header = src_fw_module->man4_module_entry.id;
@@ -1846,7 +1846,7 @@ static int sof_ipc4_route_free(struct snd_sof_dev *sdev, struct snd_sof_route *s
18461846
static int sof_ipc4_dai_config(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget,
18471847
unsigned int flags, struct snd_sof_dai_config_data *data)
18481848
{
1849-
struct snd_sof_widget *pipe_widget = swidget->pipe_widget;
1849+
struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget;
18501850
struct sof_ipc4_pipeline *pipeline = pipe_widget->private;
18511851
struct snd_sof_dai *dai = swidget->private;
18521852
struct sof_ipc4_gtw_attributes *gtw_attr;

‎sound/soc/sof/sof-audio.c‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static void sof_reset_route_setup_status(struct snd_sof_dev *sdev, struct snd_so
3131
int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
3232
{
3333
const struct sof_ipc_tplg_ops *tplg_ops = sdev->ipc->ops->tplg;
34+
struct snd_sof_widget *pipe_widget;
3435
int err = 0;
3536
int ret;
3637

@@ -43,6 +44,8 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
4344
if (--swidget->use_count)
4445
return 0;
4546

47+
pipe_widget = swidget->spipe->pipe_widget;
48+
4649
/* reset route setup status for all routes that contain this widget */
4750
sof_reset_route_setup_status(sdev, swidget);
4851

@@ -67,10 +70,9 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
6770
* skip for static pipelines
6871
*/
6972
if (swidget->dynamic_pipeline_widget && swidget->id != snd_soc_dapm_scheduler) {
70-
ret = sof_widget_free(sdev, swidget->pipe_widget);
73+
ret = sof_widget_free(sdev, pipe_widget);
7174
if (ret < 0 && !err)
7275
err = ret;
73-
swidget->pipe_widget->complete = 0;
7476
}
7577

7678
if (!err)
@@ -103,14 +105,13 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
103105
* widget in the pipeline is freed. Skip setting up scheduler widget for static pipelines.
104106
*/
105107
if (swidget->dynamic_pipeline_widget && swidget->id != snd_soc_dapm_scheduler) {
106-
if (!swidget->pipe_widget) {
107-
dev_err(sdev->dev, "No scheduler widget set for %s\n",
108-
swidget->widget->name);
108+
if (!swidget->spipe || !swidget->spipe->pipe_widget) {
109+
dev_err(sdev->dev, "No pipeline set for %s\n", swidget->widget->name);
109110
ret = -EINVAL;
110111
goto use_count_dec;
111112
}
112113

113-
ret = sof_widget_setup(sdev, swidget->pipe_widget);
114+
ret = sof_widget_setup(sdev, swidget->spipe->pipe_widget);
114115
if (ret < 0)
115116
goto use_count_dec;
116117
}
@@ -159,7 +160,7 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
159160
snd_sof_dsp_core_put(sdev, swidget->core);
160161
pipe_widget_free:
161162
if (swidget->id != snd_soc_dapm_scheduler)
162-
sof_widget_free(sdev, swidget->pipe_widget);
163+
sof_widget_free(sdev, swidget->spipe->pipe_widget);
163164
use_count_dec:
164165
swidget->use_count--;
165166
return ret;
@@ -400,7 +401,7 @@ static int sof_set_up_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_d
400401
struct snd_sof_pcm_stream_pipeline_list *pipeline_list = &spcm->stream[dir].pipeline_list;
401402
struct snd_soc_dapm_widget_list *list = spcm->stream[dir].list;
402403
struct snd_sof_widget *swidget = widget->dobj.private;
403-
struct snd_sof_widget *pipe_widget;
404+
struct snd_sof_pipeline *spipe;
404405
struct snd_soc_dapm_path *p;
405406
int ret;
406407

@@ -412,7 +413,7 @@ static int sof_set_up_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_d
412413
return ret;
413414

414415
/* skip populating the pipe_widgets array if it is NULL */
415-
if (!pipeline_list->pipe_widgets)
416+
if (!pipeline_list->pipelines)
416417
goto sink_setup;
417418

418419
/*
@@ -421,14 +422,14 @@ static int sof_set_up_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_d
421422
* order source to sink.
422423
*/
423424
for (i = 0; i < pipeline_list->count; i++) {
424-
pipe_widget = pipeline_list->pipe_widgets[i];
425-
if (pipe_widget == swidget->pipe_widget)
425+
spipe = pipeline_list->pipelines[i];
426+
if (spipe == swidget->spipe)
426427
break;
427428
}
428429

429430
if (i == pipeline_list->count) {
430431
pipeline_list->count++;
431-
pipeline_list->pipe_widgets[i] = swidget->pipe_widget;
432+
pipeline_list->pipelines[i] = swidget->spipe;
432433
}
433434
}
434435

@@ -563,25 +564,27 @@ int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm,
563564
for_each_dapm_widgets(list, i, widget) {
564565
struct snd_sof_widget *swidget = widget->dobj.private;
565566
struct snd_sof_widget *pipe_widget;
567+
struct snd_sof_pipeline *spipe;
566568

567569
if (!swidget)
568570
continue;
569571

570-
pipe_widget = swidget->pipe_widget;
572+
spipe = swidget->spipe;
573+
pipe_widget = spipe->pipe_widget;
571574
if (!pipe_widget) {
572575
dev_err(sdev->dev, "error: no pipeline widget found for %s\n",
573576
swidget->widget->name);
574577
ret = -EINVAL;
575578
goto widget_free;
576579
}
577580

578-
if (pipe_widget->complete)
581+
if (spipe->complete)
579582
continue;
580583

581584
if (ipc_tplg_ops->pipeline_complete) {
582-
pipe_widget->complete = ipc_tplg_ops->pipeline_complete(sdev, pipe_widget);
583-
if (pipe_widget->complete < 0) {
584-
ret = pipe_widget->complete;
585+
spipe->complete = ipc_tplg_ops->pipeline_complete(sdev, pipe_widget);
586+
if (spipe->complete < 0) {
587+
ret = spipe->complete;
585588
goto widget_free;
586589
}
587590
}

‎sound/soc/sof/sof-audio.h‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ struct sof_token_info {
286286
/**
287287
* struct snd_sof_pcm_stream_pipeline_list - List of pipelines associated with a PCM stream
288288
* @count: number of pipeline widgets in the @pipe_widgets array
289-
* @pipe_widgets: array of pipeline widgets
289+
* @pipelines: array of pipelines
290290
*/
291291
struct snd_sof_pcm_stream_pipeline_list {
292292
uint32_t count;
293-
struct snd_sof_widget **pipe_widgets;
293+
struct snd_sof_pipeline **pipelines;
294294
};
295295

296296
/* PCM stream, mapped to FW component */
@@ -380,11 +380,6 @@ struct snd_sof_widget {
380380
struct snd_soc_component *scomp;
381381
int comp_id;
382382
int pipeline_id;
383-
/*
384-
* complete flag is used to indicate that pipeline set up is complete for scheduler type
385-
* widgets. It is unused for all other widget types.
386-
*/
387-
int complete;
388383
/*
389384
* the prepared flag is used to indicate that a widget has been prepared for getting set
390385
* up in the DSP.
@@ -411,7 +406,7 @@ struct snd_sof_widget {
411406

412407
struct snd_soc_dapm_widget *widget;
413408
struct list_head list; /* list in sdev widget list */
414-
struct snd_sof_widget *pipe_widget;
409+
struct snd_sof_pipeline *spipe;
415410
void *module_info;
416411

417412
const guid_t uuid;
@@ -449,6 +444,22 @@ struct snd_sof_widget {
449444
void *private; /* core does not touch this */
450445
};
451446

447+
/** struct snd_sof_pipeline - ASoC SOF pipeline
448+
* @pipe_widget: Pointer to the pipeline widget
449+
* @started_count: Count of number of PCM's that have started this pipeline
450+
* @paused_count: Count of number of PCM's that have started and have currently paused this
451+
pipeline
452+
* @complete: flag used to indicate that pipeline set up is complete.
453+
* @list: List item in sdev pipeline_list
454+
*/
455+
struct snd_sof_pipeline {
456+
struct snd_sof_widget *pipe_widget;
457+
int started_count;
458+
int paused_count;
459+
int complete;
460+
struct list_head list;
461+
};
462+
452463
/* ASoC SOF DAPM route */
453464
struct snd_sof_route {
454465
struct snd_soc_component *scomp;

‎sound/soc/sof/sof-priv.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ struct snd_sof_dev {
571571
struct list_head pcm_list;
572572
struct list_head kcontrol_list;
573573
struct list_head widget_list;
574+
struct list_head pipeline_list;
574575
struct list_head dai_list;
575576
struct list_head dai_link_list;
576577
struct list_head route_list;

0 commit comments

Comments
 (0)