/**
 * @file hv_drv_OsdInterrupt.h
 * @brief Osd driver layer interrupt handle interface.
 * @verbatim
 * ==============================================================================
 *                        ##### How to use this driver #####
 * ==============================================================================
 * (+) Use Hv_Mw_OsdInterrupt_Enable(...) to register Osd ISR.
 * (+) Use Hv_Mw_OsdInterrupt_Disable(...) to unregister Osd ISR.
 * @endverbatim
 *
 * @author HiView SoC Software Team
 * @version 0.0.1
 * @date 2022-08-22
 */


#ifndef _HV_MW_OSDINTERRUPT_H
#define _HV_MW_OSDINTERRUPT_H

#include "hv_comm_DataType.h"

#define OSD_INT_DMA_LENGTH_ERR_BIT      (BIT_0)
#define OSD_INT_DMA_READ_GOING_BIT      (BIT_1)
#define OSD_INT_DMA_READ_DONE_BIT       (BIT_2)
#define OSD_INT_DMA_RESET_ERR_BIT       (BIT_5)
#define OSD_INT_DMA_START_ERR_BIT       (BIT_6)
#define OSD_INT_DMA_CNT_ERR_BIT         (BIT_7)
#define OSD_INT_REGEN_CLR_BIT           (BIT_9)

#ifdef HV_SCALER_DEBUG_VERSION
extern UINT32 g_uiDMACount, g_uiRegenClrCount, g_uiIrqCount;
#endif

typedef enum _OsdInterruptTrigType
{
    OSD_INT_TRIG_HIGH_LEVEL = 0,
    OSD_INT_TRIG_LOW_LEVEL = 1,
    OSD_INT_TRIG_POSITIVE_EDGE = 4,
    OSD_INT_TRIG_NEGATIVE_EDGE = 5,
} OsdInterruptTrigType;

/**
 * @brief Set flag to control if send sync event to osd task when reg_en interrupt come
 * @param[in] bSyncEnable HV_TRUE-send, HV_FALSE-not send
 * @return VOID without return
 */
VOID Hv_Mw_OsdInterrupt_SetSyncFlag(BOOL bSyncEnable);

/**
 * @brief Set frame delay count for waiting after set reg_en (count = 0, if not set)
 * @param[in] ucFrameDelay More frame delay count
 * @return VOID without return
 */
VOID Hv_Mw_OsdInterrupt_SetSyncFrameDelay(UCHAR8 ucFrameDelay);

/**
 * @brief Debug function, would set interrupt triggered counts to zero
 * @param[in] None
 * @return VOID without return
 */
VOID Hv_Mw_OsdInterrupt_DebugInit(VOID);

/**
 * @brief Debug function, would print interrupt triggered counts
 * @param[in] bResult Test success or not
 * @return VOID without return
 */
VOID Hv_Mw_OsdInterrupt_DebugPrint(BOOL bResult);

/**
 * @brief register Osd ISR and enable Osd Interrupt
 * @param[in] enTrigType interrupt trigger type OSD_INT_TRIG_HIGH_LEVEL: high-level triggered
 *                                              OSD_INT_TRIG_LOW_LEVEL: low-level triggered, not supported
 *                                              OSD_INT_TRIG_POSITIVE_EDGE: rising-edge triggered
 *                                              OSD_INT_TRIG_NEGATIVE_EDGE: falling-edge triggered
 * @param[in] usEnabledBits Osd interrupt source bits
 * @return VOID without return
 */
VOID Hv_Mw_OsdInterrupt_Enable(OsdInterruptTrigType enTrigType, USHORT16 usEnabledBits);

/**
 * @brief unregister Osd ISR and disable Osd interrupt
 * @param[in] None
 * @return VOID without return
 */
VOID Hv_Mw_OsdInterrupt_Disable(VOID);

#endif
