#ifndef _HV_CAL_OSDDMA_H
#define _HV_CAL_OSDDMA_H

#include "hv_comm_DataType.h"

#define OSD_DMA_CHANNEL_COUNTS 8

#define DMA_MAX_BUFFER_DEPTH 512
#define DMA_COLDATA_ALIGN_BYTES 16

typedef enum _OsdDMADirection
{
    OSD_DMA_DIRECTION_FORWARD,
    OSD_DMA_DIRECTION_BACKWARD,
} OsdDMADirection;

typedef enum _OsdDMAMode
{
    OSD_DMA_MODE_FRAME,
    OSD_DMA_MODE_BLOCK,
} OsdDMAMode;

/* Inner DMA */

/**
 * @brief print Inner DMA status
 * @param[in] None
 * @return VOID without return
 */
VOID Hv_Cal_OsdInnerDMA_DebugPrint(VOID);

/**
 * @brief check Inner DMA working status
 * @param[in] None
 * @return HV_TRUE for DMA working, otherwise HV_FALSE
 */
BOOL Hv_Cal_OsdInnerDMA_CheckGoing(VOID);

/**
 * @brief check Inner DMA working status
 * @param[in] None
 * @return HV_TRUE for DMA work done, otherwise HV_FALSE
 */
BOOL Hv_Cal_OsdInnerDMA_CheckDone(VOID);

/**
 * @brief clear DMA work done flag
 * @param[in] None
 * @return VOID without return
 */
VOID Hv_Cal_OsdInnerDMA_ClearDoneFlag(VOID);

BOOL Hv_Cal_OsdInnerDMA_GetStartFlag(VOID);

/**
 * @brief clear Inner DMA start flag
 * @param[in] None
 * @return VOID without return
 */
VOID Hv_Cal_OsdInnerDMA_ClearStart(VOID);

/**
 * @brief start Inner DMA
 * @param[in] None
 * @return VOID without return
 */
VOID Hv_Cal_OsdInnerDMA_Start(VOID);

/**
 * @brief set Inner DMA group counts
 * @param[in] ucNum total group counts
 * @return VOID without return
 */
VOID Hv_Cal_OsdInnerDMA_SetTotalGroups(UCHAR8 ucNum);

/**
 * @brief set Inner DMA group info
 * @param[in] ucIndex group index, 0~7
 * @param[in] uiDstAddr destination address in OSD SRAM
 * @param[in] uiSrcAddr source address in DDR
 * @param[in] uiLength data length, aligned to 16
 * @return VOID without return
 */
VOID Hv_Cal_OsdInnerDMA_SetGroupInfo(UCHAR8 ucIndex, UINT32 uiDstAddr, UINT32 uiSrcAddr, UINT32 uiLength);

/* RDMA */

/**
 * @brief set DMA enable/disable status
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] bEnable 1 for enable, 0 for disable
 * @return VOID without return
 */

VOID Hv_Cal_OsdOuterRDMA_SetEnable(OsdDataPath enPath, BOOL bEnable);

