Commit 043ae13b authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Mark Brown

ASoC: SOF: Add system_suspend_target field to struct snd_sof_dev

Add the system_suspend_target field to struct snd_sof_dev
to track the intended system suspend power target. This will
be used as one of the criteria for determining the
final DSP power state.
Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200129220726.31792-4-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent fb9a8119
...@@ -481,7 +481,7 @@ int hda_dsp_resume(struct snd_sof_dev *sdev) ...@@ -481,7 +481,7 @@ int hda_dsp_resume(struct snd_sof_dev *sdev)
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
struct pci_dev *pci = to_pci_dev(sdev->dev); struct pci_dev *pci = to_pci_dev(sdev->dev);
if (sdev->s0_suspend) { if (sdev->system_suspend_target == SOF_SUSPEND_S0IX) {
/* restore L1SEN bit */ /* restore L1SEN bit */
if (hda->l1_support_changed) if (hda->l1_support_changed)
snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
...@@ -530,7 +530,7 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev) ...@@ -530,7 +530,7 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev)
struct pci_dev *pci = to_pci_dev(sdev->dev); struct pci_dev *pci = to_pci_dev(sdev->dev);
int ret; int ret;
if (sdev->s0_suspend) { if (sdev->system_suspend_target == SOF_SUSPEND_S0IX) {
/* enable L1SEN to make sure the system can enter S0Ix */ /* enable L1SEN to make sure the system can enter S0Ix */
hda->l1_support_changed = hda->l1_support_changed =
snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
......
...@@ -372,7 +372,7 @@ static int sof_pcm_trigger(struct snd_soc_component *component, ...@@ -372,7 +372,7 @@ static int sof_pcm_trigger(struct snd_soc_component *component,
stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_START; stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_START;
break; break;
case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_SUSPEND:
if (sdev->s0_suspend && if (sdev->system_suspend_target == SOF_SUSPEND_S0IX &&
spcm->stream[substream->stream].d0i3_compatible) { spcm->stream[substream->stream].d0i3_compatible) {
/* /*
* trap the event, not sending trigger stop to * trap the event, not sending trigger stop to
......
...@@ -323,10 +323,13 @@ int snd_sof_prepare(struct device *dev) ...@@ -323,10 +323,13 @@ int snd_sof_prepare(struct device *dev)
struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct snd_sof_dev *sdev = dev_get_drvdata(dev);
#if defined(CONFIG_ACPI) #if defined(CONFIG_ACPI)
sdev->s0_suspend = acpi_target_system_state() == ACPI_STATE_S0; if (acpi_target_system_state() == ACPI_STATE_S0)
sdev->system_suspend_target = SOF_SUSPEND_S0IX;
else
sdev->system_suspend_target = SOF_SUSPEND_S3;
#else #else
/* will suspend to S3 by default */ /* will suspend to S3 by default */
sdev->s0_suspend = false; sdev->system_suspend_target = SOF_SUSPEND_S3;
#endif #endif
return 0; return 0;
...@@ -337,6 +340,6 @@ void snd_sof_complete(struct device *dev) ...@@ -337,6 +340,6 @@ void snd_sof_complete(struct device *dev)
{ {
struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct snd_sof_dev *sdev = dev_get_drvdata(dev);
sdev->s0_suspend = false; sdev->system_suspend_target = SOF_SUSPEND_NONE;
} }
EXPORT_SYMBOL(snd_sof_complete); EXPORT_SYMBOL(snd_sof_complete);
...@@ -60,6 +60,13 @@ enum sof_d0_substate { ...@@ -60,6 +60,13 @@ enum sof_d0_substate {
SOF_DSP_D0I3, /* DSP D0i3(low power) substate*/ SOF_DSP_D0I3, /* DSP D0i3(low power) substate*/
}; };
/* System suspend target state */
enum sof_system_suspend_state {
SOF_SUSPEND_NONE = 0,
SOF_SUSPEND_S0IX,
SOF_SUSPEND_S3,
};
struct snd_sof_dev; struct snd_sof_dev;
struct snd_sof_ipc_msg; struct snd_sof_ipc_msg;
struct snd_sof_ipc; struct snd_sof_ipc;
...@@ -325,8 +332,9 @@ struct snd_sof_dev { ...@@ -325,8 +332,9 @@ struct snd_sof_dev {
/* power states related */ /* power states related */
enum sof_d0_substate d0_substate; enum sof_d0_substate d0_substate;
/* flag to track if the intended power target of suspend is S0ix */
bool s0_suspend; /* Intended power target of system suspend */
enum sof_system_suspend_state system_suspend_target;
/* DSP firmware boot */ /* DSP firmware boot */
wait_queue_head_t boot_wait; wait_queue_head_t boot_wait;
......
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