The next step, before executing a compiled transfer, is to make a request to the DMA driver to allocate a channel on which the transfer is to take place. Once a channel has been allocated, the driver which allocated it has exclusive use of the channel, until the DMA driver receives a corresponding call to free the channel.
Channels are requested through one of the following methods:
To request a specific channel, chan, use the function request_dma().
int request_dma(unsigned int chan, const char *dev_id);
To request a channel by capability, or the next available channel, use the function request_dma_bycap().
int request_dma_bycap(const char **dmac, const char **caps, const char *dev_id);
These functions accept the following parameters:
| Parameters | Description |
|---|---|
| dmac | A NULL terminated list of pointers to strings which identify acceptable DMA controllers. These are the string ID used to identify the DMA controller. For the FDMA this value is "fdma_dmac" which is exported from stm-dma.h as STM_DMAC_ID. |
| caps |
A NULL terminated list of pointers to strings which identify acceptable DMA channel capabilities.
Use this parameter to specify the capability of the requested channel. It may be one of the following:
|
| dev_id | A string that is unique to your device driver. This is used in debugging information. |
| chan | When requesting a specific channel, use this parameter to specify the channel. The number must be within the available range. |
request_dma returns 0 if the channel was successfully allocated. request_dma_bycap() returns the channel number if the allocation is successful, which must be zero or positive. Both functions return a negative error code if the allocation fails.