Commit 54e6becc authored by Vinod Koul's avatar Vinod Koul Committed by Mark Brown

ASoC: Intel: add support for platform suspend

This adds support for platform suspend and resume. We ensure all pcms are
suspended by invoking snd_soc_suspend() and then stop the DSP
Signed-off-by: default avatarSubhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent fc9406ab
......@@ -667,6 +667,9 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
static int sst_soc_probe(struct snd_soc_platform *platform)
{
struct sst_data *drv = dev_get_drvdata(platform->dev);
drv->soc_card = platform->component.card;
return sst_dsp_init_v2_dpcm(platform);
}
......@@ -729,9 +732,64 @@ static int sst_platform_remove(struct platform_device *pdev)
return 0;
}
#ifdef CONFIG_PM_SLEEP
static int sst_soc_prepare(struct device *dev)
{
struct sst_data *drv = dev_get_drvdata(dev);
int i;
/* suspend all pcms first */
snd_soc_suspend(drv->soc_card->dev);
snd_soc_poweroff(drv->soc_card->dev);
/* set the SSPs to idle */
for (i = 0; i < drv->soc_card->num_rtd; i++) {
struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
if (dai->active) {
send_ssp_cmd(dai, dai->name, 0);
sst_handle_vb_timer(dai, false);
}
}
return 0;
}
static void sst_soc_complete(struct device *dev)
{
struct sst_data *drv = dev_get_drvdata(dev);
int i;
/* restart SSPs */
for (i = 0; i < drv->soc_card->num_rtd; i++) {
struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
if (dai->active) {
sst_handle_vb_timer(dai, true);
send_ssp_cmd(dai, dai->name, 1);
}
}
snd_soc_resume(drv->soc_card->dev);
}
#else
#define sst_soc_prepare NULL
#define sst_soc_complete NULL
#endif
static const struct dev_pm_ops sst_platform_pm = {
.prepare = sst_soc_prepare,
.complete = sst_soc_complete,
};
static struct platform_driver sst_platform_driver = {
.driver = {
.name = "sst-mfld-platform",
.pm = &sst_platform_pm,
},
.probe = sst_platform_probe,
.remove = sst_platform_remove,
......
......@@ -174,6 +174,7 @@ struct sst_data {
struct sst_platform_data *pdata;
struct snd_sst_bytes_v2 *byte_stream;
struct mutex lock;
struct snd_soc_card *soc_card;
};
int sst_register_dsp(struct sst_device *sst);
int sst_unregister_dsp(struct sst_device *sst);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment