/**
 * @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_OsdOperation.h"
#include "PanelConfig.h"

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_COMMON_DATABASE_SET(UserData, ucBrightness, ucBrightness);
        Hv_App_PQ_SetBrightness(ucBrightness);
        HV_COMMON_DATABASE_SET(UserData, ucContrast, ucContrast);
        Hv_App_PQ_SetContrast(ucContrast);
    }
}

VOID Hv_App_SetDefaultStandardDisplayMode(BOOL bIsHdr, UCHAR8 ucFlag)
{
    OSD_LOG_INFO("Set DisplayMode to default standard");
    Hv_Mw_OsdAdjustFunction(E_USERDATA_BRIGHTNESS, ACT_SET_DEFAULT, 0, ucFlag);
    Hv_Mw_OsdAdjustFunction(E_USERDATA_CONTRAST, ACT_SET_DEFAULT, 0, ucFlag);

    if (bIsHdr)
    {
        /* PQ_GAMUT_ADOBE */
        Hv_App_PQ_SetGamut(4);
    }
    else
    {
        /* Native */
        Hv_Mw_OsdAdjustFunction(E_USERDATA_COLOR_SPACE, ACT_SET_DEFAULT, 0, ucFlag);
    }
    Hv_Mw_OsdAdjustFunction(E_USERDATA_GAMMA, ACT_SET_DEFAULT, 0, ucFlag);
    Hv_Mw_OsdAdjustFunction(E_USERDATA_COLOR_TEMP, ACT_SET_DEFAULT, 0, ucFlag);
    Hv_Mw_OsdAdjustFunction(E_USERDATA_HUE, ACT_SET_DEFAULT, 0, ucFlag);
    Hv_Mw_OsdAdjustFunction(E_USERDATA_SATURATION, ACT_SET_DEFAULT, 0, ucFlag);
    Hv_Mw_OsdAdjustFunction(E_USERDATA_DARKSTABILIZER, ACT_SET_DEFAULT, 0, ucFlag);
}

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 (0 != sOsdValue)
                {
                    Hv_App_OsdSetUserdata(E_USERDATA_DCR, UD_DCR_V_OFF);
                }
            }
            if (ucFlag & SET_INTERFACE)
            {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DCR)
                if (0 != sOsdValue)
                {
                    HV_COMMON_DATABASE_SET(UserData, ucDcr, HV_FALSE);
                }
#endif
                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:
        {
                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));
                        }
#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));
                    }
#endif
                }
            }
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetColorFilterType(sRealValue);
            }
            break;
        }
#endif
        case E_USERDATA_VIDEOSOURCE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucVideoSource, sRealValue);
                Hv_Mw_Video_SetMainVideoSource(sRealValue);
            }
            break;
        }

        case E_USERDATA_AUTOSOURCE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, bAutoVideoSrcSelSw, sRealValue);
            }
            break;
        }

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

        case E_USERDATA_PROPORTION:
        {
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucProportion, sRealValue);
                Hv_Mw_Video_SetAspectRatio(sRealValue);
            }
            break;
        }

        case E_USERDATA_RESPONSETIME:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_PQ_SetODLevel(sRealValue);    // 0-OFF
            }
            break;
        }

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MPRT)
        case E_USERDATA_MPRT:
        {
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucMprt, sRealValue);
                Hv_Drv_MPRT_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_COMMON_DATABASE_SET(UserData, ucMprt, GET_REAL_MAP_VALUE(E_USERDATA_MPRT, UD_MPRT_V_OFF));
                    Hv_Drv_MPRT_SetOutMprtPwmEnable(GET_REAL_MAP_VALUE(E_USERDATA_MPRT, UD_MPRT_V_OFF));
#endif
                }
            }
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucFreeSync, sRealValue);
                Hv_Mw_Video_SetFreeSyncSwitch(sRealValue);
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_HDR)
        case E_USERDATA_HDR:
        {
            if (ucFlag & SET_RELATED)
            {
                if (UD_HDR_V_AUTO == sOsdValue)
                {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MPRT)
                    Hv_App_OsdSetUserdata(E_USERDATA_MPRT, UD_MPRT_V_OFF);
                    HV_COMMON_DATABASE_SET(UserData, ucMprt, GET_REAL_MAP_VALUE(E_USERDATA_MPRT, UD_MPRT_V_OFF));
                    Hv_Drv_MPRT_SetOutMprtPwmEnable(GET_REAL_MAP_VALUE(E_USERDATA_MPRT, UD_MPRT_V_OFF));
#endif
                }
            }

            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, enHdrSwitchBackup, sRealValue);
                Hv_App_PQ_ForceSwitchHdr(sRealValue);
            }
            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 (UD_DCR_V_ON == sOsdValue)
                {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DARK_STABILIZER)
                    Hv_App_OsdSetUserdata(E_USERDATA_DARKSTABILIZER, 0);
                    HV_COMMON_DATABASE_SET(UserData, ucDarkStabilizer, 0);
#endif
                }
            }
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucDcr, sRealValue);
                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;
        }
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBILIGHT)
        case E_USERDATA_DYN_CROSSHAIR:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetDynCrosshair(sRealValue);
            }
            break;
        }
#endif
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY)
        case E_USERDATA_MAGNIFY_GLASS:
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP)
            if (ucFlag & SET_RELATED)
            {
                if (UD_MAGNIFY_GLASS_V_OFF != sRealValue)
                {
                    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_COMMON_DATABASE_SET(UserData, ucSharpness, 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_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
                }
            }
#endif
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, bMagnifyGlassSw, sRealValue);
                Hv_Mw_Video_SetMagnifyGlassSwitch(sRealValue);
            }
            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
        case E_USERDATA_VOLUME:
        {
            if (ucFlag & SET_RELATED)
            {
                Hv_App_OsdSetUserdata(E_USERDATA_MUTE, UD_MUTE_V_OFF);
            }
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucVolume, sRealValue);
                HV_COMMON_DATABASE_SET(UserData, bMute, GET_REAL_MAP_VALUE(E_USERDATA_MUTE, UD_MUTE_V_OFF));
                Hv_Mw_Audio_UIUnMute();
                Hv_Mw_Audio_SetVolume(sRealValue);
            }
            break;
        }

        case E_USERDATA_MUTE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, bMute, sRealValue);
                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_COMMON_DATABASE_SET(UserData, ucAudioSource, sRealValue);
                Hv_Mw_Channel_AudioSourceConfig(sRealValue);
            }
            break;
        }

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

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_LIGHT_EFFECT)
        case E_USERDATA_LIGHT_EFFECT:
        {
            if (ucFlag & SET_OSDDATA)
            {
                HV_COMMON_DATABASE_SET(UserData, ucLightEffect, sRealValue);
            }
            if (ucFlag & SET_INTERFACE)
            {
                Hv_Mw_Led_SetRedLed(HV_FALSE);
                Hv_Mw_Led_SetBlueLed(sRealValue);
                Hv_Mw_Led_SetLedPowerMode(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 == sOsdValue)
                {
                    UCHAR8 ucDisplayMode = Hv_App_GetOsdDataValue(E_USERDATA_DISPLAY_MODE);
                    Hv_App_SetDisplayMode(ucDisplayMode, SET_ALL);
                }
            }
            break;
        }
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_OSD_ROTATION)
        case E_USERDATA_ROTATION:
        {
            if (ucFlag & SET_INTERFACE)
            {
                Hv_App_OsdSetRotateType(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));

                    BOOL bAutoVideoBackup = HV_COMMON_DATABASE_GET(UserData, bAutoVideoSrcSelSw);
                    HV_COMMON_DATABASE_SET(UserData, bAutoVideoBackup, bAutoVideoBackup);
                    Hv_App_OsdSetUserdata(E_USERDATA_AUTOSOURCE, UD_AUTOSOURCE_V_OFF);
                    HV_COMMON_DATABASE_SET(UserData, bAutoVideoSrcSelSw, GET_REAL_MAP_VALUE(E_USERDATA_AUTOSOURCE, UD_AUTOSOURCE_V_OFF));

                    Hv_App_OsdSetUserdata(E_USERDATA_SHARPNESS, 0);
                    HV_COMMON_DATABASE_SET(UserData, ucSharpness, 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

#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));
                    }
#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
                }
                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));
                        }
#endif
                    }
                    BOOL bAutoVideoBackup = HV_COMMON_DATABASE_GET(UserData, bAutoVideoBackup);
                    Hv_App_OsdSetUserdata(E_USERDATA_AUTOSOURCE, GET_OSD_MAP_VALUE(E_USERDATA_AUTOSOURCE, bAutoVideoBackup));
                    HV_COMMON_DATABASE_SET(UserData, bAutoVideoSrcSelSw, bAutoVideoBackup);
                }
            }
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucPxPMode, sRealValue);
                Hv_Mw_Video_SetPxpMode(sRealValue);
            }
            break;
        }

        case E_USERDATA_PXPVIDEOSOURCE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucPxPVideoSource, sRealValue);
                Hv_Mw_Video_SetSubVideoSource(sRealValue);
            }
            break;
        }

        case E_USERDATA_PXP_SWITCH:
        {
            if (ucFlag & SET_INTERFACE)
            {
                UCHAR8 ucMain = HV_COMMON_DATABASE_GET(UserData, ucVideoSource);
                HV_COMMON_DATABASE_SET(UserData, ucVideoSource, HV_COMMON_DATABASE_GET(UserData, ucPxPVideoSource));
                HV_COMMON_DATABASE_SET(UserData, ucPxPVideoSource, ucMain);
                Hv_Mw_OsdUserdataUpdate(E_USERDATA_VIDEOSOURCE);
                Hv_Mw_OsdUserdataUpdate(E_USERDATA_PXPVIDEOSOURCE);

                HV_COMMON_DATABASE_SET(UserData, bPxPSwitch, sRealValue);
                Hv_Mw_Video_SetMainSubVideoSourceSwap(sRealValue);
            }
            break;
        }

        case E_USERDATA_PIP_POSITION:
        {
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucPipPosition, sRealValue);
                Hv_Mw_Video_SetSubVideoWindowPosition(sRealValue);
            }
            break;
        }

        case E_USERDATA_PIP_SIZE:
        {
            if (ucFlag & SET_INTERFACE)
            {
                HV_COMMON_DATABASE_SET(UserData, ucPipSize, sRealValue);
                Hv_Mw_Video_SetSubVideoWindowSize(sRealValue);
            }
            break;
        }
#endif
        default:
        {
            break;
        }
    }
}

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

#if 1
    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_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);     //HV_COMMON_DATABASE_GET(UserData, ucMprt);
            *psRealDefaultValue = pstDefaultData->ucMprt;
            break;
        }
#endif
        case E_USERDATA_FREESYNC:
        {
            *psRealValue = HV_COMMON_DATABASE_GET(UserData, ucFreeSync);     //Hv_Mw_Video_GetFreeSyncSwitch();
            *psRealDefaultValue = pstDefaultData->ucFreeSync;
            break;
        }
#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;
        }
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBILIGHT)
        case E_USERDATA_DYN_CROSSHAIR:
        {
            *psRealValue = Hv_App_OsdGetDynCrosshair();
            *psRealDefaultValue = pstDefaultData->ucDynCrosshair;
            break;
        }
#endif
#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_VARIABLEBACKLIGHT) || (HV_CONFIG_ON == HV_PROJECT_CONFIG_FULL_LOCALDIMMING))
        case E_USERDATA_VARIABLEBACKLIGHT:
        {
            *psRealValue = Hv_App_PQ_GetDCR();
            *psRealDefaultValue = pstDefaultData->bVariableBackLight;
            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, 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

        default:
        {
            break;
        }
    }
#endif
}

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_RED:
        {
            ColorTemperature stColTemp = {0};
            if (UD_COLOR_TEMP_V_COOL == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP))
            {
                stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempCool);
            }
            else if (UD_COLOR_TEMP_V_STANDARD == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP))
            {
                stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempStandard);
            }
            else if (UD_COLOR_TEMP_V_WARM == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP))
            {
                stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempWarm);
            }
            else
            {
                break;
            }
            pstProp->sOsdValue = LINEAR_MAPPING_VALUE(stColTemp.ucColorTempRGain,
                                                      PQ_RGBGAIN_FAC_OSD_START, PQ_RGBGAIN_FAC_OSD_END,
                                                      USERDATA_RED_MIN, USERDATA_RED_MAX);
            break;
        }

        case E_USERDATA_GREEN:
        {
            ColorTemperature stColTemp = {0};
            if (UD_COLOR_TEMP_V_COOL == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP))
            {
                stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempCool);
            }
            else if (UD_COLOR_TEMP_V_STANDARD == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP))
            {
                stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempStandard);
            }
            else if (UD_COLOR_TEMP_V_WARM == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP))
            {
                stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempWarm);
            }
            else
            {
                break;
            }
            pstProp->sOsdValue = LINEAR_MAPPING_VALUE(stColTemp.ucColorTempGGain,
                                                      PQ_RGBGAIN_FAC_OSD_START, PQ_RGBGAIN_FAC_OSD_END,
                                                      USERDATA_GREEN_MIN, USERDATA_GREEN_MAX);
            break;
        }

        case E_USERDATA_BLUE:
        {
            ColorTemperature stColTemp = {0};
            if (UD_COLOR_TEMP_V_COOL == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP))
            {
                stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempCool);
            }
            else if (UD_COLOR_TEMP_V_STANDARD == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP))
            {
                stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempStandard);
            }
            else if (UD_COLOR_TEMP_V_WARM == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP))
            {
                stColTemp = HV_COMMON_DATABASE_GET(FactoryData, stColTempWarm);
            }
            else
            {
                break;
            }
            pstProp->sOsdValue = LINEAR_MAPPING_VALUE(stColTemp.ucColorTempBGain,
                                                      PQ_RGBGAIN_FAC_OSD_START, PQ_RGBGAIN_FAC_OSD_END,
                                                      USERDATA_BLUE_MIN, USERDATA_BLUE_MAX);
            break;
        }

        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;
}

#ifndef OSD_CHECK_DISABLE_BY_EACH_ITEM

static const USHORT16 ausHdmiDisableItemArray[] =
{
    /* HdmiFormat */
    ITEM_HDMI_FORMAT_SCENE_MAIN,
    ITEM_HDMI_FORMAT_ADJUST_SCENE_MAIN,
};
    
static const USHORT16 ausColorSpaceDisableItemArray[] =
{
    ITEM_COLOR_FILTER_SCENE_MAIN,
    ITEM_COLOR_FILTER_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausColorSpaceNativeDisableItemArray[] =
{
    ITEM_BRIGHTNESS_SCENE_MAIN,
    ITEM_BRIGHTNESS_ADJUST_SCENE_MAIN,
    ITEM_BRIGHTNESS_SCENE_BRIGHTNESS,

    ITEM_CONTRAST_SCENE_MAIN,
    ITEM_CONTRAST_ADJUST_SCENE_MAIN,
    ITEM_CONTRAST_SCENE_CONTRAST,

    ITEM_SATURATION_SCENE_MAIN,
    ITEM_SATURATION_ADJUST_SCENE_MAIN,

    ITEM_HUE_SCENE_MAIN,
    ITEM_HUE_ADJUST_SCENE_MAIN,

    ITEM_RED_SCENE_MAIN,
    ITEM_RED_ADJUST_SCENE_MAIN,

    ITEM_GREEN_SCENE_MAIN,
    ITEM_GREEN_ADJUST_SCENE_MAIN,

    ITEM_BLUE_SCENE_MAIN,
    ITEM_BLUE_ADJUST_SCENE_MAIN,

    ITEM_LOW_BLUE_LIGHT_SCENE_MAIN,
    ITEM_LOW_BLUE_LIGHT_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausDynBackLightDisableItemArray[] =
{
    ITEM_BRIGHTNESS_SCENE_MAIN,
    ITEM_BRIGHTNESS_ADJUST_SCENE_MAIN,
    ITEM_BRIGHTNESS_SCENE_BRIGHTNESS,

    ITEM_CONTRAST_SCENE_MAIN,
    ITEM_CONTRAST_ADJUST_SCENE_MAIN,
    ITEM_CONTRAST_SCENE_CONTRAST,

    ITEM_MODE_SCENE_MAIN,
    ITEM_MODE_ADJUST_SCENE_MAIN,
    ITEM_MODE_SCENE_MODE,

    ITEM_DARK_SCENE_MAIN,
    ITEM_DARK_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausHdrDisableItemArray[] =
{
    ITEM_BRIGHTNESS_SCENE_MAIN,
    ITEM_BRIGHTNESS_ADJUST_SCENE_MAIN,
    ITEM_BRIGHTNESS_SCENE_BRIGHTNESS,

    ITEM_CONTRAST_SCENE_MAIN,
    ITEM_CONTRAST_ADJUST_SCENE_MAIN,
    ITEM_CONTRAST_SCENE_CONTRAST,
        
    ITEM_DCR_SCENE_MAIN,
    ITEM_DCR_ADJUST_SCENE_MAIN,

    ITEM_MODE_SCENE_MAIN,
    ITEM_MODE_ADJUST_SCENE_MAIN,
    ITEM_MODE_SCENE_MODE,

    ITEM_DARK_SCENE_MAIN,
    ITEM_DARK_ADJUST_SCENE_MAIN,

    ITEM_HUE_SCENE_MAIN,
    ITEM_HUE_ADJUST_SCENE_MAIN,

    ITEM_GAMMA_SCENE_MAIN,
    ITEM_GAMMA_ADJUST_SCENE_MAIN,

    ITEM_SHARPNESS_SCENE_MAIN,
    ITEM_SHARPNESS_ADJUST_SCENE_MAIN,

    ITEM_LDG_SCENE_MAIN,
    ITEM_LDG_ADJUST_SCENE_MAIN,

    //ITEM_COLOR_FILTER_SCENE_MAIN,
    //ITEM_COLOR_FILTER_ADJUST_SCENE_MAIN,

    ITEM_COLOR_SPACE_SCENE_MAIN,
    ITEM_COLOR_SPACE_ADJUST_SCENE_MAIN,

    ITEM_TEMPRETURE_SCENE_MAIN,
    ITEM_TEMPRETURE_ADJUST_SCENE_MAIN,

    ITEM_LOW_BLUE_LIGHT_SCENE_MAIN,
    ITEM_LOW_BLUE_LIGHT_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausHdrOnDisableItemArray[] =
{
    ITEM_MPRT_SCENE_MAIN,
    ITEM_MPRT_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausColorTempDisableItemArray[] =
{
    ITEM_RED_SCENE_MAIN,
    ITEM_RED_ADJUST_SCENE_MAIN,

    ITEM_GREEN_SCENE_MAIN,
    ITEM_GREEN_ADJUST_SCENE_MAIN,

    ITEM_BLUE_SCENE_MAIN,
    ITEM_BLUE_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausYcbcrDisableItemArray[] =
{
    ITEM_LDG_SCENE_MAIN,
    ITEM_LDG_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausFrameRateDisableItemArray[] =
{
    ITEM_MPRT_SCENE_MAIN,
    ITEM_MPRT_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausFrcDisableItemArray[] =
{
    ITEM_MPRT_SCENE_MAIN,
    ITEM_MPRT_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausFreesyncDisableItemArray[] =
{
    ITEM_MPRT_SCENE_MAIN,
    ITEM_MPRT_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausFreesync2DisableItemArray[] =
{
    ITEM_HDR_SCENE_MAIN,
    ITEM_HDR_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausOutOfRangeDisableItemArray[] =
{
    ITEM_FREESYNC_SCENE_MAIN,
    ITEM_FREESYNC_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausPipDisableItemArray[] =
{
    ITEM_PIP_POSITION_SCENE_MAIN,
    ITEM_PIP_POSITION_ADJUST_SCENE_MAIN,

    ITEM_PIP_SIZE_SCENE_MAIN,
    ITEM_PIP_SIZE_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausSameSignalItemArray[] =
{
    ITEM_INPUT_SWAP_SCENE_MAIN,
    ITEM_INPUT_SWAP_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausMagnifyDisableItemArray[] =
{
    ITEM_DISPLAY_SIZE_SCENE_MAIN,
    ITEM_DISPLAY_SIZE_ADJUST_SCENE_MAIN,

    ITEM_SHARPNESS_SCENE_MAIN,
    ITEM_SHARPNESS_ADJUST_SCENE_MAIN,

    ITEM_DARK_SCENE_MAIN,
    ITEM_DARK_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausPxpOnDisableItemArray[] =
{
    ITEM_HDR_SCENE_MAIN,
    ITEM_HDR_ADJUST_SCENE_MAIN,

    ITEM_DISPLAY_SIZE_SCENE_MAIN,
    ITEM_DISPLAY_SIZE_ADJUST_SCENE_MAIN,

    ITEM_SHARPNESS_SCENE_MAIN,
    ITEM_SHARPNESS_ADJUST_SCENE_MAIN,

    ITEM_DARK_SCENE_MAIN,
    ITEM_DARK_ADJUST_SCENE_MAIN,

    ITEM_HDMI_FORMAT_SCENE_MAIN,
    ITEM_HDMI_FORMAT_ADJUST_SCENE_MAIN,

    ITEM_AUTO_SELECT_SCENE_MAIN,
    ITEM_AUTO_SELECT_ADJUST_SCENE_MAIN,

    ITEM_FREESYNC_SCENE_MAIN,
    ITEM_FREESYNC_ADJUST_SCENE_MAIN,

    ITEM_ROTATE_SCENE_MAIN,
    ITEM_ROTATE_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausPxpOffDisableItemArray[] =
{
    ITEM_SUB_INPUT_SCENE_MAIN,
    ITEM_SUB_INPUT_ADJUST_SCENE_MAIN,

    ITEM_INPUT_SWAP_SCENE_MAIN,
    ITEM_INPUT_SWAP_ADJUST_SCENE_MAIN,

    ITEM_AUDIO_SOURCE_SCENE_MAIN,
    ITEM_AUDIO_SOURCE_ADJUST_SCENE_MAIN,

    ITEM_PIP_POSITION_SCENE_MAIN,
    ITEM_PIP_POSITION_ADJUST_SCENE_MAIN,

    ITEM_PIP_SIZE_SCENE_MAIN,
    ITEM_PIP_SIZE_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausRotationDisableItemArray[] =
{
    ITEM_ROTATE_SCENE_MAIN,
    ITEM_ROTATE_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausOtaDisableItemArray[] =
{
    ITEM_OTA_SCENE_MAIN,
};

static const USHORT16 ausAudioDelayDisableItemArray[] =
{
    ITEM_TIME_DELAY_SCENE_MAIN,
    ITEM_TIME_DELAY_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausColorFilterDisableItemArray[] =
{
    ITEM_HDR_SCENE_MAIN,
    ITEM_HDR_ADJUST_SCENE_MAIN,
};

static const USHORT16 ausAlwaysDisableItemArray[] =
{
    ITEM_KEY3_SCENE_MAIN,
    ITEM_KEY3_ADJUST_SCENE_MAIN,

    ITEM_MODEL_SCENE_MAIN,
    ITEM_MODEL_VALUE_SCENE_MAIN,
    ITEM_SN_SCENE_MAIN,
    ITEM_SN_VALUE_SCENE_MAIN,
    ITEM_VERSION_SCENE_MAIN,
    ITEM_VERSION_VALUE_SCENE_MAIN,
    ITEM_SOURCE_SCENE_MAIN,
    ITEM_SOURCE_VALUE_SCENE_MAIN,
    ITEM_RESOLUTION_SCENE_MAIN,
    ITEM_RESOLUTION_VALUE_SCENE_MAIN,

#if 0
    /* for monkey */
    ITEM_YES_SCENE_RESET_ALL,
    ITEM_LOCK_SCENE_MAIN,
    ITEM_INPUT_SCENE_MAIN,
    //ITEM_FACTORY_SCENE_MAIN,
    //ITEM_PXP_MODE_SCENE_MAIN,
#endif
};

static const USHORT16 ausMonkeyTestDisableItemArray[] =
{
    /* for monkey test */
    ITEM_YES_SCENE_RESET_ALL,
    ITEM_LOCK_SCENE_MAIN,
    ITEM_INPUT_SCENE_MAIN,
    ITEM_AUTO_SELECT_SCENE_MAIN,
    ITEM_FACTORY_SCENE_MAIN,
    ITEM_INPUT_SWAP_SCENE_MAIN,
};

VOID Hv_App_CheckItemDisableState(VOID)
{
    OsdTimingInfo *pstTiming = Hv_App_OsdGetCurrentTimingInfo();


    /* Enable all items disabled by prev conditions */
    Hv_Mw_ItemRecoverDisableArray();

    /* Check new conditions to disable items */
    Hv_Mw_ItemDisableByCondition((UD_VIDEOSOURCE_V_HDMI1 != Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE)) &&
                                    (UD_VIDEOSOURCE_V_HDMI2 != Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE)),
                                   ausHdmiDisableItemArray,
                                   ARRAY_SIZE(ausHdmiDisableItemArray));

    Hv_Mw_ItemDisableByCondition((UD_COLOR_SPACE_V_NATIVE == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)),
                                   ausColorSpaceDisableItemArray,
                                   ARRAY_SIZE(ausColorSpaceDisableItemArray));
    Hv_Mw_ItemDisableByCondition((UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)),
                                   ausColorSpaceNativeDisableItemArray,
                                   ARRAY_SIZE(ausColorSpaceNativeDisableItemArray));

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_VARIABLEBACKLIGHT)
    Hv_Mw_ItemDisableByCondition((UD_VARIABLEBACKLIGHT_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_VARIABLEBACKLIGHT)),
                                   ausDynBackLightDisableItemArray,
                                   ARRAY_SIZE(ausDynBackLightDisableItemArray));
#endif

    Hv_Mw_ItemDisableByCondition(((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr),
                                   ausHdrDisableItemArray,
                                   ARRAY_SIZE(ausHdrDisableItemArray));

    Hv_Mw_ItemDisableByCondition(UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR),
                                   ausHdrOnDisableItemArray,
                                   ARRAY_SIZE(ausHdrOnDisableItemArray));

    Hv_Mw_ItemDisableByCondition((UD_COLOR_TEMP_V_CUSTOM != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP)),
                                   ausColorTempDisableItemArray,
                                   ARRAY_SIZE(ausColorTempDisableItemArray));

    Hv_Mw_ItemDisableByCondition((pstTiming->bSignalSync && (pstTiming->enColorFmt == ColorFormatType_YCbCr422
                                    || pstTiming->enColorFmt == ColorFormatType_YCbCr444
                                    || pstTiming->enColorFmt == ColorFormatType_YCbCr420)),
                                   ausYcbcrDisableItemArray,
                                   ARRAY_SIZE(ausYcbcrDisableItemArray));

    Hv_Mw_ItemDisableByCondition(pstTiming->usFrameRate < 85,
                                   ausFrameRateDisableItemArray,
                                   ARRAY_SIZE(ausFrameRateDisableItemArray));

    Hv_Mw_ItemDisableByCondition(pstTiming->bIsFrc,
                                   ausFrcDisableItemArray,
                                   ARRAY_SIZE(ausFrcDisableItemArray));

    Hv_Mw_ItemDisableByCondition(pstTiming->bIsFreesync,
                                   ausFreesyncDisableItemArray,
                                   ARRAY_SIZE(ausFreesyncDisableItemArray));

    Hv_Mw_ItemDisableByCondition(pstTiming->bIsFreesync && (2 >= pstTiming->ucFreesyncVersion),
                                   ausFreesync2DisableItemArray,
                                   ARRAY_SIZE(ausFreesync2DisableItemArray));

    Hv_Mw_ItemDisableByCondition((pstTiming->usHActive > PANEL_H_ACTIVE) && (pstTiming->usVActive > PANEL_V_ACTIVE),
                                   ausOutOfRangeDisableItemArray,
                                   ARRAY_SIZE(ausOutOfRangeDisableItemArray));

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP)
    Hv_Mw_ItemDisableByCondition((UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) &&
                                    (pstTiming->bSubSignalSync && (pstTiming->enSubColorFmt == ColorFormatType_YCbCr422
                                    || pstTiming->enSubColorFmt == ColorFormatType_YCbCr444
                                    || pstTiming->enSubColorFmt == ColorFormatType_YCbCr420)),
                                   ausYcbcrDisableItemArray,
                                   ARRAY_SIZE(ausYcbcrDisableItemArray));

    Hv_Mw_ItemDisableByCondition(UD_PXPMODE_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE),
                                   ausPxpOffDisableItemArray,
                                   ARRAY_SIZE(ausPxpOffDisableItemArray));

    Hv_Mw_ItemDisableByCondition(UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE),
                                   ausPxpOnDisableItemArray,
                                   ARRAY_SIZE(ausPxpOnDisableItemArray));

    Hv_Mw_ItemDisableByCondition(UD_PXPMODE_V_PIP != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE),
                                   ausPipDisableItemArray,
                                   ARRAY_SIZE(ausPipDisableItemArray));

    Hv_Mw_ItemDisableByCondition(Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE) == Hv_App_GetOsdDataValue(E_USERDATA_PXPVIDEOSOURCE),
                                   ausSameSignalItemArray,
                                   ARRAY_SIZE(ausSameSignalItemArray));
#endif

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY)
    Hv_Mw_ItemDisableByCondition(UD_MAGNIFY_GLASS_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_MAGNIFY_GLASS),
                                   ausMagnifyDisableItemArray,
                                   ARRAY_SIZE(ausMagnifyDisableItemArray));
#endif

#if (HV_CONFIG_OFF == HV_PROJECT_CONFIG_OSD_ROTATION)
    Hv_Mw_ItemDisableByCondition(HV_TRUE, ausRotationDisableItemArray,
                                   ARRAY_SIZE(ausRotationDisableItemArray));
#else

#endif

#ifndef CONFIG_USER_USB_OTA_ON
    Hv_Mw_ItemDisableByCondition(HV_TRUE, ausOtaDisableItemArray,
                                   ARRAY_SIZE(ausOtaDisableItemArray));
#endif


    Hv_Mw_ItemDisableByCondition((((UD_VIDEOSOURCE_V_DP == Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE)) ||
                                     (UD_VIDEOSOURCE_V_USB_C == Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE)))
                                     && (pstTiming->usHActive < 800) && (pstTiming->usVActive < 600))
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_PXP)
                                    || (((UD_PXPVIDEOSOURCE_V_DP == Hv_App_GetOsdDataValue(E_USERDATA_PXPVIDEOSOURCE)) ||
                                         (UD_PXPVIDEOSOURCE_V_USB_C == Hv_App_GetOsdDataValue(E_USERDATA_PXPVIDEOSOURCE)))
                                        && (pstTiming->usSubHActive < 800) && (pstTiming->usSubVActive < 600))
#endif
                                   , ausAudioDelayDisableItemArray,
                                   ARRAY_SIZE(ausAudioDelayDisableItemArray));

    Hv_Mw_ItemDisableByCondition(UD_COLOR_FILTER_V_NONE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_FILTER),
                                 ausColorFilterDisableItemArray,
                                 ARRAY_SIZE(ausColorFilterDisableItemArray));

    Hv_Mw_ItemDisableByCondition(HV_TRUE, ausAlwaysDisableItemArray,
                                   ARRAY_SIZE(ausAlwaysDisableItemArray));
#ifdef HV_SCALER_DEBUG_VERSION
    Hv_Mw_ItemDisableByCondition(Hv_Mw_OsdIsMonkeyRunning(), ausMonkeyTestDisableItemArray,
                                   ARRAY_SIZE(ausMonkeyTestDisableItemArray));
#endif
}

#else

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

    switch (usItemId)
    {
        case ITEM_HDMI_FORMAT_SCENE_MAIN:
        case ITEM_HDMI_FORMAT_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = ((UD_VIDEOSOURCE_V_HDMI1 != Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE)) &&
                            (UD_VIDEOSOURCE_V_HDMI2 != Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE))) ||
                           (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE));
            break;
        }
        case ITEM_COLOR_FILTER_SCENE_MAIN:
        case ITEM_COLOR_FILTER_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE == Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE));
            break;
        }
        case ITEM_BRIGHTNESS_SCENE_MAIN:
        case ITEM_BRIGHTNESS_ADJUST_SCENE_MAIN:
        case ITEM_BRIGHTNESS_SCENE_BRIGHTNESS:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)) ||
                           (UD_VARIABLEBACKLIGHT_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_VARIABLEBACKLIGHT)) ||
                           (((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr));
            break;
        }
        case ITEM_CONTRAST_SCENE_MAIN:
        case ITEM_CONTRAST_ADJUST_SCENE_MAIN:
        case ITEM_CONTRAST_SCENE_CONTRAST:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)) ||
                           (UD_VARIABLEBACKLIGHT_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_VARIABLEBACKLIGHT)) ||
                           (((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr));
            break;
        }
        case ITEM_SATURATION_SCENE_MAIN:
        case ITEM_SATURATION_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE));
            break;
        }
        case ITEM_HUE_SCENE_MAIN:
        case ITEM_HUE_ADJUST_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_RED_SCENE_MAIN:
        case ITEM_RED_ADJUST_SCENE_MAIN:
        case ITEM_GREEN_SCENE_MAIN:
        case ITEM_GREEN_ADJUST_SCENE_MAIN:
        case ITEM_BLUE_SCENE_MAIN:
        case ITEM_BLUE_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (UD_COLOR_SPACE_V_NATIVE != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_SPACE)) ||
                           (UD_COLOR_TEMP_V_CUSTOM != Hv_App_GetOsdDataValue(E_USERDATA_COLOR_TEMP));
            break;
        }
        case ITEM_LOW_BLUE_LIGHT_SCENE_MAIN:
        case ITEM_LOW_BLUE_LIGHT_ADJUST_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_MAIN:
        case ITEM_MODE_SCENE_MODE:
        {
            bNeedDisable = (UD_VARIABLEBACKLIGHT_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_VARIABLEBACKLIGHT)) ||
                           (((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr));
            break;
        }
        case ITEM_DARK_SCENE_MAIN:
        case ITEM_DARK_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (UD_VARIABLEBACKLIGHT_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_VARIABLEBACKLIGHT)) ||
                           (((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_DCR_SCENE_MAIN:
        case ITEM_DCR_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr));
            break;
        }
        case ITEM_GAMMA_SCENE_MAIN:
        case ITEM_GAMMA_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr));
            break;
        }
        case ITEM_SHARPNESS_SCENE_MAIN:
        case ITEM_SHARPNESS_ADJUST_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_LDG_SCENE_MAIN:
        case ITEM_LDG_ADJUST_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)));
            break;
        }
        case ITEM_COLOR_SPACE_SCENE_MAIN:
        case ITEM_COLOR_SPACE_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr));
            break;
        }
        case ITEM_TEMPRETURE_SCENE_MAIN:
        case ITEM_TEMPRETURE_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (((UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) && pstTiming->bIsHdr));
            break;
        }
        case ITEM_MPRT_SCENE_MAIN:
        case ITEM_MPRT_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (UD_HDR_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_HDR)) ||
                           (pstTiming->usFrameRate < 85) ||
                           (pstTiming->bIsFrc) ||
                           (pstTiming->bIsFreesync);
            break;
        }
        case ITEM_HDR_SCENE_MAIN:
        case ITEM_HDR_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (pstTiming->bIsFreesync && (2 >= pstTiming->ucFreesyncVersion)) ||
                           (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:
        case ITEM_FREESYNC_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = ((pstTiming->usHActive > PANEL_H_ACTIVE) && (pstTiming->usVActive > PANEL_V_ACTIVE)) ||
                           (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE));
            break;
        }
        case ITEM_SUB_INPUT_SCENE_MAIN:
        case ITEM_SUB_INPUT_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE));
            break;
        }
        case ITEM_INPUT_SWAP_SCENE_MAIN:
        case ITEM_INPUT_SWAP_ADJUST_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)) ||
                           Hv_Mw_OsdIsMonkeyRunning();
            break;
        }
        case ITEM_AUDIO_SOURCE_SCENE_MAIN:
        case ITEM_AUDIO_SOURCE_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF == Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE));
            break;
        }
        case ITEM_PIP_POSITION_SCENE_MAIN:
        case ITEM_PIP_POSITION_ADJUST_SCENE_MAIN:
        case ITEM_PIP_SIZE_SCENE_MAIN:
        case ITEM_PIP_SIZE_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_PIP != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE));
            break;
        }
        case ITEM_DISPLAY_SIZE_SCENE_MAIN:
        case ITEM_DISPLAY_SIZE_ADJUST_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:
        case ITEM_AUTO_SELECT_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
                           Hv_Mw_OsdIsMonkeyRunning();
            break;
        }
        case ITEM_ROTATE_SCENE_MAIN:
        case ITEM_ROTATE_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = (UD_PXPMODE_V_OFF != Hv_App_GetOsdDataValue(E_USERDATA_PXPMODE)) ||
#if (HV_CONFIG_OFF == HV_PROJECT_CONFIG_OSD_ROTATION)
                           HV_TRUE;
#else
                           HV_FALSE;
#endif

            break;
        }
        case ITEM_OTA_SCENE_MAIN:
        {
#ifndef CONFIG_USER_USB_OTA_ON
            bNeedDisable = HV_TRUE;
#else
            bNeedDisable = HV_FALSE;
#endif
            break;
        }
        case ITEM_TIME_DELAY_SCENE_MAIN:
        case ITEM_TIME_DELAY_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = ((((UD_VIDEOSOURCE_V_DP == Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE)) ||
                              (UD_VIDEOSOURCE_V_USB_C == Hv_App_GetOsdDataValue(E_USERDATA_VIDEOSOURCE)))
                            && (pstTiming->usHActive < 800) && (pstTiming->usVActive < 600))
                            || (((UD_PXPVIDEOSOURCE_V_DP == Hv_App_GetOsdDataValue(E_USERDATA_PXPVIDEOSOURCE)) ||
                                 (UD_PXPVIDEOSOURCE_V_USB_C == Hv_App_GetOsdDataValue(E_USERDATA_PXPVIDEOSOURCE)))
                                  && (pstTiming->usSubHActive < 800) && (pstTiming->usSubVActive < 600)));
            break;
        }
        case ITEM_KEY3_SCENE_MAIN:
        case ITEM_KEY3_ADJUST_SCENE_MAIN:
        {
            bNeedDisable = HV_TRUE;
            break;
        }
        case ITEM_MODEL_SCENE_MAIN:
        case ITEM_MODEL_VALUE_SCENE_MAIN:
        case ITEM_SN_SCENE_MAIN:
        case ITEM_SN_VALUE_SCENE_MAIN:
        case ITEM_VERSION_SCENE_MAIN:
        case ITEM_VERSION_VALUE_SCENE_MAIN:
        case ITEM_SOURCE_SCENE_MAIN:
        case ITEM_SOURCE_VALUE_SCENE_MAIN:
        case ITEM_RESOLUTION_SCENE_MAIN:
        case ITEM_RESOLUTION_VALUE_SCENE_MAIN:
        {
            bNeedDisable = HV_TRUE;
            break;
        }
        case ITEM_YES_SCENE_RESET_ALL:
        case ITEM_LOCK_SCENE_MAIN:
        case ITEM_INPUT_SCENE_MAIN:
        {
            bNeedDisable = Hv_Mw_OsdIsMonkeyRunning();
            break;
        }
        case ITEM_FACTORY_SCENE_MAIN:
        {
            bNeedDisable = Hv_Mw_OsdIsMonkeyRunning() ||
                           (!HV_COMMON_DATABASE_GET(SystemData, bFactoryMode));
            break;
        }
        default:
        {
            break;
        }
    }

    return bNeedDisable;
}

#endif

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);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_CROSSHAIR);
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_AMBIENT_LIGHT)
    if (UD_AMBIENTLIGHT_V_VIDEO != Hv_App_GetOsdDataValue(E_USERDATA_AMBIENTLIGHT))
#endif
    {
        Hv_Mw_SetFromOsdUserdata(E_USERDATA_DYN_CROSSHAIR);       /* must after menu pos init */
    }
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_CUSTOM_KEY1);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_CUSTOM_KEY2);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_CUSTOM_KEY3);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_REFRESH_RATE);
    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);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_TIME_DELAY);

    Hv_Mw_SetFromOsdUserdata(E_USERDATA_MPRT);
    Hv_Mw_SetFromOsdUserdata(E_USERDATA_LIGHT_EFFECT);
}

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_DCR)     //use E_USERDATA_VARIABLEBACKLIGHT
            || (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_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)
            || (usId == E_USERDATA_MPRT))
        {
            continue;
        }
        Hv_Mw_SetFromOsdUserdata(usId);
    }

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

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

    if (bIsHdr)
    {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_VARIABLEBACKLIGHT)
        /* 关闭动态背光 */
        Hv_Mw_OsdAdjustFunction(E_USERDATA_VARIABLEBACKLIGHT, ACT_SET, UD_VARIABLEBACKLIGHT_V_OFF, SET_ALL);
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MPRT)
        /* 关闭运动清晰度 */
        Hv_Mw_OsdAdjustFunction(E_USERDATA_MPRT, ACT_SET, UD_MPRT_V_OFF, SET_ALL);
#endif
        /* 亮度设为最大 */
        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);
#if (HV_PROJECT_CONFIG_COLOR_FILTER == HV_CONFIG_ON)
        /* 恢复色盲模式 */
        Hv_Mw_SetFromOsdUserdata(E_USERDATA_COLOR_FILTER);
#endif
    }
}

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

    Hv_App_HdrPqSetting(pstTiming->bIsHdr);
}

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;
    }
    return;
}