From patchwork Wed Dec 23 19:01:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 7913841 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E4E299F1AF for ; Wed, 23 Dec 2015 19:03:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04DAD205F9 for ; Wed, 23 Dec 2015 19:03:39 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C1DB6205EF for ; Wed, 23 Dec 2015 19:03:37 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0291E26671A; Wed, 23 Dec 2015 20:03:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 06DD8266572; Wed, 23 Dec 2015 20:01:44 +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 C759A2665D1; Wed, 23 Dec 2015 20:01:42 +0100 (CET) Received: from mail-qg0-f52.google.com (mail-qg0-f52.google.com [209.85.192.52]) by alsa0.perex.cz (Postfix) with ESMTP id 00BEB266578 for ; Wed, 23 Dec 2015 20:01:29 +0100 (CET) Received: by mail-qg0-f52.google.com with SMTP id o11so83330095qge.2 for ; Wed, 23 Dec 2015 11:01:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=5D2tKloJI2dZFAWQ89C1DW28PcFOPvybTjK5kto/0EY=; b=Ataln9FVKDr+M9cENXYROqNeWNpzZ4q+PclT8yfNNhX458VtHtk03RTy1ga2K2aQB5 geCPjCJD2lP00Gs1Z9EK29WrmXM6l6nSCw3xiijVRG1kjfuGatChFPhCPLENwLAcuJQe Bv9SlP+B+9U4TfXXezO7tRXEwe0Qr8i6Ywxjlkh1fSbBIAk8rCXF2BzOFjQSanwo+/Aw 9SO20gAlDIqRbtg52bnU88K3WVXfIrEj0mIH7pWTC/Ta7PZuROScRNX2FDfQqY4ZOYIr 7H7iF7Z4f7MbylFUxObuJTU0e5UfPZv6ZzbYfu3OkCx1/Pr+/eOtJEWOhzE6F1xOXeMZ L5ZA== X-Received: by 10.140.106.228 with SMTP id e91mr42008931qgf.59.1450897288520; Wed, 23 Dec 2015 11:01:28 -0800 (PST) Received: from cm.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by smtp.gmail.com with ESMTPSA id p19sm18566797qgp.9.2015.12.23.11.01.27 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 23 Dec 2015 11:01:28 -0800 (PST) From: Alex Deucher X-Google-Original-From: Alex Deucher To: airlied@gmail.com, dri-devel@lists.freedesktop.org, broonie@kernel.org, alsa-devel@alsa-project.org, maruthi.bayyavarapu@amd.com, rajeevkumar.linux@gmail.com Date: Wed, 23 Dec 2015 14:01:14 -0500 Message-Id: <1450897275-17152-7-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1450897275-17152-1-git-send-email-alexander.deucher@amd.com> References: <1450897275-17152-1-git-send-email-alexander.deucher@amd.com> MIME-Version: 1.0 Cc: tiwai@suse.de, Alex Deucher , Maruthi Srinivas Bayyavarapu , lgirdwood@gmail.com Subject: [alsa-devel] [PATCH 7/8] ASoC: AMD: add pm ops 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maruthi Srinivas Bayyavarapu genpd will power off/on ACP to manage runtime ACP PM. ACP runtime PM hooks are added to get it deinitialized and initialized respectively, after it is powered off/on. When system goes to suspend when audio usecase is active, ACP will be powered off through genpd. When it resumes, ACP needs to be initialized and reconfigured. Acked-by: Christian König Signed-off-by: Maruthi Bayyavarapu Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher --- sound/soc/amd/acp-pcm-dma.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 0494ac8..a45e910 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -15,6 +15,7 @@ #include #include +#include #include @@ -895,6 +896,10 @@ static int acp_audio_probe(struct platform_device *pdev) return status; } + pm_runtime_set_autosuspend_delay(&pdev->dev, 10000); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_enable(&pdev->dev); + return status; } @@ -904,15 +909,70 @@ static int acp_audio_remove(struct platform_device *pdev) acp_deinit(adata->acp_mmio); snd_soc_unregister_platform(&pdev->dev); + pm_runtime_disable(&pdev->dev); + + return 0; +} + +static int acp_pcm_resume(struct device *dev) +{ + struct snd_pcm_substream *stream; + struct snd_pcm_runtime *rtd; + struct audio_substream_data *sdata; + struct audio_drv_data *adata = dev_get_drvdata(dev); + + acp_init(adata->acp_mmio); + + stream = adata->play_stream; + rtd = stream ? stream->runtime : NULL; + if (rtd != NULL) { + /* Resume playback stream from a suspended state */ + sdata = rtd->private_data; + config_acp_dma(adata->acp_mmio, sdata); + } + + stream = adata->capture_stream; + rtd = stream ? stream->runtime : NULL; + if (rtd != NULL) { + /* Resume capture stream from a suspended state */ + sdata = rtd->private_data; + config_acp_dma(adata->acp_mmio, sdata); + } + + acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); + return 0; +} + +static int acp_pcm_runtime_suspend(struct device *dev) +{ + struct audio_drv_data *adata = dev_get_drvdata(dev); + acp_deinit(adata->acp_mmio); + acp_reg_write(0, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); return 0; } +static int acp_pcm_runtime_resume(struct device *dev) +{ + struct audio_drv_data *adata = dev_get_drvdata(dev); + + acp_init(adata->acp_mmio); + acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); + return 0; +} + +static const struct dev_pm_ops acp_pm_ops = { + .resume = acp_pcm_resume, + .runtime_suspend = acp_pcm_runtime_suspend, + .runtime_resume = acp_pcm_runtime_resume, +}; + static struct platform_driver acp_dma_driver = { .probe = acp_audio_probe, .remove = acp_audio_remove, .driver = { .name = "acp_audio_dma", + .pm = &acp_pm_ops, }, };