/**
 * @file hv_mw_AppInterface.h
 * @brief Header file of Api Interface.
 * 
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use Hv_Mw_xxxxxxxxxx(...) to set module param. 
 * 
 * @endverbatim
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-08-10
 */
#ifndef __SDK_MIDDLEWARE_RUNTIME_COMMANDIF_INC_COMMANDIF_H__
#define __SDK_MIDDLEWARE_RUNTIME_COMMANDIF_INC_COMMANDIF_H__

#include "hv_comm_DataType.h"
#include "hv_comm_PqDef.h"
#include "hv_comm_Event.h"
#include "hv_mw_Channel_Manager.h"
#include "hv_comm_DataBase.h"
#include "hv_drv_OsdTypes.h"


//TODO: 0~100
extern VOID Hv_Mw_PQ_SetBrightness(UCHAR8 ucValue);

//TODO: 0~100
extern VOID Hv_Mw_PQ_SetContrast(UCHAR8 ucCh, UINT32 uiContrast);

//TODO: Saturation: 0~30

//TODO: 0~20
extern VOID Hv_Mw_PQ_SetSharpness(UCHAR8 ucSharpness);

extern VOID Hv_Mw_Video_SetTemperature(UINT32 uiValue);

//TODO: 0~20
extern VOID Hv_Mw_Video_SetBlackGain(UINT32 uiValue);

//TODO: 标准、冷色、暖色、sRGB、DCI-P3、AdobeRGB、自定义(R/G/B:0~100)
extern VOID Hv_Mw_Video_SetColorMode(UINT32 uiValue);

//TODO: 2.0,2.2,2.4,2.6
extern Status Hv_Mw_PQ_GammaInit(const UINT32 *puiGammabin, UINT32 uiLen);
extern Status Hv_Mw_PQ_GammaLutInit(const UINT32 *puiGammalut);
extern Status Hv_Mw_PQ_OsdGammaLutInit(const UINT32 *puiOsdGmiAddr, const UINT32 *puiOsdGmdAddr);

extern VOID Hv_Mw_PQ_SetGamma(UCHAR8 ucGammaIndex);

//TODO: MPRT: ON/OFF
extern VOID Hv_Drv_MPRT_SetOutMprtPwmEnable(BOOL bEn);

//TODO: Luminance Dynamic Range: Auto/Full/Limit

//TODO: DCR: ON/OFF

//TODO: Eyeshield: ON/OFF

//TODO: Virtual Crosshair: ON/OFF

//TODO: Refresh Rate Display: ON/OFF

//TODO: Light Effect: OFF/ON
extern VOID Hv_Mw_Led_SetLedPowerMode(UCHAR8 bMode);
extern VOID Hv_Mw_Led_SetRedLed(BOOL bEn);
extern VOID Hv_Mw_Led_SetBlueLed(BOOL bEn);

extern UINT32 Hv_Comm_GetCodeVersion(void);

//auto poweroff. 0-off, 0-23 hours. userdata:ucPoweroffHours
VOID Hv_Mw_Power_TimerStart(UINT32 uiHours);

extern VOID Hv_Mw_OsdSetLanguage(USHORT16 usLangId);

extern VOID Hv_Mw_OsdSetTransparency(UCHAR8 ucAlpha);

extern VOID Hv_Mw_OsdSetRotateType(OsdRotationType enRotate);

//TODO: Factory Reset
extern VOID Hv_Mw_Factory_FactoryReset(VOID);

//TODO: Get Model

//TODO: Get SN

//TODO: Get SW Version

//TODO: Get input source

//TODO: Get current video timing

//HDR Switch 0 - 1
extern VOID Hv_Mw_PQ_SetHdrSwitch(UINT32 uiValue);

//CM init
extern Status Hv_Mw_PQ_CMInit(const UINT32 *puiCmAddr, UINT32 uiLen);
extern VOID Hv_Mw_PQ_CMEnable(BOOL bEn);
//CM 6 color Hue
extern VOID Hv_Mw_PQ_CMSetHue(UCHAR8 ucCmMod, UCHAR8 ucCmHue);

//CM 6 color Sat 
extern VOID Hv_Mw_PQ_CMSetSat(UCHAR8 ucCmMod, UCHAR8 ucSat);

//CM 6 color Lum
extern VOID Hv_Mw_PQ_CMSetLum(UCHAR8 ucCmMod, UCHAR8 ucLum);

//Sharpness
extern Status Hv_Mw_PQ_SharpnessInit(const UINT32 *puiSharpnessbin, UINT32 uiLen, const UINT32 *puiSharpnessParam);

//LDC
extern Status Hv_Mw_PQ_LdcInit(const UINT32 *puiLdcAddr, UINT32 uiLen);
extern Status Hv_Mw_PQ_LdcLutInit(const UINT32 *puiLdcLutAddr, UINT32 *puiBlAddr);

extern VOID Hv_Mw_PQ_SetLdBypass(UCHAR8 ucLdBypass);
extern VOID Hv_Mw_PQ_LdcPwmBlend(UINT32 uiPwm);
extern VOID Hv_Mw_PQ_LdcSetMode(UCHAR8 ucLdcModeIndex, USHORT16 usMaxWeightVal);
extern VOID Hv_Mw_PQ_SetMaxBl(UCHAR8 ucMaxBl);
extern VOID Hv_Mw_PQ_GetBlkAvg(USHORT16 ucPstX, USHORT16 ucPstY, UCHAR8* pucRed,UCHAR8* pucGreen,UCHAR8* pucBlue);
//Global contrast
extern Status Hv_Mw_PQ_GcInit(const UINT32 *puiGcAddr, UINT32 uiLen);
extern Status Hv_Mw_PQ_GcLutInit(const UINT32 *puiGcLutAddr, UINT32 *puiGcLutAddr1);

extern VOID Hv_Mw_PQ_GcModeSwitch(UCHAR8 ucGcMode, UCHAR8 ucCurBlkSta);

//HDR 
extern Status Hv_Mw_PQ_HdrInit(const UINT32 *puiHdrAddr1, UCHAR8 ucHdrIdx);
extern VOID Hv_Mw_PQ_SetHdrMode(UCHAR8 ucCh, UCHAR8 ucHdrModel, UCHAR8 *ucInfo);

//WCG Gamut
extern Status Hv_Mw_PQ_WcgInit(const UINT32 *puiWcgAddr, UINT32 uiLen);
extern Status Hv_Mw_PQ_WcgLutInit(const UINT32 *puiGmiAddr, const UINT32 *puiRgbAddr, const UINT32 *puiGmdAddr);
extern VOID Hv_Mw_PQ_SetGamut(UCHAR8 ucGamutIndex);
#if (HV_PROJECT_CONFIG_COLOR_FILTER == HV_CONFIG_ON)
#endif

//Matrix 
extern VOID Hv_Mw_PQ_SetRGBGain(UCHAR8 ucCh, USHORT16 usRed, USHORT16 usGreen, USHORT16 usBlue);
extern VOID Hv_Mw_PQ_SetRGBGainFac(UCHAR8 ucCh, USHORT16 usRed, USHORT16 usGreen, USHORT16 usBlue);
extern VOID Hv_Mw_PQ_SetBlackLevel(UCHAR8 ucCh, UCHAR8 ucBlackLevel);
extern VOID Hv_Mw_PQ_SetSaturation(UCHAR8 ucCh, UCHAR8 ucSaturation);
extern VOID Hv_Mw_PQ_SetHue(UCHAR8 ucCh, UCHAR8 ucHue);

//CSC
//Csc Init
extern Status Hv_Mw_PQ_CscInit(const UINT32 *puiCscAddr, UINT32 uiLen);
extern VOID Hv_Mw_PQ_SetBrightRange(UCHAR8 ucCh, UCHAR8 ucRange);
extern VOID Hv_Mw_PQ_SetColorSpace(UCHAR8 ucCh, UCHAR8 ucColorSpace);
//Dither
extern Status Hv_Mw_PQ_DitherInit(const UINT32 *puiDitherAddr, UINT32 uiLen);


extern Status Hv_Mw_PQ_ScalerUpLutInit(const UINT32 *puiScalerAddr);

