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

📄 adjust_customer.c

📁 RTD2662板卡源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
#define _VIDEO_SATURATION_MIN	0x00
#endif

//--------------------------------------------------
// Description  : Set  2610 Saturation
// Input Value  : saturationNone
// Output Value : None
//--------------------------------------------------
 void CVideoSetSaturation(BYTE ucValue)
{
#if(_VIDEO_AUTO_WHITE_BLANCE == _ENABLE)
	BYTE ucSaturation;
	BYTE temp;

	ucSaturation = 108;//GET_VDC_CHROMA();//160
	if(ucValue > 50)
    {
		temp = ((UINT16)((_VIDEO_SATURATION_MAX - ucSaturation)*(ucValue - 50))) / 50;
		temp += ucSaturation;
   	}
	else if(ucValue < 50)
    {
		temp = ((UINT16)((ucSaturation -_VIDEO_SATURATION_MIN) * (50 - ucValue))) / 50;
		temp = ucSaturation - temp;
   	}
	else
		temp = ucSaturation;
 	CVideoSetVDCSaturation(temp);
#else
	ucValue = ucValue * 2.5;
 	CVideoSetVDCSaturation(ucValue);
#endif
}

//--------------------------------------------------
// Description  : Set  2610 Contrast
// Input Value  : ucValue
// Output Value : None
//--------------------------------------------------
void CVideoSetContrast(BYTE ucValue)
{
	ucValue = ucValue * 2.5;
    CVideoSetVDCContrast(ucValue);
}

void CAdjustHueSatSet(BYTE color, SWORD TempU1, SWORD TempU2, SWORD TempV1, SWORD TempV2)
{
    BYTE i;
    SWORD u,v;

    BYTE value = (color & 0x0f);
	//CTimerWaitForEvent(_EVENT_DEN_STOP);
	CScalerPageSelect(_PAGE7);

    CScalerSetByte(_P7_ICM_SEL_D1, value);
    CScalerSetByte(_P7_ICM_ACCESS_PORT_D2,0x00);
    if(value == 0)
    {		//R
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x02);
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0xd2);
	  	if(CGetInputSourceNum(_GET_INPUT_SOURCE())>1)
    		CScalerSetByte(_P7_ICM_DATA_PORT_D3,0xaa);
	  	else
	  		CScalerSetByte(_P7_ICM_DATA_PORT_D3,0xee);
    }
	else if(value == 1)
    {//G
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x08);
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x00);
	 	if(CGetInputSourceNum(_GET_INPUT_SOURCE())>1)
        	CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x66);
	  	else
	  		CScalerSetByte(_P7_ICM_DATA_PORT_D3,0xee);
    }
    else if(value == 2)
    {//B
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x0d);
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x2e);
	  	if(CGetInputSourceNum(_GET_INPUT_SOURCE())>1)
			CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x66);
      	else
			CScalerSetByte(_P7_ICM_DATA_PORT_D3,0xbe);
    }
    else if(value == 3)
    {//Y
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x05);
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x2e);
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x62);  //ff
    }
    else if(value == 4)
    {//C
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x0a);
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0xd2);
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,0x66);
    }
    //CTimerWaitForEvent(_EVENT_DEN_STOP);
    CScalerSetByte(_P7_ICM_SEL_D1,value);
    CScalerSetByte(_P7_ICM_ACCESS_PORT_D2,((color & 0xf0)+0x03));
	//CScalerSendAddr(_P7_ICM_DATA_PORT_D3, _WRITE, _NON_AUTOINC);//provisional 既﹚
	
    for(i=1; i<9; i++)
    {
		u = ((TempU1+TempU2)*CAdjustColorGammaCal(value, i)/64) - ((TempU1*i)/8);
		v = ((TempV1+TempV2)*CAdjustColorGammaCal(value, i)/64) - ((TempV1*i)/8);
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,u);	//CScalerSetByte(0xe3,u);		
        CScalerSetByte(_P7_ICM_DATA_PORT_D3,v);	//CScalerSetByte(0xe3,v);		
    }
 	if(_GET_INPUT_SOURCE() == _SOURCE_VGA || _GET_INPUT_SOURCE() == _SOURCE_DVI)//CGetInputSourceNum(_GET_INPUT_SOURCE())>1)
 		CScalerSetByte(_P7_ICM_CTRL_D0,0xdf);
 	else
 		CScalerSetByte(_P7_ICM_CTRL_D0,0xdc);
	
}

