summaryrefslogtreecommitdiff
path: root/sound/soc/tegra/tegra_pcm.c
diff options
context:
space:
mode:
authorSumit Bhattacharya <sumitb@nvidia.com>2011-12-07 17:58:14 +0530
committerVarun Wadekar <vwadekar@nvidia.com>2011-12-15 11:47:34 +0530
commit96d3f4ab25478b4b108118c6839cc386853a78ef (patch)
tree05636de6653a7db68a92e89de99461cd90d53bd5 /sound/soc/tegra/tegra_pcm.c
parentc37dac584d6f0af1dc2b3c941b103bd81d11bd91 (diff)
ASoC: Tegra: Acquire wake_lock during playback 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. Change-Id: I71e5fae0268f73a3e57f8d886c1b228d46899ea4 Signed-off-by: Sumit Bhattacharya <sumitb@nvidia.com> Reviewed-on: http://git-master/r/68671 Reviewed-by: Nikesh Oswal <noswal@nvidia.com> Reviewed-by: Scott Peterson <speterson@nvidia.com>
Diffstat (limited to 'sound/soc/tegra/tegra_pcm.c')
-rw-r--r--sound/soc/tegra/tegra_pcm.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
index f506d0954acb..53f4e4c3c08c 100644
--- a/sound/soc/tegra/tegra_pcm.c
+++ b/sound/soc/tegra/tegra_pcm.c
@@ -185,6 +185,15 @@ static int tegra_pcm_open(struct snd_pcm_substream *substream)
if (ret < 0)
goto err;
+#ifdef CONFIG_HAS_WAKELOCK
+ snprintf(prtd->tegra_wake_lock_name, sizeof(prtd->tegra_wake_lock_name),
+ "tegra-pcm-%s-%d",
+ (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? "out" : "in",
+ substream->pcm->device);
+ wake_lock_init(&prtd->tegra_wake_lock, WAKE_LOCK_SUSPEND,
+ prtd->tegra_wake_lock_name);
+#endif
+
return 0;
err:
@@ -202,6 +211,10 @@ static int tegra_pcm_close(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
struct tegra_runtime_data *prtd = runtime->private_data;
+#ifdef CONFIG_HAS_WAKELOCK
+ wake_lock_destroy(&prtd->tegra_wake_lock);
+#endif
+
if (prtd->dma_chan)
tegra_dma_free_channel(prtd->dma_chan);
@@ -246,6 +259,9 @@ static int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
/* Fall-through */
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+#ifdef CONFIG_HAS_WAKELOCK
+ wake_lock(&prtd->tegra_wake_lock);
+#endif
spin_lock_irqsave(&prtd->lock, flags);
prtd->running = 1;
spin_unlock_irqrestore(&prtd->lock, flags);
@@ -260,6 +276,10 @@ static int tegra_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
spin_unlock_irqrestore(&prtd->lock, flags);
tegra_dma_dequeue_req(prtd->dma_chan, &prtd->dma_req[0]);
tegra_dma_dequeue_req(prtd->dma_chan, &prtd->dma_req[1]);
+
+#ifdef CONFIG_HAS_WAKELOCK
+ wake_unlock(&prtd->tegra_wake_lock);
+#endif
break;
default:
return -EINVAL;