/**
 * @file hv_drv_DpuCommon.h
 * @brief Header file of dpu module.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 *
 * @endverbatim
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-08-22
 */
#ifndef __HV_DRV_DPU_SCALER_H__
#define __HV_DRV_DPU_SCALER_H__

#include "hv_comm_DataType.h"
#include "hv_comm_Define.h"

typedef enum _ScalerCursorType
{
    //SCALER_CURSOR_HS_RX,
    SCALER_CURSOR_SRP,
    SCALER_CURSOR_LDG,
    SCALER_CURSOR_DISPCTRL_PRE,
    SCALER_CURSOR_DITHER,
    SCALER_CURSOR_DISPCTRL_POST,
    SCALER_CURSOR_NUM,
} ScalerCursorType;

#define COLOR_CAPTURE_FRAME_CNT     (SCALER_CURSOR_NUM)
#define COLOR_CAPTURE_POINT_CNT     (SCALER_CURSOR_NUM * COLOR_CAPTURE_FRAME_CNT)

/**
 * @brief dpu scaler init.
 * @param[in] void.
 * @return void.
 */
VOID Hv_Drv_DpuScaler_Init(const PanelParam stPanelParam);

/**
 * @brief make dtc to framesync mode.
 * @param[in] video config parameter.
 * @return void.
 */
VOID Hv_Drv_DpuScaler_Enter_FrameSync(const VideoConfigParams* pstVideoConfigParams);

/**
 * @brief make dtc to frc mode.
 * @param[in] void.
 * @return void.
 */
VOID Hv_Drv_DpuScaler_Exit_FrameSync(VOID);

/**
 * @brief dtc clock config.
 * @param[in] void.
 * @return void.
 */
VOID Hv_Drv_DpuScaler_DtcClockConfig(VOID);

/**
 * @brief reload dynomic value of ptcd pll to manual mode.
 * @param[in] void.
 * @return void.
 */
VOID Hv_Drv_PLL_PtcdReload(VOID);

/**
 * @brief toggle ptcd pll and make it valid.
 * @param[in] void.
 * @return void.
 */
VOID Hv_Drv_PLL_TogglePtcdUpdate(VOID);

/**
 * @brief Get frame sync state.
 * @return state.
 */
UINT32 Hv_Drv_DpuScaler_GetFrmsyncState(VOID);

/**
 * @brief Get dtc state.
 * @return state.
 */
UINT32 Hv_Drv_DpuScaler_GetDtcState(VOID);

/**
 * @brief check dtc state stable or not.
 * @param[in] void.
 * @return HV_TRUE：stable.
 */
Status Hv_Drv_DpuScaler_CheckDtcStable(const VideoConfigParams* pstVideoConfigParams);

//Status Hv_Drv_DpuScaler_Config(ChannelType enChannelType, const VideoConfigParams* pstVideoConfigParams);

/**
 * @brief dtc clock config sequence.
 * @param[in] real config clock freq;dst clock freq;video config para.
 * @return HV_SUCCESS.
 */
Status Hv_Drv_DpuScaler_DpuClockConfig(UINT32* uiDClkCfg, UINT32 uiDClockDst,VideoConfigParams* pstVideoConfigParams);

/**
 * @brief port mux for dtc input.
 * @param[in] channel type;port index.
 * @return HV_SUCCESS.
 */
Status Hv_Drv_DpuScaler_SetPortMux(ChannelType enChannelType, LinkPortIndex enPortIndex);

/**
 * @brief MainSoftwareModeVideoMute.
 * @param[in] channel type;port index.
 * @param[in] bMute mute enable.
 */
VOID Hv_Drv_DpuScaler_MainSoftwareModeVideoMute(ChannelType enChannelType, BOOL bMute);

/**
 * @brief video mute of software mode.
 * @param[in] channel type:main or sub.
 * @return void.
 */
VOID Hv_Drv_DpuScaler_SoftwareVideoMute(ChannelType enChannelType);

/**
 * @brief video unmute of software and hardware mode.
 * @param[in] channel type:main or sub.
 * @return void.
 */
VOID Hv_Drv_DpuScaler_VideoUnmute(ChannelType enChannelType);

/**
 * @brief video unmute of software mode.
 * @param[in] channel type:main or sub.
 * @return void.
 */
Status Hv_Drv_DpuScaler_SoftwareVideoUnmute(ChannelType enChannelType);

