Software Drivers

xaxivdma.c File Reference

#include "xaxivdma.h"
#include "xaxivdma_i.h"

Defines

#define INITIALIZATION_POLLING   100000

Functions

XAxiVdma_ChannelXAxiVdma_GetChannel (XAxiVdma *InstancePtr, u16 Direction)
int XAxiVdma_CfgInitialize (XAxiVdma *InstancePtr, XAxiVdma_Config *CfgPtr, u32 EffectiveAddr)
void XAxiVdma_Reset (XAxiVdma *InstancePtr, u16 Direction)
int XAxiVdma_ResetNotDone (XAxiVdma *InstancePtr, u16 Direction)
int XAxiVdma_IsBusy (XAxiVdma *InstancePtr, u16 Direction)
u32 XAxiVdma_CurrFrameStore (XAxiVdma *InstancePtr, u16 Direction)
u32 XAxiVdma_GetVersion (XAxiVdma *InstancePtr)
u32 XAxiVdma_GetStatus (XAxiVdma *InstancePtr, u16 Direction)
int XAxiVdma_SetLineBufThreshold (XAxiVdma *InstancePtr, int LineBufThreshold, u16 Direction)
int XAxiVdma_FsyncSrcSelect (XAxiVdma *InstancePtr, u32 Source, u16 Direction)
int XAxiVdma_GenLockSourceSelect (XAxiVdma *InstancePtr, u32 Source, u16 Direction)
int XAxiVdma_StartParking (XAxiVdma *InstancePtr, int FrameIndex, u16 Direction)
void XAxiVdma_StopParking (XAxiVdma *InstancePtr, u16 Direction)
void XAxiVdma_StartFrmCntEnable (XAxiVdma *InstancePtr, u16 Direction)
int XAxiVdma_SetBdAddrs (XAxiVdma *InstancePtr, u32 BdAddrPhys, u32 BdAddrVirt, int NumBds, u16 Direction)
int XAxiVdma_StartWriteFrame (XAxiVdma *InstancePtr, XAxiVdma_DmaSetup *DmaConfigPtr)
int XAxiVdma_StartReadFrame (XAxiVdma *InstancePtr, XAxiVdma_DmaSetup *DmaConfigPtr)
int XAxiVdma_DmaConfig (XAxiVdma *InstancePtr, u16 Direction, XAxiVdma_DmaSetup *DmaConfigPtr)
int XAxiVdma_DmaSetBufferAddr (XAxiVdma *InstancePtr, u16 Direction, u32 *BufferAddrSet)
int XAxiVdma_DmaStart (XAxiVdma *InstancePtr, u16 Direction)
void XAxiVdma_DmaStop (XAxiVdma *InstancePtr, u16 Direction)
void XAxiVdma_DmaRegisterDump (XAxiVdma *InstancePtr, u16 Direction)
int XAxiVdma_SetFrameCounter (XAxiVdma *InstancePtr, XAxiVdma_FrameCounter *CfgPtr)
void XAxiVdma_GetFrameCounter (XAxiVdma *InstancePtr, XAxiVdma_FrameCounter *CfgPtr)
int XAxiVdma_SetFrmStore (XAxiVdma *InstancePtr, u8 FrmStoreNum, u16 Direction)
void XAxiVdma_GetFrmStore (XAxiVdma *InstancePtr, u8 *FrmStoreNum, u16 Direction)
int XAxiVdma_GetDmaChannelErrors (XAxiVdma *InstancePtr, u16 Direction)
int XAxiVdma_ClearDmaChannelErrors (XAxiVdma *InstancePtr, u16 Direction, u32 ErrorMask)

Detailed Description

Implementation of the driver API functions for the AXI Video DMA engine.

 MODIFICATION HISTORY:
 Ver   Who  Date     Changes
 ----- ---- -------- -------------------------------------------------------
 1.00a jz   08/16/10 First release
 2.00a jz   12/10/10 Added support for direct register access mode, v3 core
 2.01a jz   01/19/11 Added ability to re-assign BD addresses
	rkv  03/28/11 Added support for frame store register.
 3.00a srt  08/26/11 Added support for Flush on Frame Sync and dynamic
		      programming of Line Buffer Thresholds and added API
		      XAxiVdma_SetLineBufThreshold.
 4.00a srt  11/21/11 - XAxiVdma_CfgInitialize API is modified to use the
			EffectiveAddr.

 

Define Documentation

#define INITIALIZATION_POLLING   100000

Function Documentation

int XAxiVdma_CfgInitialize ( XAxiVdma InstancePtr,
XAxiVdma_Config CfgPtr,
u32  EffectiveAddr 
)

Initialize the driver with hardware configuration

Parameters:
InstancePtr is the pointer to the DMA engine to work on
CfgPtr is the pointer to the hardware configuration structure
EffectiveAddr is the virtual address map for the device
Returns:
  • XST_SUCCESS if everything goes fine
  • XST_FAILURE if reset the hardware failed, need system reset to recover
Note:
If channel fails reset, then it will be set as invalid
int XAxiVdma_ClearDmaChannelErrors ( XAxiVdma InstancePtr,
u16  Direction,
u32  ErrorMask 
)

Clear DMA Channel Errors.

Parameters:
InstancePtr is the XAxiVdma instance to operate on
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
ErrorMask is the mask of error bits to clear
Returns:
- XST_SUCCESS, when error bits are cleared.
  • XST_INVALID_PARAM, when channel pointer is invalid.
  • XST_DEVICE_NOT_FOUND, when the channel is not valid.
Note:
None
u32 XAxiVdma_CurrFrameStore ( XAxiVdma InstancePtr,
u16  Direction 
)

Get the current frame that hardware is working on

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
The current frame that the hardware is working on
Note:
If returned frame number is out of range, then the channel is invalid
int XAxiVdma_DmaConfig ( XAxiVdma InstancePtr,
u16  Direction,
XAxiVdma_DmaSetup DmaConfigPtr 
)

Configure one DMA channel using the configuration structure

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the DMA channel to work on
DmaConfigPtr is the pointer to the setup structure
Returns:
  • XST_SUCCESS if successful
  • XST_DEVICE_BUSY if the DMA channel is not idle, BDs are still being used
  • XST_INVAID_PARAM if buffer address not valid, for example, unaligned address with no DRE built in the hardware, or Direction invalid
  • XST_DEVICE_NOT_FOUND if the channel is invalid
void XAxiVdma_DmaRegisterDump ( XAxiVdma InstancePtr,
u16  Direction 
)

Dump registers of one DMA channel

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the DMA channel to work on
Returns:
None
Note:
If channel is invalid, then do nothing on that channel
int XAxiVdma_DmaSetBufferAddr ( XAxiVdma InstancePtr,
u16  Direction,
u32 *  BufferAddrSet 
)

Configure buffer addresses for one DMA channel

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the DMA channel to work on
BufferAddrSet is the set of addresses for the transfers
Returns:
  • XST_SUCCESS if successful
  • XST_DEVICE_BUSY if the DMA channel is not idle, BDs are still being used
  • XST_INVAID_PARAM if buffer address not valid, for example, unaligned address with no DRE built in the hardware, or Direction invalid
  • XST_DEVICE_NOT_FOUND if the channel is invalid
int XAxiVdma_DmaStart ( XAxiVdma InstancePtr,
u16  Direction 
)

Start one DMA channel

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the DMA channel to work on
Returns:
  • XST_SUCCESS if channel started successfully
  • XST_FAILURE otherwise
  • XST_DEVICE_NOT_FOUND if the channel is invalid
  • XST_INVALID_PARAM if Direction invalid
void XAxiVdma_DmaStop ( XAxiVdma InstancePtr,
u16  Direction 
)

Stop one DMA channel

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the DMA channel to work on
Returns:
None
Note:
If channel is invalid, then do nothing on that channel
int XAxiVdma_FsyncSrcSelect ( XAxiVdma InstancePtr,
u32  Source,
u16  Direction 
)

