/**
 * @file hv_app_Function.c
 * @brief osd app function c file.
 * @details This file provides the following functions: \n
 *          (1) Osd operation functions \n
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-09-01
 * @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>2022-09-01      <td>create
 * </table>
 */
 
#include "hv_app_Osd.h"
#include "hv_app_PQ.h"
#include "hv_app_OsdDialog.h"
#include "hv_app_OsdMenu.h"
#include "hv_app_Function.h"
#include "hv_comm_DataBase.h"
#include "hv_mw_AppInterface.h"
#include "hv_mw_OsdLog.h"
#include "hv_mw_OsdComm.h"
#include "hv_mw_OsdDraw.h"
#include "hv_mw_OsdOperation.h"
#if (HV_OSD_CONFIG_AUTO_TEST == HV_CONFIG_ON)
#include "hv_app_OsdTest.h"
#endif

__attribute__((long_call))unsigned char Hv_Ddr_Type(void);

USHORT16 Hv_App_GetDisplayMode(VOID)
{
    return HV_COMMON_DATABASE_GET(UserData, ucDisplayMode);
}

VOID Hv_App_SetDisplayMode(UCHAR8 ucMode, UCHAR8 ucFlag)
{
    HV_ASSERT_TRUE_VOID(ucMode <= USERDATA_DISPLAY_MODE_MAX);
    UCHAR8 ucBrightness = HV_COMMON_DATABASE_GET_STARRAY(UserData, stMode, ucMode, ucBrightness);
    UCHAR8 ucContrast = HV_COMMON_DATABASE_GET_STARRAY(UserData, stMode, ucMode, ucContrast);

    HV_COMMON_DATABASE_SET(UserData, ucDisplayMode, ucMode);

    if (ucFlag & SET_RELATED)
    {
        Hv_App_OsdSetUserdata(E_USERDATA_BRIGHTNESS, GET_OSD_MAP_VALUE(E_USERDATA_BRIGHTNESS, ucBrightness));
        Hv_App_OsdSetUserdata(E_USERDATA_CONTRAST, GET_OSD_MAP_VALUE(E_USERDATA_CONTRAST, ucContrast));
    }
    if (ucFlag & SET_INTERFACE)
    {
        Hv_App_PQ_SetBrightness(ucBrightness);
        Hv_App_PQ_SetContrast(ucContrast);
    }
}

VOID Hv_App_SetDefaultSetting(BOOL bSetDefault)
{
    UCHAR8 ucBrightness = HV_COMMON_DATABASE_GET(UserData, ucBrightness);
    UCHAR8 ucContrast = HV_COMMON_DATABASE_GET(UserData, ucContrast);
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_VARIABLEBACKLIGHT)
    UCHAR8 bVariableBackLight = HV_COMMON_DATABASE_GET(UserData, bVariableBackLight);
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
    UCHAR8 ucLocalDimming = HV_COMMON_DATABASE_GET(UserData, ucLocalDimming);
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DCR)
    UCHAR8 ucDcr = HV_COMMON_DATABASE_GET(UserData, ucDcr);
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DARK_STABILIZER)
    UCHAR8 ucDarkStabilizer = HV_COMMON_DATABASE_GET(UserData, ucDarkStabilizer);
#endif
    UCHAR8 ucOsdTrans = HV_COMMON_DATABASE_GET(UserData, ucOsdTrans);
#if (HV_PROJECT_CONFIG_OSD_ROTATION == HV_CONFIG_ON)
    UCHAR8 ucOsdRotation = HV_COMMON_DATABASE_GET(UserData, ucOsdRotation);
#endif

#if 0 //TODO
    /* 亮度 */
    Hv_App_PQ_SetBrightness(bSetDefault ? USERDATA_BRIGHTNESS_DEFAULT : ucBrightness);
    /* 对比度 */
    Hv_App_PQ_SetContrast(bSetDefault ? USERDATA_CONTRAST_DEFAULT : ucContrast);

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_VARIABLEBACKLIGHT)
    /* 动态背光 */
    Hv_App_PQ_SetDCR(bSetDefault ? USERDATA_VARIABLEBACKLIGHT_DEFAULT : bVariableBackLight);
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING))
    Hv_App_PQ_LdcSetMode(ucLocalDimming);
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DCR)
    /* 动态对比度 */
    //Hv_App_PQ_DynamicContrastEnable(bSetDefault ? USERDATA_DCR_DEFAULT : ucDcr);
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DARK_STABILIZER)
    /* 暗再现 */
    Hv_App_PQ_DarkStablizer(bSetDefault ? USERDATA_DARKSTABILIZER_DEFAULT : ucDarkStabilizer);
#endif
    /* OSD透明度 */
    Hv_Mw_OsdSetTransparency(bSetDefault ? USERDATA_MENUTRANSPARENCY_DEFAULT : ucOsdTrans);
#if (HV_PROJECT_CONFIG_OSD_ROTATION == HV_CONFIG_ON)
    /* OSD旋转 */
    Hv_App_OsdSetRotateType(bSetDefault ? USERDATA_ROTATION_DEFAULT : ucOsdRotation);
#endif
#endif
}

static VOID Hv_App_HdrPqSetting(BOOL bIsHdr);

VOID Hv_App_SetFuncInterface(UserdataId enWhichData, SHORT16 sOsdValue, UCHAR8 ucFlag)
{
    OSD_LOG_DEBUG("Set userdata[%d] %s = %d, flag = 0x%x", enWhichData, Hv_App_GetUserdataName(enWhichData), sOsdValue, ucFlag);
    OsdTimingInfo *pstTiming = Hv_App_OsdGetCurrentTimingInfo();

    if (ucFlag & SET_OSDDATA)
    {
        Hv_App_OsdSetUserdata(enWhichData, sOsdValue);
    }

    if (0 == (ucFlag & (SET_INTERFACE | SET_RELATED)))
    {
        return;
    }

    SHORT16 sRealValue = GET_REAL_MAP_VALUE(enWhichData, sOsdValue);

    switch (enWhichData)
    {
        case E_USERDATA_DISPLAY_MODE:
        {
            Hv_App_SetDisplayMode(sRealValue, ucFlag);
            break;
        }

        case E_USERDATA_BRIGHTNESS:
        {
            if (ucFlag & SET_RELATED)
            {
                USHORT16 usMode = Hv_App_GetOsdDataValue(E_USERDATA_DISPLAY_MODE);
                HV_COMMON_DATABASE_SET_STARRAY(UserData, stMode, usMode, ucBrightness, sRealValue);
            }
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetBrightness(sRealValue);
            }

            break;
        }

        case E_USERDATA_CONTRAST:
        {
            if (ucFlag & SET_RELATED)
            {
                USHORT16 usMode = Hv_App_GetOsdDataValue(E_USERDATA_DISPLAY_MODE);
                HV_COMMON_DATABASE_SET_STARRAY(UserData, stMode, usMode, ucContrast, sRealValue);
            }
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetContrast(sRealValue);
            }
            break;
        }

        case E_USERDATA_HUE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetHue(sRealValue);
            }
            break;
        }

        case E_USERDATA_SATURATION:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetSaturation(sRealValue);
            }
            break;
        }

        case E_USERDATA_SHARPNESS:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetSharpness(sRealValue);
            }
            break;
        }

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DARK_STABILIZER)
        case E_USERDATA_DARKSTABILIZER:
        {
            if (ucFlag & SET_RELATED)
            {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DCR)
                if (0 != sOsdValue)
                {
                    HV_COMMON_DATABASE_SET(UserData, ucDcr, HV_FALSE);
                    Hv_App_OsdSetUserdata(E_USERDATA_DCR, UD_DCR_V_OFF);
                }
#endif
            }
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_DarkStablizer(sRealValue);
            }
            break;
        }
#endif

        case E_USERDATA_COLOR_TEMP:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetColorTemp(sRealValue, HV_COMMON_DATABASE_GET(UserData, ucLowBlueLight));
            }
            break;
        }

        case E_USERDATA_LOW_BLUE_LIGHT:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetColorTemp(HV_COMMON_DATABASE_GET(UserData, ucColorTemperature), sRealValue);
            }
            break;
        }

        case E_USERDATA_COLOR_SPACE:
        {
#if (HV_PROJECT_CONFIG_COLOR_FILTER == HV_CONFIG_ON)
            if (ucFlag & SET_RELATED)
            {
                Hv_App_OsdSetUserdata(E_USERDATA_COLOR_FILTER, UD_COLOR_FILTER_V_NONE);
            }
            UCHAR8 ucColorFilter = GET_REAL_MAP_VALUE(E_USERDATA_COLOR_FILTER, UD_COLOR_FILTER_V_NONE);
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetColorFilterType(ucColorFilter);
            }
#endif
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetGamut(sRealValue);
            }
            break;
        }

        case E_USERDATA_RED:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetRGain(sRealValue);
            }
            break;
        }

        case E_USERDATA_GREEN:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetGGain(sRealValue);
            }
            break;
        }

        case E_USERDATA_BLUE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetColorTemp(GET_REAL_MAP_VALUE(E_USERDATA_COLOR_TEMP, UD_COLOR_TEMP_V_CUSTOM), HV_COMMON_DATABASE_GET(UserData, ucLowBlueLight));
            }
            break;
        }

        case E_USERDATA_GAMMA:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetGamma(sRealValue);
            }
            break;
        }
#if (HV_PROJECT_CONFIG_COLOR_FILTER == HV_CONFIG_ON)
        case E_USERDATA_COLOR_FILTER:
        {
            if (ucFlag & SET_RELATED)
            {
                if (UD_COLOR_FILTER_V_NONE == sOsdValue)
                {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP)
                    if (UD_PXPMODE_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE))
#endif
                    {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_HDR)
                        if (HV_COMMON_DATABASE_GET(UserData, enHdrSwitchBackup) != HV_COMMON_DATABASE_GET(UserData, enHdrSwitch))
                        {
                            Hv_App_OsdSetUserdata(E_USERDATA_HDR, GET_OSD_MAP_VALUE(E_USERDATA_HDR, HV_COMMON_DATABASE_GET(UserData, enHdrSwitchBackup)));
                            Hv_App_PQ_ForceSwitchHdr(HV_COMMON_DATABASE_GET(UserData, enHdrSwitchBackup));
                            Hv_App_HdrPqSetting(pstTiming->bIsHdr);
                        }
#endif
                    }
                }
                else
                {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_HDR)
                    if (UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR))
                    {
                        Hv_App_OsdSetUserdata(E_USERDATA_HDR, UD_HDR_V_OFF);
                        HV_COMMON_DATABASE_SET(UserData, enHdrSwitchBackup, HV_COMMON_DATABASE_GET(UserData, enHdrSwitch));
                        Hv_App_PQ_ForceSwitchHdr(GET_REAL_MAP_VALUE(E_USERDATA_HDR, UD_HDR_V_OFF));
                        Hv_App_HdrPqSetting(pstTiming->bIsHdr);
                    }
#endif
                }
            }
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetColorFilterType(sRealValue);
            }
            break;
        }
#endif
        case E_USERDATA_VIDEOSOURCE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Video_SetMainVideoSource(sRealValue);
            }
            break;
        }

        case E_USERDATA_AUTOSOURCE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Video_SetVideoAutoSelectSw(sRealValue);
            }
            break;
        }

        case E_USERDATA_HDMI_FORMAT:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetHdmiFormat(sRealValue);
            }
            break;
        }

        case E_USERDATA_HDMI_ALLM:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_HdmiRx_SwitchAllmMode(sRealValue);
            }
            break;
        }

        case E_USERDATA_QMS:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_HdmiRx_SwitchQmsMode(sRealValue);
            }
            break;
        }

        case E_USERDATA_DP_VERSION:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_DpRx_SetAllDpVer(sRealValue);
            }
            break;
        }

        case E_USERDATA_PROPORTION:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Video_SetAspectRatio(sRealValue);
            }
            break;
        }

        case E_USERDATA_RESPONSETIME:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetODLevel(sRealValue);
            }
            break;
        }

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MPRT)
        case E_USERDATA_MPRT:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Video_SetOutMprtPwmEnable(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FREESYNC)
        case E_USERDATA_FREESYNC:
        {
            if (ucFlag & SET_RELATED)
            {
                if (UD_FREESYNC_V_ON == sOsdValue)
                {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MPRT)
                    Hv_App_OsdSetUserdata(E_USERDATA_MPRT, UD_MPRT_V_OFF);
                    Hv_Mw_Video_SetOutMprtPwmEnable(GET_REAL_MAP_VALUE(E_USERDATA_MPRT, UD_MPRT_V_OFF));
#endif
                }
                else
                {
                    Hv_App_OsdSetUserdata(E_USERDATA_QMS, UD_QMS_V_OFF);
                    Hv_Mw_HdmiRx_SwitchQmsMode(GET_REAL_MAP_VALUE(E_USERDATA_QMS, UD_QMS_V_OFF));
                }
            }
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Video_SetFreeSyncSwitch(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_HDR)
        case E_USERDATA_HDR:
        {
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, enHdrSwitchBackup, sRealValue);
                Hv_App_PQ_ForceSwitchHdr(sRealValue);
            }
            if (ucFlag & SET_RELATED)
            {
                Hv_App_HdrPqSetting(pstTiming->bIsHdr);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_LDR)
        case E_USERDATA_LDR:
        {
            if (ucFlag & SET_INTERFACE)
            {
                if (pstTiming->enColorFmt != ColorFormatType_YCbCr422
                    && pstTiming->enColorFmt != ColorFormatType_YCbCr444
                    && pstTiming->enColorFmt != ColorFormatType_YCbCr420)
                {
                    HV_COMMON_DATABASE_SET(UserData, ucLdrRgb, sRealValue);
                }
                Hv_App_PQ_SetBrightRange(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DCR)
        case E_USERDATA_DCR:
        {
            if (ucFlag & SET_RELATED)
            {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DARK_STABILIZER)
                if (UD_DCR_V_ON == sOsdValue)
                {
                    Hv_App_OsdSetUserdata(E_USERDATA_DARKSTABILIZER, 0);
                    HV_COMMON_DATABASE_SET(UserData, ucDarkStabilizer, 0);
                }
#endif
            }
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_DynamicContrastEnable(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_CROSSHAIR)
        case E_USERDATA_CROSSHAIR:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetCrosshair(sRealValue);
            }
            break;
        }

        case E_USERDATA_DYN_CROSSHAIR:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetDynCrosshair(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY)
        case E_USERDATA_MAGNIFY_GLASS:
        {
            UCHAR8 ucPrevMagnifyGlassSw =  HV_COMMON_DATABASE_GET(UserData, bMagnifyGlassSw);
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP)
            if (ucFlag & SET_RELATED)
            {
                if (UD_MAGNIFY_GLASS_V_OFF != sOsdValue)
                {
                    Hv_App_OsdSetUserdata(E_USERDATA_PXPMODE, UD_PXPMODE_V_OFF);
                    HV_COMMON_DATABASE_SET(UserData, ucPxPMode,  GET_REAL_MAP_VALUE(E_USERDATA_PXPMODE, UD_PXPMODE_V_OFF));

                    Hv_App_OsdSetUserdata(E_USERDATA_PROPORTION, UD_PROPORTION_V_AUTO);
                    HV_COMMON_DATABASE_SET(UserData, ucProportion, GET_REAL_MAP_VALUE(E_USERDATA_PROPORTION, UD_PROPORTION_V_AUTO));

                    Hv_App_OsdSetUserdata(E_USERDATA_SHARPNESS, 0);
                    Hv_App_PQ_SetSharpness(GET_REAL_MAP_VALUE(E_USERDATA_SHARPNESS, 0));
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DARK_STABILIZER)
                    Hv_App_OsdSetUserdata(E_USERDATA_DARKSTABILIZER, 0);
                    Hv_App_PQ_DarkStablizer(GET_REAL_MAP_VALUE(E_USERDATA_DARKSTABILIZER, 0));
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DCR)
                    Hv_App_OsdSetUserdata(E_USERDATA_DCR, UD_DCR_V_OFF);
                    Hv_App_PQ_DynamicContrastEnable(GET_REAL_MAP_VALUE(E_USERDATA_DCR, UD_DCR_V_OFF));
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_ROTATION)
                    Hv_App_OsdSetUserdata(E_USERDATA_ROTATION, UD_ROTATION_V_OFF);
                    Hv_App_OsdSetRotateType(GET_REAL_MAP_VALUE(E_USERDATA_ROTATION, UD_ROTATION_V_OFF));
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DPU_BRIGHT_FRAME)
                    if (UD_BRIGHT_FRAME_V_ON == Hv_App_GetOsdDataValue(E_USERDATA_BRIGHT_FRAME))
                    {
                        Hv_App_OsdSetUserdata(E_USERDATA_BRIGHT_FRAME, UD_BRIGHT_FRAME_V_OFF);
                        Hv_Mw_DCW_SetBrightFrameEn(GET_REAL_MAP_VALUE(E_USERDATA_BRIGHT_FRAME, UD_BRIGHT_FRAME_V_OFF));
                        Hv_App_PQ_SetBrightness(HV_COMMON_DATABASE_GET(UserData, ucBrightness));
                        Hv_App_PQ_SetContrast(HV_COMMON_DATABASE_GET(UserData, ucContrast));
                    }
#endif
                }
            }
#endif
            if (ucFlag & SET_INTERFACE)
            {
                if (UD_MAGNIFY_GLASS_V_1_2X == sOsdValue)
                {
                    Hv_Mw_Video_SetMagnifyGlassRatio(1.2);
                }
                else if (UD_MAGNIFY_GLASS_V_1_5X == sOsdValue)
                {
                    Hv_Mw_Video_SetMagnifyGlassRatio(1.5);
                }
                else if (UD_MAGNIFY_GLASS_V_2_0X == sOsdValue)
                {
                    Hv_Mw_Video_SetMagnifyGlassRatio(2.0);
                }
                else
                {
                    Hv_Mw_Video_SetMagnifyGlassSwitch(HV_FALSE);
                }
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_REFRESH_RATE)
        case E_USERDATA_REFRESH_RATE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetFrameRateShow(sRealValue);
            }
            break;
        }
#endif

        case E_USERDATA_TIME_COUNTER:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetTimerCounterShow(sRealValue);
            }
            break;
        }

        case E_USERDATA_LANGUAGE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetLanguage(sRealValue);
            }
            break;
        }

        case E_USERDATA_MENUX:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetMenuPostion(HV_TRUE, sRealValue);
            }
            break;
        }

        case E_USERDATA_MENUY:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetMenuPostion(HV_FALSE, sRealValue);
            }
            break;
        }

        case E_USERDATA_MENUTIMER:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetMenuTime(sRealValue);
            }
            break;
        }

        case E_USERDATA_MENUTRANSPARENCY:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetTrans(sRealValue);
            }
            break;
        }

        case E_USERDATA_MENULOCK:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetLock(sRealValue);
            }
            break;
        }
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_CUSTOM_KEY)
        case E_USERDATA_CUSTOM_KEY1:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetCustomKey(1, sRealValue);
            }
            break;
        }

        case E_USERDATA_CUSTOM_KEY2:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetCustomKey(2, sRealValue);
            }
            break;
        }

        case E_USERDATA_CUSTOM_KEY3:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetCustomKey(3, sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_LIGHT_EFFECT)
        case E_USERDATA_LIGHT_EFFECT:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Led_SetRedLed(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBIENT_LIGHT)
        case E_USERDATA_AMBIENTLIGHT:
        {
            if (ucFlag & SET_RELATED)
            {
                if (UD_AMBIENTLIGHT_V_AUDIO == sOsdValue)
                {
                    if (0 != Hv_App_GetOsdDataValue(E_USERDATA_TIME_DELAY))
                    {
                        Hv_App_OsdSetUserdata(E_USERDATA_TIME_DELAY, 0);
                        Hv_Mw_Audio_SetDelayTime(GET_REAL_MAP_VALUE(E_USERDATA_TIME_DELAY, 0));
                    }
                }
            }
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucAmbientLight, sRealValue);
                Hv_App_PQ_SetAmbilight(sRealValue, HV_COMMON_DATABASE_GET(UserData, ucMonoLight));
            }
            break;
        }

        case E_USERDATA_MONOLIGHT:
        {
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucMonoLight, sRealValue);
                Hv_App_PQ_SetMonoLight(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_VARIABLEBACKLIGHT)
        case E_USERDATA_VARIABLEBACKLIGHT:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetDCR(sRealValue);
                if (UD_VARIABLEBACKLIGHT_V_OFF == sRealValue)
                {
                    UCHAR8 ucDisplayMode = Hv_App_GetOsdDataValue(E_USERDATA_DISPLAY_MODE);
                    Hv_App_SetDisplayMode(ucDisplayMode, SET_ALL);
                }
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
        case E_USERDATA_LOCALDIMMING:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_LdcSetMode(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_ROTATION)
        case E_USERDATA_ROTATION:
        {
#if (HV_PROJECT_CONFIG_OSD_ROTATION_TYPE == OSD_ROTATE_MENU_IN_PLACE)
            if (ucFlag & SET_RELATED)
            {
                USHORT16 usOsdX = Hv_App_OsdGetMenuPostion(HV_TRUE);
                USHORT16 usOsdY = Hv_App_OsdGetMenuPostion(HV_FALSE);
                USHORT16 usOsdRotate = Hv_App_OsdGetRotateType();
                Hv_Mw_OsdCalculateRotateInplacePostion(&usOsdX, &usOsdY, usOsdRotate, sRealValue);
                Hv_App_OsdSetMenuPostion(HV_TRUE, usOsdX);
                Hv_App_OsdSetMenuPostion(HV_FALSE, usOsdY);
                Hv_Mw_OsdUserdataUpdate(E_USERDATA_MENUX);
                Hv_Mw_OsdUserdataUpdate(E_USERDATA_MENUY);
            }
#endif

            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetRotateType(sRealValue);
#if 0
                if (OSD_ROTATION_180 == sRealValue)
                {
                    Hv_Mw_Video_SetHflipSwitch(HV_TRUE);
                    Hv_Mw_Video_SetVflipSwitch(HV_TRUE);
                }
                else if (HV_COMMON_DATABASE_GET(UserData, bMainHfilpEn) && HV_COMMON_DATABASE_GET(UserData, bMainHfilpEn))
                {
                    Hv_Mw_Video_SetHflipSwitch(HV_FALSE);
                    Hv_Mw_Video_SetVflipSwitch(HV_FALSE);
                }
#endif
            }
            break;
        }
#endif

        case E_USERDATA_VOLUME:
        {
            if (ucFlag & SET_RELATED)
            {
                Hv_App_OsdSetUserdata(E_USERDATA_MUTE, UD_MUTE_V_OFF);
            }
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Audio_UIUnMute();
                Hv_Mw_Audio_SetVolume(sRealValue);
            }
            break;
        }

        case E_USERDATA_MUTE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                if (UD_MUTE_V_OFF == sOsdValue)
                {
                    Hv_Mw_Audio_UIUnMute();
                }
                else
                {
                    Hv_Mw_Audio_UIMute();
                }
            }
            break;
        }

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AUDIO_SETTING)
        case E_USERDATA_AUDIO_SOURCE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Channel_AudioSourceConfig(sRealValue);
            }
            break;
        }

        case E_USERDATA_TIME_DELAY:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Audio_SetDelayTime(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP)
        case E_USERDATA_PXPMODE:
        {
            if (ucFlag & SET_RELATED)
            {
                if (UD_PXPMODE_V_OFF != sOsdValue)
                {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY)
                    Hv_App_OsdSetUserdata(E_USERDATA_MAGNIFY_GLASS, UD_MAGNIFY_GLASS_V_OFF);
                    HV_COMMON_DATABASE_SET(UserData, bMagnifyGlassSw, GET_REAL_MAP_VALUE(E_USERDATA_MAGNIFY_GLASS, UD_MAGNIFY_GLASS_V_OFF));
#endif
                    Hv_App_OsdSetUserdata(E_USERDATA_PROPORTION, UD_PROPORTION_V_AUTO);
                    HV_COMMON_DATABASE_SET(UserData, ucProportion, GET_REAL_MAP_VALUE(E_USERDATA_PROPORTION, UD_PROPORTION_V_AUTO));

                    HV_COMMON_DATABASE_SET(UserData, bAutoVideoBackup, HV_COMMON_DATABASE_GET(UserData, bAutoVideoSrcSelSw));
                    Hv_App_OsdSetUserdata(E_USERDATA_AUTOSOURCE, UD_AUTOSOURCE_V_OFF);
                    Hv_Mw_Video_SetVideoAutoSelectSw(HV_FALSE);

                    Hv_App_OsdSetUserdata(E_USERDATA_SHARPNESS, 0);
                    Hv_App_PQ_SetSharpness(GET_REAL_MAP_VALUE(E_USERDATA_SHARPNESS, 0));
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FREESYNC)
                    Hv_App_OsdSetUserdata(E_USERDATA_FREESYNC, UD_FREESYNC_V_OFF);
                    HV_COMMON_DATABASE_SET(UserData, ucFreeSync, GET_REAL_MAP_VALUE(E_USERDATA_FREESYNC, UD_FREESYNC_V_OFF));
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DARK_STABILIZER)
                    Hv_App_OsdSetUserdata(E_USERDATA_DARKSTABILIZER, 0);
                    HV_COMMON_DATABASE_SET(UserData, ucDarkStabilizer, GET_REAL_MAP_VALUE(E_USERDATA_DARKSTABILIZER, 0));
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DCR)
                    Hv_App_OsdSetUserdata(E_USERDATA_DCR, UD_DCR_V_OFF);
                    HV_COMMON_DATABASE_SET(UserData, ucDcr, GET_REAL_MAP_VALUE(E_USERDATA_DCR, UD_DCR_V_OFF));
#endif

                    Hv_App_OsdSetUserdata(E_USERDATA_HDMI_ALLM, UD_HDMI_ALLM_V_OFF);
                    HV_COMMON_DATABASE_SET(UserData, bHdmiAllmEn, GET_REAL_MAP_VALUE(E_USERDATA_HDMI_ALLM, UD_HDMI_ALLM_V_OFF));

                    Hv_App_OsdSetUserdata(E_USERDATA_QMS, UD_QMS_V_OFF);
                    HV_COMMON_DATABASE_SET(UserData, bQms, GET_REAL_MAP_VALUE(E_USERDATA_QMS, UD_QMS_V_OFF));

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_HDR)
                    if (UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR))
                    {
                        HV_COMMON_DATABASE_SET(UserData, enHdrSwitchBackup, HV_COMMON_DATABASE_GET(UserData, enHdrSwitch));
                        Hv_App_OsdSetUserdata(E_USERDATA_HDR, UD_HDR_V_OFF);
                        Hv_App_PQ_ForceSwitchHdr(GET_REAL_MAP_VALUE(E_USERDATA_HDR, UD_HDR_V_OFF));
                        Hv_App_HdrPqSetting(pstTiming->bIsHdr);
                    }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_ROTATION)
                    Hv_App_OsdSetUserdata(E_USERDATA_ROTATION, UD_ROTATION_V_OFF);
                    Hv_App_OsdSetRotateType(GET_REAL_MAP_VALUE(E_USERDATA_ROTATION, UD_ROTATION_V_OFF));
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DPU_BRIGHT_FRAME)
                    if (UD_BRIGHT_FRAME_V_ON == Hv_App_GetOsdDataValue(E_USERDATA_BRIGHT_FRAME))
                    {
                        Hv_App_OsdSetUserdata(E_USERDATA_BRIGHT_FRAME, UD_BRIGHT_FRAME_V_OFF);
                        Hv_Mw_DCW_SetBrightFrameEn(GET_REAL_MAP_VALUE(E_USERDATA_BRIGHT_FRAME, UD_BRIGHT_FRAME_V_OFF));
                        Hv_App_PQ_SetBrightness(HV_COMMON_DATABASE_GET(UserData, ucBrightness));
                        Hv_App_PQ_SetContrast(HV_COMMON_DATABASE_GET(UserData, ucContrast));
                    }
#endif
                    Hv_App_OsdSetUserdata(E_USERDATA_CROSSHAIR, UD_CROSSHAIR_V_NONE);
                    Hv_App_OsdSetCrosshair(0);
                }
                else
                {
                    if (UD_COLOR_FILTER_V_NONE == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_FILTER))
                    {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_HDR)
                        if (HV_COMMON_DATABASE_GET(UserData, enHdrSwitchBackup) != (USHORT16)HV_COMMON_DATABASE_GET(UserData, enHdrSwitch))
                        {
                            Hv_App_OsdSetUserdata(E_USERDATA_HDR, GET_OSD_MAP_VALUE(E_USERDATA_HDR, HV_COMMON_DATABASE_GET(UserData, enHdrSwitchBackup)));
                            Hv_App_PQ_ForceSwitchHdr(HV_COMMON_DATABASE_GET(UserData, enHdrSwitchBackup));
                            Hv_App_HdrPqSetting(pstTiming->bIsHdr);
                        }
#endif
                    }
                    BOOL bAutoVideoBackup = HV_COMMON_DATABASE_GET(UserData, bAutoVideoBackup);
                    Hv_Mw_Video_SetVideoAutoSelectSw(bAutoVideoBackup);
                }
            }
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Video_SetPxpMode(sRealValue);
            }
            break;
        }

        case E_USERDATA_PXPVIDEOSOURCE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Video_SetSubVideoSource(sRealValue);
            }
            break;
        }

        case E_USERDATA_PXP_SWITCH:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Video_SetMainSubVideoSourceSwap(sRealValue);
                Hv_Mw_OsdUserdataUpdate(E_USERDATA_VIDEOSOURCE);
                Hv_Mw_OsdUserdataUpdate(E_USERDATA_PXPVIDEOSOURCE);
            }
            break;
        }

        case E_USERDATA_PIP_POSITION:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Video_SetSubVideoWindowPosition(sRealValue);
            }
            break;
        }

        case E_USERDATA_PIP_SIZE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Video_SetSubVideoWindowSize(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_BRIGHT_FRAME)
        case E_USERDATA_BRIGHT_FRAME:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetBrightFrameEn(sRealValue);
            }
            break;
        }

        case E_USERDATA_FRAME_SIZE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetFrameSize(sRealValue);
            }
            break;
        }

        case E_USERDATA_BF_BRIGHTNESS:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetBrightFrameBrightness(sRealValue);
            }
            break;
        }

        case E_USERDATA_BF_CONTRAST:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetBrightFrameContrast(sRealValue);
            }
            break;
        }

        case E_USERDATA_BF_HPOS:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetBrightFrameHPos(sRealValue);
            }
            break;
        }

        case E_USERDATA_BF_VPOS:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetBrightFrameVPos(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DPU_BRIGHT_FRAME)
        case E_USERDATA_BRIGHT_FRAME:
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP)
            if (ucFlag & SET_RELATED)
            {
                if (UD_BRIGHT_FRAME_V_OFF != sOsdValue)
                {
                    Hv_App_OsdSetUserdata(E_USERDATA_PXPMODE, UD_PXPMODE_V_OFF);
                    HV_COMMON_DATABASE_SET(UserData, ucPxPMode,  GET_REAL_MAP_VALUE(E_USERDATA_PXPMODE, UD_PXPMODE_V_OFF));
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY)
                    Hv_App_OsdSetUserdata(E_USERDATA_MAGNIFY_GLASS, UD_MAGNIFY_GLASS_V_OFF);
                    HV_COMMON_DATABASE_SET(UserData, bMagnifyGlassSw, GET_REAL_MAP_VALUE(E_USERDATA_MAGNIFY_GLASS, UD_MAGNIFY_GLASS_V_OFF));
#endif
                    Hv_App_OsdSetUserdata(E_USERDATA_PROPORTION, UD_PROPORTION_V_AUTO);
                    HV_COMMON_DATABASE_SET(UserData, ucProportion, GET_REAL_MAP_VALUE(E_USERDATA_PROPORTION, UD_PROPORTION_V_AUTO));

                    Hv_App_OsdSetUserdata(E_USERDATA_SHARPNESS, 0);
                    Hv_App_PQ_SetSharpness(GET_REAL_MAP_VALUE(E_USERDATA_SHARPNESS, 0));
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DARK_STABILIZER)
                    Hv_App_OsdSetUserdata(E_USERDATA_DARKSTABILIZER, 0);
                    Hv_App_PQ_DarkStablizer(GET_REAL_MAP_VALUE(E_USERDATA_DARKSTABILIZER, 0));
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DCR)
                    Hv_App_OsdSetUserdata(E_USERDATA_DCR, UD_DCR_V_OFF);
                    Hv_App_PQ_DynamicContrastEnable(GET_REAL_MAP_VALUE(E_USERDATA_DCR, UD_DCR_V_OFF));
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_ROTATION)
                    Hv_App_OsdSetUserdata(E_USERDATA_ROTATION, UD_ROTATION_V_OFF);
                    Hv_App_OsdSetRotateType(GET_REAL_MAP_VALUE(E_USERDATA_ROTATION, UD_ROTATION_V_OFF));
#endif
                }
            }
#endif

            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_DCW_SetBrightFrameEn(sRealValue);
                if (UD_BRIGHT_FRAME_V_OFF != sOsdValue)
                {
                    Hv_App_PQ_SetBrightFrameBrightness(HV_COMMON_DATABASE_GET(UserData, ucBrightFrameLv));
                    Hv_App_PQ_SetBrightFrameContrast(HV_COMMON_DATABASE_GET(UserData, ucBrightFrameCo));
                }
                else
                {
                    Hv_App_PQ_SetBrightness(HV_COMMON_DATABASE_GET(UserData, ucBrightness));
                    Hv_App_PQ_SetContrast(HV_COMMON_DATABASE_GET(UserData, ucContrast));
                }
            }
            break;
        }

        case E_USERDATA_FRAME_SIZE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_DCW_SetBrightFrameSize(sRealValue); 
            }
            if (ucFlag & SET_RELATED)
            {
                Hv_App_OsdSetUserdata(E_USERDATA_BF_HPOS, USERDATA_BF_HPOS_MIN);
                Hv_Mw_DCW_SetBrightFrameHPos(GET_REAL_MAP_VALUE(E_USERDATA_BF_HPOS, USERDATA_BF_HPOS_MIN));
                Hv_App_OsdSetUserdata(E_USERDATA_BF_VPOS, USERDATA_BF_VPOS_MIN);
                Hv_Mw_DCW_SetBrightFrameVPos(GET_REAL_MAP_VALUE(E_USERDATA_BF_VPOS, USERDATA_BF_VPOS_MIN));
                Hv_App_PQ_SetBrightFrameBrightness(HV_COMMON_DATABASE_GET(UserData, ucBrightFrameLv));
                Hv_App_PQ_SetBrightFrameContrast(HV_COMMON_DATABASE_GET(UserData, ucBrightFrameCo));
            }
            break;
        }

        case E_USERDATA_BF_BRIGHTNESS:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetBrightFrameBrightness(sRealValue);
            }
            break;
        }

        case E_USERDATA_BF_CONTRAST:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetBrightFrameContrast(sRealValue);
            }
            break;
        }

        case E_USERDATA_BF_HPOS:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_DCW_SetBrightFrameHPos(sRealValue);
            }
            break;
        }

        case E_USERDATA_BF_VPOS:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_DCW_SetBrightFrameVPos(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_VRR_GAMMA)
        case E_USERDATA_VRR_GAMMA:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetGammaVrrEn(sRealValue);
            }
            break;
        }
#endif

        default:
        {
            break;
        }
    }
}

VOID Hv_App_GetRealValue(UserdataId enWhichData, SHORT16 *psRealValue, SHORT16 *psRealDefaultValue)
{
    const UserDataDBRegion *pstDefaultData = Hv_Mw_DataBase_GetDefaultUserDataPtr();
    OsdTimingInfo *pstTiming = Hv_App_OsdGetCurrentTimingInfo();

    switch (enWhichData)
    {
        case E_USERDATA_DISPLAY_MODE:
        {
            *psRealValue = Hv_App_GetDisplayMode();
            *psRealDefaultValue = pstDefaultData->ucDisplayMode;
            break;
        }
        case E_USERDATA_BRIGHTNESS:
        {
            *psRealValue = Hv_App_PQ_GetBrightness();
            *psRealDefaultValue = pstDefaultData->ucBrightness;
            break;
        }
        case E_USERDATA_CONTRAST:
        {
            *psRealValue = Hv_App_PQ_GetContrast();
            *psRealDefaultValue = pstDefaultData->ucContrast;
            break;
        }
        case E_USERDATA_HUE:
        {
            *psRealValue = Hv_App_PQ_GetHue();
            *psRealDefaultValue = pstDefaultData->ucHue;
            break;
        }
        case E_USERDATA_SATURATION:
        {
            *psRealValue = Hv_App_PQ_GetSaturation();
            *psRealDefaultValue = pstDefaultData->ucSaturation;
            break;
        }
        case E_USERDATA_SHARPNESS:
        {
            *psRealValue = Hv_App_PQ_GetSharpness();
            *psRealDefaultValue = pstDefaultData->ucSharpness;
            break;
        }
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DARK_STABILIZER)
        case E_USERDATA_DARKSTABILIZER:
        {
            *psRealValue = Hv_App_PQ_GetDarkStablizer();
            *psRealDefaultValue = pstDefaultData->ucDarkStabilizer;
            break;
        }
#endif
        case E_USERDATA_COLOR_TEMP:
        {
            *psRealValue = Hv_App_PQ_GetColorTemp();
            *psRealDefaultValue = pstDefaultData->ucColorTemperature;
            break;
        }
        case E_USERDATA_LOW_BLUE_LIGHT:
        {
            *psRealValue = Hv_App_PQ_GetLowBlueLight();
            *psRealDefaultValue = pstDefaultData->ucLowBlueLight;
            break;
        }
        case E_USERDATA_COLOR_SPACE:
        {
            *psRealValue = Hv_App_PQ_GetGamut();
            *psRealDefaultValue = pstDefaultData->ucColorSpace;
            break;
        }
        case E_USERDATA_RED:
        {
            *psRealValue = Hv_App_PQ_GetRGain();
            *psRealDefaultValue = pstDefaultData->ucRed;
            break;
        }
        case E_USERDATA_GREEN:
        {
            *psRealValue = Hv_App_PQ_GetGGain();
            *psRealDefaultValue = pstDefaultData->ucGreen;
            break;
        }
        case E_USERDATA_BLUE:
        {
            *psRealValue = Hv_App_PQ_GetBGain();
            *psRealDefaultValue = pstDefaultData->ucBlue;
            break;
        }
        case E_USERDATA_GAMMA:
        {
            *psRealValue = Hv_App_PQ_GetGamma();
            *psRealDefaultValue = pstDefaultData->ucGamma;
            break;
        }
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_COLOR_FILTER)
        case E_USERDATA_COLOR_FILTER:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucColorFilter);
            *psRealDefaultValue = pstDefaultData->ucColorFilter;
            break;
        }
#endif
        case E_USERDATA_VIDEOSOURCE:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucVideoSource);     //Hv_Mw_Video_GetMainVideoSource();
            *psRealDefaultValue = pstDefaultData->ucVideoSource;
            break;
        }
        case E_USERDATA_AUTOSOURCE:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, bAutoVideoSrcSelSw);     //Hv_Mw_Video_GetAutoSelect();
            *psRealDefaultValue = pstDefaultData->bAutoVideoSrcSelSw;
            break;
        }
        case E_USERDATA_HDMI_FORMAT:
        {
            Hv_App_OsdGetHdmiFormat(psRealValue, psRealDefaultValue);
            break;
        }
        case E_USERDATA_HDMI_ALLM:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, bHdmiAllmEn);
            *psRealDefaultValue = pstDefaultData->bHdmiAllmEn;
            break;
        }
        case E_USERDATA_QMS:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, bQms);
            *psRealDefaultValue = pstDefaultData->bQms;
            break;
        }
        case E_USERDATA_DP_VERSION:
        {
            *psRealValue = Hv_Mw_DpRx_GetAllDpVer();
            *psRealDefaultValue = pstDefaultData->ucDPVersion;
            break;
        }
        case E_USERDATA_PROPORTION:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucProportion);     //Hv_Mw_Video_GetAspectRatio();
            *psRealDefaultValue = pstDefaultData->ucProportion;
            break;
        }
        case E_USERDATA_RESPONSETIME:
        {
            *psRealValue = Hv_App_PQ_GetODLevel();
            *psRealDefaultValue = pstDefaultData->ucResponseTime;
            break;
        }
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MPRT)
        case E_USERDATA_MPRT:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucMprt);
            *psRealDefaultValue = pstDefaultData->ucMprt;
            break;
        }
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FREESYNC)
        case E_USERDATA_FREESYNC:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucFreeSync);     //Hv_Mw_Video_GetFreeSyncSwitch();
            *psRealDefaultValue = pstDefaultData->ucFreeSync;
            break;
        }
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_HDR)
        case E_USERDATA_HDR:
        {
            *psRealValue = Hv_App_PQ_GetHdrSwitch();
            *psRealDefaultValue = pstDefaultData->enHdrSwitch;
            break;
        }
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_LDR)
        case E_USERDATA_LDR:
        {
            *psRealValue = Hv_App_PQ_GetBrightRange();
            *psRealDefaultValue = pstDefaultData->ucLdr;
            break;
        }
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DCR)
        case E_USERDATA_DCR:
        {
            *psRealValue = Hv_App_PQ_GetDynamicContrast();
            *psRealDefaultValue = pstDefaultData->ucDcr;
            break;
        }
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_CROSSHAIR)
        case E_USERDATA_CROSSHAIR:
        {
            *psRealValue = Hv_App_OsdGetCrosshair();
            *psRealDefaultValue = pstDefaultData->ucOsdCrosshair;
            break;
        }

        case E_USERDATA_DYN_CROSSHAIR:
        {
            *psRealValue = Hv_App_OsdGetDynCrosshair();
            *psRealDefaultValue = pstDefaultData->ucDynCrosshair;
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY)
        case E_USERDATA_MAGNIFY_GLASS:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, bMagnifyGlassSw);
            *psRealDefaultValue = pstDefaultData->bMagnifyGlassSw;
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_REFRESH_RATE)
        case E_USERDATA_REFRESH_RATE:
        {
            *psRealValue = Hv_App_OsdGetFrameRateShow();
            *psRealDefaultValue = pstDefaultData->ucOsdFrameCounter;
            break;
        }
#endif

        case E_USERDATA_TIME_COUNTER:
        {
            *psRealValue = Hv_App_OsdGetTimerCounterShow();
            *psRealDefaultValue = pstDefaultData->ucOsdTimerCounter;
            break;
        }

        case E_USERDATA_LANGUAGE:
        {
            *psRealValue = Hv_App_OsdGetLanguage();
            *psRealDefaultValue = pstDefaultData->ucOsdLanguage;
            break;
        }

        case E_USERDATA_MENUX:
        {
            *psRealValue = Hv_App_OsdGetMenuPostion(HV_TRUE);
            *psRealDefaultValue = pstDefaultData->ucOsdMenuHPos;
            break;
        }

        case E_USERDATA_MENUY:
        {
            *psRealValue = Hv_App_OsdGetMenuPostion(HV_FALSE);
            *psRealDefaultValue = pstDefaultData->ucOsdMenuVPos;
            break;
        }

        case E_USERDATA_MENUTIMER:
        {
            *psRealValue = Hv_App_OsdGetMenuTime();
            *psRealDefaultValue = pstDefaultData->ucOsdTime;
            break;
        }

        case E_USERDATA_MENUTRANSPARENCY:
        {
            *psRealValue = Hv_App_OsdGetTrans();
            *psRealDefaultValue = pstDefaultData->ucOsdTrans;
            break;
        }

        case E_USERDATA_MENULOCK:
        {
            *psRealValue = Hv_App_OsdGetLock();
            *psRealDefaultValue = pstDefaultData->ucOsdLock;
            break;
        }

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_CUSTOM_KEY)
        case E_USERDATA_CUSTOM_KEY1:
        {
            *psRealValue = Hv_App_OsdGetCustomKey(1);
            *psRealDefaultValue = pstDefaultData->ucOsdCustomKey1;
            break;
        }

        case E_USERDATA_CUSTOM_KEY2:
        {
            *psRealValue = Hv_App_OsdGetCustomKey(2);
            *psRealDefaultValue = pstDefaultData->ucOsdCustomKey2;
            break;
        }

        case E_USERDATA_CUSTOM_KEY3:
        {
            *psRealValue = Hv_App_OsdGetCustomKey(3);
            *psRealDefaultValue = pstDefaultData->ucOsdCustomKey3;
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_LIGHT_EFFECT)
        case E_USERDATA_LIGHT_EFFECT:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucLightEffect);
            *psRealDefaultValue = pstDefaultData->ucLightEffect;
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBIENT_LIGHT)
        case E_USERDATA_AMBIENTLIGHT:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucAmbientLight);
            *psRealDefaultValue = pstDefaultData->ucAmbientLight;
            break;
        }
        case E_USERDATA_MONOLIGHT:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucMonoLight);
            *psRealDefaultValue = pstDefaultData->ucMonoLight;
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_VARIABLEBACKLIGHT)
        case E_USERDATA_VARIABLEBACKLIGHT:
        {
            *psRealValue = Hv_App_PQ_GetDCR();
            *psRealDefaultValue = pstDefaultData->bVariableBackLight;
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
        case E_USERDATA_LOCALDIMMING:
        {
            *psRealValue = Hv_App_PQ_GetLdcMode();
            *psRealDefaultValue = pstDefaultData->ucLocalDimming;
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_ROTATION)
        case E_USERDATA_ROTATION:
        {
            *psRealValue = Hv_App_OsdGetRotateType();
            *psRealDefaultValue = pstDefaultData->ucOsdRotation;
            break;
        }
#endif
        case E_USERDATA_VOLUME:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucVolume);
            *psRealDefaultValue = pstDefaultData->ucVolume;
            break;
        }

        case E_USERDATA_MUTE:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, bMute);
            *psRealDefaultValue = pstDefaultData->bMute;
            break;
        }

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AUDIO_SETTING)
        case E_USERDATA_AUDIO_SOURCE:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucAudioSource);
            *psRealDefaultValue = pstDefaultData->ucAudioSource;
            break;
        }

        case E_USERDATA_TIME_DELAY:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, uiSoundDelayTime);
            *psRealDefaultValue = pstDefaultData->uiSoundDelayTime;
            break;
        }
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP)
        case E_USERDATA_PXPMODE:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, bMagnifyGlassSw) ? HV_FALSE : HV_COMMON_DATABASE_GET(UserData, ucPxPMode);
            *psRealDefaultValue = pstDefaultData->ucPxPMode;
            break;
        }

        case E_USERDATA_PXPVIDEOSOURCE:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucPxPVideoSource);
            *psRealDefaultValue = pstDefaultData->ucPxPVideoSource;
            break;
        }

        case E_USERDATA_PXP_SWITCH:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, bPxPSwitch);
            *psRealDefaultValue = pstDefaultData->bPxPSwitch;
            break;
        }

        case E_USERDATA_PIP_POSITION:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucPipPosition);
            *psRealDefaultValue = pstDefaultData->ucPipPosition;
            break;
        }

        case E_USERDATA_PIP_SIZE:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucPipSize);
            *psRealDefaultValue = pstDefaultData->ucPipSize;
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_BRIGHT_FRAME)
        case E_USERDATA_BRIGHT_FRAME:
        {
            *psRealValue = Hv_App_OsdGetBrightFrameEn();
            *psRealDefaultValue = pstDefaultData->bBrightFrame;
            break;
        }

        case E_USERDATA_FRAME_SIZE:
        {
            *psRealValue = Hv_App_OsdGetFrameSize();
            *psRealDefaultValue = pstDefaultData->ucFrameSize;
            break;
        }

        case E_USERDATA_BF_BRIGHTNESS:
        {
            *psRealValue = Hv_App_OsdGetBrightFrameBrightness();
            *psRealDefaultValue = pstDefaultData->ucBFBrightness;
            break;
        }

        case E_USERDATA_BF_CONTRAST:
        {
            *psRealValue = Hv_App_OsdGetBrightFrameContrast();
            *psRealDefaultValue = pstDefaultData->ucBFContrast;
            break;
        }

        case E_USERDATA_BF_HPOS:
        {
            *psRealValue = Hv_App_OsdGetBrightFrameHPos();
            *psRealDefaultValue = pstDefaultData->ucBFHPos;
            break;
        }

        case E_USERDATA_BF_VPOS:
        {
            *psRealValue = Hv_App_OsdGetBrightFrameVPos();
            *psRealDefaultValue = pstDefaultData->ucBFVPos;
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DPU_BRIGHT_FRAME)
        case E_USERDATA_BRIGHT_FRAME:
        {
            *psRealValue = Hv_Mw_DCW_GetBrightFrameEn();
            *psRealDefaultValue = pstDefaultData->bBrightFrameEn;
            break;
        }

        case E_USERDATA_FRAME_SIZE:
        {
            *psRealValue = Hv_Mw_DCW_GetBrightFrameSize();
            *psRealDefaultValue = pstDefaultData->ucOsdBfSizeLevel;
            break;
        }

        case E_USERDATA_BF_BRIGHTNESS:
        {
            *psRealValue = Hv_App_PQ_Video_GetBrightFrameBrightness();
            *psRealDefaultValue = pstDefaultData->ucBrightFrameLv;
            break;
        }

        case E_USERDATA_BF_CONTRAST:
        {
            *psRealValue = Hv_App_PQ_GetBrightFrameContrast();
            *psRealDefaultValue = pstDefaultData->ucBrightFrameCo;
            break;
        }

        case E_USERDATA_BF_HPOS:
        {
            *psRealValue = Hv_Mw_DCW_GetBrightFrameHPos();
            *psRealDefaultValue = pstDefaultData->ucOsdBfHPosLevel;
            break;
        }

        case E_USERDATA_BF_VPOS:
        {
            *psRealValue = Hv_Mw_DCW_GetBrightFrameVPos();
            *psRealDefaultValue = pstDefaultData->ucOsdBfVPosLevel;
            break;
        }
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_VRR_GAMMA)
        case E_USERDATA_VRR_GAMMA:
        {
            *psRealValue = Hv_App_PQ_GetGammaVrrEn();
            *psRealDefaultValue = pstDefaultData->ucGammaVrrEn;    //TODO
            break;
        }
#endif

        default:
        {
            break;
        }
    }
}

VOID Hv_App_GetOsdUserdataProp(UserdataId enWhichData, UserdataProp* pstProp)
{
    HV_ASSERT_VALID_PTR_VOID(pstProp);
    Hv_App_OsdGetUserdata(enWhichData, pstProp);

    /* Do something special */
    switch (enWhichData)
    {
        case E_USERDATA_HDMI_FORMAT:
        {
            if (UD_VIDEOSOURCE_V_HDMI2 == Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE))
            {
                pstProp->sOsdValue = GET_OSD_MAP_VALUE(E_USERDATA_HDMI_FORMAT, HV_COMMON_DATABASE_GET(UserData, ucHdmi1Format));
            }
            else
            {
                pstProp->sOsdValue = GET_OSD_MAP_VALUE(E_USERDATA_HDMI_FORMAT, HV_COMMON_DATABASE_GET(UserData, ucHdmi0Format));
            }
            break;
        }

        default:
        {
            break;
        }
    }
}

SHORT16 Hv_App_GetOsdDataValue(UserdataId enWhichData)
{
    UserdataProp stUserDataProp = { 0 };
    Hv_App_GetOsdUserdataProp(enWhichData, &stUserDataProp);
    return stUserDataProp.sOsdValue;
}

BOOL Hv_App_Cb_ItemCheckDisable(USHORT16 usItemId)
{
    BOOL bNeedDisable = HV_FALSE;
    OsdTimingInfo *pstTiming = Hv_App_OsdGetCurrentTimingInfo();

#if (HV_OSD_CONFIG_AUTO_TEST == HV_CONFIG_ON)
    if (Hv_Mw_OsdIsAutoTestRunning())
    {
        switch (usItemId)
        {
            case ITEM_MODEL_SCENE_MAIN:
            case ITEM_SN_SCENE_MAIN:
            case ITEM_VERSION_SCENE_MAIN:
            case ITEM_CHECKSUM_SCENE_MAIN:
            {
                bNeedDisable = HV_TRUE;
                break;
            }
            default:
            {
                break;
            }
        }
        return bNeedDisable;
    }
#endif

    switch (usItemId)
    {
        case ITEM_FACTORY_SCENE_MAIN:
        {
            bNeedDisable = (HV_FALSE == HV_COMMON_DATABASE_GET(SystemData, bFactoryMode)) ||
#ifdef HV_SCALER_DEBUG_VERSION
                           Hv_Mw_OsdIsMonkeyRunning();
#else
                           HV_FALSE;
#endif
            break;
        }

        case ITEM_SCOPE_SCENE_MAIN:
        {
#if (HV_CONFIG_OFF == HV_PROJECT_CONFIG_MAGNIFY)
            bNeedDisable = HV_TRUE;
#endif
            break;
        }

        case ITEM_HDMI_FORMAT_SCENE_MAIN:
        {
            bNeedDisable = ((UD_VIDEOSOURCE_V_HDMI1 != Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE)) &&
                            (UD_VIDEOSOURCE_V_HDMI2 != Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE))) ||
#ifdef HV_SCALER_DEBUG_VERSION
                           Hv_Mw_OsdIsMonkeyRunning() ||
#endif
                           (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE));
            break;
        }

        case ITEM_DP_VERSION_SCENE_MAIN:
        {
            bNeedDisable = ((UD_VIDEOSOURCE_V_USB_C != Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE)) &&
                            (UD_VIDEOSOURCE_V_DP != Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE))) ||
#ifdef HV_SCALER_DEBUG_VERSION
                           Hv_Mw_OsdIsMonkeyRunning();
#else
                           HV_FALSE;
#endif
            break;
        }

        case ITEM_COLOR_FILTER_SCENE_MAIN:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)) ||
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
                           (UD_LOCALDIMMING_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_LOCALDIMMING)) ||
#endif
                           ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
            break;
        }

        case ITEM_BRIGHTNESS_SCENE_MAIN:
        case ITEM_BRIGHTNESS_ADJUST_SCENE_BRIGHTNESS:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)) ||
                           (UD_DCR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_DCR)) ||
                           (UD_VARIABLEBACKLIGHT_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_VARIABLEBACKLIGHT)) ||
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
                           (UD_LOCALDIMMING_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_LOCALDIMMING)) ||
#endif
                           ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
            break;
        }

        case ITEM_CONTRAST_SCENE_MAIN:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)) ||
                           (UD_DCR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_DCR)) ||
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
                           (UD_LOCALDIMMING_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_LOCALDIMMING)) ||
#endif
                           ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
            break;
        }

        case ITEM_DCR_SCENE_MAIN:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)) ||
                           (0 != Hv_App_GetOsdDataValue(E_USERDATA_DARKSTABILIZER)) ||
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
                           (UD_LOCALDIMMING_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_LOCALDIMMING)) ||
#endif
                           ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr) ||
                           (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           (UD_MAGNIFY_GLASS_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_MAGNIFY_GLASS));
            break;
        }

        case ITEM_SATURATION_SCENE_MAIN:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE));
            break;
        }

        case ITEM_HUE_SCENE_MAIN:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)) ||
                           ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
            break;
        }

        case ITEM_LOW_BLUE_LIGHT_SCENE_MAIN:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)) ||
                           ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
            break;
        }

        case ITEM_MODE_SCENE_MAIN:
        case ITEM_MODE_ADJUST_SCENE_MODE:
        {
            bNeedDisable = (UD_DCR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_DCR)) ||
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
                           (UD_LOCALDIMMING_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_LOCALDIMMING)) ||
#endif
                           ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
            break;
        }

        case ITEM_DARKGAIN_SCENE_MAIN:
        {
            bNeedDisable = (UD_DCR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_DCR)) ||
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
                           (UD_LOCALDIMMING_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_LOCALDIMMING)) ||
#endif
                           ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr) ||
                           (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           (UD_MAGNIFY_GLASS_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_MAGNIFY_GLASS));
            break;
        }

        case ITEM_COLOR_SPACE_SCENE_MAIN:
        {
            bNeedDisable =
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
                           (UD_LOCALDIMMING_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_LOCALDIMMING)) ||
#endif
                           ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
            break;
        }

        case ITEM_GAMMA_SCENE_MAIN:
        {
            bNeedDisable = ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
            break;
        }

        case ITEM_SHARPNESS_SCENE_MAIN:
        {
            bNeedDisable = ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr) ||
                           (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           (UD_MAGNIFY_GLASS_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_MAGNIFY_GLASS));
            break;
        }

        case ITEM_LDR_SCENE_MAIN:
        {
            bNeedDisable = ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr) ||
                           (pstTiming->bSignalSync && (pstTiming->enColorFmt == ColorFormatType_YCbCr422
                                    || pstTiming->enColorFmt == ColorFormatType_YCbCr444
                                    || pstTiming->enColorFmt == ColorFormatType_YCbCr420)) ||
                           ((UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) &&
                                    (pstTiming->bSubSignalSync && (pstTiming->enSubColorFmt == ColorFormatType_YCbCr422
                                    || pstTiming->enSubColorFmt == ColorFormatType_YCbCr444
                                    || pstTiming->enSubColorFmt == ColorFormatType_YCbCr420))) ||
                           (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           (UD_MAGNIFY_GLASS_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_MAGNIFY_GLASS));
            break;
        }

        case ITEM_COLOR_TEMP_SCENE_MAIN:
        {
            bNeedDisable = ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
            break;
        }

        case ITEM_DYN_BACKLIGHT_SCENE_MAIN:
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_VARIABLEBACKLIGHT)
            bNeedDisable = ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
#else
            bNeedDisable = HV_TRUE;
#endif
            break;
        }

        case ITEM_LOCALDIMMING_SCENE_MAIN:
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING)
            //bNeedDisable = ((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr);
#else
            bNeedDisable = HV_TRUE;
#endif
            break;
        }

        case ITEM_MPRT_SCENE_MAIN:
        {
            bNeedDisable = (pstTiming->usFrameRate < 85) ||
                           (pstTiming->bIsVrr) ||
                           (UD_QMS_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_QMS));
            break;
        }

        case ITEM_QMS_SCENE_MAIN:
        {
            bNeedDisable = (UD_FREESYNC_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_FREESYNC)) ||
                           (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE));
            break;
        }

        case ITEM_SUB_SOURCE_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
#ifdef HV_SCALER_DEBUG_VERSION
                           Hv_Mw_OsdIsMonkeyRunning();
#else
                           HV_FALSE;
#endif
            break;
        }

        case ITEM_PXP_SWITCH_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                            Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE) == Hv_App_GetOsdDataValue(E_USERDATA_PXPVIDEOSOURCE);
            break;
        }

        case ITEM_AUDIO_SOURCE_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE));
            break;
        }

        case ITEM_PIP_POSITION_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           ((UD_PXPMODE_V_PIP != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                            (BIT_1 & Hv_Mw_Channel_GetChannelOnDisplay()) == 0);
            break;
        }

        case ITEM_PIP_SIZE_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           ((UD_PXPMODE_V_PIP != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                            (BIT_1 & Hv_Mw_Channel_GetChannelOnDisplay()) == 0);
            break;
        }

        case ITEM_HDR_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           (UD_COLOR_FILTER_V_NONE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_FILTER));
            break;
        }

        case ITEM_FREESYNC_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE));
            break;
        }

        case ITEM_ALLM_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           pstTiming->bAllmSupport;
            break;
        }

        case ITEM_DISPLAY_SIZE_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           (UD_MAGNIFY_GLASS_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_MAGNIFY_GLASS));
            break;
        }

        case ITEM_AUTO_SELECT_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
#ifdef HV_SCALER_DEBUG_VERSION
                           Hv_Mw_OsdIsMonkeyRunning();
#else
                           HV_FALSE;
#endif
            break;
        }

        case ITEM_ROTATION_SCENE_MAIN:
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_ROTATION)
            bNeedDisable = (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           (UD_MAGNIFY_GLASS_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_MAGNIFY_GLASS)) ||
                           ((0 == Hv_Ddr_Type()) && (pstTiming->usFrameRate > 60));
#else
            bNeedDisable = HV_TRUE;
#endif
            break;
        }

        case ITEM_LIGHT_COLOR_SCENE_MAIN:
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBIENT_LIGHT)
            bNeedDisable = (UD_AMBIENTLIGHT_V_MONO != Hv_App_GetOsdDataValue(E_USERDATA_AMBIENTLIGHT));
#endif
            break;
        }

        case ITEM_AUDIO_TIME_DELAY_SCENE_MAIN:
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBIENT_LIGHT)
            bNeedDisable = (UD_AMBIENTLIGHT_V_AUDIO == Hv_App_GetOsdDataValue(E_USERDATA_AMBIENTLIGHT));
#endif
            break;
        }

        case ITEM_MODEL_SCENE_MAIN:
        case ITEM_SN_SCENE_MAIN:
        case ITEM_VERSION_SCENE_MAIN:
        case ITEM_CHECKSUM_SCENE_MAIN:
        {
            bNeedDisable = HV_TRUE;
            break;
        }

        case ITEM_OTA_SCENE_MAIN:
        {
#ifdef CONFIG_USER_USB_OTA_ON
#ifdef HV_SCALER_DEBUG_VERSION
            bNeedDisable = Hv_Mw_OsdIsMonkeyRunning();
#endif
#else
            bNeedDisable = HV_TRUE;
#endif
            break;
        }

        case ITEM_FRAME_SIZE_SCENE_MAIN:
        case ITEM_BF_BRIGHTNESS_SCENE_MAIN:
        case ITEM_BF_CONTRAST_SCENE_MAIN:
        {
            bNeedDisable = (UD_BRIGHT_FRAME_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_BRIGHT_FRAME));
            break;
        }

        case ITEM_BF_HPOS_SCENE_MAIN:
        {
            bNeedDisable = ((UD_BRIGHT_FRAME_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_BRIGHT_FRAME))
                         ||(USERDATA_FRAME_SIZE_MAX == Hv_App_GetOsdDataValue(E_USERDATA_FRAME_SIZE)));
            break;
        }

        case ITEM_BF_VPOS_SCENE_MAIN:
        {
            bNeedDisable = ((UD_BRIGHT_FRAME_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_BRIGHT_FRAME))
                         || (USERDATA_FRAME_SIZE_MAX == Hv_App_GetOsdDataValue(E_USERDATA_FRAME_SIZE))
                         || (USERDATA_FRAME_SIZE_MAX - 1 == Hv_App_GetOsdDataValue(E_USERDATA_FRAME_SIZE)));
            break;
        }

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DPU_BRIGHT_FRAME)
#endif
        case ITEM_SYSTEM_RESET_YES_SCENE_MAIN:
        case ITEM_MENU_LOCK_SCENE_MAIN:
        case ITEM_INPUT_SOURCE_SCENE_MAIN:
        case ITEM_INPUT_ADJUST_SCENE_INPUT:
        {
#ifdef HV_SCALER_DEBUG_VERSION
            bNeedDisable = Hv_Mw_OsdIsMonkeyRunning();
#endif
            break;
        }

        case ITEM_VRR_GAMMA_SCENE_MAIN:
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_VRR_GAMMA)
            bNeedDisable = HV_FALSE;
#else
            bNeedDisable = HV_TRUE;
#endif
            break;
        }

        default:
        {
            break;
        }
    }

    return bNeedDisable;
}

BOOL Hv_App_Cb_ItemCheckDisableHide(USHORT16 usItemId)
{
    BOOL bNeedHide = HV_FALSE;
    OsdTimingInfo *pstTiming = Hv_App_OsdGetCurrentTimingInfo();

#if (HV_OSD_CONFIG_AUTO_TEST == HV_CONFIG_ON)
        if (Hv_Mw_OsdIsAutoTestRunning())
        {
            return bNeedHide;
        }
#endif

    switch(usItemId)
    {
        case ITEM_GAME_SCENE_MAIN:
        case ITEM_PICTURE_SCENE_MAIN:
        case ITEM_COLOR_SCENE_MAIN:
        case ITEM_AUDIO_SCENE_MAIN:
        case ITEM_OSD_SCENE_MAIN:
        case ITEM_SYSTEM_SCENE_MAIN:
        {
            bNeedHide = (!pstTiming->bSignalSync && !pstTiming->bSubSignalSync);
            break;
        }

        case ITEM_PXP_SCENE_MAIN:
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP)
#ifdef HV_SCALER_DEBUG_VERSION
            bNeedHide = Hv_Mw_OsdIsMonkeyRunning();
#else
            bNeedHide = HV_FALSE;
#endif
#else
            bNeedHide = HV_TRUE;
#endif
            break;
        }

        case ITEM_AMBI_LIGHT_SCENE_MAIN:
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBIENT_LIGHT)
            bNeedHide = (!pstTiming->bSignalSync && !pstTiming->bSubSignalSync);
#else
            bNeedHide = HV_TRUE;
#endif
            break;
        }

        case ITEM_PICTURE_BOOST_SCENE_MAIN:
        {
#if ((HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_BRIGHT_FRAME) || (HV_CONFIG_ON == HV_PROJECT_CONFIG_DPU_BRIGHT_FRAME))
            bNeedHide = HV_FALSE;
#else
            bNeedHide = HV_TRUE;
#endif
            break;
        }

        default:
        {
            break;
        }
    }

    return bNeedHide;
}

VOID Hv_App_InitToUserSetting(VOID)
{
    OSD_LOG_DEBUG("Init all settings");
    Hv_Mw_OsdUserdataUpdateAll();

    Hv_Mw_SetFromOsdUserdata(E_USERDATA_DISPLAY_MODE);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_LANGUAGE);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_MENUX);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_MENUY);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_MENUTIMER);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_MENUTRANSPARENCY);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_ROTATION);
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_CROSSHAIR)
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_CROSSHAIR);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_DYN_CROSSHAIR);
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_CUSTOM_KEY)
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_CUSTOM_KEY1);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_CUSTOM_KEY2);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_CUSTOM_KEY3);
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_REFRESH_RATE)
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_REFRESH_RATE);
#endif
    Hv_Mw_OsdAdjustFunction(E_USERDATA_TIME_COUNTER, ACT_SET, UD_TIME_COUNTER_V_OFF, SET_ALL);

    Hv_App_PQ_SetDefaultValue();
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_VOLUME);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_MUTE);

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBIENT_LIGHT)
    if (UD_AMBIENTLIGHT_V_AUDIO == Hv_App_GetOsdDataValue(E_USERDATA_AMBIENTLIGHT))
    {
        Hv_Mw_OsdAdjustFunction(E_USERDATA_TIME_DELAY, ACT_SET, 0, SET_ALL);
    }
    else
#endif
    {
        Hv_Mw_SetFromOsdUserdata(E_USERDATA_TIME_DELAY);
    }

    Hv_Mw_SetFromOsdUserdata(E_USERDATA_MPRT);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_LIGHT_EFFECT);
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBIENT_LIGHT)
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_AMBIENTLIGHT);
    if (UD_AMBIENTLIGHT_V_MONO == Hv_App_GetOsdDataValue(E_USERDATA_AMBIENTLIGHT))
    {
        Hv_Mw_SetFromOsdUserdata(E_USERDATA_MONOLIGHT);
    }
#endif

#if ((HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_BRIGHT_FRAME) || (HV_CONFIG_ON == HV_PROJECT_CONFIG_DPU_BRIGHT_FRAME))
    Hv_Mw_OsdAdjustFunction(E_USERDATA_BRIGHT_FRAME, ACT_SET, UD_BRIGHT_FRAME_V_OFF, SET_ALL);
#endif
}

VOID Hv_App_ResetToFactorySetting(VOID)
{
    UCHAR8 ucLanguageBackup = Hv_App_GetOsdDataValue(E_USERDATA_LANGUAGE);
    OSD_LOG_INFO("Reset all settings");

    /* Resume all userdataDB */
    Hv_Mw_DataBase_ResumeUserData();

    /* Update all osd userdata for show */
    Hv_Mw_OsdUserdataUpdateAll();

    /* Recover userdata no need resume */
    Hv_App_OsdSetUserdata(E_USERDATA_LANGUAGE, ucLanguageBackup);

    /* Call all function from userdata */
    for (USHORT16 usId = 1; usId < E_USERDATA_MAX; usId++)
    {
        /* skip call funition */
        if ((usId == E_USERDATA_DISPLAY_MODE)
            || (usId == E_USERDATA_PROPORTION)
            || (usId == E_USERDATA_LDR)
            || (usId == E_USERDATA_COLOR_FILTER)
            || (usId == E_USERDATA_RED)
            || (usId == E_USERDATA_GREEN)
            || (usId == E_USERDATA_BLUE)
            || (usId == E_USERDATA_VIDEOSOURCE)
            || (usId == E_USERDATA_AUTOSOURCE)
            || (usId == E_USERDATA_HDMI_FORMAT)
            || (usId == E_USERDATA_HDMI_ALLM)
            || (usId == E_USERDATA_QMS)
            || (usId == E_USERDATA_DP_VERSION)
            || (usId == E_USERDATA_MAGNIFY_GLASS)
            || (usId == E_USERDATA_HDMI_FORMAT)
            || (usId == E_USERDATA_PXPMODE)
            || (usId == E_USERDATA_PXP_SWITCH)
            || (usId == E_USERDATA_PXPVIDEOSOURCE)
            || (usId == E_USERDATA_AUDIO_SOURCE)
            || (usId == E_USERDATA_PIP_SIZE)
            || (usId == E_USERDATA_PIP_POSITION)
            || (usId == E_USERDATA_FREESYNC))
        {
            continue;
        }
        Hv_Mw_SetFromOsdUserdata(usId);
    }

    /* Disable Factory mode */
    HV_COMMON_DATABASE_SET(SystemData, bFactoryMode, HV_FALSE);
}

static VOID Hv_App_HdrPqSetting(BOOL bIsHdr)
{
    if (UD_COLOR_FILTER_V_NONE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_FILTER))
    {
        /* 色盲模式打开，不设置HDR PQ相关 */
        return;
    }

    if ((bIsHdr) && (UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)))
    {
        /* 关闭动态背光 */
        Hv_Mw_OsdAdjustFunction(E_USERDATA_VARIABLEBACKLIGHT, ACT_SET, UD_VARIABLEBACKLIGHT_V_OFF, SET_ALL);
        /* 关闭运动清晰度 */
        Hv_Mw_OsdAdjustFunction(E_USERDATA_MPRT, ACT_SET, UD_MPRT_V_OFF, SET_ALL);
        /* 亮度设为最大 */
        Hv_Mw_OsdAdjustFunction(E_USERDATA_BRIGHTNESS, ACT_SET, USERDATA_BRIGHTNESS_MAX, SET_INTERFACE | SET_OSDDATA);
        /* 使用HDR专用色彩空间 */
        Hv_App_PQ_SetGamut(PQ_GAMUT_2020);
    }
    else
    {
        /* 恢复当前图像模式 */
        UCHAR8 ucDisplayMode = Hv_App_GetOsdDataValue(E_USERDATA_DISPLAY_MODE);
        Hv_App_SetDisplayMode(ucDisplayMode, SET_ALL);
        /* 恢复色彩空间 */
        Hv_Mw_SetFromOsdUserdata(E_USERDATA_COLOR_SPACE);
        /* 恢复色盲模式 */
        Hv_Mw_SetFromOsdUserdata(E_USERDATA_COLOR_FILTER);
    }
}

VOID Hv_App_UpdateSettingByCurrentTiming(USHORT16 usChannelType)
{
    OsdTimingInfo *pstTiming = Hv_App_OsdGetCurrentTimingInfo();

    if (usChannelType == CHANNEL_TYPE_MAIN)
    {
        if (!pstTiming->bIsHdr)
        {
            /* 设置色盲模式 */
            Hv_Mw_OsdAdjustFunction(E_USERDATA_COLOR_FILTER, ACT_SET, Hv_App_GetOsdDataValue(E_USERDATA_COLOR_FILTER), SET_RELATED | SET_INTERFACE);
        }

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_LDR)
        if (pstTiming->enColorFmt == ColorFormatType_YCbCr422
            || pstTiming->enColorFmt == ColorFormatType_YCbCr444
            || pstTiming->enColorFmt == ColorFormatType_YCbCr420)
        {
            /* 设置量化范围为限制，不调用接口，仅设置Userdata */
            Hv_Mw_OsdAdjustFunction(E_USERDATA_LDR, ACT_SET, UD_LDR_V_LIMIT, SET_OSDDATA);
        }
        else
        {
            /* 恢复之前RGB信号的量化范围设置值 */
            UCHAR8 ucLdr = HV_COMMON_DATABASE_GET(UserData, ucLdrRgb);
            Hv_Mw_OsdAdjustFunction(E_USERDATA_LDR, ACT_SET, ucLdr, SET_OSDDATA);
            Hv_Mw_OsdAdjustFunction(E_USERDATA_LDR, ACT_SET, ucLdr, SET_INTERFACE);
        }
#endif
        if (pstTiming->bIsVrr || (pstTiming->usFrameRate < 85))
        {
            /* 关闭运动清晰度 */
            Hv_Mw_OsdAdjustFunction(E_USERDATA_MPRT, ACT_SET, UD_MPRT_V_OFF, SET_ALL);
        }

        Hv_App_HdrPqSetting(pstTiming->bIsHdr);
    }
    else
    {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_LDR)
        if (pstTiming->enSubColorFmt == ColorFormatType_YCbCr422
            || pstTiming->enSubColorFmt == ColorFormatType_YCbCr444
            || pstTiming->enSubColorFmt == ColorFormatType_YCbCr420)
        {
            /* 设置量化范围为限制，不调用接口，仅设置Userdata */
            Hv_Mw_OsdAdjustFunction(E_USERDATA_LDR, ACT_SET, UD_LDR_V_LIMIT, SET_OSDDATA);
        }
        else
        {
            /* 恢复之前RGB信号的量化范围设置值 */
            UCHAR8 ucLdr = HV_COMMON_DATABASE_GET(UserData, ucLdrRgb);
            Hv_Mw_OsdAdjustFunction(E_USERDATA_LDR, ACT_SET, ucLdr, SET_OSDDATA);
            Hv_Mw_OsdAdjustFunction(E_USERDATA_LDR, ACT_SET, ucLdr, SET_INTERFACE);
        }
#endif
    }

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_ROTATION)
    if (0 == Hv_Ddr_Type())     //DDR2
    {
        if (pstTiming->usFrameRate > 60)
        {
            if (UD_ROTATION_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_ROTATION))
            {
                Hv_Mw_OsdAdjustFunction(E_USERDATA_ROTATION, ACT_SET, UD_ROTATION_V_OFF, SET_ALL);
            }
        }
    }
#endif
}

VOID Hv_App_OsdSetHdmiFormat(SHORT16 sRealValue)
{
    if (UD_VIDEOSOURCE_V_HDMI2 == Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE))
    {
        if (UD_FREESYNC_V_ON == Hv_App_GetOsdDataValue(E_USERDATA_FREESYNC))
        {
            HV_COMMON_DATABASE_SET(UserData, ucHdmi1Format, sRealValue);
            if (sRealValue == UD_HDMI_FORMAT_V_STANDARD)
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX1, EDID_TYPE_TMDS_VRR);
            }
            else if (sRealValue == UD_HDMI_FORMAT_V_ENHANCE)
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX1, EDID_TYPE_FRL_VRR);
            }
            else
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX1, EDID_TYPE_FRL_ENHANCED_VRR);
            }
        }
        else
        {
            HV_COMMON_DATABASE_SET(UserData, ucHdmi1Format, sRealValue);
            if (sRealValue == UD_HDMI_FORMAT_V_STANDARD)
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX1, EDID_TYPE_TMDS);
            }
            else if (sRealValue == UD_HDMI_FORMAT_V_ENHANCE)
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX1, EDID_TYPE_FRL);
            }
            else
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX1, EDID_TYPE_FRL_ENHANCED);
            }
        }
    }
    else
    {
        if (UD_FREESYNC_V_ON == Hv_App_GetOsdDataValue(E_USERDATA_FREESYNC))
        {
            HV_COMMON_DATABASE_SET(UserData, ucHdmi0Format, sRealValue);
            if (sRealValue == UD_HDMI_FORMAT_V_STANDARD)
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX0, EDID_TYPE_TMDS_VRR);
            }
            else if (sRealValue == UD_HDMI_FORMAT_V_ENHANCE)
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX0, EDID_TYPE_FRL_VRR);
            }
            else
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX0, EDID_TYPE_FRL_ENHANCED_VRR);
            }
        }
        else
        {
            HV_COMMON_DATABASE_SET(UserData, ucHdmi0Format, sRealValue);
            if (sRealValue == UD_HDMI_FORMAT_V_STANDARD)
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX0, EDID_TYPE_TMDS);
            }
            else if (sRealValue == UD_HDMI_FORMAT_V_ENHANCE)
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX0, EDID_TYPE_FRL);
            }
            else
            {
                Hv_Mw_HdmiRx_UpdateEdid(LINK_PORT_INDEX_HDMI_RX0, EDID_TYPE_FRL_ENHANCED);
            }
        }
    }
    return;
}

VOID Hv_App_OsdGetHdmiFormat(SHORT16 *psRealValue, SHORT16 *psRealDefaultValue)
{
    if (LINK_PORT_INDEX_HDMI_RX1 == HV_COMMON_DATABASE_GET(UserData, ucVideoSource))
    {
        *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucHdmi1Format);
        *psRealDefaultValue = Hv_Mw_DataBase_GetDefaultUserDataPtr()->ucHdmi1Format;
    }
    else
    {
        *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucHdmi0Format);
        *psRealDefaultValue = Hv_Mw_DataBase_GetDefaultUserDataPtr()->ucHdmi0Format;
    }
}
