/**
 * @file hv_app_PQ.h
 * @brief Header file of dpu module.
 * 
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use hv_app_PQ(...) as a function handle. 
 * 
 @ endverbatim 
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-12-01
 */

#ifndef __HV_APP_PQ_H__
#define __HV_APP_PQ_H__

#include "Common/hv_comm_DataType.h"
#include "hv_comm_Define.h"
#include "hv_comm_PqDef.h"
#include "hv_app_Function.h"



typedef struct _PQValueMap
{
    UCHAR8        ucModule;
    USHORT16        (*pfActionHandle)(USHORT16 usValue);
}PQValueMap;




#if (HV_PROJECT_CONFIG_COLOR_FILTER == HV_CONFIG_ON)
typedef enum _WCGColorFilterType
{
    COLOR_FILTER_NONE = 0,
    COLOR_FILTER_INVERT,
    COLOR_FILTER_GRAY,
    COLOR_FILTER_PROTANOPIA,
    COLOR_FILTER_DEUTERANOPIA,
    COLOR_FILTER_TRIANOPIA,
}WCGColorFilterType;

#endif









/**
 * @brief Get real value in case there is a non-linear mapping
 * @param[in] ucValue:InputValue, uiModule:PQ IP
 * @return Real Value of after mapping
 */
USHORT16 Hv_App_PQ_GetRealValue(USHORT16 ucValue, UCHAR8 uiModule);

/**
 * @brief PQ Init
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_Init(VOID);

/**
 * @brief setting PQ default value
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_SetDefaultValue(VOID);

/**
 * @brief PQ common Init
 * @param[in] None
 * @return None
 */
VOID Hv_App_PQ_CommonRegInit(VOID);

/**
 * @brief YCCM Init
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_CMInit(VOID);

/**
 * @brief CSC Init
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_CscInit(VOID);

/**
 * @brief Gamma Init
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_GammaInit(VOID);

/**
 * @brief Set different Gamma lut
 * @param[in] ucGammaIndex: index of Gamma lut to be set
 * @return VOID
 */
VOID Hv_App_PQ_SetGamma(UCHAR8 ucGammaIndex);

/**
 * @brief get value of gamma
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetGamma(VOID);

/**
 * @brief Sharpness Init
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_SharpnessInit(VOID);

/**
 * @brief Sharpness Set ting
 * @param[in] value of Sharpness
 * @return VOID
 */
VOID Hv_App_PQ_SetSharpness(UCHAR8 ucSharpness);

/**
 * @brief get value of Sharpness
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetSharpness(VOID);

/**
 * @brief LocalDimming Init
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_LdcInit(VOID);

/**
 * @briefSet Ldc mode 
 * @param[in] ucMode 
 * @return VOID
 */
VOID Hv_App_PQ_LdcSetMode(UCHAR8 ucMode);

/**
 * @brief set Max Backlight 
 * @param[in] value of Backlight
 * @return VOID
 */
VOID Hv_App_PQ_SetMaxBl(UCHAR8 ucMaxBl);

/**
 * @brief force switch HDR in OSD menu 
 * @param[in] status of HDR(on or off)
 * @return VOID
 */
VOID Hv_App_PQ_ForceSwitchHdr(UCHAR8 ucSwitch);

/**
 * @brief get value of HDR switch
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetHdrSwitch(VOID);

/**
 * @brief Global Contrast Init
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_GcInit(VOID);

//ATTENTION!!!
//DarkStablizer and DynamicContrast Can !!!NOT!!! be used at the same time
/**
 * @brief Dark Stablizer 
 * @param[in] ucCurBlkSta: 0-255
 * @return VOID
 */
VOID Hv_App_PQ_DarkStablizer(UCHAR8 ucCurBlkSta);

/**
 * @brief get value of Dark Stablizer 
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetDarkStablizer(VOID);

/**
 * @brief Dynamic Contrast Enable
 * @param[in] ucEn 0-1
 * @return VOID
 */
VOID Hv_App_PQ_DynamicContrastEnable(UCHAR8 ucEn);
/**
 * @brief get value of Dynamic Contrast
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetDynamicContrast(VOID);

/**
 * @brief HDR Init
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_HdrInit(VOID);

/**
 * @brief WCG Init
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_WcgInit(VOID);

/**
 * @brief Gamut set:Adobe RGB, sRGB, P3...
 * @param[in] Index of Gamut
 * @return VOID
 */
