From 60fafe3440ea14a5179467119de0b95423ad54dc Mon Sep 17 00:00:00 2001 From: Sitong Chen Date: Tue, 22 Dec 2020 16:44:44 +0800 Subject: [PATCH] ASoC: msm: qdsp6v2: write all periods to DSP on playback trigger In mmap mode, when playback is triggered, send as much as periods to DSP. In previous implementation, only 1 period be sent to DSP at trigger time, it's consumed in DSP and then send back a write-done event, which will be captured and trigger another write action in the event_handler. The problem is, any jitter in the event transmission will result in a delay on the next write, and a gap in the output is noticeable. A multiple-periods queue in DSP can filter out such a jitter to avoid impact to the output. Change-Id: I6f04971c076409b5ada8e40cea2b4e01de88b5a9 Signed-off-by: Han Lu Signed-off-by: Sitong Chen --- asoc/msm-pcm-q6-v2.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c index 7f2368d00208..c8114054d4d8 100644 --- a/asoc/msm-pcm-q6-v2.c +++ b/asoc/msm-pcm-q6-v2.c @@ -265,12 +265,19 @@ static void event_handler(uint32_t opcode, break; } if (prtd->mmap_flag) { - pr_debug("%s:writing %d bytes of buffer to dsp\n", - __func__, - prtd->pcm_count); - q6asm_write_nolock(prtd->audio_client, - prtd->pcm_count, - 0, 0, NO_TIMESTAMP); + int cnt = prtd->pcm_size / prtd->pcm_count; + + pr_debug("%s %d:buffer %d, period %d, %d writes\n", + __func__, __LINE__, + prtd->pcm_size, prtd->pcm_count, cnt); + while (cnt--) { + pr_debug("%s %d:writing %d bytes of buffer to dsp\n", + __func__, __LINE__, + prtd->pcm_count); + q6asm_write_nolock(prtd->audio_client, + prtd->pcm_count, + 0, 0, NO_TIMESTAMP); + } } else { while (atomic_read(&prtd->out_needed)) { pr_debug("%s:writing %d bytes of buffer to dsp\n",