📄 mode.c
字号:
CScalerSetDataPortBit(_P2_HDMI_ADDR_PORT_C9, 0x51, 0xfb, 0x00);
}
#endif
for (modecnt = 0; modecnt < _MAX_PRESET_MODE; modecnt++)
{
if (CModeCompareModeDVI(modecnt))
{
break;
}
}
}
}
else
{
CScalerSetBit(_MEAS_HS_PERIOD_H_52, ~_BIT5, 0x00);
modecnt = _MODE_NOSUPPORT;
}
CScalerSetBit(_SYNC_SELECT_47, ~_BIT0, 0x00);
// We don't support input image less than 240 active lines
if(stModeInfo.IVHeight < 240)//cyc:for minimum resolution 720x480i
modecnt = _MODE_NOSUPPORT;
// If no mode found, set to mode 0
else if (modecnt >= _MAX_PRESET_MODE)
modecnt = 0;
// We don't support input image large than 2048 active pixel
if((stModeInfo.IHWidth > 2048))
modecnt = _MODE_NOSUPPORT;
return modecnt;
}
/**
* CModeCompareModeDVI
* Compare mode in the preset table for DVI
* @param <BYTE ucModeCnt> {mode number of the preset table}
* @return {_TRUE if the input mode number is correspondence to the input mode,_FALSE if not}
*
*/
//--------------------------------------------------
// Description : Compare mode for DVI
// Input Value : Mode number
// Output Value : Retrun _TRUE if it's correspondence
//--------------------------------------------------
bit CModeCompareModeDVI(BYTE ucModeCnt)
{
if (stModeInfo.IHWidth != tINPUTMODE_PRESET_TABLE[ucModeCnt].IHWidth)
return _FALSE;
if (stModeInfo.IVHeight != tINPUTMODE_PRESET_TABLE[ucModeCnt].IVHeight)
return _FALSE;
if (abs(stModeInfo.IVFreq - tINPUTMODE_PRESET_TABLE[ucModeCnt].IVFreq) >
tINPUTMODE_PRESET_TABLE[ucModeCnt].IVFreqTolerance)
return _FALSE;
return _TRUE;
}
#endif // #if((_TMDS_SUPPORT == _ON) || (_HDMI_SUPPORT == _ON))
//----------------------------------------------------------------------------------------------------
// Mode Display Functions
//----------------------------------------------------------------------------------------------------
/**
* CModeDisplayActiveMode
* mode setup according to the source
* Display active mode process
* @param <none>
* @return {none}
*
*/
bit CModeDisplayActiveMode(void)
{
#if(_ICM_FUNC)
// ICM off
CScalerPageSelect(_PAGE7);
CScalerSetByte(_P7_ICM_CTRL_D0, 0x00);
#endif
// added by ghyu
//COsdFxDisableOsd();
//CTimerReactiveTimerEvent(SEC(1), COsdFxEnableOsd);
switch (_GET_INPUT_SOURCE())
{
case _SOURCE_VGA:
return CModeSetupModeVGA();
#if(_YPBPR_SUPPORT == _ON)
case _SOURCE_YPBPR:
return CYPbPrSetupMode();
#endif
#if((_TMDS_SUPPORT == _ON) || (_HDMI_SUPPORT == _ON))
case _SOURCE_DVI:
case _SOURCE_HDMI:
return CModeSetupModeDVI();
#endif
}
}
/**
* CModeSetupModeVGA
* Setup VGA display
* Display active mode process
* @param <none>
* @return {none}
*
*/
//--------------------------------------------------
// Description : Setup VGA mode
// Input Value : None
// Output Value : None
//--------------------------------------------------
bit CModeSetupModeVGA(void)
{
BYTE option = 0;
//DebugPrintf("\n CModeSetupModeVGA %c",0x20);
// Get information from mode table, such as IHTotal, IHStartPos, IHWidth, IVStartPos, IVHeight.
CModeGetModeTableInfo();
// Start up settings of VGA mode.
CModeStartUpVGA();
// Get scaling option, Capture window setup, Scaling setup, Display setup
CModeSetupDisplay();
// Load mode user data from eeprom
CEepromLoadModeData(stModeInfo.ModeCurr);
// Setup color processing
CModeSetupColorProcess();
// Setup color conversion
CModeSetupColorConversion();//jerry20070605
CAdjustBacklight();
CAdjustAdcGainOffset();
CAdjustAdcClock(stModeUserData.Clock);
//CAdjustPhase(stModeUserData.Phase);
CAdjustHPosition();
CModeModifyVTotal();
CAdjustVPosition();
CAdjustPeakingCoding();
CScalerPageSelect(_PAGE0);
CScalerSetBit(_P0_ADC_RBG_CTRL_CE, 0x0F, (1/*ucAdcPGA*/ << 4) & 0xF0);
CScalerPageSelect(_PAGE6);
CScalerSetBit(_P6_ENABLE_BIST_CTRL_A0, ~_BIT3, 0x00); //Disable De-interlace Mode
pData[0] = CFrameSyncDo();
if (pData[0] == 2)
{
return _FALSE;
}
CModeSetupEtcs(_FUNCTION_ENABLE);
return _TRUE;
}
/**
* CModeSetupModeDVI
* Setup DVI display
* Display active mode process
* @param <none>
* @return {none}
*
*/
//--------------------------------------------------
// Description : Setup mode DVI
// Input Value : None
// Output Value : None
//--------------------------------------------------
#if((_TMDS_SUPPORT == _ON) || (_HDMI_SUPPORT == _ON))
bit CModeSetupModeDVI(void)
{
BYTE option = 0;
// Do initial settings of DVI mode.
CModeStartUpDVI();
//if(CHdmiFormatDetect())
// COsdFxDisableOsd();
// Get scaling option, Capture window setup, Scaling setup, Display setup
CModeSetupDisplay();
// Setup color processing
CModeSetupColorProcess();
// Setup color conversion
CModeSetupColorConversion();//jerry20070605
CAdjustBacklight();
CAdjustPeakingCoding();
CAdjustYpbprSaturation(GET_SATURATION());
CAdjustYpbprhue(GET_HUE());
CScalerSetBit(_COLOR_CTRL_62,~_BIT2,_BIT2); // Enable SRGB
CAccAdjust(_DISABLE); // disable DCC mode
//For Digital Interlace Mode Compensation
CScalerPageSelect(_PAGE2);
CScalerGetDataPortByte(_P2_HDMI_ADDR_PORT_C9, _P2_HDMI_VCR_50, 1, pData, _NON_AUTOINC);
if((pData[0] & 0x40) == 0x40)
{
CScalerSetBit(_SCALE_CTRL_32, ~(_BIT7 | _BIT6), (_BIT7 | _BIT6));
}
#if(_DE_INTERLACE_SUPPORT == _ON) //v003_interlace_check
//if(GET_INTERLACE_MODE(stSystemData.InputSource)){
if(GET_INTERLACE_MODE())
{
if(stModeInfo.IHWidth <= 720)
{ //for 480i & 576i
//CScalerCodeW(tTMDS_RGB_TO_YUV);//eric 20070607
CModeDeInterlaceSetting();
CScalerPageSelect(_PAGE6);
CScalerSetBit(_P6_PEAKING_ENABLE_C1, ~_BIT0, _BIT0);
}
}
#endif
//forster modified 061123
CAdjustInterlaceIVS2DVSDelay();
pData[0] = CFrameSyncDo();
//DebugPrintf("\n CFrameSyncDo=%x", pData[0]);
if (pData[0] == 2)
{
// ??? if(CHdmiFormatDetect())//741002
// ??? COsdFxEnableOsd();//741002
return _FALSE;
}
CAdjustInterlaceIVS2DVSProtection();
#if(((_TMDS_SUPPORT == _ON) || (_HDMI_SUPPORT == _ON)) && (_DVI_LONG_CABLE_SUPPORT == _ON))
CAdjustTMDSCRCCheck();
#endif
CAdjustTMDSCaptureCheck();
CAdjustHdmiCbCr422(); //730702
CModeSetupEtcs(_FUNCTION_DISABLE);
// ??? if(CHdmiFormatDetect())//741002
// ??? COsdFxEnableOsd();//741002
#if (_HDMI_HOT_PLUG_OPTION == _ENABLE)
else{
//DebugPrintf("zhyftest plug\n",1);
CAdjustBackgroundColor(0x00, 0x00, 0xff); // set background blue screen
// force to background
CScalerSetBit(_VDISP_CTRL_28, 0xff, _BIT5); // Display output is forced to the background color
// CModeHdmiHP();
CModeHDMIChageDelay();
}
#endif
return _TRUE;
}
#endif // #if((_TMDS_SUPPORT == _ON) || (_HDMI_SUPPORT == _ON))
/**
* CModeSetupDisplay
* Setup capture window,scaling and display
* @param <BYTE ucPar> {enable/disable some bit of register}
* @return {none}
*
*/
//--------------------------------------------------
// Description : Setup display
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CModeSetupDisplay(void)
{
BYTE option = 0;
// Get scaling option
option = CModeGetScaleSetting(); ///!decide capture size and display size
// Capture window setup
CModeSetCaptureWindow(option); ///!set captur size
// Scaling setup
CModeSetScaling(option); ///!set scaling factor
// Display setup
CModeSetDisplay(option); ///!set display size
}
/**
* CModeSetupColorProcess
* Setup contrast and brightness
* @param <BYTE ucPar> {enable/disable some bit of register}
* @return {none}
*
*/
//--------------------------------------------------
// Description : Setup contrast and brightness
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CModeSetupColorProcess(void)
{
CEepromLoadBriConData();
CEepromLoadColorTempData();
CAdjustBrightness();
CAdjustContrast();
CScalerSetByte(_COLOR_CTRL_62, 0x03);
}
/**
* CModeSetupColorConversion
* Setup color conversion(RGB->YUV & YUV->RGB)
* @param <BYTE ucPar> {enable/disable some bit of register}
* @return {none}
*
*/
//--------------------------------------------------
// Description : Setup color conversion(RGB->YUV & YUV->RGB)
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CModeSetupColorConversion(void)//jerry20070605
{
if(_GET_INPUT_SOURCE() == _SOURCE_VGA)
{
CScalerCodeW(tRGB2YUV601_TABLE_FOR_RGB_SOURCE);
CScalerCodeW(tYUV2RGB601_TABLE_FOR_RGB_SOURCE);
}
else if(bSourceVideo())
{//AV/SV/TV
CScalerCodeW(tRGB2YUV601_TABLE_FOR_NON_RGB_SOURCE);
CScalerCodeW(tYUV2RGB601_TABLE_FOR_NON_RGB_SOURCE);
}
else if(_GET_INPUT_SOURCE() == _SOURCE_YPBPR)
{
if(stModeInfo.ModeCurr < 4)
{ //SD 720p below
CScalerCodeW(tRGB2YUV601_TABLE_FOR_NON_RGB_SOURCE);
CScalerCodeW(tYUV2RGB601_TABLE_FOR_NON_RGB_SOURCE);
}
else
{ //HD 720p above
CScalerCodeW(tRGB2YUV709_TABLE_FOR_NON_RGB_SOURCE);
CScalerCodeW(tYUV2RGB709_TABLE_FOR_NON_RGB_SOURCE);
}
}
#if(_HDMI_SUPPORT == _ON)
else if(_GET_INPUT_SOURCE() == _SOURCE_DVI || _GET_INPUT_SOURCE() == _SOURCE_HDMI)
{
if(CHdmiFormatDetect())
{ //HDMI timing
CScalerPageSelect(_PAGE2);
CScalerGetDataPortByte(_P2_HDMI_PSAP_CD, 0x07, 1, pData, _NON_AUTOINC);
if(HDMI_ModeMap[pData[0]]<3)
{ //SD 720p below
CScalerGetDataPortByte(_P2_HDMI_PSAP_CD, 0x04, 1, pData, _NON_AUTOINC);
if((pData[0] & 0x60) == 0x00){//RGB
CScalerCodeW(tRGB2YUV601_TABLE_FOR_RGB_SOURCE);
CScalerCodeW(tYUV2RGB601_TABLE_FOR_NON_RGB_SOURCE);
}
else
{//YUV422 & YUV444
CScalerCodeW(tRGB2YUV601_TABLE_FOR_NON_RGB_SOURCE);
CScalerCodeW(tYUV2RGB601_TABLE_FOR_NON_RGB_SOURCE);
}
}
else
{//HD 720p above
CScalerGetDataPortByte(_P2_HDMI_PSAP_CD, 0x04, 1, pData, _NON_AUTOINC);
if((pData[0] & 0x60) == 0x00)
{//RGB
CScalerCodeW(tRGB2YUV709_TABLE_FOR_RGB_SOURCE);
CScalerCodeW(tYUV2RGB709_TABLE_FOR_NON_RGB_SOURCE);
}
else
{//YUV422 & YUV444
CScalerCodeW(tRGB2YUV709_TABLE_FOR_NON_RGB_SOURCE);
CScalerCodeW(tYUV2RGB709_TABLE_FOR_NON_RGB_SOURCE);
}
}
}
else
{ //DVI timing
CScalerCodeW(tRGB2YUV601_TABLE_FOR_RGB_SOURCE);
CScalerCodeW(tYUV2RGB601_TABLE_FOR_RGB_SOURCE);
}
}
#endif
}
/**
* CModeSetupEtcs
* Setup other setings for display
* @param <BYTE ucPar> {enable/disable some bit of register}
* @return {none}
*
*/
//--------------------------------------------------
// Description : Setup other setings for display
// Input Value : None
// Output Value : None
//--------------------------------------------------
void CModeSetupEtcs(BYTE ucPar)
{
CAdjustBackgroundColor(0x00,0x00,0x00); //avoid 4:3 or letter aspect_ratio blue_background
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -