⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osdoper.c

📁 此程序为twell8806驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
	int newv, regv;

	newv = ( flag==UP  ? OSDItemValue+1  :  OSDItemValue-1  );
	if( newv< UserRange.Min || newv> UserRange.Max )
		return OSDItemValue;

	Mapping1( newv, &UserRange , &regv, &PanelBrightnessRange);
	SetPanelBrightnessReg(RED,  (BYTE)regv);
	SetPanelBrightnessReg(GREEN,(BYTE)regv);
	SetPanelBrightnessReg(BLUE, (BYTE)regv);
	SavePanelBrightnessEE(newv);
	OSDItemValue = newv;
	return newv;
}

#endif


CODE BYTE VideoModeTable[][16] ={
	{	0x11,   0x10,	0x13,   0x14, 0x15,  0x3a,   0x3b,   0x3c,   0x3d,  0x3e, 0x71, 0x74, 0x72, 0x73, 0x70, 0x78,	},// TW8804's Video Picture control Reg Address
//      ------+-------+-------+------+-----+------+------+-------+-------+------+------------ 
	{	0x60,   0x00,	0x80,	0x80, 0x00, 0x60,	0x00,	0xc0,	0x40, 0x00, 0x80,  0x80, 0x80, 0x80, 0x60, 0x03,  },	// Mode 1: 
	{	0x68,	0xf8,	0x90,	0x90, 0x00, 0x60,	0x00,	0xc0,   0x40, 0x00, 0x80,  0x80, 0x80, 0x80, 0x60, 0x03,  },	// Mode 2: 
	{	0x58,	0xf8,	0xa0,	0xa0, 0x00, 0x60,	0x00,	0xc0,	0x40, 0x00, 0x80,  0x80, 0x80, 0x80, 0x60, 0x03,  },	// Mode 3: 
//	{	0x60,	0x00,	0x80,	0x80, 0x00, 0x60,	0x00,	0xc0,	0x40, 0x00, 0x80,  0x80, 0x80, 0x80, 0x60, 0x03,  },	// User Mode 
};

#define USER_VIDEOMODE	3
void SetVideoMode(BYTE mode)
{
	int  i,regv;

	SetVideoModeEE ( mode );

	if( mode != USER_VIDEOMODE )
	{

		for (i=0 ;i<15 ; i++)
			WriteTW88( VideoModeTable[0][i],  VideoModeTable[mode+1][i] );

		regv = VideoModeTable[mode+1][15];	// Sharpness
		#ifdef TW8804D
		SetPanelSharpnessReg( (BYTE)regv );
		SetVideoVPeakingReg( (BYTE)regv );
//		SetVideoHfilterReg( (BYTE)regv );
		#else
		SetVideoSharpnessReg( (BYTE)regv);
		SetVideoVPeakingReg( (BYTE)regv/2 );
		#endif

	}
	else // USERMODE
	{
		#ifndef SUPPORT_USERCOLORFROMTXT


		{
		int  userv;

		// Load from EEPROM
		SetVideoContrast( GetVideoDatawithOffset(contrast) );
	    SetVideoBrightness( GetVideoDatawithOffset(bright) );
		SetVideoSaturation(U_SAT, GetVideoDatawithOffset(staturation_U) );
		SetVideoSaturation(V_SAT, GetVideoDatawithOffset(staturation_V) );
	    SetVideoHue(GetVideoDatawithOffset( hue) );

		userv = GetVideoDatawithOffset(sharpness);
		Mapping1( userv, &UserRange, &regv, &VideoSharpnessRange );
		}
		#ifdef TW8804D
		SetPanelSharpnessReg( (BYTE)regv );
		SetVideoVPeakingReg( (BYTE)regv );
//		SetVideoHfilterReg( (BYTE)regv );
		#else
		SetVideoSharpnessReg( (BYTE)regv);
		SetVideoVPeakingReg( (BYTE)regv/2 );
		#endif

		#endif

	}

}

