From bc7f5f34c2d6affb3c46417c138784c3e953ae8d Mon Sep 17 00:00:00 2001 From: Damian Nikodem Date: Tue, 16 Jan 2024 10:34:39 +0100 Subject: [PATCH] audio: host: reload DMA buffer on non-zero partial_size This patch ensures that the DMA buffer is reloaded when partial_size is non-zero, even if copy_bytes is zero. This condition typically occurs at the end of a stream, where the last data chunk does not meet the condition for reload DMA buffer, leaving a non-zero partial_size. Signed-off-by: Damian Nikodem --- src/audio/host-zephyr.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/audio/host-zephyr.c b/src/audio/host-zephyr.c index 998dca300b76..fd629838aba0 100644 --- a/src/audio/host-zephyr.c +++ b/src/audio/host-zephyr.c @@ -449,8 +449,20 @@ static int host_copy_normal(struct host_data *hd, struct comp_dev *dev, copy_cal comp_dbg(dev, "host_copy_normal()"); copy_bytes = host_get_copy_bytes_normal(hd, dev); - if (!copy_bytes) + if (!copy_bytes) { + if (hd->partial_size != 0) { + if (stream_sync(hd, dev)) { + ret = dma_reload(hd->chan->dma->z_dev, hd->chan->index, 0, 0, + hd->partial_size); + if (ret < 0) + comp_err(dev, "dma_reload() failed, ret = %u", ret); + + hd->partial_size = 0; + } + } + return 0; + } cb(dev, copy_bytes);