Add power management support.
Signed-off-by: Rakesh Ughreja rakesh.a.ughreja@intel.com --- sound/soc/codecs/hdac_hda.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index 80aadde..9a5188a 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -547,8 +547,57 @@ static int hdac_hda_dev_remove(struct hdac_device *hdev) return 0; }
+#ifdef CONFIG_PM +static int hdac_hda_runtime_suspend(struct device *dev) +{ + struct hdac_device *hdac = dev_to_hdac_dev(dev); + struct hdac_bus *bus = hdac->bus; + struct hdac_ext_link *hlink = NULL; + + dev_dbg(dev, "%s: entry\n", __func__); + + dev_dbg(dev, "calling legacy codec suspend\n"); + hda_codec_runtime_suspend(dev); + dev_dbg(dev, "legacy codec suspended\n"); + + hlink = snd_hdac_ext_bus_get_link(bus, dev_name(dev)); + if (!hlink) { + dev_err(dev, "hdac link not found\n"); + return -EIO; + } + snd_hdac_ext_bus_link_put(bus, hlink); + return 0; +} + +static int hdac_hda_runtime_resume(struct device *dev) +{ + struct hdac_device *hdac = dev_to_hdac_dev(dev); + struct hdac_bus *bus = hdac->bus; + struct hdac_ext_link *hlink = NULL; + + dev_dbg(dev, "%s: entry\n", __func__); + + /* controller may not have been initialized for the first time */ + if (!bus) + return 0; + + hlink = snd_hdac_ext_bus_get_link(bus, dev_name(dev)); + if (!hlink) { + dev_err(dev, "hdac link not found\n"); + return -EIO; + } + snd_hdac_ext_bus_link_get(bus, hlink); + + dev_dbg(dev, "calling legacy codec resume\n"); + hda_codec_runtime_resume(dev); + dev_dbg(dev, "%s: exit\n", __func__); + + return 0; +} +#else #define hdac_hda_runtime_suspend NULL #define hdac_hda_runtime_resume NULL +#endif
static const struct dev_pm_ops hdac_hda_pm = { SET_RUNTIME_PM_OPS(hdac_hda_runtime_suspend,