measure.c
来自「车载DVD osdIC TW8816原厂代码」· C语言 代码 · 共 1,877 行 · 第 1/4 页
C
1,877 行
WriteTW88(0xff, 0); // page 0
// make sure syncs were detected
#if (defined SUPPORT_PC) || (defined SUPPORT_DTV)
if ((InputSelection == PC) || (InputSelection == DTV))
{
if (( ReadTW88(STATUS0) & 0x01 ) == 0) { // no sync input
#ifdef DEBUG_PC
dPuts("\r\nCheck PC/DTV Cable.....");
#endif
return FALSE;
}
}
else
#else
if (IsNoInput()) // no decoder input
{
#ifdef SUPPORT_TV
if (InputSelection != TV)
#endif
{
#ifdef DEBUG_PC
dPuts("\r\nCheck CVBS/SVIDEO/COMPONENT Cable.....");
#endif
return FALSE;
}
}
#endif
#if (defined SUPPORT_PC) || (defined SUPPORT_DTV)
if ((InputSelection == PC) || (InputSelection == DTV))
{
PcMode = DetectDTVInputSource();
if (PcMode != EE_PC_UNKNOWN) // already got the format from register
return TRUE;
// else continue detect mode table
}
else
#endif
#ifdef SUPPORT_COMPONENT
if( InputSelection == COMPONENT )
{
PcMode = DetectComponentInputMode();
if (PcMode == EE_PC_UNKNOWN)
return FALSE;
else
return TRUE;
}
else
#endif
{ // video/svideo/tv
WriteTW88(0xff, 0); // page 0
VInputStd = DetectDecoderInput();
switch (VInputStd)
{
case PAL:
case SECAM:
case PALN:
PcMode = EE_YPbPr_576I;
break;
case NTSC:
case NTSC4:
case PALM:
case PAL60:
default:
PcMode = EE_YPbPr_480I;
break;
}
#ifdef SUPPORT_TV
if (InputSelection == TV)
{
#ifdef PAL_TV
PcMode = EE_YPbPr_576I;
#else
PcMode = EE_YPbPr_480I;
#endif
}
#endif
return TRUE; // video/svideo/tv don't need to detect mode table
}
#if (defined SUPPORT_PC) || (defined SUPPORT_DTV)
do{
vpn = GetHpnVpn(1); // VPN, IVF
ivf = IVF;
#ifdef DEBUG_PC
dPrintf("\r\n======================== LOOP:%d", (WORD)i);
#endif
PcMode = DecideVGAInputSource(vpn, IVF);
// Check SYNC Loss // HHY 1.47
if( PcMode == EE_PC_UNKNOWN ) {
if(! (ReadTW88(STATUS0) & 0x01) ) {
PcMode = EE_PC_NO_SIGNAL;
#ifdef DEBUG_PC
ePuts("\r\n-----> Sync Loss");
#endif
break;
}
}
i++;
} while ( (PcMode == EE_PC_UNKNOWN) && i<3 ); // max try 3 times
#ifdef DEBUG_PC
if (PcMode < EE_PC_NO_SIGNAL)
dPrintf("\r\n PcMode = %d(%s)", (WORD)PcMode, PcModeStr[PcMode] );
#endif
if( !(ReadTW88(STATUS0) & 0x01) ) {
PcMode = EE_PC_NO_SIGNAL;
#ifdef DEBUG_PC
ePuts("\r\n-----> finished, but Sync Loss");
#endif
}
if ((PcMode != EE_PC_UNKNOWN) && (PcMode != EE_PC_NO_SIGNAL))
{
SetADCandInputRegisterByMode(PcMode);
return TRUE;
}
else
{
return FALSE;
}
#endif
}
// Hans
BYTE SourceMonitor(void)
{
static bit AUTO_STATUS=0;
BYTE std, cRet = TRUE;
#ifdef SUPPORT_COMPONENT
BYTE cMode;
#endif
#if defined( SUPPORT_PC ) || defined( SUPPORT_DTV )
BYTE statusD0, statusD1;
#endif
#ifdef SUPPORT_TV
if (InputSelection == TV) return TRUE;
#endif
if( ( GetDisplayedOSD() & MENU ) ) return TRUE;
if (AutoDetect)
{
WriteTW88(0xff, 0); // page 0
if( AUTO_STATUS == 0 ){
AUTO_STATUS = 1;
#ifdef DEBUG
Printf("\r\nAuto detection Enable");
#endif
}
switch ( GetInputSelection() ) {
case COMPOSITE:
#ifdef SUPPORT_SVIDEO
case SVIDEO:
#endif
#ifdef SUPPORT_TV
case TV:
#endif
//----- Check Decoder ----------------
std = DetectDecoderInput();
if (std == NOINPUT) // sync loss
{
cRet = 2; // go to "NoSignal" state
}
else
{
if ( std!=UNKNOWN && std!= VInputStd )
cCounter++;
else
cCounter = 0;
if (cCounter > 5)
{
cCounter = 0;
VInputStd = std;
cRet = FALSE; // refresh signal setting
}
}
break;
#ifdef SUPPORT_COMPONENT
case COMPONENT:
//----- Check No Input
if(IsNoInput()) { // no decoder input
#ifdef DEBUG
dPrintf("\r\n ModeDetect ==========component sync loss");
#endif
cRet = 2; // go to "NoSignal" state
}
else
{
cMode = ((ReadDecoder(CVFMT) & 0x70) >> 4);
if (cMode != ComponentMode )
cCounter++;
else
cCounter = 0;
if (cCounter > 5)
{
#ifdef DEBUG
dPrintf("\r\n ModeDetect ==========component sync changed");
#endif
cCounter = 0;
ComponentMode = cMode;
cRet = FALSE; // refresh signal setting
}
}
break;
#endif
#if defined( SUPPORT_PC ) || defined( SUPPORT_DTV )
case PC:
case DTV:
statusD0 = ReadTW88(STATUS0);
statusD1 = ReadTW88(STATUS1);
ResetStatusRegs();
if (!( statusD0 & 0x01 )) //means sync loss
{
cRet = 2; // go to "NoSignal" state
}
else
{
if ( (statusD1 & 0x30) == 0x30) // means VSYNC & HSYNC changed
cCounter++;
else
cCounter = 0;
if (cCounter > 5)
{
cCounter = 0;
cRet = FALSE; // refresh signal setting
}
}
break;
#endif
default:
cRet = TRUE;
break;
}
}
else
{
if( AUTO_STATUS == 1 ){
AUTO_STATUS = 0;
#ifdef DEBUG
Printf("\r\nAuto detection Disable");
#endif
}
}
return cRet;
}
// Hans
BYTE NoSignal(void)
{
BYTE cRet = FALSE;
#if (defined SUPPORT_PC) || (defined SUPPORT_DTV)
BYTE statusD0, statusD1;
#endif
#ifdef SUPPORT_TV
if (InputSelection == TV) return FALSE;
#endif
if( ( GetDisplayedOSD() & MENU ) ) return FALSE;
if (AutoDetect == 0)
return FALSE;
#if (defined SUPPORT_PC) || (defined SUPPORT_DTV)
WriteTW88(0xff, 0); // page 0
statusD0 = ReadTW88(STATUS0);
statusD1 = ReadTW88(STATUS1);
if ((InputSelection == PC) || (InputSelection == DTV) )
{
if ((statusD0 & 0x01 ) == 1) // sync detected
{
if (PcMode == EE_PC_UNKNOWN)
{
if ((statusD1 & 0x30) == 0x30) // means Hsync or VSync were changed
{
#ifdef DEBUG
dPrintf("\r\n NoSignal ========== Signal timing changed++D1: %d", (WORD)statusD1);
#endif
bPanelMute = 0;
cRet = TRUE;
}
else
{
if (bPanelMute == 0)
{
#ifdef DEBUG
dPrintf("\r\n NoSignal ========== Signal out of rang");
#endif
bPanelMute = 1;
AudioOff();
if(bBlueScreenOn)
{
PanelFreeRun(1);
WriteTW88(0x70, 0x20);
WriteTW88(0x76, 0xff);
PanelBlack(0);
}
else
PanelMute(1);
DisplayPCInfo(OutOfRangeStr[GetOSDLang()]);
}
cRet = FALSE;
}
}
else // ee_pc_no_signal
{
#ifdef DEBUG
dPrintf("\r\n NoSignal ========== Syncs was detected++D0: %d", (WORD)statusD0);
#endif
bPanelMute = 0;
DisplayInputHold = 0;
cRet = TRUE;
}
}
else // sync loss
{
PcMode = EE_PC_NO_SIGNAL;
if (bPanelMute == 0)
{
#ifdef DEBUG
dPrintf("\r\n NoSignal ========== PC/DTV Sync loss++D0: %d", (WORD)statusD0);
#endif
bPanelMute = 1;
AudioOff();
if(bBlueScreenOn)
{
PanelFreeRun(1);
WriteTW88(0x70, 0x20);
WriteTW88(0x76, 0xff);
PanelBlack(0);
}
else
PanelMute(1);
DisplayInputHold = 1; // Hold Input Information in no signal.
ClearOSDInfo();
DisplayInput();
}
cRet = FALSE;
}
}
else
#endif
{
if(IsNoInput() ) // no decoder input
{
if (bPanelMute == 0)
{
#ifdef DEBUG
dPrintf("\r\n NoSignal ========== Sync loss");
#endif
bPanelMute = 1;
AudioOff();
#ifdef SUPPORT_TV
if (InputSelection != TV)
#endif
if(bBlueScreenOn)
{
WriteTW88(0x2f, 0xe8);// force to black
WriteTW88(0x70, 0x20);
WriteTW88(0x76, 0xff);
PanelBlack(0);
}
else
PanelMute(1);
DisplayInputHold = 1; // Hold Input Information in no signal.
ClearOSDInfo();
DisplayInput();
}
cRet = FALSE;
}
else
{
if(bBlueScreenOn)
WriteTW88(0x2f, 0xe0);// restore 0x02f to default setting
bPanelMute = 0;
DisplayInputHold = 0;
cRet = TRUE;
}
}
//#if (defined SUPPORT_PC) || (defined SUPPORT_DTV)
// ResetStatusRegs();
//#endif
return cRet;
}
// Hans
void SourceProcess(void)
{
BYTE cRet = FALSE;
switch(cSourceState)
{
case ssInputSetup:
InputSetup();
cSourceState = ssMeasureSetup;
break;
case ssMeasureSetup:
PanelMute(1);
MeasureSetup();
SetDelayCount(100); // 100 * 10ms delay
cSourceState = ssModeDetect;
break;
case ssModeDetect:
if (GetDelayCount()) return; // ensure delay enough time for signal detection
cRet = ModeDetect();
if (cRet == TRUE)
cSourceState = ssSourceConfigAndDisplay;
else
cSourceState = ssNoSignal;
break;
case ssSourceConfigAndDisplay:
cRet = SourceConfigAndDisplay();
if (cRet == TRUE)
cSourceState = ssSourceMonitor;
else
cSourceState = ssNoSignal;
break;
case ssSourceMonitor:
cRet = SourceMonitor();
if (cRet == FALSE)
cSourceState = ssMeasureSetup;
else if (cRet == 2)
cSourceState = ssNoSignal;
// else keep monitor state
break;
case ssNoSignal:
cRet = NoSignal();
if (cRet == TRUE)
cSourceState = ssMeasureSetup;
break;
case ssIDLE:
default:
break;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?