diff options
author | Manjula Gupta <magupta@nvidia.com> | 2011-07-22 14:43:01 +0530 |
---|---|---|
committer | Niket Sirsi <nsirsi@nvidia.com> | 2011-07-22 14:47:16 -0700 |
commit | b3b7824a869f8db2cef777b25f44d702832ea522 (patch) | |
tree | 6b88c5e934b6d41a7f7ebb18c420cba3df6dc624 | |
parent | cd997b022260b15c7b9a419ec11cdc1c90ccdaa8 (diff) |
ASOC: tegra: Acquire wake_lock during play/capture
Acquire wake_lock from alsa kernel when pcm playback/capture
starts and hold it until playack/capture ends. It is needed
to prevent device from going into suspend state in middle
of audio playback.
Fix for Bug 829538
Change-Id: Ic5335a4bbbd5855a275f1fd1b6c2a57a5ed8dd27
Reviewed-on: http://git-master/r/42580
Tested-by: Manjula Gupta <magupta@nvidia.com>
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
-rw-r--r-- | sound/soc/tegra/tegra_pcm.c | 19 | ||||
-rw-r--r-- | sound/soc/tegra/tegra_soc.h | 8 |
2 files changed, 27 insertions, 0 deletions
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c index 83314f23de53..ab39dd565875 100644 --- a/sound/soc/tegra/tegra_pcm.c +++ b/sound/soc/tegra/tegra_pcm.c @@ -155,6 +155,10 @@ static int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd) for (i = 0; i < DMA_REQ_QCOUNT; i++) tegra_pcm_capture(prtd); /* dma enqueue req */ } + +#ifdef CONFIG_HAS_WAKELOCK + wake_lock(&prtd->wake_lock); +#endif break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: @@ -179,6 +183,10 @@ static int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd) prtd->dma_reqid_tail = DMA_REQ_QCOUNT - 1; } } + +#ifdef CONFIG_HAS_WAKELOCK + wake_unlock(&prtd->wake_lock); +#endif break; default: ret = -EINVAL; @@ -265,6 +273,13 @@ static int tegra_pcm_open(struct snd_pcm_substream *substream) goto fail; } +#ifdef CONFIG_HAS_WAKELOCK + snprintf(prtd->wake_lock_name, sizeof(prtd->wake_lock_name), + "tegra-pcm-%s-%d", + (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? "out" : "in", + substream->pcm->device); + wake_lock_init(&prtd->wake_lock, WAKE_LOCK_SUSPEND, prtd->wake_lock_name); +#endif /* Set HW params now that initialization is complete */ snd_soc_set_runtime_hwparams(substream, &tegra_pcm_hardware); @@ -298,6 +313,10 @@ static int tegra_pcm_close(struct snd_pcm_substream *substream) prtd->state = STATE_EXIT; +#ifdef CONFIG_HAS_WAKELOCK + wake_lock_destroy(&prtd->wake_lock); +#endif + if (prtd->dma_chan) { prtd->dma_state = STATE_EXIT; for (i = 0; i < DMA_REQ_QCOUNT; i++) diff --git a/sound/soc/tegra/tegra_soc.h b/sound/soc/tegra/tegra_soc.h index 0f2d9ce822af..7fc2952ddd52 100644 --- a/sound/soc/tegra/tegra_soc.h +++ b/sound/soc/tegra/tegra_soc.h @@ -57,6 +57,10 @@ #include <asm/mach-types.h> #include <asm/hardware/scoop.h> +#ifdef CONFIG_HAS_WAKELOCK +#include <linux/wakelock.h> +#endif + #define STATE_INIT 0 #define STATE_ABORT 1 #define STATE_EXIT 2 @@ -104,6 +108,10 @@ struct tegra_runtime_data { int period_index; int dma_state; struct tegra_dma_channel *dma_chan; +#ifdef CONFIG_HAS_WAKELOCK + struct wake_lock wake_lock; + char wake_lock_name[32]; +#endif }; struct tegra_audio_data { |