#define CENTER    0x00
#define RIGHT     0x10
#define LEFT      0x20
void CAdjustSetHueUVDelta(BYTE color, BYTE select)
{
    SWORD TempU1,TempV1,TempU2,TempV2;

	pData[0] = (select >> 3); //(select >> 4) << 1
	pData[1] = pData[0] + 1;

	if(CGetInputSourceNum(_GET_INPUT_SOURCE())>1)
	{
	  TempU1 = Video_TempUV1[color][pData[0]];
	  TempV1 = Video_TempUV1[color][pData[1]];
	}
	else
	{
	  TempU1 = Graphic_TempUV1[color][pData[0]];
	  TempV1 = Graphic_TempUV1[color][pData[1]];
	}

	pData[2] = color*3 + (select >> 4);

	if(stICMColor.ICM_COLOR[color] < 8)
	{
	   TempU2 = (long)TempUV2[pData[2]][0] * (8 - stICMColor.ICM_COLOR[color]) >> 3;
	   TempV2 = (long)TempUV2[pData[2]][1] * (8 - stICMColor.ICM_COLOR[color]) >> 3;
	}
	else
	{
	   TempU2 = (long)TempUV2[pData[2]][2] * (stICMColor.ICM_COLOR[color] - 8) >> 3;
	   TempV2 = (long)TempUV2[pData[2]][3] * (stICMColor.ICM_COLOR[color] - 8) >> 3;
	}
	CAdjustHueSatSet((select | color), TempU1, TempU2, TempV1, TempV2);


}
#if(_COLOR_PREFERENCE == _PANASONIC_STYLE)

    #define	RF_StartOffset		5
    #define	AV_StartOffset		0
    #define	YPbPr_StartOffset	0