BYTE IsInputAnalogRGB()
{
	#if defined SUPPORT_COMPONENT
	if( InputSelection==COMPONENT ) return TRUE;
	#elif defined SUPPORT_SCART
	if( InputSelection==SCART ) return TRUE;
	#endif

	return FALSE;
}

BYTE GetVideoDatawithOffset(BYTE offset)
{
	OSDItemValue = GetVideoDatafromEE(offset);
	
	return OSDItemValue;
}

BYTE ChangeVideoData(BYTE offset, BYTE flag)
{
	int newv, inc;

	inc = ( flag==UP  ? 1  :  -1  );

	newv = OSDItemValue + inc;
	if( newv< UserRange.Min || newv> UserRange.Max )
		return OSDItemValue;

	switch (offset)
	{
	case contrast: SetVideoContrast(newv);
		 break;
	case bright:  SetVideoBrightness(newv);
		 break;
	case staturation_U: 
	case staturation_V: 
					SetVideoSaturation(offset-staturation_U,newv);
		 break;
	case hue:	  SetVideoHue(newv);
		 break;
	}

	SaveVideoDatatoEE(offset, newv);

	OSDItemValue = newv;
	return newv;
	
}

void SetVideoContrast(BYTE newv)
{
	int regv;

	Mapping1( newv, &UserRange , &regv, &VideoContrastRange);
	WriteTW88( Contast_Reg_Addr[InputSelection-1], (BYTE)regv );

}

void SetVideoBrightness(BYTE newv) 
{

	int regv;

	if( InputSelection == DTV )
	{

		Mapping1( newv, &UserRange , &regv, &PanelBrightnessRange);
		SetDTVBrightnessReg( (BYTE)regv);
	}
	else 
	{
		Mapping1( newv, &UserRange , &regv, &VideoBrightnessRange);

		if( IsInputAnalogRGB() ) 
			SetDigitalVideoBrightnessReg( regv );
		else 
			SetVideoBrightnessReg( (BYTE)regv);
	}
}

void SetVideoHue(BYTE newv) 
{

	int regv;

	if( InputSelection == DTV ){
		Mapping1( newv, &UserRange , &regv, &PanelHueRange);
		SetPanelHueReg( (BYTE)regv);
	}
	else {
		Mapping1( newv, &UserRange , &regv, &VideoHueRange);
		if( IsInputAnalogRGB() ) 
			SetDigitalVideoHueReg( regv );
		else 
			SetVideoHueReg( (BYTE)regv);
	}

}

void SetVideoSaturation(BYTE svtype, BYTE newv) 
{

	int regv;

	if( IsInputAnalogRGB() )
	 {
		Mapping1( newv, &UserRange , &regv, &DigitalVideoSaturationRange);
		SetDigitalVideoSaturationReg(svtype, (BYTE)regv);
	}
	else 
	{

		Mapping1( newv, &UserRange , &regv, &VideoSaturationRange);

		if( InputSelection == DTV )
		{
			SetPanelSaturationReg( svtype, regv );
		}
		else 
		{
			SetVideoSaturationReg( svtype, (BYTE)regv);
		}
	}
}


BYTE SetVideoSharpness(BYTE flag) 
{
	BYTE orgv;
	char inc;
	int newv, regv;

	orgv = ReadTW88( PNLSHARPNESS )&0x07;
	regv = orgv & 0x0f;
	inc = ( flag==UP  ? 1  :  -1  );
	regv += inc;
	if( regv < VideoSharpnessRange.Min ||
		regv > VideoSharpnessRange.Max )
		return OSDItemValue;

	Mapping1( (BYTE)regv, &VideoSharpnessRange, &newv, &UserRange );

	SetPanelSharpnessReg( (BYTE)regv );
	SetVideoVPeakingReg( (BYTE)regv );
//	SetVideoHfilterReg( (BYTE)regv );

	SaveVideoDatatoEE( sharpness, newv );
	OSDItemValue = newv;

	return newv;
}

/*
BYTE SetOSDDurationValue(BYTE flag)
{
	int val;

	val = ( flag==UP  ? OSDItemValue+1  :  OSDItemValue-1  );
	if( val< OSDDurationRange.Min || val > OSDDurationRange.Max )
		return OSDItemValue;

	OSDItemValue = val;
	SaveOSDDurationEE(val);
	SetOSDDuration( val );
	return OSDItemValue;

}

*/
#ifdef WQVGA
CODE BYTE Init_Video_Data[]={
	37, 52, 50, 50, 50, 50 }; // Contrast,Bright,Staturation_U,Staturation_V,Hue,Sharpness
#else
CODE BYTE Init_Video_Data[]={
	38, 50, 62, 62, 50, 50 }; // Contrast,Bright,Staturation_U,Staturation_V,Hue,Sharpness
#endif

#ifdef ADD_ANALOGPANEL
CODE BYTE Init_Video_Data_A[]={
	37, 52, 50, 50, 50, 50 }; // Contrast,Bright,Staturation_U,Staturation_V,Hue,Sharpness
#endif

CODE BYTE Init_DTV_Data[]={
	50, 50, 50, 50, 50, 50 }; // Contrast,Bright,Staturation_U,Staturation_V,Hue,Sharpness

void ResetVideoValue(void)
{
	
	BYTE i, CurInput;
	#ifdef DEBUG
	dPrintf("\r\n---- ResetVideoValue -----");
	#endif
	CurInput = InputSelection;
	for (InputSelection=COMPOSITE; InputSelection<PC ; InputSelection++ ) {

		if( InputSelection == DTV )
		{
			for( i=0; i<6; i++){
				SaveVideoDatatoEE(i, Init_DTV_Data[i]);	// All 50%
			}
		}
		else {
			for( i=0; i<6; i++){
				#ifdef ADD_ANALOGPANEL
				if(IsAnalogOn())
				SaveVideoDatatoEE(i, Init_Video_Data_A[i]);
				else
				#endif
				SaveVideoDatatoEE(i, Init_Video_Data[i]);
			}
		}
	}
	InputSelection = CurInput;
	SetVideoMode(USER_VIDEOMODE);

}

#ifdef WIDE_SCREEN

#include "\data\WideModeData.txt"
/*
void SetHDelay( WORD delay)
{
	BYTE high;
	#ifdef WIDE_SCREEN
	Printf("\n SetHDelay: %4x ", delay);
	#endif
	WriteDecoder( HDELAY_LO, (BYTE)delay );
	high =	ReadDecoder( CROP_HI ) & 0xf3;
	high |= (BYTE)( delay >> 6 );
	WriteDecoder( CROP_HI, high );
}

void SetVideoOverScan(BYTE overscan)	//in 1/20
{
	if(GetInputSelection() == PC)   return;

	VideoOverScan = overscan;
	SetHDelay( DEF_HDELAY + 720 * overscan / 20 / 2 );	// Video H Active : 720 pixels
}

*/
#if (defined SUPPORT_PC) || (defined SUPPORT_DTV)
void SetScale4_3Y(void) // 16:9 --> 4:3  // Normal
{
	extern  CODE struct _PCMDATA  PCMDATA[];
	extern	IDATA BYTE PcMode;
	DWORD outv, scale;

	// Vertical
	scale = (DWORD)PCMDATA[PcMode].VAN	;
	outv  = (DWORD)PVR_; 
	scale = 0x10000L * scale / outv;

	YScale2( scale );

	// Horizontal
	if (PcMode >= EE_XGA_60 && PcMode >= EE_XGA_75)
		scale = (DWORD)PCMDATA[PcMode].HAN-4; //just 1024	for focus issue(1:1).
	else
		scale = (DWORD)PCMDATA[PcMode].HAN;	

	scale = scale * 0x10000L * 3 / PVR_ /4;

	XScale2( scale );
}

