ASoC: SOF: PM: implement prepare/complete callbacks
authorKeyon Jie <yang.jie@linux.intel.com>
Fri, 25 Oct 2019 22:41:17 +0000 (17:41 -0500)
committerMark Brown <broonie@kernel.org>
Mon, 28 Oct 2019 14:45:33 +0000 (14:45 +0000)
Implement the prepare() and complete() callbacks for power management,
initialize s0_suspend flag at prepare(), and reset it at complete().

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191025224122.7718-22-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/pm.c
sound/soc/sof/sof-priv.h

index 584241e..99e4e6f 100644 (file)
@@ -439,3 +439,26 @@ int snd_sof_suspend(struct device *dev)
        return sof_suspend(dev, false);
 }
 EXPORT_SYMBOL(snd_sof_suspend);
+
+int snd_sof_prepare(struct device *dev)
+{
+       struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+
+#if defined(CONFIG_ACPI)
+       sdev->s0_suspend = acpi_target_system_state() == ACPI_STATE_S0;
+#else
+       /* will suspend to S3 by default */
+       sdev->s0_suspend = false;
+#endif
+
+       return 0;
+}
+EXPORT_SYMBOL(snd_sof_prepare);
+
+void snd_sof_complete(struct device *dev)
+{
+       struct snd_sof_dev *sdev = dev_get_drvdata(dev);
+
+       sdev->s0_suspend = false;
+}
+EXPORT_SYMBOL(snd_sof_complete);
index c2541d0..6408ac8 100644 (file)
@@ -492,6 +492,8 @@ int snd_sof_runtime_resume(struct device *dev);
 int snd_sof_runtime_idle(struct device *dev);
 int snd_sof_resume(struct device *dev);
 int snd_sof_suspend(struct device *dev);
+int snd_sof_prepare(struct device *dev);
+void snd_sof_complete(struct device *dev);
 int snd_sof_set_d0_substate(struct snd_sof_dev *sdev,
                            enum sof_d0_substate d0_substate);