[Sound-open-firmware] [PATCH 15/25] host: host_copy: only copy when there is data and wait until finish

Keyon Jie yang.jie at linux.intel.com
Tue Feb 7 15:03:02 CET 2017


We don't copy when host_avail is 0(usually stream finished), at the
same time, we need wait until the dma copy is finished before we
can start next pulling copy.

Signed-off-by: Keyon Jie <yang.jie at linux.intel.com>
---
 src/audio/host.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/audio/host.c b/src/audio/host.c
index 4b60943..0580837 100644
--- a/src/audio/host.c
+++ b/src/audio/host.c
@@ -809,14 +809,26 @@ static int host_reset(struct comp_dev *dev)
 static int host_copy(struct comp_dev *dev)
 {
 	struct host_data *hd = comp_get_drvdata(dev);
+	int ret;
 
+	trace_host("CpS");
 	if (dev->state != COMP_STATE_RUNNING)
 		return 0;
 
-	trace_host("CpS");
+	if (!hd->host_avail)
+		return 0;
+
+	/* do DMA transfer */
+	wait_init(&hd->complete);
 	dma_set_config(hd->dma, hd->chan, &hd->config);
 	dma_start(hd->dma, hd->chan);
 
+	/* wait for DMA to finish */
+	hd->complete.timeout = PLATFORM_DMA_TIMEOUT;
+	ret = wait_for_completion_timeout(&hd->complete);
+	if (ret < 0)
+		trace_comp_error("eHc");
+
 	return 0;
 }
 struct comp_driver comp_host = {
-- 
2.7.4



More information about the Sound-open-firmware mailing list