Status Hv_Drv_DpuScaler_MainHdrDmEnable(UINT32 uiValue);

Status Hv_Drv_DpuScaler_SubHdrDmEnable(UINT32 uiValue);

Status Hv_Drv_DpuScaler_MainHdrProcessSOP(const HDRParam* pstHdrParam);
Status Hv_Drv_DpuScaler_SubHdrProcessSOP(const HDRParam* pstHdrParam);

Status Hv_Drv_DpuScaler_MainRatio(const VideoConfigParams* pstVideoConfigParams);
Status Hv_Drv_DpuScaler_SubRatio(const VideoConfigParams* pstVideoConfigParams);

Status Hv_Drv_DpuScaler_MainHdrEnable(UINT32 uiValue);
Status Hv_Drv_DpuScaler_SubHdrEnable(UINT32 uiValue);

VOID Hv_Drv_DpuScaler_DpuIntProc(DpuInterruptDefine *pstDpuInterruptDefine, const VideoConfigParams* pstVideoConfigParams, UCHAR8 (*pfPQCallback)(PQCALLBACKMODE , const VOID *));

VOID Hv_Drv_DpuScaler_DtcIntProc(DtcInterruptDefine *pstDpuInterruptDefine);

#ifdef CONFIG_USER_DOUBLE_CHANNEL_ON
VOID Hv_Drv_DpuScaler_SetMainFakeBlendFlag(BOOL bBlendEn);
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DPU_BRIGHT_FRAME)
VOID Hv_Drv_DpuScaler_SetBrightFramSyncFlag(BOOL bSync, DpuCapCutParam* pstDpuCapCutParam);
#endif
VOID Hv_Drv_DpuScaler_VsyncHandler(HsIpInterruptDefine *pstDpuInterruptDefine, DisplayInterruptType enType,const VideoConfigParams* pstVideoConfigParams, UCHAR8 (*pfPQCallback)(PQCALLBACKMODE , const VOID *));
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY)
VOID Hv_Drv_DpuScaler_MagnifyGlassSetParam(BOOL bMgSw, DpuCapCutParam* pstDpuCapCutParam);
#endif
Status Hv_Drv_DpuScaler_MainHdrSetPatternEn(UINT32 uiEn);

UINT32 Hv_Drv_DpuScaler_GetPxlBits(ColorFormatType enColorFormatType, ColorDepthType enClrDepth);

VOID Hv_Drv_DpuScaler_SetHflipSwitch(UINT32 uiValue);

/**
 * @brief enable vsync irq.
 * @param[in] void.
 * @return void.
 */
VOID Hv_Drv_DpuScaler_Enable_Vsync_Interrupt(VOID);
/**
 * @brief disable vsync irq.
 * @param[in] void.
 * @return void.
 */
VOID Hv_Drv_DpuScaler_Disable_Vsync_Interrupt(VOID);

//Status Hv_Drv_DpuScaler_DtcSoftwareReset(VOID);

/**
 * @brief config dpu and dma when burn in state.
 * @param[in] void.
 * @return void.
 */
Status Hv_Drv_DpuScaler_BurnInConfig(VOID);

VOID Hv_Drv_DpuScaler_MainChannelEncDecDisenable(VOID);

VOID Hv_Drv_DpuScaler_CalcDcwCapCutParam(const VideoConfigParams* pstVideoConfigParams, DpuCapCutParam* pstDpuCapCutParam);

VOID Hv_Drv_DpuScaler_CalcCapCutParam(const VideoConfigParams* pstVideoConfigParams, DpuCapCutParam* pstDpuCapCutParam);
VOID Hv_Drv_DpuScaler_SetMainChannelState(USHORT16 usState);
VOID Hv_Drv_DpuScaler_SetSubChannelState(USHORT16 usState);
VOID Hv_Drv_DpuScaler_FrameBufferConfig01(const VideoConfigParams* pstVideoConfigParams);

Status Hv_Drv_DpuScaler_DpuVdm01Settings(const VideoConfigParams* pstVideoConfigParams);

VOID Hv_Drv_DpuScaler_ColorCaptureEn(BOOL bEn);
VOID Hv_Drv_DpuScaler_ColorCaptureLoadPositionTable(USHORT16 *pusXArray, USHORT16 *pusYArray);
UINT32 Hv_Drv_DpuScaler_CalculateAvgColor(VOID);
#endif
