aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2010-09-30 09:56:32 -0400
committerDan Williams <dan.j.williams@intel.com>2010-10-05 18:49:26 -0400
commit782bc950d84e404422ba21008fd51ee894c8d231 (patch)
treec8a10b80bcc571c6de8a19c39b0f447ca61039d6
parentb30a3f6257ed2105259b404d419b4964e363928c (diff)
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>
-rw-r--r--drivers/dma/dmaengine.c2
-rw-r--r--include/linux/dmaengine.h9
2 files changed, 10 insertions, 1 deletions
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 9d31d5eb95c1..e5e79ced4f4b 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -692,6 +692,8 @@ int dma_async_device_register(struct dma_device *device)
692 !device->device_prep_dma_interrupt); 692 !device->device_prep_dma_interrupt);
693 BUG_ON(dma_has_cap(DMA_SLAVE, device->cap_mask) && 693 BUG_ON(dma_has_cap(DMA_SLAVE, device->cap_mask) &&
694 !device->device_prep_slave_sg); 694 !device->device_prep_slave_sg);
695 BUG_ON(dma_has_cap(DMA_CYCLIC, device->cap_mask) &&
696 !device->device_prep_dma_cyclic);
695 BUG_ON(dma_has_cap(DMA_SLAVE, device->cap_mask) && 697 BUG_ON(dma_has_cap(DMA_SLAVE, device->cap_mask) &&
696 !device->device_control); 698 !device->device_control);
697 699
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index c61d4ca27bcc..32cd84b47478 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -67,10 +67,11 @@ enum dma_transaction_type {
67 DMA_PRIVATE, 67 DMA_PRIVATE,
68 DMA_ASYNC_TX, 68 DMA_ASYNC_TX,
69 DMA_SLAVE, 69 DMA_SLAVE,
70 DMA_CYCLIC,
70}; 71};
71 72
72/* last transaction type for creation of the capabilities mask */ 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 @@ struct dma_tx_state {
422 * @device_prep_dma_memset: prepares a memset operation 423 * @device_prep_dma_memset: prepares a memset operation
423 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation 424 * @device_prep_dma_interrupt: prepares an end of chain interrupt operation
424 * @device_prep_slave_sg: prepares a slave dma operation 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 * @device_control: manipulate all pending operations on a channel, returns 429 * @device_control: manipulate all pending operations on a channel, returns
426 * zero or error code 430 * zero or error code
427 * @device_tx_status: poll for transaction completion, the optional 431 * @device_tx_status: poll for transaction completion, the optional
@@ -478,6 +482,9 @@ struct dma_device {
478 struct dma_chan *chan, struct scatterlist *sgl, 482 struct dma_chan *chan, struct scatterlist *sgl,
479 unsigned int sg_len, enum dma_data_direction direction, 483 unsigned int sg_len, enum dma_data_direction direction,
480 unsigned long flags); 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 int (*device_control)(struct dma_chan *chan, enum dma_ctrl_cmd cmd, 488 int (*device_control)(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
482 unsigned long arg); 489 unsigned long arg);
483 490