📄 mode1
字号:
#if DO_COMPSYNC
pol = RegByteIn(0x07);
if (pol & 0x01) {
RegBitOut(0x17, 0x80, 0x80);
#if MASCOTV_C
RegBitOut(0x32, 0x00, 0x80);
#endif
}
if (pol & 0x03 == 0x03) {
RegBitOut(0x18,0x00,0xc0);
}
#endif
#if CHIMEI14_PATCH
if ((CurrentWidth == 1024) && (CurrentHeight == 768)) {
if((CurrentMode == 13) //126 1024x768 70Hz
&& (VsyncCnt >= 0xb40) && (VsyncCnt <= 0xb50) && (HsyncCnt >= 0x8d0) && (HsyncCnt <= 0x8e0))
{
RegByteOut(0x41, 0xA7);
}
else if((CurrentMode == 14) //127 1024x768 72Hz
&& (VsyncCnt >= 0xa2a) && (VsyncCnt <= 0xa31) && (HsyncCnt >= 0x9d0) && (HsyncCnt <= 0x9da))
{
RegByteOut(0x41, 0xa9);
}
else
{
if ( !modeAdjustHt() )
return MODE_OUTOFSYNC;
}
} else {
temp = modeAdjust();
if (temp == 0)
return MODE_OUTOFSYNC;
if (temp == 2)
return MODE_OVERFLOW;
}
#else
temp = modeAdjust();
if (temp == 0)
return MODE_OUTOFSYNC;
if (temp == 2)
return MODE_OVERFLOW;
#endif
#if DO_COLOR_TUNE
if (!(MosaicFlag & FLAG_PORTB)) {
setColorRGB(); // gain
}
#endif
disableOSD();
// clear sync flags
MosaicFlag &= ~FLAG_SYNCMASK; // clear sync bits
if ( HsyncCnt > HSYNC_KHZ(100))
{
if (eepData.MascotFlag & FLAG_POWERSTATUS)
miscTurnOnPower();
dspMute(1);
osdOutOfScanRange();
miscDelay(4000);
powerSavingMode();
return mode;
}
#if (CHIMEI_N141X201_C3+CHIMEI_N141X201_C4)
else if (CurrentWidth > 1024 || CurrentHeight > 768)
{
dspMute(1);
osdOutOfScanRange();
}
#endif
else if ( HsyncCnt < HSYNC_KHZ(MIN_hsync) || HsyncCnt > HSYNC_KHZ(MAX_hsync)
|| VsyncCnt > VSYNC_HZ(MIN_vsync) || VsyncCnt < VSYNC_HZ(MAX_vsync)
|| CurrentWidth > 1024 || CurrentHeight > 768)
{
OutWithBackground = 1;
osdOutOfScanRange();
}
if (eepData.MascotFlag & FLAG_POWERSTATUS)
{
RegBitOut(0x40,0x00,0x70); //mute -> normal display
miscTurnOnPower();
if ((eepData.MascotFlag & FLAG_FACTORY)&& ( !OutWithBackground ))
{
versionMenu();
}
}
else
{
miscEnterSleepMode();
}
return mode;
}
#define TOP_DCLK_M 0x01 // 108M
#define TOP_DCLK_N 0x19
#define ORDER_UP 1
#define ORDER_DOWN 2
#define ORDER_RETRY 8
#define MADJ_RETRY 30
#define MADJ_LIMIT 60
char modeAdjust(void)
{
//unsigned char i;
unsigned char val;
char madj_cnt = 0;
#if DEBUGMSG
printf(" ModeAdjust\n");
#endif
miscDelay(400);
RegByteOut(0x01,0x00);
#if MASCOT2_R2
madj_next:
val = RegByteIn(0x01);
if(val & 0x01)
{
#if DEBUGMSG
printf(" Freq is changed, sync_status = %2X\n", (unsigned int)val);
#endif
return 2;
}
#if 1 //MV_D
RegByteOut(0x02, 0x00);
RegByteOut(0xB0, 0x80);
#if 1
while( RegByteIn(0xB0)&0x80 );
#else
val = 0;
while( RegByteIn(0xB0)&0x80 )
{
val++;
miscDelay(1);
if (val == 255)
goto madj_fail;
}
#endif
val = RegByteIn(0x02)&0x03;
RegByteOut(0x02, 0x00);
RegByteOut(0xB0, 0x80);
while ( RegByteIn(0xB0)&0x80 );
if (val != (RegByteIn(0x02)&0x03)) goto madj_next;
if (val == 0x01) goto madj_down;
if (val == 0x02) goto madj_up;
#if DEBUGMSG
if (val != 0x00) {
printf(" ModeAdjust fail, CR02=%02X\n", (unsigned int)val);
}
#endif
#else
RegByteOut(0x02, 0x00);
RegByteOut(0xB0, 0x81);
for (i = 0; i < 100; i++) {
if (!(RegByteIn(0xB0)&0x80)) {
if (!(RegByteIn(0xB0)&0x80)) {
val = RegByteIn(0x02);
if (val & 0x01) goto madj_down;
if (val & 0x02) goto madj_up;
}
}
}
#endif
//madj_done:
#if DEBUGMSG
printf(" ModeAdjust done\n");
#endif
RegByteOut(0xB0, 0x00);
return 1;
madj_down:
#if DEBUGMSG
printf(" DClk- : ");
#endif
if (madj_cnt > 0) {
#if DEBUGMSG
printf(" Fail: U-Turn ");
#endif
madj_fail:
RegByteOut(0xB0, 0x00);
return 0;
}
if (madj_cnt-- < -MADJ_LIMIT) {
#if DEBUGMSG
printf(" Fail: overlimit ");
#endif
goto madj_fail;
}
miscDClkDown();
goto madj_next;
madj_up:
#if DEBUGMSG
printf(" DClk+ : ");
#endif
if (madj_cnt < 0) {
#if DEBUGMSG
printf(" Fail: U-Turn ");
#endif
goto madj_fail;
}
if (madj_cnt++ > MADJ_LIMIT) {
#if DEBUGMSG
printf(" Fail: overlimit ");
#endif
goto madj_fail;
}
miscDClkUp();
goto madj_next;
#else //MASCOT2_R2
unsigned char order;
order = 0;
RegByteOut(0xB0, 0x81);
madj0:
RegByteOut(0x02, 0x00);
// wait for 2 frames
RegByteOut(0x00, 0x00);
while (!(RegByteIn(0x00)&0x80));
RegByteOut(0x00, 0x00);
while (!(RegByteIn(0x00)&0x80));
val = RegByteIn(0x02);
if (val & 0x01) {
#if (DEBUGMSG>=2)
printf(" Underflow");
#endif
if (order == ORDER_UP) {
madj_err:
#if (DEBUGMSG>=2)
printf(" Error retry\n");
#endif
RegByteOut(0x2B, TOP_DCLK_M);
RegByteOut(0x2C, TOP_DCLK_N);
RegByteOut(0x2E, RegByteIn(0x2E));
order = ORDER_RETRY;
goto madj0;
}
madj1:
order |= ORDER_DOWN;
miscDClkDown();
goto madj0;
}
if (val & 0x02) {
#if (DEBUGMSG>=2)
printf(" Overflow");
#endif
if (order == ORDER_DOWN+ORDER_RETRY)
goto madj1;
if (order == ORDER_DOWN) {
#if (DEBUGMSG>=2)
printf(" Error!");
#endif
goto madj_err;
}
order = ORDER_UP;
miscDClkUp();
goto madj0;
}
RegByteOut(0xB0, 0x00);
#if DEBUGMSG
printf(" ModeAdjust done\n");
#endif
#endif //MASCOT2_R2
}
#if CHIMEI14_PATCH
bit modeAdjustHt(void)
{
unsigned char val, i, ht;
char madj_cnt = 0;
#if DEBUGMSG
printf(" ModeAdjustHt\n");
#endif
ht = RegByteIn(0x41);
madj_next:
RegByteOut(0x02, 0x00);
RegByteOut(0xB0, 0x81);
for (i = 0; i < 20; i++) {
if (!(RegByteIn(0xB0)&0x80)) {
val = RegByteIn(0x02);
if (val & 0x01) goto madj_up;
if (val & 0x02) goto madj_down;
}
}
//madj_done:
#if DEBUGMSG
printf(" ModeAdjustHt done\n");
#endif
RegByteOut(0xB0, 0x00);
return 1;
madj_down:
#if DEBUGMSG
printf(" Ht- : ");
#endif
if (madj_cnt > 0) {
#if DEBUGMSG
printf(" Fail: U-Turn ");
#endif
madj_fail:
RegByteOut(0xB0, 0x00);
return 0;
}
if (madj_cnt-- < -MADJ_LIMIT) {
#if DEBUGMSG
printf(" Fail: overlimit ");
#endif
goto madj_fail;
}
RegByteOut(0x41, --ht);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -