From patchwork Thu Mar 28 08:40:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang, Libin" X-Patchwork-Id: 10874577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FA70186D for ; Thu, 28 Mar 2019 08:57:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA77828BC2 for ; Thu, 28 Mar 2019 08:57:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE37628BF2; Thu, 28 Mar 2019 08:57:28 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E590628BC2 for ; Thu, 28 Mar 2019 08:57:27 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 61E3B86C; Thu, 28 Mar 2019 09:56:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 61E3B86C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1553763445; bh=0W3BWFj4CtXTVKidC0a8rFU2MlXbOX59Iqi9e0AFslI=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=i+UemFmk9FaggCrYqV5ddXcaurXI1TI1F8H7eE0sFt10VUke9+JsQRWJwbL8RWeJd 9SciSalxQfVjigzaZa0UhnrCpsk8htRr7aSUUqJ2vZQxWAeRwfbkEWfUh9YIqBnfgz sjdRzOBLcEcnxofNg34zJ/pxNm0+cuYOSpMFwWc8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C4299F8963C; Thu, 28 Mar 2019 09:56:34 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7BCAEF89673; Thu, 28 Mar 2019 09:56:31 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7715EF80C16 for ; Thu, 28 Mar 2019 09:56:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7715EF80C16 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 01:56:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="144562693" Received: from younglee-svr.sh.intel.com ([10.239.159.31]) by FMSMGA003.fm.intel.com with ESMTP; 28 Mar 2019 01:56:20 -0700 From: libin.yang@intel.com To: alsa-devel@alsa-project.org, tiwai@suse.de, broonie@kernel.org Date: Thu, 28 Mar 2019 16:40:05 +0800 Message-Id: <1553762405-19897-1-git-send-email-libin.yang@intel.com> X-Mailer: git-send-email 2.7.4 Cc: libin.yang@intel.com Subject: [alsa-devel] [PATCH] ASoC: hdmi: implement component supsend/resume callback X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Libin Yang Implement the hdmi codec component driver's suspend/resume callback. This can make sure that the dapm event is triggered after the display audio power domain is turned on if bus_control is set. Also this patch removes the codec device PM suspend/resume. Signed-off-by: Libin Yang --- sound/soc/codecs/hdac_hdmi.c | 51 +++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 5eeb0fe..478c6f2 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -1873,36 +1873,27 @@ static void hdmi_codec_remove(struct snd_soc_component *component) pm_runtime_disable(&hdev->dev); } -#ifdef CONFIG_PM_SLEEP -static int hdmi_codec_resume(struct device *dev) +static int hdmi_component_suspend(struct snd_soc_component *component) { - struct hdac_device *hdev = dev_to_hdac_dev(dev); - struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); - int ret; + struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); + struct hdac_device *hdev = hdmi->hdev; - ret = pm_runtime_force_resume(dev); - if (ret < 0) - return ret; - /* - * As the ELD notify callback request is not entertained while the - * device is in suspend state. Need to manually check detection of - * all pins here. pin capablity change is not support, so use the - * already set pin caps. - * - * NOTE: this is safe to call even if the codec doesn't actually resume. - * The pin check involves only with DRM audio component hooks, so it - * works even if the HD-audio side is still dreaming peacefully. - */ - hdac_hdmi_present_sense_all_pins(hdev, hdmi, false); - return 0; + return pm_runtime_force_suspend(&hdev->dev); +} + +static int hdmi_component_resume(struct snd_soc_component *component) +{ + struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); + struct hdac_device *hdev = hdmi->hdev; + + return pm_runtime_force_resume(&hdev->dev); } -#else -#define hdmi_codec_resume NULL -#endif static const struct snd_soc_component_driver hdmi_hda_codec = { .probe = hdmi_codec_probe, .remove = hdmi_codec_remove, + .suspend = hdmi_component_suspend, + .resume = hdmi_component_resume, .use_pmdown_time = 1, .endianness = 1, .non_legacy_dai_naming = 1, @@ -2104,6 +2095,7 @@ static int hdac_hdmi_runtime_resume(struct device *dev) struct hdac_device *hdev = dev_to_hdac_dev(dev); struct hdac_bus *bus = hdev->bus; struct hdac_ext_link *hlink = NULL; + struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); dev_dbg(dev, "Enter: %s\n", __func__); @@ -2128,6 +2120,18 @@ static int hdac_hdmi_runtime_resume(struct device *dev) snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); + /* + * As the ELD notify callback request is not entertained while the + * device is in suspend state. Need to manually check detection of + * all pins here. pin capablity change is not support, so use the + * already set pin caps. + * + * NOTE: this is safe to call even if the codec doesn't actually resume. + * The pin check involves only with DRM audio component hooks, so it + * works even if the HD-audio side is still dreaming peacefully. + */ + hdac_hdmi_present_sense_all_pins(hdev, hdmi, false); + return 0; } #else @@ -2137,7 +2141,6 @@ static int hdac_hdmi_runtime_resume(struct device *dev) static const struct dev_pm_ops hdac_hdmi_pm = { SET_RUNTIME_PM_OPS(hdac_hdmi_runtime_suspend, hdac_hdmi_runtime_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, hdmi_codec_resume) }; static const struct hda_device_id hdmi_list[] = {