void SetScale(void)
{
	DWORD scale, outv;

	// Vertical
	scale = (DWORD)PCMDATA[PcMode].VAN;
	outv  = (DWORD)PVR_ ; 
	scale = 0x10000L * scale / outv;
	YScale2( scale );
	#ifdef DEBUG_PC
	Printf("\n PCMode[%d] %ld YScale: %ld", (WORD)PcMode, outv, scale);
	#endif
	// Horizontal
	scale = PCMDATA[PcMode].HAN;
	outv  = PHR_ ; 
//	scale = scale  * 0x100L / outv;
	scale = (scale*0x10000L+outv-1) / outv;
	XScale2( scale );
}

void SetScale4_3X(void)	
{
	DWORD scale, outv;

	// Horizontal
	scale = (DWORD)PCMDATA[PcMode].HAN;
	outv  = (DWORD)PHR_ ; 
	scale = scale  * 0x10000L / outv;
	XScale2( scale );

	// Vertical
	scale = (DWORD)PCMDATA[PcMode].VAN; 
	outv  = outv * 3 / 4;			// 4:3
	scale = 0x10000L * scale / outv;
	YScale2( scale);				// *********** plus 2
}
void SetLRBlank(BYTE bl)
{
	WriteTW88(0x66, bl);
}
#endif

void Set4WideScreen( BYTE id )
{
	if( id > WIDESCREEN_FULL ){
		Set4WideScreen(WIDESCREEN_WIDE);
		id = WIDESCREEN_WIDE;
	}

	WideScreenMode = id;

  #if (defined SUPPORT_PC) || (defined SUPPOER_DTV) 	
  if(	(GetInputSelection()== PC) || (GetInputSelection()== DTV) )
  {
	switch( id ) {
	case WIDESCREEN_NORMAL:		
								SetScale4_3Y();
								SetLRBlank((PHR_- (PVR_*4/3 ))/2);
								break;
	case WIDESCREEN_WIDE:		
								SetScale();
								SetLRBlank(0);
								break;
								
	case WIDESCREEN_PANO:		
								SetScale();
								SetLRBlank(0);
								break;
								
	case WIDESCREEN_FULL:		
								SetScale4_3X();
								SetLRBlank(0);
								break;
/*	case WIDESCREEN_ZOOM:		
								SetScale4_3X();
								SetLRBlank(0);
								break;
*/	
								}
	}
	else 
#endif
	{
		int i;
		CODE_P BYTE *WideData;
		
		#ifdef SUPPORT_COMPONENT
		if (GetInputSelection()== COMPONENT )
		{
			switch (ComponentMode)
			{
				case YPBPR_576i:	WideData = WIDEDATA_576i[id];	break;
				#ifndef WQVGA
				case YPBPR_480p:	WideData = WIDEDATA_480p[id];	break;
				case YPBPR_576p:	WideData = WIDEDATA_576p[id];	break;
				case YPBPR_720p:	WideData = WIDEDATA_720p[id];	break;
				case YPBPR_1080i:	WideData = WIDEDATA_1080i[id];	break;
				#endif
				default:			WideData = WIDEDATA_480i[id];	break;
			}

		}
		else 
		#endif
		{
				//if( ReadVInputSTD()== NTSC || ReadVInputSTD()== NTSC4 ) 
				if( GetVInputStd() == NTSC || GetVInputStd()== NTSC4 ) {
					#ifdef ADD_ANALOGPANEL
					if(IsAnalogOn()) 
					WideData = WIDEDATA_NA[id];
					else
					#endif
					WideData = WIDEDATA_N[id];
				}
				else{
					#ifdef ADD_ANALOGPANEL
					if(IsAnalogOn()) 
					WideData = WIDEDATA_PA[id];
					else
					#endif
					WideData = WIDEDATA_P[id];
				}
		}

		//#ifdef DEBUG
		//Printf( "\r\nWrite Wide: ");
		//#endif
		WaitEndofDisplayArea();	
		for(i=0; i<WIDE_DATA_MAX; i++){
					WriteTW88(WIDE_ADDRESS[i], *WideData);
					//#ifdef DEBUG
					//Printf( " %2x", (WORD)*WideData );
					//#endif
					WideData++;
		}
	}
	SaveWideModeEE(WideScreenMode);
}
#endif // WIDE_SCREEN

⌨️ 快捷键说明

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