Commit 782bc950d84e404422ba21008fd51ee894c8d231

Authored by Sascha Hauer
Committed by Dan Williams
1 parent b30a3f6257

dmaengine: add possibility for cyclic transfers

Cyclic transfers are useful for audio where a single buffer divided
in periods has to be transfered endlessly until stopped. After being
prepared the transfer is started using the dma_async_descriptor->tx_submit
function. dma_async_descriptor->callback is called after each period.
The transfer is stopped using the DMA_TERMINATE_ALL callback.
While being used for cyclic transfers the channel cannot be used
for other transfer types.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Showing 2 changed files with 10 additions and 1 deletions Side-by-side Diff

drivers/dma/dmaengine.c
... ... @@ -692,6 +692,8 @@
692 692 !device->device_prep_dma_interrupt);
693 693 BUG_ON(dma_has_cap(DMA_SLAVE, device->cap_mask) &&
694 694 !device->device_prep_slave_sg);
  695 + BUG_ON(dma_has_cap(DMA_CYCLIC, device->cap_mask) &&
  696 + !device->device_prep_dma_cyclic);
695 697 BUG_ON(dma_has_cap(DMA_SLAVE, device->cap_mask) &&
696 698 !device->device_control);
697 699  
include/linux/dmaengine.h
... ... @@ -67,10 +67,11 @@
67 67 DMA_PRIVATE,
68 68 DMA_ASYNC_TX,
69 69 DMA_SLAVE,
  70 + DMA_CYCLIC,
70 71 };
71 72  
72 73 /* last transaction type for creation of the capabilities mask */
73   -#define DMA_TX_TYPE_END (DMA_SLAVE + 1)
  74 +#define DMA_TX_TYPE_END (DMA_CYCLIC + 1)
74 75  
75 76  
76 77 /**
... ... @@ -422,6 +423,9 @@
422 423 * @device_prep_dma_memset: prepares a memset operation
423 424 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation
424 425 * @device_prep_slave_sg: prepares a slave dma operation
  426 + * @device_prep_dma_cyclic: prepare a cyclic dma operation suitable for audio.
  427 + * The function takes a buffer of size buf_len. The callback function will
  428 + * be called after period_len bytes have been transferred.
425 429 * @device_control: manipulate all pending operations on a channel, returns
426 430 * zero or error code
427 431 * @device_tx_status: poll for transaction completion, the optional
... ... @@ -478,6 +482,9 @@
478 482 struct dma_chan *chan, struct scatterlist *sgl,
479 483 unsigned int sg_len, enum dma_data_direction direction,
480 484 unsigned long flags);
  485 + struct dma_async_tx_descriptor *(*device_prep_dma_cyclic)(
  486 + struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
  487 + size_t period_len, enum dma_data_direction direction);
481 488 int (*device_control)(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
482 489 unsigned long arg);
483 490