/**
 * @brief Set video aspect ratio.
 * @param[in] enVideoRatio:read in hv_comm_Define.h
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetAspectRatio(VideoRatio enVideoRatio);

/**
 * @brief Set PIP / PBP funciton enable.
 * @param[in] 0- close PIP or PBP 1-PIP enable 2-pbp enable.
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetPxpMode(PxpMode enPxpMode);

/**
 * @brief set main channel video inputport source.
 * @param[in] 0- HDMI0 1:HDMI1 2-DP0 3-DP1.
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetMainVideoSource(LinkPortIndex enLinkPortIndex);


/**
 * @brief set sub channel video inputport source.
 * @param[in] 0- HDMI0 1:HDMI1 2-DP0 3-DP1.
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetSubVideoSource(LinkPortIndex enLinkPortIndex);


/**
 * @brief swap main and sub channel inputport source.
 * @param[in] none.
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetMainSubVideoSourceSwap();


/**
 * @brief In pip Mode set sub window position.
 * @param[in] 0:左上 1：左下 2：右上 3右下
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetSubVideoWindowPosition(PipPos enPipPos);

/**
 * @brief set pip sub h position
 */
extern VOID Hv_Mw_Video_SetPipWindowHPosition(USHORT16 usHPosLevel);

/**
 * @brief set pip sub V position
 */
extern VOID Hv_Mw_Video_SetPipWindowVPosition(USHORT16 usVPosLevel);

/**
 * @brief get pip sub h position
 */
extern USHORT16 Hv_Mw_Video_GetPipWindowHPosition(VOID);

/**
 * @brief get pip sub V position
 */
extern USHORT16 Hv_Mw_Video_GetPipWindowVPosition(VOID);

/**
 * @brief set pip window size.
 * @param[in] 0-small 1-big
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetSubVideoWindowSize(PipSize enPipSize);

/**
 * @brief set FreeSync funciton switch.
 * @param[in] HV_OFF-close HV_ON-open
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetFreeSyncSwitch(UCHAR8 ucSw);

/**
 * @brief set professional esport funciton switch.
 * @param[in] HV_OFF-close HV_ON-open
 */
extern VOID Hv_Mw_Video_SetProEsportSwitch(UCHAR8 ucSw);

/**
 * @brief set auto search signal source function enable .
 * @param[in] HV_OFF-close HV_ON-open
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetVideoAutoSelectSw(UCHAR8 ucSw);

/**
 * @brief set ALLM status.
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern BOOL Hv_Mw_Video_SetMainALLMStatus(VOID);

/**
 * @brief set Magnify Glass function Switch .
 * @param[in] HV_OFF-close HV_ON-open
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetMagnifyGlassSwitch(UCHAR8 ucSw);

/**
 * @brief set Magnify Glass function ratio .
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetMagnifyGlassRatio(FLOAT32 fMgRatio);

/**
 * @brief set Magnify Glass  position
 * @param[in] range usMgPosH: 0-pannel Hactive, usMgPosV: 0-panel Vactive
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetMagnifyGlassPos(USHORT16 usMgPosH, USHORT16 usMgPosV);

/**
 * @brief set Magnify Glass  sampling location
 * @param[in] range usSampleLocH: 0-pannel Hactive, usSampleLocV: 0-panel Vactive
 */
extern VOID Hv_Mw_Video_SetMagnifyGlassSamplingLocation(USHORT16 usSampleLocH, USHORT16 usSampleLocV);

/**
 * @brief set Magnify Glass Size
 * @param[in] range usMgHsize:0-panne Havtive , usMgVsize: 0-panel Vactive
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetMagnifyGlassSize(USHORT16 usMgHsize, USHORT16 usMgVsize);

/**
 * @brief Set h flip
 * @param[in] HV_OFF-close HV_ON-open
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetHflipSwitch(UCHAR8 ucSw);

/**
 * @brief Set v flip
 * @param[in] HV_OFF-close HV_ON-open
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Video_SetVflipSwitch(UCHAR8 ucSw);

/**
 * @brief Set mprt enable.
 * @param[in] enMprtType:0-disable , 1: normal mprt, 2: vrr mprt
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern VOID Hv_Mw_Video_SetOutMprtPwmEnable(MprtType enMprtType);

/**
 * @brief Set main channel over scan enbale.
 * @param[in] HV_OFF-close HV_ON-open
 */
extern VOID Hv_Mw_Video_SetOverScanEn(UCHAR8 ucSw);

extern BOOL Hv_Mw_Video_GetOverScanEn(VOID);
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OVER_PANEL_CLOCK_EN)
extern VOID Hv_Mw_Video_SetOverClockEn(UCHAR8 ucSw);
extern BOOL Hv_Mw_Video_GetOverClockEn(VOID);
#endif

