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

Keyon Jie yang.jie at linux.intel.com
Thu Feb 9 16:04:07 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 ccae9b7..7c0e9f3 100644
--- a/src/audio/host.c
+++ b/src/audio/host.c
@@ -803,14 +803,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 == 0)
+		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