ASoC: msm: Fix issue with Pause/resume
The driver is sending the next buffer everytime after coming
out of PAUSE. This shouldnt happen as the previous driver might
still be with DSP.
Fix by putting appropriate check to the pending_buffer flag.
The pending_buffer flag should also be atomic to handle
intermediate close of session.
Change-Id: Ieb102b968b6d18736bab0cf4298cc51b7ed3affe
CRs-Fixed: 326259
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
diff --git a/sound/soc/msm/msm-compr-q6.c b/sound/soc/msm/msm-compr-q6.c
index cf6f1e7..590d4af 100644
--- a/sound/soc/msm/msm-compr-q6.c
+++ b/sound/soc/msm/msm-compr-q6.c
@@ -88,10 +88,10 @@
atomic_inc(&prtd->out_count);
wake_up(&the_locks.write_wait);
if (!atomic_read(&prtd->start)) {
- prtd->pending_buffer = 1;
+ atomic_set(&prtd->pending_buffer, 1);
break;
} else
- prtd->pending_buffer = 0;
+ atomic_set(&prtd->pending_buffer, 0);
if (runtime->status->hw_ptr >= runtime->control->appl_ptr)
break;
@@ -131,8 +131,7 @@
case APR_BASIC_RSP_RESULT: {
switch (payload[0]) {
case ASM_SESSION_CMD_RUN: {
- if (!prtd->pending_buffer &&
- !atomic_read(&prtd->start))
+ if (!atomic_read(&prtd->pending_buffer))
break;
pr_debug("%s:writing %d bytes"
" of buffer[%d] to dsp\n",
@@ -156,6 +155,7 @@
prtd->out_head =
(prtd->out_head + 1)
& (runtime->periods - 1);
+ atomic_set(&prtd->pending_buffer, 0);
}
break;
case ASM_STREAM_CMD_FLUSH:
@@ -302,7 +302,7 @@
pr_info("snd_pcm_hw_constraint_integer failed\n");
prtd->dsp_cnt = 0;
- prtd->pending_buffer = 1;
+ atomic_set(&prtd->pending_buffer, 1);
compr->codec = FORMAT_MP3;
populate_codec_list(compr, runtime);
runtime->private_data = compr;
@@ -321,7 +321,7 @@
pr_debug("%s\n", __func__);
dir = IN;
-
+ atomic_set(&prtd->pending_buffer, 0);
q6asm_cmd(prtd->audio_client, CMD_CLOSE);
q6asm_audio_client_buf_free_contiguous(dir,
prtd->audio_client);
diff --git a/sound/soc/msm/msm-pcm-lpa.c b/sound/soc/msm/msm-pcm-lpa.c
index f644722..0a29016 100644
--- a/sound/soc/msm/msm-pcm-lpa.c
+++ b/sound/soc/msm/msm-pcm-lpa.c
@@ -95,10 +95,10 @@
atomic_inc(&prtd->out_count);
wake_up(&the_locks.write_wait);
if (!atomic_read(&prtd->start)) {
- prtd->pending_buffer = 1;
+ atomic_set(&prtd->pending_buffer, 1);
break;
} else
- prtd->pending_buffer = 0;
+ atomic_set(&prtd->pending_buffer, 0);
pr_debug("%s:writing %d bytes of buffer to dsp 2\n",
__func__, prtd->pcm_count);
@@ -121,6 +121,7 @@
else
prtd->out_head =
(prtd->out_head + 1) & (runtime->periods - 1);
+ atomic_set(&prtd->pending_buffer, 0);
break;
}
case ASM_DATA_CMDRSP_EOS:
@@ -131,8 +132,7 @@
case APR_BASIC_RSP_RESULT: {
switch (payload[0]) {
case ASM_SESSION_CMD_RUN: {
- if (!prtd->pending_buffer &&
- !atomic_read(&prtd->start))
+ if (!atomic_read(&prtd->pending_buffer))
break;
pr_debug("%s:writing %d bytes"
" of buffer to dsp\n",
@@ -152,6 +152,7 @@
prtd->out_head =
(prtd->out_head + 1)
& (runtime->periods - 1);
+ atomic_set(&prtd->pending_buffer, 0);
}
break;
case ASM_STREAM_CMD_FLUSH:
@@ -303,7 +304,7 @@
pr_debug("snd_pcm_hw_constraint_integer failed\n");
prtd->dsp_cnt = 0;
- prtd->pending_buffer = 1;
+ atomic_set(&prtd->pending_buffer, 1);
runtime->private_data = prtd;
lpa_audio.prtd = prtd;
lpa_set_volume(lpa_audio.volume);
@@ -343,6 +344,7 @@
pr_debug("%s\n", __func__);
dir = IN;
+ atomic_set(&prtd->pending_buffer, 0);
lpa_audio.prtd = NULL;
q6asm_cmd(prtd->audio_client, CMD_CLOSE);
q6asm_audio_client_buf_free_contiguous(dir,
diff --git a/sound/soc/msm/msm-pcm-q6.h b/sound/soc/msm/msm-pcm-q6.h
index 214bd9d..e5551ea 100644
--- a/sound/soc/msm/msm-pcm-q6.h
+++ b/sound/soc/msm/msm-pcm-q6.h
@@ -77,7 +77,7 @@
int out_head;
int periods;
int mmap_flag;
- int pending_buffer;
+ atomic_t pending_buffer;
};
#endif /*_MSM_PCM_H*/