MLK-21002-1: ASoC: imx-pcm-rpmsg: fix data consumed faster with pause
authorShengjiu Wang <shengjiu.wang@nxp.com>
Wed, 27 Feb 2019 05:58:26 +0000 (13:58 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
commite36957e97ca9b604b71b7722c6b4d2e159c1a568
tree77955dbb22e4bf0a83e8013a70d3d2acbadc38e4
parentce594891d28ebbf671988c585414b28f01ce66dd
MLK-21002-1: ASoC: imx-pcm-rpmsg: fix data consumed faster with pause

In LPA, we use the timer to simulate the interrupt, if the period time
is 1s, the timer is 500ms, which means the interrupt is more frequent
than actual.

With pause ALSA will update the hw_ptr_jiffies, because the interrupt
is more frequent, so sometimes in snd_pcm_update_hw_ptr0, the condition
delta > new_hw_ptr will be true, then the new_hw_ptr will be added whole
buffer_size, which cause the whole buffer be flushed.

if (in_interrupt) {
/* we know that one period was processed */
/* delta = "expected next hw_ptr" for in_interrupt != 0 */
delta = runtime->hw_ptr_interrupt + runtime->period_size;
if (delta > new_hw_ptr) {
/* check for double acknowledged interrupts */
hdelta = curr_jiffies - runtime->hw_ptr_jiffies;
if (hdelta > runtime->hw_ptr_buffer_jiffies/2 + 1) {
hw_base += runtime->buffer_size;
if (hw_base >= runtime->boundary) {
hw_base = 0;
crossed_boundary++;
}
new_hw_ptr = hw_base + pos;
goto __delta;
}
}
}

So even we use the timer to simulate the interrupt, the timer should
be same as the period time, otherwise will cause issue.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
(cherry picked from commit 9a9af932118774083119dba72c5c6133852ba926)
sound/soc/fsl/imx-pcm-rpmsg.c