From a4a4baa347df3a95229253b42bd9233d3db6740a Mon Sep 17 00:00:00 2001 From: Asish Bhattacharya Date: Wed, 12 Oct 2011 13:58:41 +0530 Subject: [PATCH] ASOC: msm8960: Reset irq pointer if trigger start done. In case of seek the audio is paused and rerun. the last buffer might return after the prepare is called. This results in pointer mismatch. CRs-Fixed: 311642 Change-Id: I5115737af5d452da57a258f1b0bc87db1c6987a2 Signed-off-by: Asish Bhattacharya --- sound/soc/msm/msm-pcm-lpa.c | 5 +++++ sound/soc/msm/msm-pcm-q6.h | 1 + 2 files changed, 6 insertions(+) diff --git a/sound/soc/msm/msm-pcm-lpa.c b/sound/soc/msm/msm-pcm-lpa.c index eeb163ed101..2719d22163d 100644 --- a/sound/soc/msm/msm-pcm-lpa.c +++ b/sound/soc/msm/msm-pcm-lpa.c @@ -79,9 +79,11 @@ static void event_handler(uint32_t opcode, struct snd_pcm_runtime *runtime = substream->runtime; struct audio_aio_write_param param; struct audio_buffer *buf = prtd->audio_client->port[IN].buf; + unsigned long flag = 0; int i = 0; pr_debug("%s\n", __func__); + spin_lock_irqsave(&the_locks.event_lock, flag); switch (opcode) { case ASM_DATA_EVENT_WRITE_DONE: { uint32_t *ptrmem = (uint32_t *)¶m; @@ -163,6 +165,7 @@ static void event_handler(uint32_t opcode, pr_debug("Not Supported Event opcode[0x%x]\n", opcode); break; } + spin_unlock_irqrestore(&the_locks.event_lock, flag); } static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) @@ -201,6 +204,7 @@ static int msm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) pr_debug("%s\n", __func__); switch (cmd) { case SNDRV_PCM_TRIGGER_START: + prtd->pcm_irq_pos = 0; case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: pr_debug("SNDRV_PCM_TRIGGER_START\n"); @@ -511,6 +515,7 @@ static struct platform_driver msm_pcm_driver = { static int __init msm_soc_platform_init(void) { + spin_lock_init(&the_locks.event_lock); init_waitqueue_head(&the_locks.enable_wait); init_waitqueue_head(&the_locks.eos_wait); init_waitqueue_head(&the_locks.write_wait); diff --git a/sound/soc/msm/msm-pcm-q6.h b/sound/soc/msm/msm-pcm-q6.h index 42e54de02b3..214bd9d5049 100644 --- a/sound/soc/msm/msm-pcm-q6.h +++ b/sound/soc/msm/msm-pcm-q6.h @@ -43,6 +43,7 @@ struct buffer_rec { }; struct audio_locks { + spinlock_t event_lock; wait_queue_head_t read_wait; wait_queue_head_t write_wait; wait_queue_head_t eos_wait;