From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rakesh Ughreja Subject: [RFC 09/10] ASoC: hdac_hda: add runtime PM support Date: Fri, 1 Dec 2017 14:44:07 +0530 Message-ID: <1512119648-2700-10-git-send-email-rakesh.a.ughreja@intel.com> References: <1512119648-2700-1-git-send-email-rakesh.a.ughreja@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by alsa0.perex.cz (Postfix) with ESMTP id 79D48267C34 for ; Fri, 1 Dec 2017 10:10:19 +0100 (CET) In-Reply-To: <1512119648-2700-1-git-send-email-rakesh.a.ughreja@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: alsa-devel@alsa-project.org, broonie@kernel.org, tiwai@suse.de, liam.r.girdwood@linux.intel.com Cc: vinod.koul@intel.com, patches.audio@intel.com, Rakesh Ughreja , pierre-louis.bossart@linux.intel.com List-Id: alsa-devel@alsa-project.org Add power management support. Signed-off-by: Rakesh Ughreja --- 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, -- 2.7.4