void CAdjustPeakingFilter(SBYTE ucPeaking)
{
	if(_GET_INPUT_SOURCE() == _SOURCE_VGA)
    {
		CScalerPageSelect(_PAGE7);
		CScalerSetBit(_P7_PEAKING_ENABLE_A9, ~_BIT3, 0x00);	// disable Peaking and Coring
		return;
	}
	else if(_GET_INPUT_SOURCE() == _SOURCE_DVI || _GET_INPUT_SOURCE() == _SOURCE_HDMI)
    {
		//if(HDMI_V_Height>=720)		//720p above
			pData[0] = 0x00;					//bit[3:2]->10: 9 pixels; ->01: 7 pixels; ->00: 5 pixels      
		//else
			//pData[0] = 0x00;					//bit[3:2]->10: 9 pixels; ->01: 7 pixels; ->00: 5 pixels      
		pData[1] = 0x7E;						//Peaking_C0 (126) 
		pData[2] = 0xF7;						//Peaking_C1 (-19) 	
		pData[3] = 0x4A;						//Peaking_C2 (82)
		pData[4] = 0x00;						//Gain_Blur
		pData[5] = ucPeaking*13;		//Gain_Pos(Min~Max)
		pData[6] = ucPeaking*13;		//Gain_Neg(Min~Max)
		pData[7] = 0x0F;						//Pos_Range(MSB)+Neg_Range(MSB)
		pData[8] = 0xFF;						//Pos_Range(LSB)(1023)
		pData[9] = 0xFF; 						//Neg_Range(LSB)(1023)
		pData[10] = 0x09;					//Coring(LV_min~LV_max)		
	}		
	else if(_GET_INPUT_SOURCE() == _SOURCE_YPBPR)
    {
		//if(HDMI_V_Height>=720)		//720p above
			pData[0] = 0x00;					//bit[3:2]->10: 9 pixels; ->01: 7 pixels; ->00: 5 pixels      
		//else
			//pData[0] = 0x00;					//bit[3:2]->10: 9 pixels; ->01: 7 pixels; ->00: 5 pixels      
		pData[1] = 0x7E;						//Peaking_C0 (126) 
		pData[2] = 0xF7;						//Peaking_C1 (-19) 	
		pData[3] = 0x4A;						//Peaking_C2 (82)
		pData[4] = 0x00;						//Gain_Blur
		pData[5] = ucPeaking*13;		//Gain_Pos(Min~Max)
		pData[6] = ucPeaking*13;		//Gain_Neg(Min~Max)
		pData[7] = 0x0F;						//Pos_Range(MSB)+Neg_Range(MSB)
		pData[8] = 0xFF;						//Pos_Range(LSB)(1023)
		pData[9] = 0xFF; 						//Neg_Range(LSB)(1023)
		pData[10] = 0x03;					//Coring(LV_min~LV_max)			
	}	
	else
    {//AV SV TV		
		pData[0] = 0x00;					//bit[3:2]->10: 9 pixels; ->01: 7 pixels; ->00: 5 pixels      		 
		pData[1] = 0x7E;						//Peaking_C0 (126) 
		pData[2] = 0xF7;						//Peaking_C1 (-19) 	
		pData[3] = 0x4A;						//Peaking_C2 (82)
		pData[4] = 0x00;						//Gain_Blur
		pData[5] = ucPeaking*13;		//Gain_Pos(Min~Max)
		pData[6] = ucPeaking*13;		//Gain_Neg(Min~Max)
		pData[7] = 0x00;						//Pos_Range(MSB)+Neg_Range(MSB)  //0515_0x0F
		pData[8] = 0x08;						//Pos_Range(LSB)(1023)			//0515_0xFF
		pData[9] = 0x20; 						//Neg_Range(LSB)(1023)			//0515_0xFF  Mark:0x08
		pData[10] = 0x08;					//Coring(LV_min~LV_max)				//0515_0x06
	}	
		

	CScalerPageSelect(_PAGE7);
	CScalerWrite(_P7_PEAKING_DATA00_AA, 11, pData, _AUTOINC);
#if(_HDMI_SUPPORT == _ON || _TMDS_SUPPORT == _ON)
	if((_GET_INPUT_SOURCE()==_SOURCE_DVI ||  _GET_INPUT_SOURCE() == _SOURCE_HDMI) && !CHdmiFormatDetect())//HDMI Source & input DVI timing
		CScalerSetBit(_P7_PEAKING_ENABLE_A9, ~_BIT3, 0x00);		// disable Peaking and Coring
	else
#endif
	    CScalerSetBit(_P7_PEAKING_ENABLE_A9, ~_BIT3, _BIT3);	// enable Peaking and Coring

    switch(_GET_INPUT_SOURCE())
    {
    case _SOURCE_VGA:
		CScalerPageSelect(_PAGE6);
		CScalerSetBit(_P6_PEAKING_ENABLE_C1, ~_BIT3, 0x00);	// disable Peaking and Coring
		return;

    case _SOURCE_HDMI:
    case _SOURCE_DVI:
		//if(HDMI_V_Height>=720)		//720p above
			pData[0] = 0x00;					//bit[3:2]->10: 9 pixels; ->01: 7 pixels; ->00: 5 pixels      
		//else
			//pData[0] = 0x00;					//bit[3:2]->10: 9 pixels; ->01: 7 pixels; ->00: 5 pixels      
		pData[1] = 0x7E;						//Peaking_C0 (126) 
		pData[2] = 0xF7;						//Peaking_C1 (-19) 	
		pData[3] = 0x4A;						//Peaking_C2 (82)
		pData[4] = 0x00;						//Gain_Blur
		pData[5] = 0x14/*ucPeaking*13*/;		//Gain_Pos(Min~Max)
		pData[6] = 0x14/*ucPeaking*13*/;		//Gain_Neg(Min~Max)
		pData[7] = 0x0F;						//Pos_Range(MSB)+Neg_Range(MSB)
		pData[8] = 0xFF;						//Pos_Range(LSB)(80)
		pData[9] = 0xFF; 						//Neg_Range(LSB)(80)
		pData[10] = 0x09;					//Coring(LV_min~LV_max)		
        break;

    case _SOURCE_YPBPR:
		pData[0] = 0x00;					//bit[3:2]->10: 9 pixels; ->01: 7 pixels; ->00: 5 pixels      		   
		pData[1] = 0x7E;						//Peaking_C0 (126) 
		pData[2] = 0xF7;						//Peaking_C1 (-19) 	
		pData[3] = 0x4A;						//Peaking_C2 (82)
		pData[4] = 0x00;						//Gain_Blur
		pData[5] = 0x14/*ucPeaking*13*/;		//Gain_Pos(Min~Max)
		pData[6] = 0x14/*ucPeaking*13*/;		//Gain_Neg(Min~Max)
		pData[7] = 0x0F;						//Pos_Range(MSB)+Neg_Range(MSB)
		pData[8] = 0xFF;						//Pos_Range(LSB)(1023)
		pData[9] = 0xFF; 						//Neg_Range(LSB)(1023)
		pData[10] = 0x09;					//Coring(LV_min~LV_max)			
        break;

    default:   //AV TV SV		
		pData[0] = 0x00;					//bit[3:2]->10: 9 pixels; ->01: 7 pixels; ->00: 5 pixels    		
		pData[1] = 0x7E;						//Peaking_C0 (126) 
		pData[2] = 0xF7;						//Peaking_C1 (-19) 	
		pData[3] = 0x4A;						//Peaking_C2 (82)
		pData[4] = 0x00;						//Gain_Blur
		pData[5] = 0x1E/*ucPeaking*13*/;		//Gain_Pos(Min~Max)
		pData[6] = 0x1E/*ucPeaking*13*/;		//Gain_Neg(Min~Max)
		pData[7] = 0x0F;						//Pos_Range(MSB)+Neg_Range(MSB)
		pData[8] = 0xFF;						//Pos_Range(LSB)(1023)
		pData[9] = 0xFF; 						//Neg_Range(LSB)(1023)
		pData[10] = 0x09;					//Coring(LV_min~LV_max)	
        break;
	}

	CScalerPageSelect(_PAGE6);
	CScalerWrite(_P6_PEAKING_DATA00_C2, 11, pData, _AUTOINC);
#if(_HDMI_SUPPORT == _ON || _TMDS_SUPPORT == _ON)
	if((_GET_INPUT_SOURCE()==_SOURCE_DVI || _GET_INPUT_SOURCE() == _SOURCE_HDMI) && !CHdmiFormatDetect())//HDMI Source & input DVI timing
		CScalerSetBit(_P6_PEAKING_ENABLE_C1, ~_BIT3, 0x00);		// disable Peaking and Coring
	else
#endif
		CScalerSetBit(_P6_PEAKING_ENABLE_C1, ~_BIT3, _BIT3);	// enable Peaking and Coring
	
}
	
#else

#if(_Peaking_Coring_Table == SharpnessTable1)
                                                                                                    
BYTE code PeakingCoeff[][6] =
{
		//Peaking_Coef0,  Peaking_Coef1,  Peaking_Coef2,  Coring_Min,  Coring_Max_Pos,  Coring_Max_Neg ,

		//level=1 :
		0x30, 0xe5, 0x3, 0x5, 0x50, 0xb0,
		//level=2 :
		0x38, 0xe1, 0x3, 0x5, 0x50, 0xb0,
		//level=3 :
		0x40, 0xdc, 0x4, 0x5, 0x50, 0xb0,
		//level=4 :
		0x46, 0xd7, 0x6, 0x5, 0x50, 0xb0,
		//level=5 :
		0x4e, 0xd3, 0x6, 0x5, 0x50, 0xb0,
		//level=6 :
		0x56, 0xce, 0x7, 0x5, 0x50, 0xb0,
		//level=7 :
		0x5e, 0xca, 0x7, 0x5, 0x50, 0xb0,
		//level=8 :
		0x66, 0xc5, 0x8, 0x5, 0x50, 0xb0,
		//level=9 :
		0x6e, 0xc1, 0x8, 0x5, 0x50, 0xb0,
		//level=10 :
		0x76, 0xbc, 0x9, 0x5, 0x50, 0xb0,
		//level=11 :
		0x40, 0xdc, 0x4, 0x5, 0x50, 0xb0,
		//level=12 :
		0x46, 0xd7, 0x6, 0x5, 0x50, 0xb0,
		//level=13 :
		0x4e, 0xd3, 0x6, 0x5, 0x50, 0xb0,
		//level=14 :
		0x56, 0xce, 0x7, 0x5, 0x50, 0xb0,
		//level=15 :
		0x5e, 0xca, 0x7, 0x5, 0x50, 0xb0,
		//level=16 :
		0x66, 0xc5, 0x8, 0x5, 0x50, 0xb0,

};

BYTE code TVPeakingCoeff[][6] =
{
		//Peaking_Coef0,  Peaking_Coef1,  Peaking_Coef2,  Coring_Min,  Coring_Max_Pos,  Coring_Max_Neg ,

		//level=0 :
		0x0, 0x0, 0x0, 0x14, 0x50, 0xb0,
		//level=1 :
		0x4, 0x1, 0xfd, 0x16, 0x50, 0xb0,
		//level=2 :
		0x6, 0x2, 0xfb, 0x18, 0x50, 0xb0,
		//level=3 :
		0xa, 0x3, 0xf8, 0x1a, 0x50, 0xb0,
		//level=4 :
		0xc, 0x5, 0xf5, 0x1c, 0x50, 0xb0,
		//level=5 :
		0x10, 0x6, 0xf2, 0x1e, 0x50, 0xb0,
		//level=6 :
		0x12, 0x7, 0xf0, 0x1f, 0x50, 0xb0,
		//level=7 :
		0x16, 0x8, 0xed, 0x1f, 0x50, 0xb0,
		//level=8 :
		0x1a, 0xa, 0xe9, 0x1f, 0x50, 0xb0,
		//level=9 :
		0x1c, 0xb, 0xe7, 0x1f, 0x50, 0xb0,
		//level=10 :
		0x20, 0xc, 0xe4, 0x1f, 0x50, 0xb0,
		//level=11 :
		0x22, 0xd, 0xe2, 0x1f, 0x50, 0xb0,
		//level=12 :
		0x26, 0xf, 0xde, 0x1f, 0x50, 0xb0,
		//level=13 :
		0x2c, 0x11, 0xd9, 0x1f, 0x50, 0xb0,
		//level=14 :
		0x32, 0x14, 0xd3, 0x1f, 0x50, 0xb0,
		//level=15 :
		0x38, 0x16, 0xce, 0x1f, 0x50, 0xb0,
		//level=16 :
		0x3e, 0x19, 0xc8, 0x1f, 0x50, 0xb0,
};

#elif(_Peaking_Coring_Table == SharpnessTable2)

BYTE code PeakingCoeff[][6] =
{
		//Peaking_Coef0,  Peaking_Coef1,  Peaking_Coef2,  Coring_Min,  Coring_Max_Pos,  Coring_Max_Neg ,

		//level=1 :
		0x08, 0x00, 0xFC, 0x00, 0x28, 0xF8,
		//level=2 :
		0x0C, 0x00, 0xFA, 0x00, 0x28, 0xF8,
		//level=3 :
		0x10, 0x00, 0xF8, 0x00, 0x28, 0xF8,
		//level=4 :
	     	0x18, 0x00, 0xF4, 0x00, 0x28, 0xF8,	//3
		//level=5 :
		0x20, 0x00, 0xF0, 0x00, 0x28, 0xF8,
		//level=6 :
		0x28, 0x00, 0xEC, 0x00, 0x28, 0xF8,
		//level=7 :
		0x30, 0x00, 0xE8, 0x00, 0x28, 0xF8,
		//level=8 :
		0x38, 0x00, 0xE4, 0x00, 0x28, 0xF8,
		//level=9 :
		0x40, 0x00, 0xE0, 0x00, 0x28, 0xF8,
		//level=10 :
		0x46, 0x00, 0xDD, 0x00, 0x28, 0xF8,
		//level=11 :
		0x4E, 0x00, 0xD9, 0x00, 0x28, 0xF8,
		//level=12 :
		0x56, 0x00, 0xD5, 0x00, 0x28, 0xF8,
		//level=13 :
		0x5E, 0x00, 0xD1, 0x00, 0x28, 0xF8,
		//level=14 :
		0x66, 0x00, 0xCD, 0x00, 0x28, 0xF8,
		//level=15 :
		0x6E, 0x00, 0xC9, 0x00, 0x28, 0xF8,
		//level=16 :
		0x76, 0x00, 0xC5, 0x00, 0x28, 0xF8,
};


BYTE code TVPeakingCoeff[][6] =
 {
 		//Peaking_Coef0,  Peaking_Coef1,  Peaking_Coef2,  Coring_Min,  Coring_Max_Pos,  Coring_Max_Neg ,

		//level=1 :
		 0x08, 0x00, 0xFC, 0x12, 0x60, 0xF8,
		//level=2 :
		 0x0A, 0x00, 0xFB,	0x12, 0x60, 0xF8,
		//level=3 :
		 0x0C, 0x00, 0xFA,	0x12, 0x60, 0xF8,
		//level=4 :
		 0x0E, 0x00, 0xF9,	0x12, 0x60, 0xF8,
		//level=5 :
		 0x10, 0x00, 0xF8,	0x12, 0x60, 0xF8,
		//level=6 :
		 0x12, 0x00, 0xF7,	0x12, 0x60, 0xF8,
		//level=7 :
		 0x14, 0x00, 0xF6,	0x12, 0x60, 0xF8,
		//level=8 :
		 0x16, 0x00, 0xF5,	0x12, 0x60, 0xF8,
		//level=9 :
	     	 0x18, 0x00, 0xF4,	0x12, 0x60, 0xF8,
		//level=10 :
		 0x1A, 0x00, 0xF3,	0x12, 0x60, 0xF8,
		//level=11 :
		 0x1C, 0x00, 0xF2,	0x12, 0x60, 0xF8,
		//level=12 :
		 0x1E, 0x00, 0xF1,	0x12, 0x60, 0xF8,
		//level=13 :
		 0x20, 0x00, 0xF0,	0x12, 0x60, 0xF8,
		//level=14 :
		 0x22, 0x00, 0xEF,	0x12, 0x60, 0xF8,
		 //level=15 :
		 0x24, 0x00, 0xEE,	0x12, 0x60, 0xF8,
		//level=16 :
		 0x26, 0x00, 0xED,	0x12, 0x60, 0xF8,
};
#endif
//----------------------------------------------------
// CAdjustPeakingFilter
// Adjust Peaking Filter and Coring Control
// @param <Coefficient C0 of Peaking Filter>
// @return {none}
//----------------------------------------------------

void CAdjustPeakingFilter(SBYTE ucPeaking)
{
#if (_Peaking_Coring_Table != SharpnessNoneTable)//reference Table
	if((_GET_INPUT_SOURCE()==_SOURCE_VGA)||(_GET_INPUT_SOURCE()==_SOURCE_DVI) || (_GET_INPUT_SOURCE() == _SOURCE_HDMI))
	{
		CScalerPageSelect(_PAGE7);
		CScalerSetByte(_P7_PC_ACCESS_PORT_D6, 0x00);

		return;
	}

⌨️ 快捷键说明

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