/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*-----------------------------------------------------------------------------
 *
 * $Author: xiaojun.zhu $
 * $Date: 2015/08/08 $
 * $RCSfile: pe_if.h,v $
 * $Revision: #9 $
 *
 *---------------------------------------------------------------------------*/

/** @file nptv_if.h
 *  NPTV video path control, include  input source select ,
 *  timing information, and video quality control
 */

#ifndef _PE_IF_H_
#define _PE_IF_H_

#include "drv_hdmi2.h"
#include "util.h"
#include "drv_vga.h"
#include "drv_tvd.h"
#include "api_notify.h"
#include "u_drv_cust.h"
#include "drv_ycproc.h"
// Quality Item and Enumation
#include "pe_table.h"

#define PQ_OK                   0  ///< Success
#define PQ_NOT_OK              -1  ///< Not ok
#define PQ_NOT_SUPPORTED       -2  ///< Not support
#define PQ_PARAMETER_ERROR     -3  ///< Parameter error
#define PQ_DONT_CARE           -4  ///< Don't care
#define PQ_ERR_INV             -5  ///< Invalid argument passed
#define PQ_ERR_TIMEDOUT        -6  ///< Timeout occured
#define PQ_PARAMETER_NOCHANGE  -7  /// Paramenter no change

#define MJC_CTRL_EFCT_OFF		0x00            // MJC 1W1R (bypass)
#define MJC_CTRL_EFCT_LOW		0x40
#define MJC_CTRL_EFCT_MID		0x80
#define MJC_CTRL_EFCT_HIGH		0xff
#define MJC_CTRL_EFCT_MSK		0xff

#define HDR_TYPE                0x3

#define SUPPORT_OSTG_TWO_CHA 1
#define OSTG_CHANNEL1_OFFSET  0x4000

#define VIDEO_INFO       1
#define METADATA_INFO    2

#define SCANPWM_MAX_CH 4
#define SCANPWM_FIRST_CH 3


#if SUPPORT_OSTG_TWO_CHA
        #define vOSTG_IO32WriteFldAlign(reg32,val,fld) \
        {       \
                vIO32WriteFldAlign(reg32,val,fld);  \
                if((((reg32) >= (OSTG_00))&&((reg32) <= (GAMMA_12))) || \
                    (((reg32) >= (OSD_MIX_0))&&((reg32) <= (DEBUG_04))) || \
                    (((reg32) >= (SPARE_00))&&((reg32) <= (DONT_TOUCH))) ||\
                    (((reg32) >= (OSD_TIMING_00))&&((reg32) <= (SYNC_STA))) ||\
                    (((reg32) >= (AMBL_00_ES2))&&((reg32) <= (AMBL_03_ES2))) ||\
                    ((reg32) == (XVYCC_00)) || \
                    ((reg32) == (XVYCC_01)) || \
                    (((reg32) >= (XVYCC_05))&&((reg32) <= (XVYCC_12)))|| \
                    (((reg32) >= (XVYCC_15))&&((reg32) <= (XVYCC_23)))||\
                    (((reg32) >= (ADL_CONTROL))&&((reg32) <= (ADL_CONTROL)))||\
                    (reg32 == DEMURA_CTRL_0))                                                     \
                {                                                                                       \
                    vIO32WriteFldAlign(reg32 + OSTG_CHANNEL1_OFFSET, val, fld);\
                }\
        }
#else
    #define vOSTG_IO32WriteFldAlign(reg32,val,fld)   vIO32WriteFldAlign(reg32,val,fld)
#endif



#define HDR_SUB_PATH_OFFSET  0x500
#define HDR_MAIN_PATH_OFFSET 0x300

#define vSUB_HDR_IO32WriteFldAlign(reg32,val,fld) vIO32WriteFldAlign(reg32 + HDR_SUB_PATH_OFFSET, val, fld)
#define vSUB_HDR_IO32ReadFldAlign(reg32,fld) IO32ReadFldAlign(reg32+ HDR_SUB_PATH_OFFSET, fld)
#define vSUB_HDR_IO32Write4B(reg32,val) vIO32Write4B(reg32 + HDR_SUB_PATH_OFFSET,val)
#define vSUB_HDR_IO32Read4B(reg32) u4IO32Read4B(reg32 + HDR_SUB_PATH_OFFSET) 

#define vMAIN_HDR_IO32WriteFldAlign(reg32,val,fld) vIO32WriteFldAlign(reg32 + HDR_MAIN_PATH_OFFSET, val, fld)
#define vMAIN_HDR_IO32ReadFldAlign(reg32,fld) IO32ReadFldAlign(reg32 + HDR_MAIN_PATH_OFFSET, fld)
#define vMAIN_HDR_IO32Write4B(reg32,val) vIO32Write4B(reg32 + HDR_MAIN_PATH_OFFSET,val)
#define vMAIN_HDR_IO32Read4B(reg32) u4IO32Read4B(reg32 + HDR_MAIN_PATH_OFFSET) 

#define TRACE(type, mode, filename)		Trace_##type(mode, filename)
#define TRACE_LOG(type, filename, fmt,...)		type##_Trace_LOG(filename, fmt,##__VA_ARGS__ )

enum
{
    MJC_CTRL_INTP_OFF,
    MJC_CTRL_INTP_HFBK,
    MJC_CTRL_INTP_NORM
};
typedef enum
{
    VDP_ARG_MJC_EFFECT_OFF,
    VDP_ARG_MJC_EFFECT_LOW,
    VDP_ARG_MJC_EFFECT_MIDDLE,
    VDP_ARG_MJC_EFFECT_HIGH
} MJC_EFFECT_MODE;

typedef enum
{
    VDP_ARG_MJC_MODE_NORM,
    VDP_ARG_MJC_MODE_NO_DEBLUR,
    VDP_ARG_MJC_MODE_NO_FILM
} MJC_DEJUDDER_MODE;

typedef enum
{
    VDP_ARG_MJC_DEMO_ALL,
    VDP_ARG_MJC_DEMO_RIGHT,     // Enable Right, disable left
    VDP_ARG_MJC_DEMO_LEFT       // Enable left, disable right
} MJC_DEMO_MODE;

enum
{
    SV_COLOR_HDMI_sRGB,
	SV_COLOR_HDMI_Adobe_RGB,
	SV_COLOR_HDMI_sYCC,
    SV_COLOR_HDMI_xvYCC,
    SV_COLOR_HDMI_BT2020,
    SV_COLOR_HDMI_BT2020c,
    SV_COLOR_HDMI_Normal,
};

enum
{
    SV_COLOR_HDMI_Colorimetry_RGB,
    SV_COLOR_HDMI_Colorimetry_601,
    SV_COLOR_HDMI_Colorimetry_709,
    SV_COLOR_HDMI_Colorimetry_XVYCC601,
    SV_COLOR_HDMI_Colorimetry_XVYCC709,
    SV_COLOR_HDMI_Colorimetry_sYCC601,
	SV_COLOR_HDMI_Colorimetry_AdobeYCC601,
	SV_COLOR_HDMI_Colorimetry_AdobeRGB,
	SV_COLOR_HDMI_Colorimetry_BT2020,
	SV_COLOR_HDMI_Colorimetry_UnKnown
};

enum
{
    SV_HDR_TYPE_SDR,
    SV_HDR_TYPE_HDR1,
    SV_HDR_TYPE_HDR2,
    SV_HDR_TYPE_HDR3,
    SV_HDR_TYPE_UNKNOWN
};

enum
{
    SV_SCE_CLOR_TYPE_A,
    SV_SCE_CLOR_TYPE_B,
    SV_SCE_CLOR_TYPE_C,
    SV_SCE_CLOR_TYPE_D,
    SV_SCE_CLOR_TYPE_UNKNOWN
}; //FOR SCE INDEX FROM s SPEC

enum
{
    VDP_HDR_TYPE_SDR,
    VDP_HDR_TYPE_HDR10,
    VDP_HDR_TYPE_HLG,
    VDP_HDR_TYPE_DOVI,
    VDP_HDR_TYPE_TECHNI,
    VDP_HDR_TYPE_HDR10PLUS,
    VDP_HDR_TYPE_UNKNOWN
};
typedef enum
{
    VDP_TRANSFER_CHARACTOR_SMPTEST2084         = 16,
    VDP_TRANSFER_CHARACTOR_ARIBSTD_B67         = 18,
}VDP_TRANSFER_CHARACTOR_E;
enum
{
    VDP_HDR_SRC_OTT,
    VDP_HDR_SRC_HDMI
};

typedef enum
{
    SV_MMP_SOURCE_TYPE_VIDEO,
    SV_MMP_SOURCE_TYPE_PICTURE,
    SV_MMP_SOURCE_TYPE_UNKNOWN
}SV_MMP_TYPE_E;

typedef enum {
    B2R_IF_COLOR_DEPTH_8BIT = 8,
    B2R_IF_COLOR_DEPTH_10BIT = 10,
    B2R_IF_COLOR_DEPTH_12BIT = 12,
    B2R_IF_COLOR_DEPTH_16BIT = 16
}B2R_IF_COLOR_DEPTH_T;

typedef enum
{
	LCE_NOT_CH_EVENT			= 0x0,
    LCE_SW_REG_CH_EVENT			= 0x1,
    LCE_ALL_MASK				= 0xFF
}LCE_CHANGE_EVENT_E;

typedef enum
{
    VDP_ARG_LCE_DEMO_ALL,
    VDP_ARG_LCE_DEMO_RIGHT,     // Enable Right, disable left
    VDP_ARG_LCE_DEMO_LEFT       // Enable left, disable right
} LCE_DEMO_MODE;


typedef enum
{
    SV_VP9_HDR_TYPE_NONE,
    SV_VP9_HDR_TYPE_HDR1,
    SV_VP9_HDR_TYPE_HDR2,
}VP9_HDR_TYPE_E;

typedef enum
{
    SV_HDRTYPE_SDR,
    SV_HDRTYPE_HDR,
    SV_HDRTYPE_ST2084,
    SV_HDRTYPE_HLG,
    SV_HDRTYPE_Future_EOTF,
    SV_HDRTYPE_UNKNOWN
}HDR_ETOF_MODE;
typedef struct
{
    UINT32 u4Arg1;
    UPTR   u4Arg2;
    UINT32 u4Arg3;
    UINT32 u4Arg4;
    UINT32 u4Arg5;
	UINT32 u4Arg6;
} MSG_T;

typedef enum
{
	MSG_TYPE_HDR10PLUS,
	MSG_TYPE_HDRTECHNI,
	MSG_TYPE_MAX
}MSG_TYPE_T;//only append , can not allow to change order 



#ifdef CC_FBM_SUPPORT_SRS
typedef enum
{
	SV_4K4K_TBL = 0,
	SV_2K4K_TBL,
	SV_MAX_TBL
} SRS_TBL_SEL;
#endif

