From patchwork Fri Dec 15 11:30:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ughreja, Rakesh A" X-Patchwork-Id: 10114831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0423160231 for ; Fri, 15 Dec 2017 11:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3E2F29F1C for ; Fri, 15 Dec 2017 11:28:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6A6329F26; Fri, 15 Dec 2017 11:28:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7104E29F1C for ; Fri, 15 Dec 2017 11:28:50 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2A74C267C19; Fri, 15 Dec 2017 12:27:30 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id DEFA6267C19; Fri, 15 Dec 2017 12:27:28 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id 972EB267BAA for ; Fri, 15 Dec 2017 12:26:37 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Dec 2017 03:26:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,404,1508828400"; d="scan'208";a="3055260" Received: from raughrej-desk.iind.intel.com ([10.223.84.131]) by orsmga006.jf.intel.com with ESMTP; 15 Dec 2017 03:26:34 -0800 From: Rakesh Ughreja To: alsa-devel@alsa-project.org, broonie@kernel.org, tiwai@suse.de, liam.r.girdwood@linux.intel.com Date: Fri, 15 Dec 2017 17:00:46 +0530 Message-Id: <1513337448-31685-10-git-send-email-rakesh.a.ughreja@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513337448-31685-1-git-send-email-rakesh.a.ughreja@intel.com> References: <1513337448-31685-1-git-send-email-rakesh.a.ughreja@intel.com> Cc: vinod.koul@intel.com, patches.audio@intel.com, Rakesh Ughreja , pierre-louis.bossart@linux.intel.com Subject: [alsa-devel] [RFC v3 09/11] ASoC: hdac_hda: add runtime PM support X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 4b4d80c..22cabd4 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -546,8 +546,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,