Skip to content

Commit 0a2dea1

Browse files
ranj063broonie
authored andcommitted
ASoC: SOF: Add new fields to snd_sof_route
Add two new fields to save the source widget and sink widget pointers in struct snd_sof_route to make it easier to look up routes by source/sink widget. Also, add a flag to indicate if the route has been set up in the DSP. These will be used when the dynamic pipeline feature is implemented and routes will have to be set up at run time. Also, add a new sof_tear_down_pipelines() callback, that will used to reset the set up status for all routes during suspend. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20210927120517.20505-7-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d1a7af0 commit 0a2dea1

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

sound/soc/sof/pm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
208208
if (target_state == SOF_DSP_PM_D0)
209209
goto suspend;
210210

211+
sof_tear_down_pipelines(dev);
212+
211213
/* release trace */
212214
snd_sof_release_trace(sdev);
213215

sound/soc/sof/sof-audio.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ int sof_restore_pipelines(struct device *dev)
276276

277277
return ret;
278278
}
279+
sroute->setup = true;
279280
}
280281

281282
/* restore dai links */
@@ -317,6 +318,20 @@ int sof_restore_pipelines(struct device *dev)
317318
return ret;
318319
}
319320

321+
/* This function doesn't free widgets. It only resets the set up status for all routes */
322+
void sof_tear_down_pipelines(struct device *dev)
323+
{
324+
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
325+
struct snd_sof_route *sroute;
326+
327+
/*
328+
* No need to protect sroute->setup as this function is called only during the suspend
329+
* callback and all streams should be suspended by then
330+
*/
331+
list_for_each_entry(sroute, &sdev->route_list, list)
332+
sroute->setup = false;
333+
}
334+
320335
/*
321336
* Generic object lookup APIs.
322337
*/

sound/soc/sof/sof-audio.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ struct snd_sof_route {
118118

119119
struct snd_soc_dapm_route *route;
120120
struct list_head list; /* list in sdev route list */
121+
struct snd_sof_widget *src_widget;
122+
struct snd_sof_widget *sink_widget;
123+
bool setup;
121124

122125
void *private;
123126
};
@@ -240,6 +243,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
240243

241244
/* PM */
242245
int sof_restore_pipelines(struct device *dev);
246+
void sof_tear_down_pipelines(struct device *dev);
243247
int sof_set_hw_params_upon_resume(struct device *dev);
244248
bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev);
245249
bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev);

sound/soc/sof/topology.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,6 +3501,9 @@ static int sof_route_load(struct snd_soc_component *scomp, int index,
35013501
sroute->route = route;
35023502
dobj->private = sroute;
35033503
sroute->private = connect;
3504+
sroute->src_widget = source_swidget;
3505+
sroute->sink_widget = sink_swidget;
3506+
sroute->setup = true;
35043507

35053508
/* add route to route list */
35063509
list_add(&sroute->list, &sdev->route_list);

0 commit comments

Comments
 (0)