typedef struct _SV_HDR_INFO_T
{
    HDR_ETOF_MODE   eEOTF;
    UINT16          au2Primaries_x[3];
    UINT16          au2Primaries_y[3];
    UINT16          u2White_Point_x;
    UINT16          u2White_Point_y;
    UINT16          u2MinLuminance;
    UINT16          u2MaxLuminance;
    UINT16          u2ContentLevel;
    UINT16          u2FrameAverageLevel;
}SV_HDR_INFO_T;
typedef struct _PANEL_GAMUT_T
{
  UINT32 BT709_c00;   
  UINT32 BT709_c01;
  UINT32 BT709_c02;
  UINT32 BT709_c10;
  UINT32 BT709_c11;
  UINT32 BT709_c12;
  UINT32 BT709_c20;
  UINT32 BT709_c21;
  UINT32 BT709_c22;
  UINT32 BT2020_c00;  
  UINT32 BT2020_c01;
  UINT32 BT2020_c02;
  UINT32 BT2020_c10;
  UINT32 BT2020_c11;
  UINT32 BT2020_c12;
  UINT32 BT2020_c20;
  UINT32 BT2020_c21;
  UINT32 BT2020_c22;
}PANEL_GAMUT_T;
typedef struct _TONE_MAP_T
{
  //Tone-mapping
  UINT32 reg_p1;
  UINT32 reg_p2;
  UINT32 reg_p3;
  UINT32 reg_p4;
  UINT32 reg_p5;
  UINT32 reg_p6;
  UINT32 reg_p7;
  UINT32 reg_p8;
  UINT32 reg_p9;
  UINT32 reg_p10;
  UINT32 reg_p11;
  UINT32 reg_p12;
  UINT32 reg_p13;
  UINT32 reg_p14;
  UINT32 reg_p15;
  UINT32 reg_p16;

  UINT32 reg_slope0;
  UINT32 reg_slope1;
  UINT32 reg_slope2;
  UINT32 reg_slope3;
  UINT32 reg_slope4;
  UINT32 reg_slope5;
  UINT32 reg_slope6;
  UINT32 reg_slope7;
  UINT32 reg_slope8;
  UINT32 reg_slope9;
  UINT32 reg_slope10;
  UINT32 reg_slope11;
  UINT32 reg_slope12;
  UINT32 reg_slope13;
  UINT32 reg_slope14;
  UINT32 reg_slope15;
}TONE_MAP_T;
#ifdef DRV_SUPPORT_EXTMJC

EXTERN INT32 d_custom_extmjc_set_ui(UINT8  ui2_level,
                                          UINT8  ui2_mode,
                                          UINT8  ui2_demo,
                                          UINT8* pui1_msg_error);

#define vMJCSetDemoMode(A, B, C)        d_custom_extmjc_set_ui(A, B, C, NULL)

#endif

enum
{
    PEQTY_APPLY_TIME_OUTPUT_VSYNC_ISR,
    PEQTY_APPLY_TIME_INPUT_VSYNC_ISR,
    PEQTY_APPLY_TIME_MJC_INPUT_VSYNC_ISR,
    PEQTY_APPLY_TIME_MJC_OUTPUT_VSYNC_ISR,
    PEQTY_APPLY_TIME_OD_VSYNC_ISR,
    PEQTY_APPLY_TIME_SCALER_OUTPUT_VSYNC_ISR,
};

typedef enum {
    E_CUST_NO_EVEMT                 = 0,
    E_CUST_SOURCE_CHANGE            = (1<<0),
    E_CUST_SIGNAL_FMT_CHANGE        = (1<<1),
    E_CUST_PLANE_MUTE_CHANGE        = (1<<2),
    E_CUST_OUT_MUTE_CHANGE      	= (1<<3),
    E_CUST_OUT_POSI_CHANGE          = (1<<4),
    E_CUST_SRC_AREA_CHANGE          = (1<<5),
    E_CUST_SCALING_REQ_CHANGE       = (1<<6),
    E_CUST_BLUR_REQ_CHANGE          = (1<<7),
    E_CUST_MJC_FREQ_CHANGE          = (1<<8),
    E_CUST_OUT_FMT_CHANGE           = (1<<9),
    E_CUST_BORDER_PLN_REQ_CHANGE    = (1<<10),
    E_CUST_BL_POWER_LIMIT_CHANGE    = (1<<11),
    E_CUST_VDO_DELAY_CHANGE         = (1<<12),
    E_CUST_POWER_STATE_CHANGE       = (1<<13),
    E_CUST_SCREEN_SAVER_CHANGE      = (1<<14),
    E_CUST_AGING_MODE_CHANGE        = (1<<15),
    E_CUST_MUFFIN_SCALING_CHANGE    = (1<<16),
    E_CUST_TV_OUT_FMT_CHANGE        = (1<<17),
    E_CUST_OUT_SCALING_CHANGE       = (1<<18),
    E_CUST_OSD_STATE_CHANGE         = (1<<19),
    E_CUST_PIC_SETTING_CHANGE       = (1<<20),
    E_CUST_SCR_SETTING_CHANGE       = (1<<21),
    E_CUST_3D_SETTING_CHANGE        = (1<<22),
    E_CUST_ECO_SETTING_CHANGE       = (1<<23),
    E_CUST_PHOTO_SETTING_CHANGE     = (1<<24),
    E_CUST_DEMO_SETTING_CHANGE      = (1<<25),
    E_CUST_DEMO_OSD_MASK_CHANGE     = (1<<26),
    E_CUST_SERVICE_SETTING_CHANGE   = (1<<27),
    E_CUST_SERVICE_TRANS_START     	= (1<<28),
    E_CUST_SERVICE_VCOM_CHANGE      = (1<<28) + 1,
    E_CUST_UI_INPUT_TARGET_CHANGE   = (1<<28) + 2,
    E_CUST_WB_OFFSET_CHANGE         = (1<<28) + 3,
    E_CUST_SCR_MIRROR_CONFIG_CHANGE = (1<<28) + 4,
    E_CUST_BT_SETTING_CHANGE        = (1<<28) + 5,
    E_CUST_LETTER_BOX_CHANGE        = (1<<28) + 6,
    E_CUST_PIC_CONTROL_STATE_CHANGE = (1<<28) + 7,
    E_CUST_COLOR_ADJUST_CHANGE      = (1<<28) + 8,//?
    E_CUST_WB_OFFSET_20P_EN_CHANGE  = (1<<28) + 9,//?
#ifdef CC_SUPPORT_PHOTO8K
    E_CUST_DIVPHOTO_STATE_CHANGE    = (1<<28) + 10,
    E_CUST_VB1_MODE_CHANGE          = (1<<28) + 11,
#endif
	E_CUST_COLOR_SENSOR_SETTING_CHANGE = (1<<28) + 12,

} E_CUST_EVENT;

