summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorSumit Bhattacharya <sumitb@nvidia.com>2011-07-21 14:05:43 +0530
committerVarun Colbert <vcolbert@nvidia.com>2011-07-22 17:42:37 -0700
commit28ac81f7287f782cf40bbb2d7a468317a4c12ec5 (patch)
tree48b6223de6e433c35183beed34d54ef78907eda6 /sound
parent33c758a53ad9e4fbcc9622b18cfc75a21dec51b0 (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. Bug 827122 Change-Id: I25359f24dafda657756a3c2904d46e14b6675e7c Reviewed-on: http://git-master/r/42336 Tested-by: Sumit Bhattacharya <sumitb@nvidia.com> Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com> Reviewed-by: Scott Peterson <speterson@nvidia.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/tegra/tegra_pcm.c18
-rw-r--r--sound/soc/tegra/tegra_soc.h8
2 files changed, 26 insertions, 0 deletions
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
index 8ee01173d6c0..4b0554522be2 100644
--- a/sound/soc/tegra/tegra_pcm.c
+++ b/sound/soc/tegra/tegra_pcm.c
@@ -129,6 +129,9 @@ static int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+#ifdef CONFIG_HAS_WAKELOCK
+ wake_lock(&prtd->wake_lock);
+#endif
prtd->dma_state = STATE_INIT;
tegra_pcm_queue_dma(prtd); /* dma enqueue req1 */
tegra_pcm_queue_dma(prtd); /* dma enqueue req2 */
@@ -148,6 +151,9 @@ static int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
prtd->dma_head_idx = 0;
prtd->dma_tail_idx = DMA_REQ_QCOUNT - 1;
}
+#ifdef CONFIG_HAS_WAKELOCK
+ wake_unlock(&prtd->wake_lock);
+#endif
break;
default:
@@ -241,6 +247,15 @@ 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);
@@ -274,6 +289,9 @@ static int tegra_pcm_close(struct snd_pcm_substream *substream)
return 0;
}
+#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 45726cbde45a..539b46fbaa5b 100644
--- a/sound/soc/tegra/tegra_soc.h
+++ b/sound/soc/tegra/tegra_soc.h
@@ -59,6 +59,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
@@ -100,6 +104,10 @@ struct tegra_runtime_data {
int dma_state;
struct tegra_dma_req dma_req[DMA_REQ_QCOUNT];
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 {