/**
 * @file hv_app_DdcciPQ.c
 * @brief ddcci for TPV PQ Factory mode.
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2024-05-06
 * @copyright Copyright(c),2022-8, Hiview Software. All rights reserved.
 * @par History:
 * <table>
 * <tr><th>Author       <th>Date            <th>Change Description
 * <tr><td>HiView SoC Software Team    <td>2024-05-06      <td>create
 * </table>
 */


#include "hv_app_DdcciPQ.h"
#include "hv_comm_DataBase.h"
#include "hv_comm_PqDef.h"
#include "hv_mw_PQ.h"
#include "hv_app_PQ.h"

#if 0
typedef enum _PQSetFlag
{
    PQ_FAC_SET_NO_SAVE = 0,
    PQ_FAC_SET_SAVE,
}PQSetFlag;

typedef enum _PQSaveFlag
{
    PQ_FAC_SAVE = 0,
    PQ_FAC_RECALL,
}PQSaveFlag;

static ColorTemperature s_stColorTemp = {0};
static UCHAR8  s_ucTempSaveFlg = 0;
USHORT16 Hv_App_Ddcci_PQ_GetRGBGainMaxVal(VOID)
{
    return (USHORT16)HV_COMMON_DATABASE_GET(FactoryData, ucRGBGainMaxVal);
}

VOID Hv_App_Ddcci_PQ_SetRGain(USHORT16 usRed)
{
    UCHAR8 ucRed = (UCHAR8)(usRed & 0x00FF);
    Hv_App_PQ_SetRGainFac(ucRed);
    s_stColorTemp.ucColorTempRGain = ucRed;
    s_ucTempSaveFlg |= BIT(0);
    return;
}

USHORT16 Hv_App_Ddcci_PQ_GetRGain(VOID)
{
    return HV_PQ_DATABASE_GET(DiagData, usDBRGainFac);
}

VOID Hv_App_Ddcci_PQ_SetGGain(USHORT16 usGreen)
{
    UCHAR8 ucGreen = (UCHAR8)(usGreen & 0x00FF);
    Hv_App_PQ_SetGGainFac(ucGreen);
    s_stColorTemp.ucColorTempGGain = ucGreen;
    s_ucTempSaveFlg |= BIT(1);
    return;
}

USHORT16 Hv_App_Ddcci_PQ_GetGGain(VOID)
{
    return HV_PQ_DATABASE_GET(DiagData, usDBGGainFac);
}

VOID Hv_App_Ddcci_PQ_SetBGain(USHORT16 usBlue)
{
    UCHAR8 ucBlue = (UCHAR8)(usBlue & 0x00FF);
    Hv_App_PQ_SetBGainFac(ucBlue);
    s_stColorTemp.ucColorTempBGain = ucBlue;
    s_ucTempSaveFlg |= BIT(2);
    return;
}

USHORT16 Hv_App_Ddcci_PQ_GetBGain(VOID)
{
    return HV_PQ_DATABASE_GET(DiagData, usDBBGainFac);
}


VOID Hv_App_Ddcci_PQ_SetROffset(USHORT16 usRed)
{
    UCHAR8 ucRed = (UCHAR8)(usRed & 0x00FF);
    Hv_App_PQ_SetROffsetFac(ucRed);
    s_stColorTemp.ucColorTempROffset = ucRed;
    s_ucTempSaveFlg |= BIT(3);
    return;
}

USHORT16 Hv_App_Ddcci_PQ_GetROffset(VOID)
{
    return HV_PQ_DATABASE_GET(DiagData, usDBROffsetFac);
}

VOID Hv_App_Ddcci_PQ_SetGOffset(USHORT16 usGreen)
{
    UCHAR8 ucGreen = (UCHAR8)(usGreen & 0x00FF);
    Hv_App_PQ_SetGOffsetFac(ucGreen);
    s_stColorTemp.ucColorTempGOffset = ucGreen;
    s_ucTempSaveFlg |= BIT(4);
    return;
}

USHORT16 Hv_App_Ddcci_PQ_GetGOffset(VOID)
{
    return HV_PQ_DATABASE_GET(DiagData, usDBGOffsetFac);
}

VOID Hv_App_Ddcci_PQ_SetBOffset(USHORT16 usBlue)
{
    UCHAR8 ucBlue = (UCHAR8)(usBlue & 0x00FF);
    Hv_App_PQ_SetBOffsetFac(ucBlue);
    s_stColorTemp.ucColorTempBOffset = ucBlue;
    s_ucTempSaveFlg |= BIT(5);
    return;
}

USHORT16 Hv_App_Ddcci_PQ_GetBOffset(VOID)
{
    return HV_PQ_DATABASE_GET(DiagData, usDBBOffsetFac);
}

VOID Hv_App_Ddcci_PQ_SetContrast(UCHAR8 ucVal)
{
    Hv_App_PQ_SetContrast(ucVal);
    HV_PQ_DATABASE_SET(FactoryData, ucFactoryContrast, ucVal);
    return;
}

UCHAR8 Hv_App_Ddcci_PQ_GetContrast(VOID)
{
    return HV_PQ_DATABASE_GET(FactoryData, ucFactoryContrast);
}

VOID Hv_App_Ddcci_PQ_SetBrightness(UCHAR8 ucVal)
{
    Hv_App_PQ_SetBrightness(ucVal);
    HV_PQ_DATABASE_SET(FactoryData, ucFactoryBrightness, ucVal);
    
    return;
}

UCHAR8 Hv_App_Ddcci_PQ_GetBrightness(VOID)
{
    return Hv_App_PQ_GetBrightness();
}

VOID Hv_App_Ddcci_PQ_SetDefaultBrightness(UCHAR8 ucVal, UCHAR8 ucAct)
{
    Hv_App_PQ_SetBrightness(ucVal);
    if (HV_TRUE == ucAct)
    {
        HV_PQ_DATABASE_SET(FactoryData, ucFactoryBrightness, ucVal);
    }

    return;
}

UCHAR8 Hv_App_Ddcci_PQ_GetDefaultBrightness(VOID)
{
    return HV_PQ_DATABASE_GET(FactoryData, ucFactoryBrightness);
}

VOID Hv_App_Ddcci_PQ_SetSubBrightness(UCHAR8 ucVal, UCHAR8 ucFlag)
{
    /* reserved for HP */
    return;
}

UCHAR8 Hv_App_Ddcci_PQ_GetSubBrightness(VOID)
{
    /* reserved for HP */
    return 0;
}

VOID Hv_App_Ddcci_PQ_SetTextModeBrightness(UCHAR8 ucVal, UCHAR8 ucFlag)
{
    /* reserved for Dell */
    return;
}

UCHAR8 Hv_App_Ddcci_PQ_GetTextModeBrightness(VOID)
{
    /* reserved for Dell */
    return 0;
}

VOID Hv_App_Ddcci_PQ_SetReadModeBrightness(UCHAR8 ucVal, UCHAR8 ucFlag)
{
    /* reserved for Dell */
    return;
}

UCHAR8 Hv_App_Ddcci_PQ_GetReadModeBrightness(VOID)
{
    /* reserved for Dell */
    return 0;
}

VOID Hv_App_Ddcci_PQ_SetCECModeBrightness(USHORT16 usVal, UCHAR8 ucFlag)
{
    USHORT16 usBrightnessRealVal;
    if (PQ_FAC_SET_SAVE == ucFlag)
    {
        HV_COMMON_DATABASE_SET(FactoryData, usCECBrightness, usVal);
        Hv_App_PQ_SetBrightness(Hv_App_Ddcci_PQ_GetBrightness());
    }
    else
    {
        usBrightnessRealVal = LINEAR_MAPPING_VALUE(Hv_App_Ddcci_PQ_GetBrightness(), PQ_BRIGHTNESS_OSD_START, PQ_BRIGHTNESS_OSD_END, 
            PQ_BRIGHTNESS_DRV_FOR_OSD_SET_START, usVal);
        Hv_Mw_PQ_SetKspiDemoData(usBrightnessRealVal);
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SetMaxBrightnessDuty(USHORT16 usVal, UCHAR8 ucFlag)
{
    USHORT16 usBrightnessRealVal;
    if (PQ_FAC_SET_SAVE == ucFlag)
    {
        HV_COMMON_DATABASE_SET(FactoryData, usMaxBrightnessDuty, usVal);
        Hv_App_PQ_SetBrightness(Hv_App_Ddcci_PQ_GetBrightness());
    }
    else
    {
        usBrightnessRealVal = LINEAR_MAPPING_VALUE(Hv_App_Ddcci_PQ_GetBrightness(), PQ_BRIGHTNESS_OSD_START, PQ_BRIGHTNESS_OSD_END, 
            PQ_BRIGHTNESS_DRV_FOR_OSD_SET_START, usVal);
        Hv_Mw_PQ_SetKspiDemoData(usBrightnessRealVal);
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SetSRGBBrightness(UCHAR8 ucVal, UCHAR8 ucFlag)
{
    /* reserved for ASUS */
    return;
}

UCHAR8 Hv_App_Ddcci_PQ_GetSRGBBrightness(VOID)
{
    /* reserved for ASUS */
    return 0;
}


static VOID PQ_SaveColor(ColorTemperature stColTemp)
{
    /* 如果对应参数没被修改，需要从fac中读取默认值 */
    if ((s_ucTempSaveFlg && BIT(0)) == 0)
    {
        s_stColorTemp.ucColorTempRGain = stColTemp.ucColorTempRGain;
    }
    if ((s_ucTempSaveFlg && BIT(1)) == 0)
    {
        s_stColorTemp.ucColorTempGGain = stColTemp.ucColorTempGGain;
    }
    if ((s_ucTempSaveFlg && BIT(2)) == 0)
    {
        s_stColorTemp.ucColorTempBGain = stColTemp.ucColorTempBGain;
    }
    if ((s_ucTempSaveFlg && BIT(3)) == 0)
    {
        s_stColorTemp.ucColorTempROffset = stColTemp.ucColorTempROffset;
    }
    if ((s_ucTempSaveFlg && BIT(4)) == 0)
    {
        s_stColorTemp.ucColorTempGOffset = stColTemp.ucColorTempGOffset;
    }
    if ((s_ucTempSaveFlg && BIT(5)) == 0)
    {
        s_stColorTemp.ucColorTempBOffset = stColTemp.ucColorTempBOffset;
    }
    s_ucTempSaveFlg = 0;

    return;
}

VOID Hv_App_Ddcci_PQ_SaveColorSRGB(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempSrgb);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTempSrgb, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTempSrgb, pstDefaultFacData->stColTempSrgb);
        Hv_App_PQ_SetGamut(GAMUT_SRGB);
    }
    else
    {

    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColorNative(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempNative);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTempNative, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTempNative, pstDefaultFacData->stColTempNative);
        Hv_App_PQ_SetGamut(GAMUT_NATIVE);
    }
    else
    {
        
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColor4000K(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTemp4000K);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp4000K, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp4000K, pstDefaultFacData->stColTemp4000K);
    }
    else
    {
        
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColor5000K(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTemp5000K);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp5000K, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp5000K, pstDefaultFacData->stColTemp5000K);
    }
    else
    {
        
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColor6500K(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTemp6500K);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp6500K, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp6500K, pstDefaultFacData->stColTemp6500K);
        Hv_App_SetFuncInterface(E_USERDATA_COLOR_SPACE,UD_COLOR_SPACE_V_PANEL_NATIVE,SET_ALL);
        Hv_App_SetFuncInterface(E_USERDATA_COLOR_TEMP,UD_COLOR_TEMP_V_WARM,SET_ALL);
    }
    else
    {
        
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColor7500K(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTemp7500K);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp7500K, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp7500K, pstDefaultFacData->stColTemp7500K);
        Hv_App_SetFuncInterface(E_USERDATA_COLOR_SPACE,UD_COLOR_SPACE_V_PANEL_NATIVE,SET_ALL);
        Hv_App_SetFuncInterface(E_USERDATA_COLOR_TEMP,UD_COLOR_TEMP_V_NORMAL,SET_ALL);
    }
    else
    {
        
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColor8200K(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTemp8200K);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp8200K, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp8200K, pstDefaultFacData->stColTemp8200K);
    }
    else
    {
        
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColor9300K(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTemp9300K);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp9300K, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp9300K, pstDefaultFacData->stColTemp9300K);
        Hv_App_SetFuncInterface(E_USERDATA_COLOR_SPACE,UD_COLOR_SPACE_V_PANEL_NATIVE,SET_ALL);		
        Hv_App_SetFuncInterface(E_USERDATA_COLOR_TEMP,UD_COLOR_TEMP_V_COOL,SET_ALL);
    }
    else
    {
        
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColor10000K(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTemp10000K);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp10000K, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp10000K, pstDefaultFacData->stColTemp10000K);
    }
    else
    {
        
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColor11500K(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTemp11500K);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp11500K, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTemp11500K, pstDefaultFacData->stColTemp11500K);
    }
    else
    {
        
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColorUser(UCHAR8 ucFlag)
{
    ColorTemperature stColTemp;
    const FactoryDataDBRegion *pstDefaultFacData;
    if (PQ_FAC_SAVE == ucFlag)
    {
        stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempUser);
        PQ_SaveColor(stColTemp);
        HV_COMMON_DATABASE_SET(FactoryData, stColTempUser, s_stColorTemp);
    }
    else if (PQ_FAC_RECALL == ucFlag)
    {
        pstDefaultFacData = Hv_Mw_DataBase_GetDefaultFactoryDataPtr();
        HV_COMMON_DATABASE_SET(FactoryData, stColTempUser, pstDefaultFacData->stColTempUser);
        Hv_App_SetFuncInterface(E_USERDATA_COLOR_TEMP,UD_COLOR_TEMP_V_USER,SET_ALL);
    }
    else
    {
        
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColorTextMode(UCHAR8 ucFlag)
{
    /* reserved for DELL */
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColorStandMode(UCHAR8 ucFlag)
{
    /* reserved for DELL */
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColorCustomMode(UCHAR8 ucFlag)
{
    /* reserved for DELL */
    return;
}

VOID Hv_App_Ddcci_PQ_SaveColorXX00K(UCHAR8 ucFlag)
{
    /* reserved for HP */
    return;
}

VOID Hv_App_Ddcci_PQ_SaveCinema(UCHAR8 ucFlag)
{
    /* reserved for HP */
    return;
}

VOID Hv_App_Ddcci_PQ_SaveGaming(UCHAR8 ucFlag)
{
    /* reserved for HP */
    return;
}

VOID Hv_App_Ddcci_PQ_SaveNative(UCHAR8 ucFlag)
{
    /* reserved for HP */
    return;
}


VOID Hv_App_Ddcci_PQ_SetHDR(UCHAR8 ucFlag)
{
    USHORT16 usBrightness;

    if (HV_ENABLE == ucFlag)
    {
        Hv_Mw_PQ_SetInpPatt(ucFlag, 3);
        usBrightness = Hv_App_PQ_GetRealValue(PQ_BRIGHTNESS_OSD_END, PQ_BRIGHTNESS_HDR);
        Hv_Mw_PQ_SetKspiDemoData(usBrightness);
    }
    else
    {
        Hv_Mw_PQ_SetInpPatt(ucFlag, 0);
        Hv_App_PQ_SetBrightness(Hv_App_Ddcci_PQ_GetBrightness());
    }
    return;
}

VOID Hv_App_Ddcci_PQ_SetHDRDuty(USHORT16 usVal)
{
    USHORT16 usBrightness  = 0;
    HV_COMMON_DATABASE_SET(FactoryData, usHDRDuty, usVal);

    usBrightness = Hv_App_PQ_GetRealValue(PQ_BRIGHTNESS_OSD_END, PQ_BRIGHTNESS_HDR);
    Hv_Mw_PQ_SetKspiDemoData(usBrightness);
    return;
}

VOID Hv_App_Ddcci_PQ_SaveMovieHDRMode(UCHAR8 ucFlag)
{
    /* reserved for DELL */
    return;
}

VOID Hv_App_Ddcci_PQ_SaveGameHDRMode(UCHAR8 ucFlag)
{
    /* reserved for DELL */
    return;
}

VOID Hv_App_Ddcci_PQ_SavePictureMode(UCHAR8 ucFlag)
{
    /* reserved for HP */
    return;
}

VOID Hv_App_Ddcci_PQ_SaveAdobeRGB(UCHAR8 ucFlag)
{
    /* reserved for HP */
    return;
}

VOID Hv_App_Ddcci_PQ_SaveBT709(UCHAR8 ucFlag)
{
    /* reserved for HP */
    return;
}

VOID Hv_App_Ddcci_PQ_SaveAllTemp(VOID)
{
    UCHAR8 ucAllTempSaveFlg = s_ucTempSaveFlg;

    Hv_App_Ddcci_PQ_SaveColorSRGB(PQ_FAC_SAVE);
    s_ucTempSaveFlg = ucAllTempSaveFlg;
    Hv_App_Ddcci_PQ_SaveColorNative(PQ_FAC_SAVE);
    s_ucTempSaveFlg = ucAllTempSaveFlg;
    Hv_App_Ddcci_PQ_SaveColor4000K(PQ_FAC_SAVE);
    s_ucTempSaveFlg = ucAllTempSaveFlg;
    Hv_App_Ddcci_PQ_SaveColor5000K(PQ_FAC_SAVE);
    s_ucTempSaveFlg = ucAllTempSaveFlg;
    Hv_App_Ddcci_PQ_SaveColor6500K(PQ_FAC_SAVE);
    s_ucTempSaveFlg = ucAllTempSaveFlg;
    Hv_App_Ddcci_PQ_SaveColor7500K(PQ_FAC_SAVE);
    s_ucTempSaveFlg = ucAllTempSaveFlg;
    Hv_App_Ddcci_PQ_SaveColor8200K(PQ_FAC_SAVE);
    s_ucTempSaveFlg = ucAllTempSaveFlg;
    Hv_App_Ddcci_PQ_SaveColor9300K(PQ_FAC_SAVE);
    s_ucTempSaveFlg = ucAllTempSaveFlg;
    Hv_App_Ddcci_PQ_SaveColor10000K(PQ_FAC_SAVE);
    s_ucTempSaveFlg = ucAllTempSaveFlg;
    Hv_App_Ddcci_PQ_SaveColor11500K(PQ_FAC_SAVE);
    s_ucTempSaveFlg = ucAllTempSaveFlg;
    Hv_App_Ddcci_PQ_SaveColorUser(PQ_FAC_SAVE);

    return;
}

VOID Hv_App_Ddcci_PQ_SelectGamma(UCHAR8 ucVal)
{
    Hv_App_PQ_SetGamma(ucVal);
    HV_COMMON_DATABASE_SET(FactoryData, ucFactoryGamma, ucVal);
    HV_COMMON_DATABASE_SET(FactoryData, bModifyFlag, HV_TRUE);
    Hv_Mw_DataBase_Sync();
    return;
}

UCHAR8 Hv_App_Ddcci_PQ_GetGamma(VOID)
{
    return HV_COMMON_DATABASE_GET(FactoryData, ucFactoryGamma);
}

VOID Hv_App_Ddcci_PQ_SetDCR(UCHAR8 ucVal)
{
    Hv_App_PQ_DynamicContrastEnable(ucVal);
    return;
}

VOID Hv_App_Ddcci_PQ_EnterCECMode(UCHAR8 ucVal, CecPara *pstCecPara)
{
    Hv_App_PQ_CECModeEn(HV_ENABLE);
    /* 设置CEC的亮度 */
    Hv_App_PQ_SetBrightness(Hv_App_PQ_GetBrightness());
    pstCecPara->usCurrentBrightness = HV_PQ_DATABASE_GET(DiagData, usDBBrightness);
    pstCecPara->usMaxBrightness = HV_COMMON_DATABASE_GET(FactoryData, usMaxBrightnessDuty);
    pstCecPara->CecMinLum = PQ_CEC_MIN_LUM;
    pstCecPara->CecMaxLum = PQ_CEC_MAX_LUM;

    return;
}

VOID Hv_App_Ddcci_PQ_ExitCECMode(UCHAR8 ucVal)
{
    Hv_App_PQ_CECModeEn(HV_DISABLE);
    /* 设置OSD默认亮度 */
    Hv_App_PQ_SetBrightness(Hv_App_PQ_GetBrightness());
    return;
}

VOID Hv_App_Ddcci_PQ_GetPanelBrightness(PQPanelPara *pstPQPanelPara)
{
    pstPQPanelPara->usPanelTypicalBright = HV_COMMON_DATABASE_GET(FactoryData, usPanelBrightness);
    pstPQPanelPara->usPanelMaxBrightness = HV_COMMON_DATABASE_GET(FactoryData, usMaxBrightnessDuty);
    return;
}
#endif