extern UINT8 fgIsHdr;
#ifdef CC_MAPLE_CUST_DRV
extern UINT8 bIsMetaData;
#endif

//-----------------------------------------------------------------------------
//function Declare
//-----------------------------------------------------------------------------
/*****************************************************************************************/
/********************************   SYSTEM & DEBUG     ***********************************/
/*****************************************************************************************/
void vApiVideoPeInit(void);
void vApiApplyPQSetting(UINT8 bPath);
void vApiApplyVideoEvent(UINT8 bApplyTime);
void vApiRegisterVideoEvent(UINT8 bVdpArg, UINT8 bPath, UINT8 bOnOff);
void vApiRegisterVideoEventByApplyTime(UINT8 bVdpArg, UINT8 bPath, UINT8 bOnOff, UINT8 bApplyTime);
void vApiVideoDemoMode(UINT8 bmode, Region DemoRec, UINT16 bDEMOModules);
UINT8 bApiVideoProc(UINT8 u1VidPath, PE_ARG_TYPE u1UiItem);
UINT32 PE_SetArg(UCHAR ucVdpId, PE_ARG_TYPE ucArg, INT16 i2Value);
UINT32 PE_GetArg(UCHAR ucVdpId, PE_ARG_TYPE ucArg, INT16* pi2Value);
INT32 PE_SetPqInfo(UCHAR ucVdpId, UINT32 u4PqType, const void* pkvPqSetInfo, UINT32 u4Size);
INT32 PE_GetPqInfo(UCHAR ucVdpId, UINT32 u4PqType, void* pkvPqGetInfo, UINT32 u4Size);
UINT8 bApiGetPeUiDebugMode(void);
void vApiSetPeUiDebugMode(UINT8 bOnOff);
void DRVCUST_GetLcdimPanelOrder(UINT8 *u1PanelOrder, UINT8 u1BlockNum);
void DRVCUST_GetLcdimPanelDimGain(UINT8 *u1PanelDimGain, UINT8 u1BlockNum);
void vApiCustTimCheck(void);
BOOL vApiCustTimLengthVerify(void);


/*****************************************************************************************/
/********************************   QUALITY TABLE    ***********************************/
/*****************************************************************************************/
void PE_InitUiRange(void);
void PE_SetUiPicMode(UINT8 u1PicMode);
void PE_SetUiRange(UINT8 u1VdpVisType, PE_ARG_TYPE ucArgType, PE_UI_RANGE_T *prUiRange);
UINT32 PE_GetUiRange(UINT8 u1VidPath, PE_ARG_TYPE ucArgType, PE_UI_RANGE_T *prUiRange);

void bApiSetPWMDft(void);
void bApiParseCustomQtyItem(void);
UINT8 bApiSetQtyDft(UINT8 u1SrcTypTmg, UINT32 u4UiItem, UINT16 u2Value);
UINT8 bApiGetCustomSourceTypeTiming(UINT8 bSrcTypTmg);
UINT8 u1ApiVidInSrcType2VisType(UINT8 u1SrcTypTmg);
UINT8 bApiGetQtyDft(UINT16 wSearchItem, UINT8 bQtyIdx);
UINT8 bApiGetQtyMin(UINT16 u2QtyItem);
UINT8 bApiGetQtyMax(UINT16 u2QtyItem);
UINT16 bApiQtyMapping(UINT8 u1QtyIndex, UINT16 u2QtyItem,
                     INT16 const i2Min, INT16 const i2Max,
                     INT16 const i2Dft, INT16 const i2Cur);
void vApiSetMmpSourceType(UINT8 VidPath, SV_MMP_TYPE_E bVideoType);
UINT8 vApiGetMmpSourceType(UINT8 VidPath);

/*****************************************************************************************/
/************************************   FLASHPQ    *************************************/
/*****************************************************************************************/
void vApiFlashPqReadFlash(UINT8 bIndex, UINT64 u8Offset, UPTR u4MemPtr, UINT32 u4MemLen);
void vApiFlashLdReadFlash(UPTR u4MemPtr, UINT32 u4MemLen);
void vApiFlashPqSetGammaId(UINT8 bIndex);
void vApiFlashPqSetSmartPicId(UINT8 bIndex);
void vApiFlashPqSetSceId(UINT8 bIndex);
void vApiFlashPqSetOdId(UINT8 bIndex);
UINT8 * bApiFlashPqGetVersion(UINT8 bIndex, UINT8 bType);
UINT8 bApiFlashPqGetVersionLength(UINT8 bIndex, UINT8 bType);
UINT8 bApiFlashPqVerifyHeader(UINT8 bIndex);
UINT8 vApiFlashPqGetSmartPicId(void);
UINT8 bApiFlashPqUpdateGamma(void);
UINT8 bApiFlashPqUpdateSCE(void);
UINT8 bApiFlashPqUpdateQtyDft(UINT8 bIndex);
UINT8 bApiFlashPqUpdateQtyMinMax(UINT8 u1VidPath, UINT8 bIndex);
UINT8 bApiFlashPqUpdateOD(void);
UINT8 bApiFlashPqUpdatePanelTable(void);
UINT16 vApiFlashPqGetGammaId(void);
UINT16 vApiFlashPqGetSceId(void);
UINT16 vApiFlashPqGetLceId(void);

