aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSubhransu S. Prusty <[email protected]>2015-11-10 18:42:07 +0530
committerMark Brown <[email protected]>2015-11-21 13:58:19 +0000
commite342ac08d0d57be81e5defb131f014b4ce27b107 (patch)
treecc915781279925657de337dc01e0602ccf9a7610
parent18382ead3640b5aab9bf4545249d84b51bbcba49 (diff)
ASoC: hdac_hdmi: Add PM support for HDMI
Power up/down the AFG node during runtime resume/suspend. Signed-off-by: Subhransu S. Prusty <[email protected]> Signed-off-by: Vinod Koul <[email protected]> Signed-off-by: Mark Brown <[email protected]>
-rw-r--r--sound/soc/codecs/hdac_hdmi.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index d37d688fa40a..45dfc4f608e5 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -60,6 +60,13 @@ struct hdac_hdmi_priv {
struct hdac_hdmi_dai_pin_map dai_map[3];
};
+static inline struct hdac_ext_device *to_hda_ext_device(struct device *dev)
+{
+ struct hdac_device *hdac = container_of(dev, struct hdac_device, dev);
+
+ return container_of(hdac, struct hdac_ext_device, hdac);
+}
+
static int
hdac_hdmi_query_cvt_params(struct hdac_device *hdac, struct hdac_hdmi_cvt *cvt)
{
@@ -250,11 +257,28 @@ static int hdmi_codec_probe(struct snd_soc_codec *codec)
/* Imp: Store the card pointer in hda_codec */
edev->card = dapm->card->snd_card;
+ /*
+ * hdac_device core already sets the state to active and calls
+ * get_noresume. So enable runtime and set the device to suspend.
+ */
+ pm_runtime_enable(&edev->hdac.dev);
+ pm_runtime_put(&edev->hdac.dev);
+ pm_runtime_suspend(&edev->hdac.dev);
+
+ return 0;
+}
+
+static int hdmi_codec_remove(struct snd_soc_codec *codec)
+{
+ struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec);
+
+ pm_runtime_disable(&edev->hdac.dev);
return 0;
}
static struct snd_soc_codec_driver hdmi_hda_codec = {
.probe = hdmi_codec_probe,
+ .remove = hdmi_codec_remove,
.idle_bias_off = true,
};
@@ -307,6 +331,45 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev)
return 0;
}
+#ifdef CONFIG_PM
+static int hdac_hdmi_runtime_suspend(struct device *dev)
+{
+ struct hdac_ext_device *edev = to_hda_ext_device(dev);
+ struct hdac_device *hdac = &edev->hdac;
+
+ dev_dbg(dev, "Enter: %s\n", __func__);
+
+ /* Power down afg */
+ if (!snd_hdac_check_power_state(hdac, hdac->afg, AC_PWRST_D3))
+ snd_hdac_codec_write(hdac, hdac->afg, 0,
+ AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
+
+ return 0;
+}
+
+static int hdac_hdmi_runtime_resume(struct device *dev)
+{
+ struct hdac_ext_device *edev = to_hda_ext_device(dev);
+ struct hdac_device *hdac = &edev->hdac;
+
+ dev_dbg(dev, "Enter: %s\n", __func__);
+
+ /* Power up afg */
+ if (!snd_hdac_check_power_state(hdac, hdac->afg, AC_PWRST_D0))
+ snd_hdac_codec_write(hdac, hdac->afg, 0,
+ AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
+
+ return 0;
+}
+#else
+#define hdac_hdmi_runtime_suspend NULL
+#define hdac_hdmi_runtime_resume NULL
+#endif
+
+static const struct dev_pm_ops hdac_hdmi_pm = {
+ SET_RUNTIME_PM_OPS(hdac_hdmi_runtime_suspend, hdac_hdmi_runtime_resume, NULL)
+};
+
static const struct hda_device_id hdmi_list[] = {
HDA_CODEC_EXT_ENTRY(0x80862809, 0x100000, "Skylake HDMI", 0),
{}
@@ -318,6 +381,7 @@ static struct hdac_ext_driver hdmi_driver = {
. hdac = {
.driver = {
.name = "HDMI HDA Codec",
+ .pm = &hdac_hdmi_pm,
},
.id_table = hdmi_list,
},