drivers: imx: edma: fix bytes copied at each iteration

The number of bytes copied at each ieration must
match half the total size copied as we have an
interrupt at HALF and MAJOR loop

Signed-off-by: Guido Roncarolo <guido.roncarolo@nxp.com>
Signed-off-by: Jerome Laclavere <jerome.laclavere@nxp.com>
This commit is contained in:
Guido Roncarolo 2019-10-18 15:21:09 +02:00 committed by Daniel Baluta
parent d781385a91
commit 6cab99c729
1 changed files with 9 additions and 4 deletions

View File

@ -11,6 +11,7 @@
#include <sof/lib/alloc.h>
#include <sof/lib/dma.h>
#include <sof/lib/io.h>
#include <sof/math/numbers.h>
#include <sof/platform.h>
#include <errno.h>
#include <stddef.h>
@ -506,19 +507,23 @@ static int edma_get_data_size(struct dma_chan_data *channel,
*
* get_data_size() and copy() are run exactly once per
* interrupt, and currently we have the elem size stored
* directly in the hardware register NBYTES so we can just
* return it.
* directly in the hardware register EDMA_TCD_SLAST
* as negative offset divided by 2
*
* TODO If we support multiple DMA transfers per SOF elem, we
* need to adjust for that and copy the whole required data per
* interrupt.
*/
int32_t data_size;
data_size = (int32_t)dma_chan_reg_read(channel, EDMA_TCD_SLAST);
switch (channel->direction) {
case SOF_IPC_STREAM_PLAYBACK:
*free = dma_chan_reg_read(channel, EDMA_TCD_NBYTES);
*free = ABS(data_size) / 2;
break;
case SOF_IPC_STREAM_CAPTURE:
*avail = dma_chan_reg_read(channel, EDMA_TCD_NBYTES);
*avail = ABS(data_size) / 2;
break;
default:
trace_edma_error("edma_get_data_size() unsupported direction %d",