From b3b7824a869f8db2cef777b25f44d702832ea522 Mon Sep 17 00:00:00 2001 From: Manjula Gupta Date: Fri, 22 Jul 2011 14:43:01 +0530 Subject: 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 Reviewed-by: Sumit Bhattacharya Reviewed-by: Bharat Nihalani --- sound/soc/tegra/tegra_pcm.c | 19 +++++++++++++++++++ sound/soc/tegra/tegra_soc.h | 8 ++++++++ 2 files changed, 27 insertions(+) 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 #include +#ifdef CONFIG_HAS_WAKELOCK +#include +#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 { -- cgit v1.2.3