BOOL Hv_Mw_Video_IsDtcVtotalInPanlSpec(VOID);

/**
 * @brief set audio source param:0-CHANNEL_TYPE_MAIN 1-CHANNEL_TYPE_SUB
 * @param[in] enChannelType ：CHANNEL_TYPE_MAIN, CHANNEL_TYPE_SUB
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Channel_AudioSourceConfig(ChannelType enChannelType);

extern Status Hv_Mw_Audio_SetVolume(UINT32 uiValue);

extern Status Hv_Mw_Audio_SetDelayTime(UINT32 uiValue);

extern Status Hv_Mw_Audio_UIMute(VOID);

extern Status Hv_Mw_Audio_UIUnMute(VOID);

/**
 * @brief Resume user data config to default.
 * @param[in] void
 * @return void.
 */
extern Status Hv_Mw_DataBase_ResumeUserData( VOID );

/**
 * @brief Resume user data config to default.
 * @param[in] range ：0-pannel Vactive
 * @return none.
 */
extern Status Hv_Mw_DataBase_ResumeSystemData( VOID );

Status Hv_Mw_Video_DataPathReconfig( VOID );

/**
 * @brief Get channel bind port and state.
 * @param[in] ChannelType: main or sub.
 * @param[out] LinkPortIndex:bind port idnex. ChanelSignalState:signal state.
 * @return Status, 0-SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Channel_GetSignalState(ChannelType enChannelType, LinkPortIndex* penChannelSrcLinkPortIndex, ChanelSignalState* penChanelSignalState);

/**
 * @brief Get channel bind port realtime video timing,ps:in vrr case framerate will change.
 * @param[in] ChannelType: main or sub.
 * @param[out] VdeTimingParam:RX video timing.
 * @return Status, 0-SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_Channel_GetVideoTiming(ChannelType enChannelType, VideoTimingParam* pstVideoTiming);

/**
 * @brief Interface for the EDID Configure.
 * @param[in] Link Port Index and the EDID Type.
 * @return Status of the Operantion result.
 */
extern Status Hv_Mw_HdmiRx_UpdateEdid(LinkPortIndex enPortIndex, EDIDType eEdidConfigure);

/**
 * @brief Set DP version.
 * @param[in] ucPortId: port index 0 or 1
 * @param[ucDpVer] DP Version 1.1 or 1.2 or 1.4
 * @return Status.
 */
extern Status Hv_Mw_DpRx_SetDpVer(LinkPortIndex enPortIndex, UCHAR8 ucDpVer);

/**
 * @brief Set DP version.
 * @param[ucDpVer] DP Version 1.1 or 1.2 or 1.4
 * @return Status.
 */
extern Status Hv_Mw_DpRx_SetAllDpVer(UCHAR8 ucDpVer);

/**
 * @brief Get DP version.
 * @param[in] ucPortId: port index 0 or 1
 * @return DP version.
 */
extern UCHAR8 Hv_Mw_DpRx_GetDpVer(LinkPortIndex enPortIndex);

/**
 * @brief Get DP version.
 * @return DP version.
 */
extern UCHAR8 Hv_Mw_DpRx_GetAllDpVer();

extern Status Hv_Mw_DpRx_HpdToggle(LinkPortIndex enPortIndex);

/**
 * @brief Set OD by level, ref UserdataResponseTime
 * @param[in] UserdataResponseTime
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
extern Status Hv_Mw_PQ_SetODLevel(UCHAR8 ucODLevel);

/**
 * @brief Get Current Inputport Frame Rate
 * @param[in] Input Port Index
 * @return UINT32, Current FrameRate.
 */
extern UINT32 Hv_Mw_InputPort_GetCurrentFrameRate(LinkPortIndex enPortIndex);

/**
 * @brief Get Current Inputport Timing Information
 * @param[in] Input Port Index
 * @return Vedio timing information.
 */
extern Status Hv_Mw_InputPort_GetVideoPara(LinkPortIndex enPortIndex, ChannelData* pstChannelData);
/**
 * @brief  Interface to get current HDMI Timing Vedio Mode.
 * @param[in] Link port index of the HDMI.
 * @return HV_TRUE:DVI Mode; HV_FALSE:HDMI Mode.
 */
extern BOOL Hv_Mw_HdmiRx_GetDviMode(LinkPortIndex enPortIndex);
/**
 * @brief Interface to Swtich the ALLM Mode.
 * @param[in] The Switch of the ALLM Mode, HV_TRUE is for Open.
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
Status Hv_Mw_HdmiRx_SwitchAllmMode(BOOL bAllmSwitch);
/**
 * @brief Interface to Swtich the QMS Mode.
 * @param[in] The Switch of the QMS Mode, HV_TRUE is for Open.
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
Status Hv_Mw_HdmiRx_SwitchQmsMode(BOOL bQmsSwitch);
/**
 * @brief Get Current Inputport Vrr Infomation
 * @param[in] Input Port Index
 * @return Vrr Vendor Information.
 */
extern Status Hv_Mw_InputPort_GetSourceVendorPara(LinkPortIndex enPortIndex, VRRInfoParam *ptVendor);

extern Status Hv_Mw_PQ_DynamicBLEn(UCHAR8 ucEn);

extern Status Hv_Mw_Video_ForceSwitchHdr(UCHAR8 ucSwitch);

#if (HV_PROJECT_CONFIG_AMBILIGHT == HV_CONFIG_ON)
extern VOID Hv_Mw_PQ_CrosshairInit(VOID);
extern VOID Hv_Mw_PQ_CrosshairEnable(BOOL bEnable);
extern VOID Hv_Mw_PQ_CrosshairSetArea(CrosshairArea *pstArea);
extern VOID Hv_Mw_PQ_CrosshairGetRGBY(CrosshairRGBY *pstValue);
#endif


#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBIENT_LIGHT)
extern VOID Hv_Mw_PQ_StartFollowingPQ(VOID);
extern VOID Hv_Mw_PQ_StopFollowingPQ(VOID);
extern VOID Hv_Mw_PQ_UpdateSingleColor(UCHAR8 ucColorType);
extern VOID Hv_Mw_PQ_StartAutoColor(VOID);
extern VOID Hv_Mw_PQ_StopAutoColor(VOID);
extern VOID Hv_Mw_PQ_StartMarqueeColor(VOID);
extern VOID Hv_Mw_PQ_StopMarqueeColor(VOID);
#endif

extern VOID Hv_Mw_Ddcci_SetRunState(UCHAR8 ucDdcRun);
extern UCHAR8 Hv_Mw_Ddcci_GetRunState(VOID);

extern Status Hw_Mw_Channel_SendNoSignalMsgToPowerManager(BOOL bEnterFlag);
extern Status Hv_Mw_Power_SendPoweroffToPowerManager(void);

extern Status Hv_Mw_DCW_SetBrightFrameEn(UCHAR8 ucEn);
extern BOOL Hv_Mw_DCW_GetBrightFrameEn(VOID);
extern VOID Hv_Mw_DCW_SetBrightFrameSize(UCHAR8 ucSizeLevel);
extern UCHAR8 Hv_Mw_DCW_GetBrightFrameSize(VOID);
extern VOID Hv_Mw_DCW_SetBrightFrameHPos(UCHAR8 ucHPosLevel);
extern UCHAR8 Hv_Mw_DCW_GetBrightFrameHPos(VOID);
extern VOID Hv_Mw_DCW_SetBrightFrameVPos(UCHAR8 ucVPosLevel);
extern UCHAR8 Hv_Mw_DCW_GetBrightFrameVPos(VOID);
VOID Hv_App_PQ_SetBrightFrameBrightness(UCHAR8 ucBrightness);
USHORT16 Hv_App_PQ_Video_GetBrightFrameBrightness(VOID);
VOID Hv_App_PQ_SetBrightFrameContrast(UCHAR8 ucContrast);
USHORT16 Hv_App_PQ_GetBrightFrameContrast(VOID);

extern VOID Hv_Mw_Video_SetPipWindowHPosition(USHORT16 usHPosLevel);
extern VOID Hv_Mw_Video_SetPipWindowVPosition(USHORT16 usVPosLevel);
extern USHORT16 Hv_Mw_Video_GetPipWindowHPosition(VOID);
extern USHORT16 Hv_Mw_Video_GetPipWindowVPosition(VOID);


#endif
