modehandle.lst

来自「台湾联咏NT68663 LCD MONITOR 控制程序(完整版)」· LST 代码 · 共 1,054 行 · 第 1/3 页

LST
1,054
字号
 332   2      		NewMode = 1;
 333   2      		SetUserMode();
 334   2      		}
 335   1      	else
 336   1      		NewMode = 0;
 337   1      #if PRINT_MESSAGE
              		printf("Mode %d\n",(unsigned short)ModePoint);
              #endif
 340   1      	LoadModeDependentSettings();
 341   1      //	if(SyncMode < 3)
 342   1      		FuncBuf[pCONTRAST] = Read24C16(ep_Contrast);		
 343   1      //	else		
 344   1      //		FuncBuf[pCONTRAST] = Read24C16(ep_DVI_Contrast);		
 345   1      	Addr = ep_Reso_Offset + (ModePoint * 8);
 346   1      	ResolutionPtr = Read24C16(Addr);
 347   1      	if(!(ResolutionPtr & 0x80))
 348   1      		NewMode = 1;
 349   1      	ResolutionPtr &= 0x7f;
 350   1      	
 351   1      	Hresolution = H_ActiveTab[ResolutionPtr];
 352   1      	Vresolution = V_ActiveTab[ResolutionPtr];
 353   1      	if(ModePoint < UserModeSt)
 354   1      		Addr = ModePoint * 8 + 2;
 355   1      	else{
 356   2      		UserModeRefReso = SearchEstimatedModeTables();
 357   2      		Addr = UserModeRefReso * 8 + 2;
 358   2      	}	
 359   1      		HPositionBase = EEP_SyncMap[Addr];
 360   1      		HPositionBase <<= 8;
 361   1      		HPositionBase |= EEP_SyncMap[Addr+1];	
 362   1      		ClockBase = EEP_SyncMap[Addr+2];
 363   1      		ClockBase <<= 8;
C51 COMPILER V6.12  MODEHANDLE                                                             03/05/2008 14:34:53 PAGE 7   

 364   1      		ClockBase |= EEP_SyncMap[Addr+3];	
 365   1      
 366   1      	if(HV_Pol & BIT_4)
 367   1      		WriteIIC563(0x021,0x81);
 368   1      	else
 369   1      		WriteIIC563(0x021,0x01);
 370   1      	//SetInterface();
 371   1      	#if PRINT_MESSAGE
              		printf("HV_Pol= %x\n",(unsigned short)HV_Pol);
              		printf("H_SYNC= %d\n",H_SYNC);
              		printf("V_SYNC= %d\n",V_SYNC);
              	#endif
 376   1      	SetADC_PLL();
 377   1      	CheckDVIresolution();
 378   1      	if(OutOfRange < 2)
 379   1      		{
 380   2      		SetScalerMode();
 381   2      		//SetScaler();
 382   2      		if(SyncMode != 3)
 383   2      			{
 384   3      			ch = FuncBuf[pPHASE];
 385   3      			if(FuncBuf[pPHASE] != 0)
 386   3      				{
 387   4      				for(FuncBuf[pPHASE]=0; FuncBuf[pPHASE]<=ch; FuncBuf[pPHASE]++)
 388   4      					SetADC_Phase();
 389   4      				}
 390   3      			FuncBuf[pPHASE] = ch;
 391   3      			}
 392   2      		SetSharpness();
 393   2      		}
 394   1      	if(SyncMode == 3)	//DVI
 395   1      		{
 396   2      		#if DVImode == DEmode
 397   2      			FuncBuf[pVPOSITION] = 0x1e0;	// for DE mode scaler shut down Jacky20040629
 398   2      			FuncBuf[pHPOSITION] = 0;
 399   2      			WriteWordIIC563(0x030,FuncBuf[pVPOSITION]);
 400   2      			WriteWordIIC563(0x02e,FuncBuf[pVPOSITION]);
 401   2      			WriteWordIIC563(0x030,FuncBuf[pVPOSITION]);
 402   2      			WriteWordIIC563(0x034,FuncBuf[pHPOSITION]);
 403   2      		#else
              			//if((SyncMode == 3) && ((PortD & BIT_3) != 0))	//DVI
              			AutoPosition();
              		#endif
 407   2      		}	
 408   1      	SetContrast();
 409   1      	SetInverter();
 410   1      }
 411          void CheckDVIresolution()
 412          {
 413   1      	Union Hf,Vf;
 414   1      	if(SyncMode == 3)
 415   1      		{
 416   2      		Vf.w = ReadWordIIC563(0x03e);
 417   2      		Hf.w = ReadWordIIC563(0x03c);
 418   2      		//if(Vf.w > 1024 || Hf.w > 1280)
 419   2      		if(Vf.w > 1200 || Hf.w > 1600)
 420   2      			{
 421   3      			OutOfRange = 2;
 422   3      			}
 423   2      		else
 424   2      			{
 425   3      			if((Vf.w == 1200 || Hf.w == 1600)&&(V_SYNC > 620))
C51 COMPILER V6.12  MODEHANDLE                                                             03/05/2008 14:34:53 PAGE 8   

 426   3      				{
 427   4      				OutOfRange = 2;
 428   4      				}
 429   3      			Hresolution = Hf.w;
 430   3      			Vresolution = Vf.w;
 431   3      			//ResolutionPtr = 0xff;
 432   3      			}
 433   2      		}
 434   1      }
 435          
 436          void SetUserMode(void)
 437          {
 438   1      /*
 439   1      code unsigned short Vt_Tab[]={
 440   1      	500,600,700,760,850,950,1050,1200
 441   1      };
 442   1      
 443   1      code unsigned char UserTimeTab[]={
 444   1      	0x00,0x7d,0x00,0x30,0x03,0x84,0x03,0x10,	//720*400  500
 445   1      	0x00,0x21,0x00,0x30,0x03,0x20,0x04,0x10,	//640x480  600
 446   1      	0x00,0x10,0x00,0x98,0x04,0x18,0x06,0x10,	//800x600  700
 447   1      	0x00,0x10,0x00,0xe0,0x06,0x72,0x0f,0x10,	//1280x720  760 (HDTV 720p)
 448   1      	0x00,0x10,0x01,0x00,0x05,0x40,0x08,0x10,	//1024x768  850
 449   1      	0x00,0x10,0x00,0xd0,0x06,0x40,0x09,0x10,	//1152x864  950
 450   1      	0x00,0x10,0x00,0xe0,0x06,0xc0,0x0c,0x10,	//1280x960  1050
 451   1      	0x00,0x10,0x00,0xf8,0x06,0x98,0x0d,0x10,	//1280x1024  1200
 452   1      	0x00,0x2e,0x01,0x30,0x0b,0xb8,0x0e,0x10		//over (1600x1200)
 453   1      };
 454   1      
 455   1      unsigned short addr;
 456   1      unsigned char i,j,k;
 457   1      	#if PRINT_MESSAGE
 458   1      		printf("Vtotal = %d\n",VTotal);
 459   1      	#endif
 460   1      	if(Interlance)
 461   1      		addr = VTotal << 1;
 462   1      	else
 463   1      		addr = VTotal;
 464   1      	j = 8;
 465   1      	for(i=0; i<8; i++)
 466   1      		{
 467   1      		if(addr < Vt_Tab[i])
 468   1      			{
 469   1      			j = i;
 470   1      			break;
 471   1      			}
 472   1      		}
 473   1      	j = j * 8;
 474   1      	ModePoint = UserModePtr;
 475   1      	UserModePtr++;
 476   1      	Write24C16(ep_User_Ptr,UserModePtr);
 477   1      	if(UserModePtr > ModeNum)
 478   1      		UserModePtr = UserModeSt;
 479   1      	#if PRINT_MESSAGE
 480   1      		printf("UserModePoint =  %d\n",(unsigned short)ModePoint);
 481   1      	#endif
 482   1      	addr = ModePoint * 8;
 483   1      	for(i=0; i<8; i++)
 484   1      		{
 485   1      		k = UserTimeTab[j];
 486   1      		Write24C16(ep_Sync_Data+addr,k);
 487   1      		#if PRINT_MESSAGE
C51 COMPILER V6.12  MODEHANDLE                                                             03/05/2008 14:34:53 PAGE 9   

 488   1      			printf("Data %x = %x\n",(unsigned short)i,(unsigned short)k);
 489   1      		#endif
 490   1      		addr++;
 491   1      		j++;
 492   1      		}
 493   1      	addr = ep_Mode_Data+ModePoint * 4;
 494   1      	k = H_SYNC >> 8;
 495   1      	Write24C16(addr,k);
 496   1      	addr++;
 497   1      	k = H_SYNC;
 498   1      	Write24C16(addr,k);
 499   1      	addr++;
 500   1      	k = V_SYNC >> 8;
 501   1      	k |= HV_Pol;
 502   1      	Write24C16(addr,k);
 503   1      	addr++;
 504   1      	k = V_SYNC;
 505   1      	Write24C16(addr,k);
 506   1      */
 507   1      	Word addr;
 508   1      	Byte i,Dat;
 509   1      
 510   1      	ModePoint = UserModePtr;
 511   1      	UserModePtr++;
 512   1      	Write24C16(ep_User_Ptr,UserModePtr);
 513   1      	if(UserModePtr > ModeNum)
 514   1      		UserModePtr = UserModeSt;
 515   1      //#if PRINT_MESSAGE
 516   1      //	printf("UserModePoint =  %d\n",(unsigned short)ModePoint);
 517   1      //#endif
 518   1      	UserModeRefReso = SearchEstimatedModeTables();
 519   1      	//write range refference
 520   1      	//printf("UserModeReferencePoint =  %d\n",(unsigned short)UserModeRefReso);
 521   1      	addr = UserModeRefReso * 8;
 522   1      	//write sync data
 523   1      	addr = ep_Sync_Data + (ModePoint * 8);	
 524   1      	for(i=0; i<8; i++)
 525   1      		Write24C16(addr++,EEP_SyncMap[UserModeRefReso*8+i]);
 526   1      
 527   1      	addr = ep_Mode_Data+ModePoint * 4;
 528   1      	Dat = H_SYNC >> 8;
 529   1      	Write24C16(addr,Dat);
 530   1      	addr++;
 531   1      	Dat = H_SYNC;
 532   1      	Write24C16(addr,Dat);
 533   1      	addr++;
 534   1      	Dat = V_SYNC >> 8;
 535   1      	Dat |= HV_Pol;
 536   1      	Write24C16(addr,Dat);
 537   1      	addr++;
 538   1      	Dat = V_SYNC;
 539   1      	Write24C16(addr,Dat);
 540   1      }
 541          
 542          
 543          void SetInterface()
 544          {
 545   1      	Word code InterfaceTab[]={0x000,0x008,0x102,0x023,0x021,0x196,0x012,0x072};
 546   1      	Byte code InterfaceDat[][8]={
 547   1      								{0x12,0x00,0x29,0x00,0x01,0x64,0x00,0x01},	//channel 1 sep +-
 548   1      								{0x12,0x00,0x29,0x40,0x01,0x65,0x00,0x00},	//channel 1 comp +-
 549   1      								{0x1a,0x00,0x29,0x40,0x01,0x65,0x7c,0x00},	//channel 1 SOG -
C51 COMPILER V6.12  MODEHANDLE                                                             03/05/2008 14:34:53 PAGE 10  

 550   1      								#if DVImode == DEmode
 551   1      								{0x10,0x00,0x03,0x01,0x01,0x24,0x00,0x01},	//DVI +-
 552   1      								#else
              								{0x10,0x00,0x03,0x09,0x01,0x94,0x00,0x01},	//DVI +-
              								#endif
 555   1      								{0x12,0x04,0x29,0x00,0x01,0x64,0x00,0x01},	//channel 2 sep +-
 556   1      								{0x12,0x04,0x29,0x40,0x01,0x65,0x00,0x00},	//channel 2 comp +-
 557   1      								{0x1a,0x04,0x29,0xc0,0x01,0x65,0xe4,0x00},	//channel 2 SOG -
 558   1      	};
 559   1      	//Byte SourSel,temp,i;
 560   1      	Byte i;
 561   1      	if(!PowerDown)
 562   1      	{
 563   2      	#if PanelInterface == TCON_TO_RSDS
              			WriteIIC563(0x101,0x90);
              	#endif
 566   2      	#if PanelInterface == LVDS_TO_TCON
 567   2      			WriteIIC563(0x101,0x40);
 568   2      	#endif
 569   2      	#if PanelInterface == TTL_TO_TCON
              			WriteIIC563(0x101,0x00);
              	#endif
 572   2      	#if PanelInterface == TCON_TO_TTL
              			WriteIIC563(0x101,0x00);
              	#endif
 575   2      	// Jacky 20040906 for LVDS power up
 576   2      		WriteIIC563(0x1f5,0x06);	//disable Pull low LVDS pad	
 577   2      		WriteIIC563(0x1f7,0xc0);	//Power up LVDS buffer
 578   2      	}
 579   1      	Interlance = 0;
 580   1      
 581   1      	if(SyncMode == 3){
 582   2      		WriteIIC563(0x020,0x83);
 583   2      		WriteIIC563(0x143,0x20);	//Power up DVI Pll
 584   2      		WriteIIC563(0x146,0xf3);	//Power up DVI SCDT detect
 585   2      	}
 586   1      	else{		
 587   2      		WriteIIC563(0x020,0x81);
 588   2      		WriteIIC563(0x143,0xa0);	//Power down DVI Pll
 589   2      	}
 590   1      	for(i=0;i<8;i++)
 591   1      		{
 592   2      		if(InterfaceTab[i] == 0x102 && PowerDown)
 593   2      			WriteIIC563(InterfaceTab[i],InterfaceDat[SyncMode][i]&0x02);
 594   2      		else if(InterfaceTab[i] == 0x021 && (HV_Pol & BIT_4))
 595   2      			WriteIIC563(InterfaceTab[i],InterfaceDat[SyncMode][i]|BIT_7);
 596   2      		else
 597   2      			WriteIIC563(InterfaceTab[i],InterfaceDat[SyncMode][i]);
 598   2      		Sleep(1);
 599   2      		}
 600   1      }
 601          
 602          void SyncSource(bit ForceChange)
 603          {
 604   1      	Byte temp,Max;
 605   1      	Bit ExitLoop;
 606   1      //	if(VideoMute || ForceChange)
 607   1      	if(NoSyncFlag || ForceChange)
 608   1      		{
 609   2      		ExitLoop = 0;
 610   2      		if(Saa7114En)
 611   2      			Max = 8;
C51 COMPILER V6.12  MODEHANDLE                                                             03/05/2008 14:34:53 PAGE 11  

 612   2      		else
 613   2      			Max = 6;
 614   2      		while(PowerTimer < (POWER_TIME-100) && !ExitLoop)
 615   2      			{
 616   3      			SyncMode++;
 617   3      			if(SyncMode > Max)	
 618   3      				SyncMode = 0;
 619   3      			if(SyncMode == 0)
 620   3      			{
 621   4      				SetInterface();
 622   4      				ExitLoop = 1;
 623   4      				FuncBuf[pVIDEOSOURCE] = 0;
 624   4      				#if PRINT_MESSAGE
              					printf("Separate Sync\n");
              				#endif
 627   4      			}
 628   3      			if(SyncMode == 1)
 629   3      			{
 630   4      				temp = ReadIIC563(0x19a);
 631   4      				if(temp & BIT_5)
 632   4      				{
 633   5      					SetInterface();
 634   5      					ExitLoop = 1;
 635   5      					FuncBuf[pVIDEOSOURCE] = 0;
 636   5      				#if PRINT_MESSAGE
              					printf("Separate Sync\n");
              				#endif
 639   5      				}
 640   4      			}
 641   3      			if(SyncMode == 2 && !BypassSOG)
 642   3      			{
 643   4      				SetInterface();
 644   4      				ExitLoop = 1;
 645   4      				FuncBuf[pVIDEOSOURCE] = 0;
 646   4      				#if PRINT_MESSAGE
              					printf("Sync on green\n");
              				#endif
 649   4      			}
 650   3      			if(SyncMode == 3)	
 651   3      			{
 652   4      				if(DetectDVI())
 653   4      				{
 654   5      					WriteIIC563(0x01d, 0x1f);
 655   5      					SetInterface();
 656   5      					if(ReadIIC563(0x1ad) != 0)	//Jacky 20050107			
 657   5      					ExitLoop = 1;
 658   5      					FuncBuf[pVIDEOSOURCE] = 1;
 659   5      					#if PRINT_MESSAGE
              						printf("DVI Input\n");
              					#endif
 662   5      				}
 663   4      			}
 664   3      			if(SyncMode == 4)
 665   3      			{
 666   4      				SetInterface();
 667   4      				ExitLoop = 1;
 668   4      				FuncBuf[pVIDEOSOURCE] = 2;
 669   4      				#if PRINT_MESSAGE
              					printf("Separate Sync\n");
              				#endif
 672   4      			}
 673   3      			if(SyncMode == 5)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?