From patchwork Fri Dec 4 23:40:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 7773261 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E9068BEEE1 for ; Fri, 4 Dec 2015 23:48:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 137A220639 for ; Fri, 4 Dec 2015 23:48:26 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C41D22045E for ; Fri, 4 Dec 2015 23:48:24 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D9886265DAB; Sat, 5 Dec 2015 00:48:23 +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 1F45F2667B4; Sat, 5 Dec 2015 00:42:31 +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 F21DE2667B1; Sat, 5 Dec 2015 00:42:29 +0100 (CET) Received: from mail-qk0-f178.google.com (mail-qk0-f178.google.com [209.85.220.178]) by alsa0.perex.cz (Postfix) with ESMTP id D2DB12657B4 for ; Sat, 5 Dec 2015 00:41:12 +0100 (CET) Received: by qkeg192 with SMTP id g192so4388821qke.1 for ; Fri, 04 Dec 2015 15:41:12 -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; bh=gn9Ruc3NcsTpabv9X/EotZ9u06EDBHOBjIjmckAt+ec=; b=JV9lWemD6dHadfgC4bh/KUx/uhxRScRGWcFriNC5dk94eN2eJJbTmnFsQVhKsf1yVc Wtlu06kfcFTeuLC3x5Nnqoge0peh1eyJ2VDJyCXEf9T5PBSQWrILp164szKGEZ1t7GJX 0y29xdEjTyCWLcM1eztB62ZXdPNgIhGmNCIH9ZD0jNN9qho1s05eNf2aqCwypm5TMZjt 8y83wEZ8innptPxo1oSNGgHXWY3lDUiWyzacwnFoudG2BkWOZeUtFXoUem0lKPgANmYI szXka6oMy/39U/JMeZGcsud4WPn5PYEGapN6B2cBotdnDudT1xMJ7S1BTKj+50VX6DY7 EZ+w== X-Received: by 10.55.197.9 with SMTP id p9mr9883892qki.11.1449272472322; Fri, 04 Dec 2015 15:41:12 -0800 (PST) Received: from localhost.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by smtp.gmail.com with ESMTPSA id e127sm5556698qkb.34.2015.12.04.15.41.10 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Dec 2015 15:41:11 -0800 (PST) From: Alex Deucher X-Google-Original-From: Alex Deucher To: broonie@kernel.org, airlied@gmail.com, dri-devel@lists.freedesktop.org, alsa-devel@alsa-project.org, maruthi.bayyavarapu@amd.com, rajeevkumar.linux@gmail.com Date: Fri, 4 Dec 2015 18:40:39 -0500 Message-Id: <1449272440-8735-12-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1449272440-8735-1-git-send-email-alexander.deucher@amd.com> References: <1449272440-8735-1-git-send-email-alexander.deucher@amd.com> Cc: tiwai@suse.de, Alex Deucher , Maruthi Srinivas Bayyavarapu , lgirdwood@gmail.com Subject: [alsa-devel] [PATCH 12/13] 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: , 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 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. Signed-off-by: Maruthi Bayyavarapu Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher --- sound/soc/amd/acp-pcm-dma.c | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 9734f2e..07a26e5 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -447,6 +448,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; } @@ -456,15 +461,77 @@ 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) +{ + u16 bank; + 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 */ + for (bank = 1; bank <= 4; bank++) + acp_turnonoff_lower_sram_bank(adata->acp_mmio, bank, + true); + 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 */ + for (bank = 5; bank <= 8; bank++) + acp_turnonoff_lower_sram_bank(adata->acp_mmio, bank, + true); + sdata = rtd->private_data; + config_acp_dma(adata->acp_mmio, sdata); + } + + acp_enable_external_interrupts(adata->acp_mmio, 1); + 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_enable_external_interrupts(adata->acp_mmio, 0); 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_enable_external_interrupts(adata->acp_mmio, 1); + 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, }, };