📄 mode.c
字号:
//**********************************************************************************************************
// The Software is proprietary, confidential, and valuable to Realtek Semiconductor
// Corporation ("Realtek"). All rights, including but not limited to copyrights,
// patents, trademarks, trade secrets, mask work rights, and other similar rights and interests,
// are reserved to Realtek. Without prior written consent from Realtek, copying, reproduction,
// modification, distribution, or otherwise is strictly prohibited. The Software shall be
// kept strictly in confidence, and shall not be disclosed to or otherwise accessed by
// any third party. @ <2003> - <2008> The Software is provided "AS IS" without any warranty of any kind,
// express, implied, statutory or otherwise.
//**********************************************************************************************************
//----------------------------------------------------------------------------------------------------
// ID Code : Mode.c No.0000
// Update Note :
//----------------------------------------------------------------------------------------------------
#define __MODE__
#include "Common\Header\Include.h"
#if(_SCALER_SERIES_TYPE == _RTD2472D_SERIES)
//--------------------------------------------------
// Description : Mode handler, the main control flow
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CModeHandler(void)
{
CKeyKeyPadLedControl();
if(CPowerHandler())
{
ucCurrState =_PWOFF_STATE; //yc 20080306 for logo
}
switch(ucCurrState)
{
case _PWOFF_STATE:
ucCurrState = GET_POWERSTATUS() ? _INITIAL_STATE : _PWOFF_STATE;
break;
case _INITIAL_STATE:
#if(_AUDIO_SUPPORT == _ON)
CAdjustAudioPower(_ON);
CAdjustAudioMute(_ON);
#endif
//ucCurrState = _SEARCH_STATE;
break;
case _SEARCH_STATE:
if(CSourceHandler())
{
CPowerM2PLLOn();// V010 Patch Note (16) : Improve power consumption by disabling M2PLL.
// Source and sync OK
if(CModeDetect())
{
// Mode stable. Initial display settings switch to active/nosignal/nosupport state
SET_READYFORDISPLAY();
if(stModeInfo.ModeCurr == _MODE_NOSIGNAL)
{
ucCurrState = _NOSIGNAL_STATE;
}
//Anderson 080129 for OD/FRC Support Start
#if(_FRC_SUPPORT == _ON)
else if(stModeInfo.ModeCurr == _MODE_NOSUPPORT)
#else
else if((stModeInfo.ModeCurr == _MODE_NOSUPPORT) || (stModeInfo.IVFreq > _V_FREQ_MAX))
#endif
{
CModeAutoMeasureOn();
ucCurrState = _NOSUPPORT_STATE;
}
else
{
#if((_OD_SUPPORT == _ON) || (_FRC_SUPPORT == _ON))
CMemorySDRAMReset();
#endif
CModeDisplayActiveMode();
if(GET_INPUTSOURCE_TYPE() ==_SOURCE_NONE)
{
return;
}
CModeAutoMeasureOn();
#if(_HDMI_SUPPORT == _ON)
#if(_HDMI_FROM_DVI_CONNECT == _OFF)
if(CHdmiFormatDetect() && ((GET_INPUTPORT_TYPE(g_ucSearchIndex) == _D0_HDMI_PORT) || (GET_INPUTPORT_TYPE(g_ucSearchIndex) == _D1_HDMI_PORT)))//Input source is the HDMI format.
#else
if(CHdmiFormatDetect())
#endif
{
CHdmiAudioFirstTracking();
}
CTimerActiveTimerEvent(SEC(0.5), CHdmiAudioWaitingFlagReadyEven);
#endif
#if(_DCR_MODE == _DCR_TYPE_3)
CDcrInitial();
#endif
#if((_OD_SUPPORT == _ON) || (_FRC_SUPPORT == _ON))
if(ucCurrState == _NOSUPPORT_STATE)
ucCurrState = _NOSUPPORT_STATE;
else
ucCurrState = _ACTIVE_STATE;
#else
ucCurrState = _ACTIVE_STATE;
#endif
}
}
else
{
// Still in search state
}
ucEvent0 = _INACTIVE_COUNTDOWN_EVENT;
}
else
{
if(GET_SEARCH_FINISH())
{
CModeSyncTimeoutCountDownEvent();
CLR_SEARCH_FINISH();
}
}
break;
case _ACTIVE_STATE:
if(CFrameSyncDetect())
CModeResetMode();
else
{
if(CModeIsChange())
{
CModeResetMode();
}
else
{
#if(_HDMI_SUPPORT == _ON)
CModeHdmiStablePolling();
#endif
if(GET_READYFORDISPLAY() == _TRUE)
{
CLR_READYFORDISPLAY();
SET_OSD_READYFORDISPLAY();
//SET_SOURCE_STATE(_CLR_AUTO_CHANGE_STATE);
CSourceSaveSearchData();
#if(_OD_SUPPORT == _ON)
//Anderson 080512 for OD & FRC ON Start
//0805 sephinroth start
if(CMemorySetODCompress() == _FALSE)
{
CMemorySetODOnOff(_OFF);
}
else
{
CMemorySetODFIFO();
CMemorySetODOnOff(_ON);
if(GET_OD_STATUS())//ryan 081121 modified overscan osd to od func
CAdjustODeltaGain(_DEFAULT_OD_GAIN);//ryan 081211 od gain to defualt when od on
else
CAdjustODeltaGain(0x00);//ryan 081211 for od gain to 0 when od off
}
//0805 sephinroth end
//Anderson 080512 for OD & FRC ON End
#endif
#if(_DDCCI_SUPPORT == _ON)
if(GET_FACTORY_MODE())
{
#if(_MCU_TYPE == _REALTEK_EMBEDDED)
MCU_I2C_CHANNEL_CTRL_FF2B = 0x00;
MCU_I2C_SET_SLAVE_FF23 &= 0xfe;
#elif((_MCU_TYPE == _REALTEK_RTD2120) || (_MCU_TYPE == _REALTEK_RTD2122))
MCU_I2C_SET_SLAVE_FF27 &= 0xfe;
#endif
}
else
{
#if(_MCU_TYPE == _REALTEK_EMBEDDED)
if(GET_INPUTSOURCE_STATUS() ==_SOURCE_HDMI)
MCU_I2C_CHANNEL_CTRL_FF2B = 0x01;
else
MCU_I2C_CHANNEL_CTRL_FF2B = 0x00;
#endif//End of #if(_MCU_TYPE == _REALTEK_EMBEDDED)
if(GET_INPUTSOURCE_STATUS() == _SOURCE_VGA)
#if(_MCU_TYPE == _REALTEK_EMBEDDED)
MCU_I2C_SET_SLAVE_FF23 &= 0xfe;
#elif((_MCU_TYPE == _REALTEK_RTD2120) || (_MCU_TYPE == _REALTEK_RTD2122))
MCU_I2C_SET_SLAVE_FF27 &= 0xfe;
#endif
else if(GET_INPUTSOURCE_STATUS() ==_SOURCE_DVI)
#if(_MCU_TYPE == _REALTEK_EMBEDDED)
MCU_I2C_SET_SLAVE_FF23 |= 0x01;
#elif((_MCU_TYPE == _REALTEK_RTD2120) || (_MCU_TYPE == _REALTEK_RTD2122))
MCU_I2C_SET_SLAVE_FF27 |= 0x01;
#endif
}
#endif//End of #if(_DDCCI_SUPPORT == _ON)
//Anderson 080129 for OD/FRC Support End
#if(_ASPECT_RATIO_SUPPORT == _ON)
CModeSetDHWidthToDisplay();
CTimerDelayXms(100);
#endif // End of #if(_ASPECT_RATIO_SUPPORT == _ON)
CPowerPanelOn();
CScalerPageSelect(_PAGE2);
CScalerSetBit(_P2_TMDS_RPS_AE, ~_BIT7, 0);//cyyeh 20080725 active AVmute detect !!
CAdjustEnableWatchDog(_WD_ALL);
#if(_HDMI_SUPPORT == _ON)
CScalerPageSelect(_PAGE2);
if((GET_INPUTPORT_TYPE(g_ucSearchIndex) == _D0_HDMI_PORT) || (GET_INPUTPORT_TYPE(g_ucSearchIndex) == _D1_HDMI_PORT))
//sephinroth 20080606
CAdjustEnableHDMIWatchDog(_WD_PACKET_VARIATION | _WD_SET_AVMUTE_ENABLE);//Enable packet variation Watch Dog
else
CAdjustDisableHDMIWatchDog(_WD_PACKET_VARIATION | _WD_SET_AVMUTE_ENABLE);//Disable packet variation Watch Dog
#endif
#if((_DCR_MODE == _DCR_TYPE_1) || (_DCR_MODE == _DCR_TYPE_2))
if(stSystemData.DcrSetting != _OFF)
ucPreBacklightPWM=_BACKLIGHT_MAX;
#endif
}
#if((_DCR_MODE == _DCR_TYPE_1) || (_DCR_MODE == _DCR_TYPE_2))
#if(_OSD_TYPE == _BENQ_OSD)
if((stSystemData.DcrSetting != _OFF) && (stGlobalData4.PictureMode != _STANDARD_PICTURE) && (stGlobalData4.PictureMode != _SRGB_PICTURE))
#else
if(stSystemData.DcrSetting != _OFF)
#endif
{
CDcrMeasureStartHD();
}
#endif
//**************************ryan 081121***********************
if(CHECKECOON())//ryan add new osd func
{
stPictureData.BackLight=AlignMapToReal(20,_BACKLIGHT_MAX,_BACKLIGHT_MIN);
CAdjustBacklight();
}
//**************************ryan 081121***********************
}
}
break;
case _NOSUPPORT_STATE:
if(GET_READYFORDISPLAY() == _TRUE)
{
CLR_READYFORDISPLAY();
SET_OSD_READYFORDISPLAY();
CModeSetFreeRun();
}
if(CModeIsChange())
CModeResetMode();
break;
case _NOSIGNAL_STATE:
if(GET_READYFORDISPLAY() == _TRUE)
{
CLR_READYFORDISPLAY();
SET_OSD_READYFORDISPLAY();
SET_SOURCE_STATE(_SOURCE_AUTO_CHANGE_STATE);
CModeSetFreeRun();
CScalerPageSelect(_PAGE2);//sephinroth ATC modify 20080710
CScalerSetDataPortBit(_P2_HDMI_ADDR_PORT_C9, _P2_HDMI_SCR_00, ~(_BIT3 | _BIT2), _BIT3);//sephinroth ATC modify
}
if(bChangeSourceKey == _FALSE)
{
if(CModeConnectIsChange() || CSourceHandler())
{
CModeResetMode();
}
}
break;
case _SLEEP_STATE:
if(bNoWakeUp)
break;
if(bSleepByOverRange)
{ //1212 sephinroth start
g_ucSearchTimes = GET_INPUTPORT_SEARCH_TIMES(g_ucSearchIndex);
g_ucSearchFinish = 0;
SET_INPUTSOURCE_TYPE(_SOURCE_NONE);
if(CSourceHandler())
{
if(CModeMeasureReady())
{
if(CModeIsChange())
{
#if(_MCU_TYPE == _REALTEK_EMBEDDED)
CMcuSelectFlashClk(_FLASH_CLK);
#endif
#if(_AUDIO_SUPPORT == _ON)
CAdjustAudioPower(_ON);
#endif
CModeResetMode();
}
}
}
else
{
#if(_MCU_TYPE == _REALTEK_EMBEDDED)
CMcuSelectFlashClk(_FLASH_CLK);
#endif
#if(_AUDIO_SUPPORT == _ON)
CAdjustAudioPower(_ON);
#endif
CModeResetMode();
}
//1212 sephinroth end
}
else if(bChangeSourceKey == _FALSE)
{
if(CModeConnectIsChange() || CSourceHandler())
{
#if(_MCU_TYPE == _REALTEK_EMBEDDED)
CMcuSelectFlashClk(_FLASH_CLK);
#endif
#if(_AUDIO_SUPPORT == _ON)
CAdjustAudioPower(_ON);
#endif
CModeResetMode();
}
}
break;
default:
break;
}
}
//----------------------------------------------------------------------------------------------------
// Measure Functions
//----------------------------------------------------------------------------------------------------
//--------------------------------------------------
// Description : Check measure ready process
// Input Value : None
// Output Value : Return _TRUE if measure finished, _FALSE if timeout
//--------------------------------------------------
bit CModeMeasureReady(void)
{
CScalerSetBit(_SYNC_SELECT_47, ~_BIT0, 0x00);
CAdjustSyncProcessorMeasureStart();
if(CTimerPollingEventProc(60, CMiscModeMeasurePollingEvent))
{
return _TRUE;
}
else
{
CScalerSetBit(_MEAS_HS_PERIOD_H_52, ~_BIT5, 0x00);
return _FALSE;
}
}
//--------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -