From patchwork Thu Aug 6 14:25:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 6960381 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 CB46E9F38B for ; Thu, 6 Aug 2015 14:32:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DAFD0206A2 for ; Thu, 6 Aug 2015 14:32:24 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 9E8BF206AC for ; Thu, 6 Aug 2015 14:32:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id AC35F262632; Thu, 6 Aug 2015 16:32:22 +0200 (CEST) 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 [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 4D7452606CB; Thu, 6 Aug 2015 16:26:28 +0200 (CEST) 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 71C352606B7; Thu, 6 Aug 2015 16:26:25 +0200 (CEST) Received: from mail-yk0-f170.google.com (mail-yk0-f170.google.com [209.85.160.170]) by alsa0.perex.cz (Postfix) with ESMTP id 16F792605CC for ; Thu, 6 Aug 2015 16:25:30 +0200 (CEST) Received: by ykoo205 with SMTP id o205so63595168yko.0 for ; Thu, 06 Aug 2015 07:25:29 -0700 (PDT) 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=zMRhRXRDxzUS0iO4zw68xeyyw4wUU6sOZ/0Jup4KMOE=; b=M8/0SnfKwtUJCL1zry91OasF+dBaKaHBKS8hkY/5JxW7LZebWMV267Xs5meuH7DG2O cE3g2kpZlutOz66o1K1iFXSHTgy2B5AyVedrPT6M8N2tlk4jByVCdAuCsfuBayFnmiLQ YotOMYd7TMkPwytYkBSz6ohhPQyrHL+ovdnO7xdwO4RUJeIAyWm5ph26OU+eyt3uWaWW HNjtSft/UJedFjwDdmYE6DpmbAJi1FYo6f+6PWiDxNNJgEzgMp6LOro42/vV4E4OK85z PI/1G/469bNPv8tmt7s1vBEoZf435yFSRaeD0hZ+htP/+aRGmNkMIZHzr0o8022wnzrc ITaw== X-Received: by 10.170.162.6 with SMTP id e6mr1966065ykd.64.1438871129599; Thu, 06 Aug 2015 07:25:29 -0700 (PDT) Received: from localhost.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by smtp.gmail.com with ESMTPSA id k128sm6182789ywe.11.2015.08.06.07.25.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Aug 2015 07:25:29 -0700 (PDT) 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 Date: Thu, 6 Aug 2015 10:25:12 -0400 Message-Id: <1438871112-25946-12-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1438871112-25946-1-git-send-email-alexander.deucher@amd.com> References: <1438871112-25946-1-git-send-email-alexander.deucher@amd.com> Cc: tiwai@suse.de, Maruthi Srinivas Bayyavarapu , lgirdwood@gmail.com Subject: [alsa-devel] [PATCH 12/12] ASoC: AMD: add ACP PCM driver runtime PM 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 Added runtime PM functionality to AMD I2S driver. This uses functionality from ACP IP methods. Signed-off-by: Maruthi Bayyavarapu Reviewed-by: Alex Deucher Reviewed-by: Murali Krishna Vemuri --- sound/soc/amd/acp-pcm-dma.c | 87 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 10 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index db09b77..7e0e5cb 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -379,10 +380,12 @@ static int acp_dma_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct audio_substream_data *rtd = runtime->private_data; + struct snd_soc_pcm_runtime *prtd = substream->private_data; kfree(rtd->dma_config); kfree(rtd->i2s_config); kfree(rtd); + pm_runtime_mark_last_busy(prtd->platform->dev); return 0; } @@ -610,6 +613,10 @@ static int acp_amdsoc_probe(struct amd_gnb_bus_dev *adev) else pr_err("ACP initialization Failed\n"); + pm_runtime_set_autosuspend_delay(&adev->dev, 10000); + pm_runtime_use_autosuspend(&adev->dev); + pm_runtime_enable(&adev->dev); + return status; } @@ -621,36 +628,96 @@ static int acp_amdsoc_remove(struct amd_gnb_bus_dev *adev) snd_soc_unregister_platform(&adev->dev); acp_dev->fini(acp_dev); - + pm_runtime_disable(&adev->dev); return 0; } static int acp_pcm_suspend(struct device *dev) { + bool pm_rts; + struct audio_drv_data *adata = + (struct audio_drv_data *)dev_get_drvdata(dev); + + pm_rts = pm_runtime_status_suspended(dev); + if (pm_rts == false) + adata->acp_dev->fini(adata->acp_dev); + return 0; } static int acp_pcm_resume(struct device *dev) { - struct snd_pcm_substream *substream; - struct snd_pcm_runtime *runtime; + bool pm_rts; + struct snd_pcm_substream *pstream, *cstream; + struct snd_pcm_runtime *prtd, *crtd; struct audio_substream_data *rtd; - struct audio_drv_data *irq_data = + struct audio_drv_data *adata = (struct audio_drv_data *)dev_get_drvdata(dev); - substream = irq_data->play_stream; - runtime = substream->runtime; - rtd = runtime->private_data; + pm_rts = pm_runtime_status_suspended(dev); + if (pm_rts == true) { + /* Resumed from system wide suspend and there is + * no pending audio activity to resume. */ + pm_runtime_disable(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + + goto out; + } - irq_data->acp_dev->config_i2s(irq_data->acp_dev, rtd->i2s_config); - irq_data->acp_dev->config_dma(irq_data->acp_dev, rtd->dma_config); + pstream = adata->play_stream; + prtd = pstream ? pstream->runtime : NULL; + if (prtd != NULL) { + /* Resume playback stream from a suspended state */ + rtd = prtd->private_data; + adata->acp_dev->config_dma(adata->acp_dev, rtd->dma_config); + adata->acp_dev->config_i2s(adata->acp_dev, rtd->i2s_config); + } + + cstream = adata->capture_stream; + crtd = cstream ? cstream->runtime : NULL; + if (crtd != NULL) { + /* Resume capture stream from a suspended state */ + rtd = crtd->private_data; + + adata->acp_dev->config_dma(adata->acp_dev, rtd->dma_config); + adata->acp_dev->config_i2s(adata->acp_dev, rtd->i2s_config); + } +out: + return 0; +} + +int acp_pcm_runtime_suspend(struct device *dev) +{ + struct audio_drv_data *adata = + (struct audio_drv_data *)dev_get_drvdata(dev); + + adata->acp_dev->acp_suspend(adata->acp_dev); + return 0; +} + +int acp_pcm_runtime_resume(struct device *dev) +{ + struct audio_drv_data *adata = + (struct audio_drv_data *)dev_get_drvdata(dev); + + adata->acp_dev->acp_resume(adata->acp_dev); + return 0; +} + +int acp_pcm_runtime_idle(struct device *dev) +{ return 0; } static const struct dev_pm_ops acp_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(acp_pcm_suspend, acp_pcm_resume) + .suspend = acp_pcm_suspend, + .resume = acp_pcm_resume, + .runtime_suspend = acp_pcm_runtime_suspend, + .runtime_resume = acp_pcm_runtime_resume, + .runtime_idle = acp_pcm_runtime_idle }; static struct amd_gnb_bus_driver acp_dma_driver = {