Configure Frame Sync Source and valid only when C_USE_FSYNC is enabled.

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Source is the value to set the source of Frame Sync
Direction is the DMA channel to work on
Returns:
  • XST_SUCCESS if successful
  • XST_FAILURE if C_USE_FSYNC is disabled.
int XAxiVdma_GenLockSourceSelect ( XAxiVdma InstancePtr,
u32  Source,
u16  Direction 
)

Configure Gen Lock Source

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Source is the value to set the source of Gen Lock
Direction is the DMA channel to work on
Returns:
  • XST_SUCCESS if successful
  • XST_FAILURE if the channel is in GenLock Master Mode. if C_INCLUDE_INTERNAL_GENLOCK is disabled.
XAxiVdma_Channel* XAxiVdma_GetChannel ( XAxiVdma InstancePtr,
u16  Direction 
)

Get a channel

Parameters:
InstancePtr is the DMA engine to work on
Direction is the direction for the channel to get
Returns:
The pointer to the channel. Upon error, return NULL.
Note:
Since this function is internally used, we assume Direction is valid
int XAxiVdma_GetDmaChannelErrors ( XAxiVdma InstancePtr,
u16  Direction 
)

Check for DMA Channel Errors.

Parameters:
InstancePtr is the XAxiVdma instance to operate on
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
- Errors seen on the channel
  • XST_INVALID_PARAM, when channel pointer is invalid.
  • XST_DEVICE_NOT_FOUND, when the channel is not valid.
Note:
None
void XAxiVdma_GetFrameCounter ( XAxiVdma InstancePtr,
XAxiVdma_FrameCounter CfgPtr 
)

Get the frame counter and delay counter for both channels

Parameters:
InstancePtr is the pointer to the DMA engine to work on
CfgPtr is the configuration structure to contain return values
Returns:
None
Note:
If returned frame counter value is 0, then the channel is not valid
void XAxiVdma_GetFrmStore ( XAxiVdma InstancePtr,
u8 *  FrmStoreNum,
u16  Direction 
)

Get the number of frame store buffers to use.

Parameters:
InstancePtr is the XAxiVdma instance to operate on
FrmStoreNum is the number of frame store buffers to use.
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
None
Note:
None
u32 XAxiVdma_GetStatus ( XAxiVdma InstancePtr,
u16  Direction 
)

Get the status of a channel

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
The status of the channel
Note:
An invalid return value indicates that channel is invalid
u32 XAxiVdma_GetVersion ( XAxiVdma InstancePtr  ) 

Get the version of the hardware

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Returns:
The version of the hardware
int XAxiVdma_IsBusy ( XAxiVdma InstancePtr,
u16  Direction 
)

Check whether a DMA channel is busy

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
  • Non-zero if the channel is busy
  • Zero if the channel is idle
void XAxiVdma_Reset ( XAxiVdma InstancePtr,
u16  Direction 
)

This function resets one DMA channel

The registers will be default values after the reset

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
None
Note:
Due to undeterminism of system delays, check the reset status through XAxiVdma_ResetNotDone(). If direction is invalid, do nothing.
int XAxiVdma_ResetNotDone ( XAxiVdma InstancePtr,
u16  Direction 
)

This function checks one DMA channel for reset completion

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
  • 0 if reset is done
  • 1 if reset is ongoing
Note:
We do not check for channel validity, because channel is marked as invalid before reset is done
int XAxiVdma_SetBdAddrs ( XAxiVdma InstancePtr,
u32  BdAddrPhys,
u32  BdAddrVirt,
int  NumBds,
u16  Direction 
)

Set BD addresses to be different.

In some systems, it is convenient to put BDs into a certain region of the memory. This function enables that.

Parameters:
InstancePtr is the pointer to the DMA engine to work on
BdAddrPhys is the physical starting address for BDs
BdAddrVirt is the Virtual starting address for BDs. For systems that do not use MMU, then virtual address is the same as physical address
NumBds is the number of BDs to setup with. This is required to be the same as the number of frame stores for that channel
Direction is the channel direction
Returns:
  • XST_SUCCESS for a successful setup
  • XST_DEVICE_BUSY if the DMA channel is not idle, BDs are still being used
  • XST_INVALID_PARAM if parameters not valid
  • XST_DEVICE_NOT_FOUND if the channel is invalid