/**
 * @brief set DMA ddr address
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] uiAddr DDR address
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetDDRAddr(OsdDataPath enPath, UINT32 uiAddr);

/**
 * @brief set DMA column step
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usStep step in bytes, aligned to 16
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetColStep(OsdDataPath enPath, USHORT16 usStep);

/**
 * @brief set DMA column direction
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] enDirection direction OSD_DMA_DIRECTION_FORWARD: access forwards
 *                                  OSD_DMA_DIRECTION_BACKWARD: access backwards
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetColDirection(OsdDataPath enPath, OsdDMADirection enDirection);

/**
 * @brief set DMA line step
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usStep step in bytes, aligned to 16
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetLineStep(OsdDataPath enPath, USHORT16 usStep);

/**
 * @brief set DMA line direction
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] enDirection direction OSD_DMA_DIRECTION_FORWARD: access forwards
 *                                  OSD_DMA_DIRECTION_BACKWARD: access backwards
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetLineDirection(OsdDataPath enPath,OsdDMADirection enDirection);

/**
 * @brief set DMA datablock size
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usDataCount data count in 128bit
 * @param[in] ucBurstLen data count in 128bit for one burst
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetDataBlock(OsdDataPath enPath, USHORT16 usDataCount, UCHAR8 ucBurstLen);

/**
 * @brief set DMA outstanding request number
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] ucReqCount request number, 1~15
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetOutstandingReq(OsdDataPath enPath,UCHAR8 ucReqCount);

/**
 * @brief set DMA access mode
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] enMode mode selection OSD_DMA_MODE_FRAME: frame mode
 *                                  OSD_DMA_MODE_BLOCK: block mode
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetAccessMode(OsdDataPath enPath, OsdDMAMode enMode);

/**
 * @brief set DMA buffer depth
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usDepth buffer depth, 1~512
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetBufferDepth(OsdDataPath enPath,USHORT16 usDepth);

/**
 * @brief set DMA total column number
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usNum column number
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetColNumber(OsdDataPath enPath, USHORT16 usNum);

/**
 * @brief set DMA total line number
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usNum line number
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetLineNumber(OsdDataPath enPath, USHORT16 usNum);

/**
 * @brief set DMA unpack format
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] enFormat pixel format
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetUnpackFormat(OsdDataPath enPath, OsdPixelFormat enFormat);

/**
 * @brief set DMA unpack size
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usWidth width of DDR area
 * @param[in] usHeight height of DDR area
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterRDMA_SetUnpackSize(OsdDataPath enPath, USHORT16 usWidth, USHORT16 usHeight);

/* WDMA */

/**
 * @brief set DMA enable/disable status
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] bEnable 1 for enable, 0 for disable
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetEnable(OsdDataPath enPath, BOOL bEnable);

/**
 * @brief set DMA ddr address
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] uiAddr DDR address
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetDDRAddr(OsdDataPath enPath, UINT32 uiAddr);

/**
 * @brief set DMA column step
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usStep step in bytes, aligned to 16
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetColStep(OsdDataPath enPath, USHORT16 usStep);

/**
 * @brief set DMA column direction
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] enDirection direction OSD_DMA_DIRECTION_FORWARD: access forwards
 *                                  OSD_DMA_DIRECTION_BACKWARD: access backwards
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetColDirection(OsdDataPath enPath, OsdDMADirection enDirection);

/**
 * @brief set DMA line step
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usStep step in bytes, aligned to 16
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetLineStep(OsdDataPath enPath, USHORT16 usStep);

/**
 * @brief set DMA line direction
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] enDirection direction OSD_DMA_DIRECTION_FORWARD: access forwards
 *                                  OSD_DMA_DIRECTION_BACKWARD: access backwards
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetLineDirection(OsdDataPath enPath,OsdDMADirection enDirection);

/**
 * @brief set DMA datablock size
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usDataCount data count in 128bit
 * @param[in] ucBurstLen data count in 128bit for one burst
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetDataBlock(OsdDataPath enPath, USHORT16 usDataCount, UCHAR8 ucBurstLen);

/**
 * @brief set DMA outstanding request number
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] ucReqCount request number, 1~15
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetOutstandingReq(OsdDataPath enPath,UCHAR8 ucReqCount);

/**
 * @brief set DMA access mode
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] enMode mode selection OSD_DMA_MODE_FRAME: frame mode
 *                                  OSD_DMA_MODE_BLOCK: block mode
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetAccessMode(OsdDataPath enPath, OsdDMAMode enMode);

/**
 * @brief set DMA buffer depth
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usDepth buffer depth, 1~512
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetBufferDepth(OsdDataPath enPath,USHORT16 usDepth);

/**
 * @brief set DMA total column number
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usNum column number
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetColNumber(OsdDataPath enPath, USHORT16 usNum);

/**
 * @brief set DMA total line number
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] usNum line number
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetLineNumber(OsdDataPath enPath, USHORT16 usNum);

/**
 * @brief set DMA pack format
 * @param[in] enPath DMA selection OSD_DATAPATH_GRAPHIC: graphic read DMA
 *                                 OSD_DATAPATH_DDRREAD: DDR read DMA
 *                                 OSD_DATAPATH_DDRWRITE: DDR write DMA
 * @param[in] enFormat pixel format
 * @return VOID without return
 */
VOID Hv_Cal_OsdOuterWDMA_SetPackFormat(OsdDataPath enPath, OsdPixelFormat enFormat);

#endif
