From: Alex Deucher <alexdeucher@gmail.com>
To: broonie@kernel.org, airlied@gmail.com,
dri-devel@lists.freedesktop.org, alsa-devel@alsa-project.org
Cc: Maruthi Srinivas Bayyavarapu <Maruthi.Bayyavarapu@amd.com>,
lgirdwood@gmail.com, perex@perex.cz
Subject: [PATCH 12/12] ASoC: AMD: add ACP PCM driver runtime PM
Date: Thu, 6 Aug 2015 10:25:12 -0400 [thread overview]
Message-ID: <1438871112-25946-12-git-send-email-alexander.deucher@amd.com> (raw)
In-Reply-To: <1438871112-25946-1-git-send-email-alexander.deucher@amd.com>
From: Maruthi Srinivas Bayyavarapu <Maruthi.Bayyavarapu@amd.com>
Added runtime PM functionality to AMD I2S driver. This uses
functionality from ACP IP methods.
Signed-off-by: Maruthi Bayyavarapu <maruthi.bayyavarapu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Murali Krishna Vemuri <murali-krishna.vemuri@amd.com>
---
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 <linux/err.h>
#include <linux/io.h>
#include <linux/pci.h>
+#include <linux/pm_runtime.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -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 = {
--
1.8.3.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-08-06 14:25 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-06 14:25 [PATCH 00/12] Add ASoC support for AMD APUs Alex Deucher
2015-08-06 14:25 ` [PATCH 01/12] drm/amdgpu: add amd_gnb_bus support Alex Deucher
2015-08-06 19:36 ` Lars-Peter Clausen
2015-08-07 10:25 ` Mark Brown
2015-08-07 14:17 ` Alex Deucher
2015-08-07 16:16 ` Felix Kuehling
2015-08-07 18:24 ` Mark Brown
2015-08-07 20:03 ` Felix Kuehling
2015-08-10 11:56 ` Mark Brown
2015-08-07 17:20 ` Mark Brown
2015-08-06 14:25 ` [PATCH 02/12] drm/amd: remove amd gnb bus default runtime pm ops Alex Deucher
2015-08-06 14:25 ` [PATCH 04/12] drm/amd: add ACP driver support (v4) Alex Deucher
2015-08-06 14:25 ` [PATCH 05/12] drm/amd: modify ACP DMA buffer position update logic (v2) Alex Deucher
2015-08-06 14:25 ` [PATCH 06/12] drm/amd: add ACP suspend/resume functionality Alex Deucher
2015-08-06 14:25 ` [PATCH 07/12] drm/amd: change ACP SRAM banks used for audio Alex Deucher
2015-08-06 14:25 ` [PATCH 08/12] drm/amd: shutdown unused ACP SRAM memory banks Alex Deucher
2015-08-06 14:25 ` [PATCH 09/12] drm/amd: remove bitfield usage in ACP IP module Alex Deucher
2015-08-06 14:25 ` [PATCH 10/12] ASoC: AMD: add AMD ASoC ACP-I2S driver (v2) Alex Deucher
2015-08-06 19:22 ` Mark Brown
2015-08-07 9:27 ` Bayyavarapu, Maruthi
2015-08-06 14:25 ` [PATCH 11/12] ASoC: AMD: add suspend/resume for ACP PCM driver Alex Deucher
2015-08-06 19:23 ` Mark Brown
2015-08-06 14:25 ` Alex Deucher [this message]
2015-08-06 19:26 ` [PATCH 12/12] ASoC: AMD: add ACP PCM driver runtime PM Mark Brown
2015-08-07 9:41 ` Bayyavarapu, Maruthi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438871112-25946-12-git-send-email-alexander.deucher@amd.com \
--to=alexdeucher@gmail.com \
--cc=Maruthi.Bayyavarapu@amd.com \
--cc=airlied@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lgirdwood@gmail.com \
--cc=perex@perex.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox