Skip to content

Commit

Permalink
ASoC: Intel: Restore Baytrail ADSP streams only when ADSP was in reset
Browse files Browse the repository at this point in the history
There is no need to restore and restart PCM streams in case ADSP didn't
reach reset and power off state during system suspend/resume cycle. In that
case stream is still active but paused and firmware doesn't allow allocating
a new stream before paused stream is freed.

ADSP remains active in case suspend sequence didn't go to suspend_late
stage. This can happen when either suspend sequence is aborted by a wakeup
or by letting only devices suspend by "echo devices >/sys/power/pm_test".

Currently stream restoring fails in these suspend cases. Fix this by adding
a flag that indicates is complete stream reinitialization needed or is it
enough to resume paused stream. Flag is set when we know that ADSP reached
suspend_late.

Initial fix to this issue came from Fang Yang. I modified it a little and
forward ported it to top of two other suspend/resume patches from me.

Signed-off-by: Jarkko Nikula <[email protected]>
Tested-by: Borun Fu <[email protected]>
Cc: yang fang <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
jhnikula authored and broonie committed Aug 11, 2014
1 parent 9246539 commit b80d19c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sound/soc/intel/sst-baytrail-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ struct sst_byt_priv_data {

/* DAI data */
struct sst_byt_pcm_data pcm[BYT_PCM_COUNT];

/* flag indicating is stream context restore needed after suspend */
bool restore_stream;
};

/* this may get called several times by oss emulation */
Expand Down Expand Up @@ -184,7 +187,10 @@ static int sst_byt_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
sst_byt_stream_start(byt, pcm_data->stream, 0);
break;
case SNDRV_PCM_TRIGGER_RESUME:
schedule_work(&pcm_data->work);
if (pdata->restore_stream == true)
schedule_work(&pcm_data->work);
else
sst_byt_stream_resume(byt, pcm_data->stream);
break;
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
sst_byt_stream_resume(byt, pcm_data->stream);
Expand All @@ -193,6 +199,7 @@ static int sst_byt_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
sst_byt_stream_stop(byt, pcm_data->stream);
break;
case SNDRV_PCM_TRIGGER_SUSPEND:
pdata->restore_stream = false;
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
sst_byt_stream_pause(byt, pcm_data->stream);
break;
Expand Down Expand Up @@ -407,6 +414,7 @@ static const struct snd_soc_component_driver byt_dai_component = {
static int sst_byt_pcm_dev_suspend_late(struct device *dev)
{
struct sst_pdata *sst_pdata = dev_get_platdata(dev);
struct sst_byt_priv_data *priv_data = dev_get_drvdata(dev);
int ret;

dev_dbg(dev, "suspending late\n");
Expand All @@ -417,6 +425,8 @@ static int sst_byt_pcm_dev_suspend_late(struct device *dev)
return ret;
}

priv_data->restore_stream = true;

return ret;
}

Expand Down

0 comments on commit b80d19c

Please sign in to comment.