UINT8 bApiFlashPqRawDataInit(void);
UINT16 u2ApiFlashPqGetRawDataTblId(void);
UINT16 u2ApiFlashPqGetRawDataCaseId(void);
void vApiFlashPqSetRawDataTblId(UINT16 u2Index);
void vApiFlashPqSetRawDataCaseId(UINT16 u2Index);
UINT8 bApiFlashPqUpdateRawDataEx(UINT16 u2TblId, UINT16 u2CaseId);
UINT8 bApiFlashLdGetInfo(LdInfo* LdInfo_Inst);
UINT8 bApiFlashPqGetRawDataInfo(RAWDATA_INFO* pstInfo);
UINT8 bApiFlashPqGetRawDataInfo_SMT(UINT16 u2TblId, UINT16 u2CaseId, RAWDATA_INFO* pstInfo);
UINT8 bApiFlashPqUpdateRawData(void);
UINT8 bApiFlashPqUpdateRawData_SMT(UINT16 u2TblId, UINT16 u2CaseId, UINT32 **pRegTbl, UINT8 **pDataTbl);
UINT8 bApiFlashPqSetRawData(UINT16 u2RegNum, UINT32 *pRegTbl, UINT8* pDataTbl);
UINT8 bApiFlashPqIsSupportSCEbySource(UINT8 index);
UINT16 wApiFlashPqGetSceIndexBySrcTiming(UINT16 u1SrcTypTmg);
UINT8 uApiFlashPqGetSceSrcNum(UINT8 index);
//void vApiFlashPqSetTiming(UINT8 u1TypeTiming);
UINT16 vApiFlashPqGetMinSceId(void);
UINT16 vApiFlashPqGetQtyId(UINT8 bIndex) ;
UINT16 vApiFlashPqGetOdId(void);
UINT16 wApiFlashPqGetPanelId(void);
UINT8 bApiFlashPqSystemInfo(void);
#ifdef CC_ENABLE_MTK_MODEL_INDEX
UINT16 vApiFlashaqGetQtyId(UINT8 bIndex);
#endif
#ifdef CC_MAPLE_CUST_DRV
void vApiFlashPqSetLceId(UINT8 bIndex);
#endif
/*****************************************************************************************/
/*****************************    CUSTOMER DRIVER    *************************************/
/*****************************************************************************************/
void DRVCUST_AutoColorTempUpdate(AUTO_COLORTEMP_SETS_INFO_T *aCTInfo);
void DRVCUST_PANEL_GAMMA_REMAP(UINT32 u4GammaSel);
void DRVCUST_PanelGammaRemapProc(void);
void DRVCUST_SET_GAMMA(void);
void DRVCUST_SetGammaRemapForceLoad(UINT8 bForceLoadGamma);
UINT8 DRVCUST_EepromReadByte(UINT16 waddr);
BOOL DRVCUST_EepromWriteByte(UINT16 waddr, UINT8 u1Data);
#ifdef CC_S_PLATFORM
UINT8 DRVCUST_DoubleEepromWrite(UINT64 u8Offset, UPTR u4MemPtr, UINT32 u4MemLen);
#endif
UINT8 DRVCUST_AutoNRDefSet(void);
UINT8 DRVCUST_NoiseLevel(void);
UINT32 DRVCUST_RGBOfstRemap(UINT32 u4Value);
void DRVCUST_SetODTable(void);
void DRVCUST_SET_MAUNAL_GAMMA(INT32 i4GammaCtrlPts[3][11]);
void DRVCUST_SendEvent(E_CUST_EVENT eCustEvent, UINT8 u1Option);
void DRVCUST_SendEcsCommand(UINT8* pData, UINT32 u4Size);
void DRVCUST_SetBEGeneralData(UINT8* pData, UINT8 u1Size);
void DRVCUST_PanelPowerStateToBe(BOOL bOnOff);
UINT8 DRVCUST_GET_CTMode(void);
UINT8 DRVCUST_GetPathByBeHandle(UINT8 u4BeHandle);
UINT8 DRVCUST_BE_Connect(UINT8 u1TxPath, UINT8 u1BeSclType , UINT8 u1PlaneOrder, UINT8 bPath);
UINT8 DRVCUST_BE_Disconnect(UINT8 u1TxPath, UINT8 bPath);
void DRVCUST_PQ_Associate(UINT8 bPqPath, UINT8 bPath);
void DRVCUST_PQ_Disassociate(UINT8 bPqPath);

BOOL DRVCUST_HDMIWithValidAviInfo(void);
BOOL DRVCUST_HDMIIsPhotoMode(void);
UINT8 DRVCUST_HDMIGetVideoColorSpace(void);
UINT8 DRVCUST_HDMIGetPhotoColorSpace(void);
UINT8 DRVCUST_HDMIGetColorimetry(void);
UINT8 DRVCUST_HDMIGetAspectRatio(void);
UINT8 DRVCUST_HDMIGetSDHDRange(UINT8 u1Type);
BOOL DRVCUST_HDMIGetHDRInfo(UINT8 bPath, SV_HDR_INFO_T* prHDRInfo);
UINT8 DRVCUST_HDMIGetColorSpace(UINT8 bPath);
void DRVCUST_SharpnessEnhanceEn(UINT8 u1Onoff);
#ifdef CC_MAPLE_CUST_DRV
UINT8 DRVCUST_GetSrsStatus(void);
void DRVCUST_SRSOnOff(UINT8 u1Onoff);
void DRVCUST_SetVideoRange(UINT8 bMode);
UINT8 DRVCUST_GetVideoRange(UINT8 bPath);
UINT8 DRVCUST_HDMIGetHDRType(UINT8 bPath);
UINT8 DRVCUST_MMGetHDRType(UINT8 bPath);
UINT8 DRVCUST_MMGetColorSpace(UINT8 bPath);
UINT8 DRVCUST_GetIsPIP(void);
UINT8 DRVCUST_GetVP9HDRType(void);
UINT8 DRVCUST_HDMIGetVideoColorSpace(void);
UINT8 DRVCUST_MMGetColorSpace(UINT8 bPath);
void DRVCUST_SetOSDHDRMatrixCoeff(void);
void DRVCUST_Resume(void);
void DRVCUST_GetConTblMtxDFT_PRE(UINT8 u1Input);
void DRVCUST_GetConTblMtxDFT_OS(UINT8 u1Input);
void DRVCUST_GetConTblMtxDFT_XV1(UINT8 u1Input);
void DRVCUST_GetConTblMtxDFT_R2Y(UINT8 u1Input);
BOOL DRVCUST_GetDVMMPInputFlag(void);

void DRVCUST_COL_CON_PARAM_INIT(void);
UINT8 DRVCUST_SetConTblDFT(UINT8 u1input, UINT8 u1blk, UINT8 u1src, UINT8 u1dst);
extern void vDrvLCEUpdateBitPlusParam(void);
#endif

void DRVCUST_SharpnessEnhanceCFGInit(void);
UINT16 DRVCUST_QtyUIMapping(UINT8 u1SrcTypTmg, UINT16 u2QtyItem, INT32 i4UiRangeMin, INT32 i4UiRangeDft,INT32 i4UiRangeMax,INT16 i2Min, INT16 i2Max, INT16 i2Dft, INT16 i2Cur);
UINT8 DRVCUST_GetCustomSourceTypeTiming(UINT8 bCustomSrcTypTmg);
void vDrvBluLightStrUIRemap(UINT8 u1Value);
#ifdef CC_S_PLATFORM
UINT8 DRVCUST_GetUISmartPicId(void);
#endif

#ifdef PHILIPS_D_INTERFACE_SUPPORT
void DRVCUST_PQBBeforeSocOutputChang(void);
void DRVCUST_PQBAfterSocOutputChanged(UINT32 u4OutputHeigt,UINT32 u4OutputWidth,UINT8 u4OutputFrameRate);
#endif

void DRVCUST_SetMacbethOnOff(UINT8 bOnoff, UINT16 u2Ylvl, UINT16 u2Ulvl, UINT16 u2Vlvl);
void DRVCUST_SetPGAM_EN(UINT8 bOnoff);
void DRVCUST_SetUWBFLAT(UINT8 bOnoff);
UINT8 DRVCUST_EepromReadByte(UINT16 waddr);


// Dynamic Backlight / Customer Backlight Driver
void DRVCUST_AutoBacklightUpdate(AUTO_BACKLIGHT_SETS_INFO_T *aBLight);
void DRVCUST_UpdateBacklightState(UINT8 u1State, UINT16 u2Duty);
void DRVCUST_SetBacklightDuty(UINT8 u1RefIndex, UINT16 u2Duty);
void DRVCUST_AdaptiveBacklightParam(UINT8 bMode);
void DRVCUST_AdaptiveBacklightInit(void);
void DRVCUST_AdaptiveBacklightProc(void);
void DRVCUST_CalVideoColorMatrix(UINT8 bPath, UINT16 wBriValue, UINT16 wContValue, UINT16 wSatValue, UINT16 wHueValue);

/*****************************************************************************************/
/*********************************      NR     *****************************************/
/*****************************************************************************************/
void vApiVideo3DNROnOff(UINT8 bOnOff);
void vApiVideoNRTIIROnOff(UINT8 bOnOff);
void vApiVideoSRMNRYCOnOff(UINT8 bYOnOff, UINT8 bCOnOff);
void vApiVideo2DNROnOff(UINT8 bOnOff);
void vApiVideoMPEGNROnOff(UINT8 bOnOff);

/*****************************************************************************************/
/*****************************************  SRS *******************************************/
/*****************************************************************************************/

void vHalVideoSrsOnOff(UINT8 bPath, UINT8 bOnOff);

/*****************************************************************************************/
/************************************  SHARPNESS  *****************************************/
/*****************************************************************************************/
void vHalVideoSharpnessOnOff(UINT8 bPath, UINT8 bOnOff);
void vHalVideoSharpnessHorizontalOnOff(UINT8 bPath, UINT8 bOnOff);
void vHalVideoSharpnessVerticalOnOff(UINT8 bPath, UINT8 bOnOff);
void vHalVideoSharpnessDiagonalOnOff(UINT8 bPath, UINT8 bOnOff);
void vHalVideoLTIOnOff(UINT8 u1VidPath, UINT8 bOnOff);
void vHalVideoLTIParam(UINT8 u1VidPath);
void vHalVideoSharpnessParam(UINT8 bPath);
void vHalVideoSharpnessParamHorizontal(UINT8 bPath);
void vHalVideoSharpnessParamVertical(UINT8 bPath);
void vHalVideoSharpnessParamDiagonal(UINT8 bPath);
void vHalVideoLTIParam(UINT8 u1VidPath);
void vHalVideoSuperResolutionOnOff(UINT8 bPath, UINT8 bOnOff);
void vHalVideoIRRParam(void);
void vHalVideoFreqAnalyzeParam(void);

#ifdef CC_FBM_SUPPORT_SRS
#ifndef CC_MTK_LOADER
void vDrvLoadSRSCtrlTBL(SRS_TBL_SEL bSRSTbl);
UINT32 IS_SupportSRS(void);
#endif
#endif
/*****************************************************************************************/
/********************************  ADAPTIVE LUMA    **************************************/
/*****************************************************************************************/
void vHalVideoAdaptiveLumaOnOff(UINT8 bPath, UINT8 bOnOff);
void vHalVideoAdaptiveLumaParam(void);
/*****************************************************************************************/
/**********************************  LOCAL CONSTRAST  ***************************************/
/*****************************************************************************************/
#ifdef CC_LCE_SUPPORT
void vHalVideoLocalContrastOnOff(UINT8 bPath, UINT8 bOnOff);
void vHalVideoAdaptivLocalContrastParam(void);
void vHalVideoLocalContrastHWOnOff(UINT8 bPath, UINT8 bOnOff);
extern void vDrvLCEOnOff(UINT8 bOnOff);
extern void vDrvLCEHWOnOff(UINT8 bOnOff);
extern void vDrvLCETraceLOGOnOff(UINT8 bOnOff);
extern void vDrvLCEUpdateParam(void);
extern void LCEvDrvCalcOfstByAPL_AFTER_SPIKE_Interpolation(UINT8 u1Ofst,UINT8 u1OfstArray[17]); //ofst 128 means 0
extern UINT8 LCEvDrvCalcOfstByAPL_AFTER_SPIKE(UINT32 u4APLIN );


void Trace_LCE(UINT8 u1Mode,CHAR *pcFileName);
void LCE_Trace_LOG(const CHAR *pcFileName, const CHAR *ps_format, ...);
extern void vDrvLCEDemo(UINT8 bOnOff, LCE_DEMO_MODE u1Tyoe);
#endif

/*****************************************************************************************/
/********************************  LOCAL DIMMING    **************************************/
/*****************************************************************************************/
void vHalVideoLcDimOnOff(UINT8 bPath, UINT8 bOnOff);

/*****************************************************************************************/
/******************   CONTRAST BRIGHTNESS SATURATION HUE**********************************/
/*****************************************************************************************/
void vHalVideoContrast(UINT8 bPath, UINT16 u2Value);
void vHalVideoBrightness(UINT8 bPath, UINT8 bValue);
void vHalVideoSaturation(UINT8 bPath, UINT16 u2Value);
void vHalVideoHue(UINT8 bPath, UINT8 bValue);

/*****************************************************************************************/
/*************************************   SCE   *******************************************/
/*****************************************************************************************/
void vHalVideoSCEOnOff(UINT8 bPath);
void vHalSetSCEPat(UINT8 bOnOff, UINT16 wYdata);
void vHalSetSCEAngular(UINT8 bmodule, UINT8 bColor, UINT8 bValue);
void vHalSetColorFilter(UINT8 bPath, UINT8 bColor, UINT8 bOnOff);

/*****************************************************************************************/
/************************************   CTI  *******************************************/
/*****************************************************************************************/
void vHalVideoCTIOnOff(UINT8 bPath, UINT8 bOnOff);
void vHalVideoCTIParam(UINT8 bPath);

/*****************************************************************************************/
/*******************************   RGB GAIN  & OFFSET ************************************/
/*****************************************************************************************/
void vHalVideoRGBGain(UINT8 bPath, UINT8 bRGB, UINT16 wValue);
void vHalVideoRGBOffset(UINT8 bPath, UINT8 bRGB, UINT16 wValue);
void vHalVideoRGBOffset2(UINT8 bPath, UINT8 bRGB, UINT16 wValue);

/**************************************************************************************/
/***********************************Bypass All PQ Item****************************************/
/**************************************************************************************/
void vApiVideoAllPQItemOnOff(UINT8 bOnOff);
/******************************************************************************************/
/***********************************  PQ Module OnOff  *********************************/
/******************************************************************************************/
void vApiVideoPqModuleOnOff(void);

/*****************************************************************************************/
/************************************  Gamma  ********************************************/
/*****************************************************************************************/
void vHalVideoGammaLoadTable(void);
void vHalVideoGammaLoadTableEX(void);
void vHalVideoGammaTblUpdate(UINT8 u1Mode);
void vHalVideoExternalGammaInit(void);
void vApiGammaInit(void);

/*****************************************************************************************/
/************************************  Noise Reduction  **********************************/
/*****************************************************************************************/
void vHalVideo2DAutoNROnOff(UINT8 bOnOff);
void vHalVideo3DAutoNROnOff(UINT8 bOnOff);
void vHalVideoAutoMDPTNROnOff(UINT8 bOnOff);
void vHalVideo2DNRParam(UINT8 bCurUI);
void vHalVideo3DNRParam(UINT8 bCurUI);
void vHalVideoMDPTNRParam(UINT8 bCurUI);
void vHalVideo3DNRStrength(UINT8 u1CurUI);
void vHalVideoMDPTNRStrength(UINT8 u1CurUI);
void vHalVideoMPEGNRParam(UINT8 bCurUI);

/*****************************************************************************************/
/***************************************  White Peak  ************************************/
/*****************************************************************************************/
void vHalVideoWhitePeakLimit(UINT8 bOnOff);

/*****************************************************************************************/
/************************************  Adaptive Backlight  *******************************/
/*****************************************************************************************/
void vHalSetAdpBacklight(UINT8 u1Level, UINT8 u1Value);
UINT8 bHalGetAdpBacklight(UINT8 u1Level);

void vHalOutRGBColorOnOff(UINT8 bOnOff);
void vHalOutRGBColor(UINT8 RValue, UINT8 GValue, UINT8 BValue);
/*****************************************************************************************/
/********************************** HDR2SDR  ****************************************/
/*****************************************************************************************/
void vDrvHDRHWInit(void);
void vDrvNXNRHDRSetParam(void);
void vDrvNXNRHDRUpdateSizeLoop(UINT32 u4InW, UINT32 u4InH);
void vDrvSetNXNRHDRDBOnOff(UINT8 bOnOff);
void vDrvHDRSWInit(void);
void vDrvHDRModeChange(void);
void vDrvHDRSetQualityISR(void);
void vDrvHDRTypeMap(UINT8 bSrc, UINT8 u1EotfValue);
void vDrvHDMI2HDRChangeNotify(void);
void vDrvMPEGHDRChangeNotify(void);
void vDrvHDRSeamlessTrigger(void);
void vDrvHDRDemo(UINT8 bOnOff, UINT8 bRegion);
void vDrvSetHDRBypass(UINT8 u1OnOff);
void vDrvSetHDREnable(UINT8);
UINT8 vDrvGetHDREnable(void);
UINT8 vDrvGetOpenHDRFlag(void);
void vDrvSetHDRPanelNits(UINT16 panelnits);
UINT16 vDrvGetPanelNit(void);
void vDrvSetHDRDynamicEnable(UINT8 u1Enable);
void DRVCUST_SET_HDRTruncateMode(UINT8 u1Enable);
void DRVCUST_SET_HDRPureMode(UINT8 u1OnOff);
void vDrvSetDemoWindowEnable(UINT8 u1Enable);
void vDrvHDRDemoSetRegion(Region rDemoRegion, UINT8 u1Mode);
void vDrvHDRQueryStatus(void);
void vDrvGetHWHDREOTF(void);
void vDrvCLITestWriteGainCurve(void);
void vDrvCLITestReadGainCurve(void);
void vDrvCLITestReadEOTF(void);
void vDrvCLITestWriteEOTF(UINT8 u8Index);
void vDrvCLITestReadOETF(void);
void vDrvCLITestWriteOETF(UINT8 u8Index);
void vDrvCLIGetHistInfoHW(UINT8 u8Index);
void vDrvHDRTrace(UINT8 u1Mode,UINT8 u1Count,const CHAR *pcFileName);
void vDrvSetHDREOTF(UINT8 u1VidPath,UINT16 u2EotfValue);
void u1DRVCUST_LoadHDRGammaTbl(void);
UINT16 DRVCUST_GetPanelNits(void);
PANEL_GAMUT_T DRVCUST_GetPanelGamut(void);
UINT8 DRVCUST_GetPanelMode(void);
TONE_MAP_T DRVCUST_GetToneMap(void);
BOOL vDrvGetHDRCapabilities(UINT32* u4OutNumTypes, UINT32* u4Types, UINT32* u4maxLuminance, UINT32* u4maxAverageLuminance, UINT32* u4minLuminance );
UINT8 vDrvGetHDRFlag(void);

#ifdef CC_SUPPORT_HDR10Plus
/********************************** HDR10 Plus  ****************************************/
void vMsgMLInit(void);
void vMsg_SendEvent(MSG_T tMsg);
void vDrvHDR10PlusMetadataParse(MSG_T rMsg);
void vDrvHDR10PlusProc(void);
void vDrvHDR10PlusModeChange(void);
UINT8 vDrvIsHDR10Plus(void);
void vDrvHDR10PlusInfo(void);
void vDrvHDR10PlusOriginalInfo(void);
void vDrvHDR10PlusSWInit(void);
#endif

#ifdef CC_SUPPORT_SUB_HDR
/**********************************SUB HDR****************************************/
void vDrvSubHDRHWInit(void);
void vDrvSubHDRSWInit(void);
void vDrvSubHDRModeChange(void);
void vDrvSubHDRSetQualityISR(void);
void vDrvSubHDRTypeMap(UINT8 bSrc, UINT8 u1EotfValue);
void vDrvSubHDRDemo(UINT8 bOnOff, UINT8 bRegion);
void vDrvSetSubHDRBypass(UINT8 u1OnOff);
void vDrvSetSubHDREnable(UINT8);
UINT8 vDrvGetSubHDREnable(void);
UINT8 vDrvGetSubOpenHDRFlag(void);
void vDrvSetSubHDRPanelNits(UINT16 panelnits);
UINT16 vDrvGetSubPanelNit(void);
void vDrvSetSubHDRDynamicEnable(UINT8 u1Enable);
void DRVCUST_SET_SubHDRTruncateMode(UINT8 u1Enable);
void DRVCUST_SET_SubHDRPureMode(UINT8 u1OnOff);
void vDrvSetSubDemoWindowEnable(UINT8 u1Enable);
void vDrvSubHDRDemoSetRegion(Region rDemoRegion, UINT8 u1Mode);
void vDrvSubHDRQueryStatus(void);
void vDrvGetHWSubHDREOTF(void);
void vDrvCLITestWriteSubGainCurve(void);
void vDrvCLITestReadSubGainCurve(void);
void vDrvCLITestReadSubEOTF(void);
void vDrvCLITestWriteSubEOTF(UINT8 u8Index);
void vDrvCLITestReadSubOETF(void);
void vDrvCLITestWriteSubOETF(UINT8 u8Index);
void vDrvCLIGetSubHistInfoHW(UINT8 u8Index);

#endif

/********************************** BLUE STRETCH  ****************************************/
/*****************************************************************************************/
void vHalVideoBlueStretchOnOff(UINT8 bPath, UINT8 bOnOff);
/******************************************************************************************/
/****************************************  LED Motion  **************************************/
/******************************************************************************************/
void vHalVideoLEDMotion(UINT8 OnOff);
BOOL DRVCUST_GetLEDMotionFlag(void);

/*****************************************************************************************/
/********************************** Demo Mode Region  ****************************************/
/*****************************************************************************************/
UINT32 DRVCUST_DemoRegion(void);
UINT32 DRVCUST_DemoModule(void);
INT32 PE_SetIMTFlag(UINT32 ucVdpId,UINT32 prData);
UINT8 vDrvVerfPETable(void);
#endif /* _PE_IF_H_ */