VOID Hv_App_PQ_SetGamut(PQGamutType enType);

/**
 * @brief get value of Gamut
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetGamut(VOID);
#if (HV_PROJECT_CONFIG_COLOR_FILTER == HV_CONFIG_ON)
/**
 * @brief colorfilter setting in WCG
 * @param[in] type of colorfilter
 * @return None
 */
VOID Hv_App_PQ_SetWCGColorFilter(WCGColorFilterType enType);
/**
 * @brief colorfilter setting
 * @param[in] type of colorfilter
 * @return None
 */
VOID Hv_App_PQ_SetColorFilterType(WCGColorFilterType enType);
/**
 * @brief get value of ColorFilter
 * @param[in] none
 * @return value of ColorFilter
 */
UCHAR8 Hv_App_PQ_GetColorFilterType(VOID);
#endif

/**
 * @brief Contrast setting
 * @param[in] ucContrast:value of contrast
 * @return VOID
 */
VOID Hv_App_PQ_SetContrast(UCHAR8 ucContrast);

/**
 * @brief get value of contrast
 * @param[in] none
 * @return value of contrast
 */
UCHAR8 Hv_App_PQ_GetContrast(VOID);

/**
 * @brief RGB Gain set in factory mode
 * @param[in] Value of R,G,B Gain
 * @return VOID
 */
VOID Hv_App_PQ_SetRGBGainFac(UCHAR8 ucRed, UCHAR8 ucGreen, UCHAR8 ucBlue);

/**
 * @brief RGB Gain setting
 * @param[in] Value of R,G,B Gain
 * @return VOID
 */
VOID Hv_App_PQ_SetRGBGain(UCHAR8 ucRed, UCHAR8 ucGreen, UCHAR8 ucBlue);

/**
 * @brief RGB Offset setting
 * @param[in] Value of R,G,B Offset
 * @return VOID
 */
VOID Hv_App_PQ_SetRGBOffset(UCHAR8 ucRed, UCHAR8 ucGreen, UCHAR8 ucBlue);

/**
 * @brief Black Level settting
 * @param[in] Value of BlackLevel 
 * @return VOID
 */
VOID Hv_App_PQ_SetBlackLevel(UCHAR8 ucBlackLevel);

/**
 * @brief Saturation setting
 * @param[in] Value of ucSaturation  
 * @return VOID
 */
VOID Hv_App_PQ_SetSaturation(UCHAR8 ucSaturation);

/**
 * @brief get value of Saturation
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetSaturation(VOID);

/**
 * @brief Changed CM lut
 * @param[in] uiLutAddr:addr of Lut
 * @return VOID
 */
VOID Hv_App_PQ_CMChangeLut(UINT32 uiLutAddr);
/**
 * @brief Hue setting
 * @param[in] Value of ucSaturation  
 * @return VOID
 */
VOID Hv_App_PQ_SetHue(UCHAR8 ucHue);

/**
 * @brief get value of hue
 * @param[in] VOID 
 * @return value
 */
UCHAR8 Hv_App_PQ_GetHue(VOID);

/**
 * @brief BrightRange setting
 * @param[in] Value of BrightRange
 * @return VOID
 */
VOID Hv_App_PQ_SetBrightRange(PQBrightRange enRange);

/**
 * @brief get value of BrightRange setting
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetBrightRange(VOID);

/**
 * @brief ColorSpace setting
 * @param[in] Value of colorSpace
 * @return VOID
 */
VOID Hv_App_PQ_SetColorSpace(PQColorSpace enColorSpace);

/**
 * @brief update default lut of scaler
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_ScalerUpLutInit(VOID);

/**
 * @brief Dither Init
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_DitherInit(VOID);

/**
 * @brief brightness setting
 * @param[in] Value of brightness
 * @return VOID
 */
VOID Hv_App_PQ_SetBrightness(UCHAR8 ucValue);

/**
 * @brief get value of brightness
 * @param[in] None
 * @return Value of brightness
 */
UCHAR8 Hv_App_PQ_GetBrightness(VOID);

