Commit e342ac08 authored by Subhransu S. Prusty's avatar Subhransu S. Prusty Committed by Mark Brown

ASoC: hdac_hdmi: Add PM support for HDMI

Power up/down the AFG node during runtime resume/suspend.
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 18382ead
...@@ -60,6 +60,13 @@ struct hdac_hdmi_priv { ...@@ -60,6 +60,13 @@ struct hdac_hdmi_priv {
struct hdac_hdmi_dai_pin_map dai_map[3]; 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 static int
hdac_hdmi_query_cvt_params(struct hdac_device *hdac, struct hdac_hdmi_cvt *cvt) 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) ...@@ -250,11 +257,28 @@ static int hdmi_codec_probe(struct snd_soc_codec *codec)
/* Imp: Store the card pointer in hda_codec */ /* Imp: Store the card pointer in hda_codec */
edev->card = dapm->card->snd_card; 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; return 0;
} }
static struct snd_soc_codec_driver hdmi_hda_codec = { static struct snd_soc_codec_driver hdmi_hda_codec = {
.probe = hdmi_codec_probe, .probe = hdmi_codec_probe,
.remove = hdmi_codec_remove,
.idle_bias_off = true, .idle_bias_off = true,
}; };
...@@ -307,6 +331,45 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev) ...@@ -307,6 +331,45 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev)
return 0; 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[] = { static const struct hda_device_id hdmi_list[] = {
HDA_CODEC_EXT_ENTRY(0x80862809, 0x100000, "Skylake HDMI", 0), HDA_CODEC_EXT_ENTRY(0x80862809, 0x100000, "Skylake HDMI", 0),
{} {}
...@@ -318,6 +381,7 @@ static struct hdac_ext_driver hdmi_driver = { ...@@ -318,6 +381,7 @@ static struct hdac_ext_driver hdmi_driver = {
. hdac = { . hdac = {
.driver = { .driver = {
.name = "HDMI HDA Codec", .name = "HDMI HDA Codec",
.pm = &hdac_hdmi_pm,
}, },
.id_table = hdmi_list, .id_table = hdmi_list,
}, },
......
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