We assume that the memory region starting from BdAddrPhys and BdAddrVirt are large enough to hold all the BDs.

int XAxiVdma_SetFrameCounter ( XAxiVdma InstancePtr,
XAxiVdma_FrameCounter CfgPtr 
)

Set the frame counter and delay counter for both channels

Parameters:
InstancePtr is the pointer to the DMA engine to work on
CfgPtr is the pointer to the configuration structure
Returns:
  • XST_SUCCESS if setup finishes successfully
  • XST_INVALID_PARAM if the configuration structure has invalid values
  • Others if setting channel frame counter fails
Note:
If channel is invalid, then do nothing on that channel
int XAxiVdma_SetFrmStore ( XAxiVdma InstancePtr,
u8  FrmStoreNum,
u16  Direction 
)

Set the number of frame store buffers to use.

Parameters:
InstancePtr is the XAxiVdma instance to operate on
FrmStoreNum is the number of frame store buffers to use.
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
- XST_SUCCESS if operation is successful
  • XST_FAILURE if operation fails.
  • XST_NO_FEATURE if access to FrameStore register is disabled
Note:
None
int XAxiVdma_SetLineBufThreshold ( XAxiVdma InstancePtr,
int  LineBufThreshold,
u16  Direction 
)

Configure Line Buffer Threshold

Parameters:
InstancePtr is the pointer to the DMA engine to work on
LineBufThreshold is the value to set threshold
Direction is the DMA channel to work on
Returns:
  • XST_SUCCESS if successful
  • XST_FAILURE otherwise
  • XST_NO_FEATURE if access to Threshold register is disabled
void XAxiVdma_StartFrmCntEnable ( XAxiVdma InstancePtr,
u16  Direction 
)

Start frame count enable on one channel

This is needed to start limiting the number of frames to transfer so that software can check the data etc after hardware stops transfer.

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
None
int XAxiVdma_StartParking ( XAxiVdma InstancePtr,
int  FrameIndex,
u16  Direction 
)

Start parking mode on a certain frame

Parameters:
InstancePtr is the pointer to the DMA engine to work on
FrameIndex is the frame to park on
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
  • XST_SUCCESS if everything is fine
  • XST_INVALID_PARAM if . channel is invalid . FrameIndex is invalid . Direction is invalid
int XAxiVdma_StartReadFrame ( XAxiVdma InstancePtr,
XAxiVdma_DmaSetup DmaConfigPtr 
)

Start a read operation

Read corresponds to send data from memory to device

Parameters:
InstancePtr is the pointer to the DMA engine to work on
DmaConfigPtr is the pointer to the setup structure
Returns:
  • XST_SUCCESS for a successful submission
  • XST_DEVICE_BUSY if the DMA channel is not idle, BDs are still being used
  • XST_INVAID_PARAM if parameters in config structure not valid
  • XST_DEVICE_NOT_FOUND if the channel is invalid
int XAxiVdma_StartWriteFrame ( XAxiVdma InstancePtr,
XAxiVdma_DmaSetup DmaConfigPtr 
)

Start a write operation

Write corresponds to send data from device to memory

Parameters:
InstancePtr is the pointer to the DMA engine to work on
DmaConfigPtr is the pointer to the setup structure
Returns:
  • XST_SUCCESS for a successful submission
  • XST_DEVICE_BUSY if the DMA channel is not idle, BDs are still being used
  • XST_INVAID_PARAM if parameters in config structure not valid
  • XST_DEVICE_NOT_FOUND if the channel is invalid
void XAxiVdma_StopParking ( XAxiVdma InstancePtr,
u16  Direction 
)

Exit parking mode, the channel will return to circular buffer mode

Parameters:
InstancePtr is the pointer to the DMA engine to work on
Direction is the channel to work on, use XAXIVDMA_READ/WRITE
Returns:
None
Note:
If channel is invalid, then do nothing