Skip to content

Commit de23a83

Browse files
ranj063broonie
authored andcommitted
ASoC: SOF: audio: Add helper to check if only D0i3 streams are active
Add a helper function to check if only D0i3-compatible streams are active. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200129220726.31792-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 61e285c commit de23a83

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,39 @@
1111
#include "sof-audio.h"
1212
#include "ops.h"
1313

14+
/*
15+
* helper to determine if there are only D0i3 compatible
16+
* streams active
17+
*/
18+
bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev)
19+
{
20+
struct snd_pcm_substream *substream;
21+
struct snd_sof_pcm *spcm;
22+
bool d0i3_compatible_active = false;
23+
int dir;
24+
25+
list_for_each_entry(spcm, &sdev->pcm_list, list) {
26+
for (dir = 0; dir <= SNDRV_PCM_STREAM_CAPTURE; dir++) {
27+
substream = spcm->stream[dir].substream;
28+
if (!substream || !substream->runtime)
29+
continue;
30+
31+
/*
32+
* substream->runtime being not NULL indicates that
33+
* that the stream is open. No need to check the
34+
* stream state.
35+
*/
36+
if (!spcm->stream[dir].d0i3_compatible)
37+
return false;
38+
39+
d0i3_compatible_active = true;
40+
}
41+
}
42+
43+
return d0i3_compatible_active;
44+
}
45+
EXPORT_SYMBOL(snd_sof_dsp_only_d0i3_compatible_stream_active);
46+
1447
bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev)
1548
{
1649
struct snd_sof_pcm *spcm;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol,
203203
int sof_restore_pipelines(struct device *dev);
204204
int sof_set_hw_params_upon_resume(struct device *dev);
205205
bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev);
206+
bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev);
206207

207208
/* Machine driver enumeration */
208209
int sof_machine_register(struct snd_sof_dev *sdev, void *pdata);

0 commit comments

Comments
 (0)