host: host_copy: only copy when there is data and wait until finish

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@linux.intel.com>
This commit is contained in:
Keyon Jie 2017-02-11 10:17:55 +08:00 committed by Liam Girdwood
parent 8cbf06c96b
commit 1ff623bdf5
1 changed files with 13 additions and 1 deletions

View File

@ -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 = {