/**
 * @brief switch hdr for debug(simulate signal source setting)
 * @param[in] status of HDR 
 * @return status of function
 */
VOID Hv_App_PQ_SetHdrSwitch(UINT32 uiValue);

/**
 * @brief R Gain setting
 * @param[in] Value of RGain
 * @return VOID
 */
VOID Hv_App_PQ_SetRGain(UCHAR8 ucRed);

/**
 * @brief get value of R Gain
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetRGain(VOID);

/**
 * @brief G Gain setting
 * @param[in] Value of GGain
 * @return VOID
 */
VOID Hv_App_PQ_SetGGain(UCHAR8 ucGreen);

/**
 * @brief get value of G Gain
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetGGain(VOID);

/**
 * @brief B Gain setting
 * @param[in] Value of BGain
 * @return VOID
 */
VOID Hv_App_PQ_SetBGain(UCHAR8 ucBlue);

/**
 * @brief get value of B Gain
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetBGain(VOID);

/**
 * @brief R Offset setting
 * @param[in] Value of ROffset
 * @return VOID
 */
VOID Hv_App_PQ_SetROffset(UCHAR8 ucRed);

/**
 * @brief G Offset setting
 * @param[in] Value of GOffset
 * @return VOID
 */
VOID Hv_App_PQ_SetGOffset(UCHAR8 ucGreen);

/**
 * @brief B Offset setting
 * @param[in] Value of BOffset
 * @return VOID
 */
VOID Hv_App_PQ_SetBOffset(UCHAR8 ucBlue);

/**
 * @brief setting color temperature.
 * @param[in] VOID
 * @return value.
 */
UCHAR8 Hv_App_PQ_GetColorTemp(VOID);

/**
 * @brief get value of low blue light
 * @param[in] VOID
 * @return value.
 */
UCHAR8 Hv_App_PQ_GetLowBlueLight(VOID);

/**
 * @brief double channel Enable to control some PQ module (only single channel).
 * @param[in] ucEn:status of enable;
 * @return VOID
 */
VOID Hv_App_PQ_DoubleChannelEnable(UCHAR8 ucEn);
/**
 * @brief DispCtrl Init.
 * @param[in] None
 * @return Status
 */
Status Hv_App_PQ_DispCtrlInit(VOID);

/**
 * @brief Set display control od level.
 * @param[in] ucODLevel, ref UserdataResponseTime
 * @return VOID
 */
VOID Hv_App_PQ_SetODLevel(UCHAR8 ucODLevel);

/**
 * @brief get value of ODlevel.
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetODLevel(VOID);

/**
 * @brief get value of dynamic backlight.
 * @param[in] VOID
 * @return value
 */
UCHAR8 Hv_App_PQ_GetDCR(VOID);

/**
 * @brief Dynamic backlight enable.
 * @param[in] status of dynamic backlight
 * @return VOID
 */
VOID Hv_App_PQ_SetDCR(UCHAR8 ucEn);

#if (HV_PROJECT_CONFIG_AMBILIGHT == HV_CONFIG_ON)
/**
 * @brief crosshair init.
 * @param[in] None
 * @return VOID
 */
VOID Hv_App_PQ_CrosshairInit(VOID);

/**
 * @brief crosshair enable.
 * @param[in] status of crosshair
 * @return VOID
 */
VOID Hv_App_PQ_CrosshairEnable(BOOL bEnable);

/**
 * @brief crosshair area setting.
 * @param[in] position of crosshair
 * @return VOID
 */
VOID Hv_App_PQ_CrosshairSetArea(CrosshairArea *pstArea);
#endif

/**
 * @brief setting color temperature.
 * @param[in] usMode mode of color temperature
 * @param[in] usLowBlueLevel level of lowblue
 * @return None.
 */
VOID Hv_App_PQ_SetColorTemp(PQColorTemp enType, UCHAR8 ucLowBlueLevel);

/**
 * @brief PQ callback for mw.
 * @param[in] enMode mode of callback
 * @param[in] pvVideoConfigParams point of video config
 * @return None.
 */
UCHAR8 Hv_App_PQ_CallBack(PQCALLBACKMODE enMode, const VOID *pvVideoConfigParams);


VOID Hv_App_PQ_LdcBacklightStart();
#endif
