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

📄 adjust_customer.c

📁 RTD2662板卡源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	else
	{

		if(_GET_INPUT_SOURCE() == _SOURCE_VIDEO_TV)
		{
			pData[0] = TVPeakingCoeff[ucPeaking][0];
			pData[1] = TVPeakingCoeff[ucPeaking][1];
			pData[2] = TVPeakingCoeff[ucPeaking][2];
			pData[3] = TVPeakingCoeff[ucPeaking][3];
			pData[4] = TVPeakingCoeff[ucPeaking][4];
			pData[5] = TVPeakingCoeff[ucPeaking][5];

		}
		else
		{
			pData[0] = PeakingCoeff[ucPeaking][0];
			pData[1] = PeakingCoeff[ucPeaking][1];
			pData[2] = PeakingCoeff[ucPeaking][2];
			pData[3] = PeakingCoeff[ucPeaking][3];
			pData[4] = PeakingCoeff[ucPeaking][4];
			pData[5] = PeakingCoeff[ucPeaking][5];
		}

		CScalerPageSelect(_PAGE7);
		CScalerSetByte(_P7_PC_ACCESS_PORT_D6, 0x80);
		CScalerWrite(_P7_PC_DATA_PORT_D7, 6, pData, _NON_AUTOINC);
		CScalerSetByte(_P7_PC_ACCESS_PORT_D6, 0x40);

	}

#else//default

	if((_GET_INPUT_SOURCE() == _SOURCE_VGA)||(_GET_INPUT_SOURCE() == _SOURCE_DVI) || (_GET_INPUT_SOURCE() == _SOURCE_HDMI))
		ucPeaking = ucPeaking * 2;
	else
		ucPeaking = ucPeaking * 8;

	if(ucPeaking > 126)
		ucPeaking = 126;
	if(ucPeaking < 14 && ucPeaking > 0)
		ucPeaking = 14;
		
	pData[0] = ((ucPeaking +1) >> 1) << 1;
	if((bit)(ucPeaking & 0x01))
	{
		pData[1] = (SWORD)-72 * pData[0] / 126;
		pData[2] = (SWORD)-(pData[0] + 2*pData[1]) / 2;
	}
	else
	{
		pData[1] = (SWORD)-73 * pData[0] / 126;
		pData[2] = (SWORD)-(pData[0] + 2*pData[1]) / 2;
	}

	pData[3] = (BYTE)_CORING_MIN;
	pData[4] = (BYTE)_CORING_MAX_POS;
	pData[5] = (SBYTE)_CORING_MAX_NEG;
	CScalerPageSelect(_PAGE7);
	CScalerSetByte(_P7_PC_ACCESS_PORT_D6, 0x80);
	CScalerWrite(_P7_PC_DATA_PORT_D7, 6, pData, _NON_AUTOINC);
	CScalerSetByte(_P7_PC_ACCESS_PORT_D6, 0x40);

#endif
}


#endif

//--------------------------------------------------
// Description  : Adjust sharpness
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CAdjustPeakingCoding(void)
{
	CAdjustPeakingFilter(GET_PEAKING_CORING());
}

//--------------------------------------------------
// Description  : Adjust backlight
// Input Value  : None
// Output Value : None
//--------------------------------------------------
void CAdjustBacklight(void)
{
    BYTE ucLight = 0;

    stSystemData.BackLight = stConBriData.Brightness;//GET_BRIGHTNESS();

    ucLight = (WORD)(_BACKLIGHT_MAX - _BACKLIGHT_MIN) * stSystemData.BackLight/100;

#if(_BACKLIGHT_PWM_INVERSE == _ENABLE)

    ucLight = _BACKLIGHT_MAX - ucLight;

#else

    ucLight = _BACKLIGHT_MIN + ucLight;

#endif

    CSetPWM(_BACKLIGHT_PWM, ucLight);
}


void CAdjustGammaTable(BYTE index)
{
#if(_GAMMA_TYPE == 	_FULL_GAMMA_NORMAL_TABLE)
	switch(index)
    {
	case 1:
   		CAdjustGamma(_FULL_GAMMA_NORMAL_TABLE, GAMMA_1_R, GAMMA_1_G, GAMMA_1_B);
		break;

	case 2:
		CAdjustGamma(_FULL_GAMMA_NORMAL_TABLE, GAMMA_2_R, GAMMA_2_G, GAMMA_2_B);
		break;

	case 3:
		CAdjustGamma(_FULL_GAMMA_NORMAL_TABLE, GAMMA_3_R, GAMMA_3_G, GAMMA_3_B);
		break;

	case 0:
		CScalerSetBit(_GAMMA_CTRL_67, ~_BIT6, 0x00);
		break;

	default:
		break;
	}
	
#elif(_GAMMA_TYPE == _FULL_GAMMA_COMPRESS_TABLE2)

	switch(index)
    {
	case 0:		// disable Gamma
		CScalerSetBit(_GAMMA_CTRL_67, ~_BIT6, 0x00);
		break;

	case 1:
    	CAdjustGamma(_FULL_GAMMA_COMPRESS_TABLE2, GAMMA_1_R, GAMMA_1_G, GAMMA_1_B);
    	break;

    case 2:
    	CAdjustGamma(_FULL_GAMMA_COMPRESS_TABLE2, GAMMA_2_R, GAMMA_2_G, GAMMA_2_B);
    	break;

    case 3:
    	CAdjustGamma(_FULL_GAMMA_COMPRESS_TABLE2, GAMMA_3_R, GAMMA_3_G, GAMMA_3_B);
    	break;
    
    default:
    	break;
	}
#endif
}

#if(sRGB_Color_Enhance == _ENABLE)
//Use sRGB to adjust Saturation and Hue
void CAdjustSaturationHue(BYTE  ucValue, BOOL bSaturationIndex)
{
//Lewis, this table have multiplied by 1024
	INT16 code YUV2RGB[3][3] =
	{
	  {1024,   0,      1436},
	  {1024,   -342,   -731},
	  {1024,   1815,   0}
	 };

//Lewis, this table have multiplied by 1024
	INT16 code RGB2YUV[3][3] =
	{
	    {306,     601,   117},
	  {-173,   -339,    512},
	    {512,   -429,   -83}
	 };

	BYTE i, j;
	INT16 temp_buff0[3][3];
	//731401***
	//INT16 temp_buff1[3][3];
	//INT16 temp_buff2[3][3];
	INT16 MATRIX_GAIN_HUE[3][3];
	//INT16 MATRIX_GAIN[3][3];
	//INT16 MATRIX_HUE[3][3];
	//731401###
	INT16 temp_hue, temp_saturation;


	if(bSaturationIndex == _TRUE) //adjust saturation
	{
		temp_saturation=(INT16)ucValue;
		temp_hue=(INT16)GET_HUE() - 50;
	}
	else
	{
		temp_saturation = (INT16)GET_SATURATION();
		temp_hue=(INT16)ucValue - 50;
	}

	//Lewis 20060717, to prevent adjust CSC matrix, the saturation overflow
	if(temp_saturation>75)
		temp_saturation = 75;
	else if(temp_saturation<25)
		temp_saturation = 25;

	temp_hue = temp_hue*19>>5; //Lewis, 20060720, limited Hue range to prevent grey bar have color
//731401***
//Lewis, this table have multiplied by 1024
	MATRIX_GAIN_HUE[0][0] = 1024;
	MATRIX_GAIN_HUE[0][1] = 0;
	MATRIX_GAIN_HUE[0][2] = 0;
	MATRIX_GAIN_HUE[1][0] = 0;
	MATRIX_GAIN_HUE[1][1] = ((temp_saturation<<7)/25)<<2;
	MATRIX_GAIN_HUE[1][2] = 0;
	MATRIX_GAIN_HUE[2][0] = 0;
	MATRIX_GAIN_HUE[2][1] = 0;
	MATRIX_GAIN_HUE[2][2] = MATRIX_GAIN_HUE[1][1];

	CAdjustMatrixMultiply(MATRIX_GAIN_HUE,RGB2YUV,temp_buff0);
	
//Lewis, this table have multiplied by 1024
	MATRIX_GAIN_HUE[0][0] = 1024;
	MATRIX_GAIN_HUE[0][1] = 0;
	MATRIX_GAIN_HUE[0][2] = 0;
	MATRIX_GAIN_HUE[1][0] = 0;
	MATRIX_GAIN_HUE[1][1] = CAdjustCosine(temp_hue);
	MATRIX_GAIN_HUE[1][2] = CAdjustSine(temp_hue);
	MATRIX_GAIN_HUE[2][0] = 0;
	MATRIX_GAIN_HUE[2][1] = (-1)*MATRIX_GAIN_HUE[1][2];//-CAdjustSine(temp);
	MATRIX_GAIN_HUE[2][2] = MATRIX_GAIN_HUE[1][1]; //CAdjustCosine(temp);


	CAdjustMatrixMultiply(MATRIX_GAIN_HUE,temp_buff0,temp_buff0);
	CAdjustMatrixMultiply(YUV2RGB,temp_buff0,temp_buff0);

	for(i=0; i<3; i++)
    {
		for(j=0; j<3; j++)
    	{
    		if (i==j)
    		   temp_buff0[i][j]-=1024;
    
    		temp_buff0[i][j] = temp_buff0[i][j]>>1;
    
    		if (temp_buff0[i][j]>255)
    			temp_buff0[i][j] = 255;
    		else if(temp_buff0[i][j]<-256)
    			temp_buff0[i][j] = -256;
    	}
    }

	//Write R
	//frank CScalerSetBit(_COLOR_CTRL_62,0xc7,0x08);
	pData[0] =(temp_buff0[0][0]<0?1:0);
	pData[1]=(BYTE)(temp_buff0[0][0]);
	pData[2] =(temp_buff0[0][1]<0?1:0);
	pData[3]=(BYTE)(temp_buff0[0][1]);
	pData[4] =(temp_buff0[0][2]<0?1:0);
	pData[5]=(BYTE)(temp_buff0[0][2]);

//	CAdjustSetsRGBRhue();
	CAdjustSetYpbprRhue();

	//Write G
	//frank CScalerSetBit(_COLOR_CTRL_62,0xc7,0x10);

	pData[0] =(temp_buff0[1][0]<0?1:0);
	pData[1]=(BYTE)(temp_buff0[1][0]);
	pData[2] =(temp_buff0[1][1]<0?1:0);
	pData[3]=(BYTE)(temp_buff0[1][1]);
	pData[4] =(temp_buff0[1][2]<0?1:0);
	pData[5]=(BYTE)(temp_buff0[1][2]);

//	CAdjustSetsRGBGhue();
	CAdjustSetYpbprGhue();

	//Write B

	pData[0] =(temp_buff0[2][0]<0?1:0);
	pData[1]=(BYTE)(temp_buff0[2][0]);
	pData[2] =(temp_buff0[2][1]<0?1:0);
	pData[3]=(BYTE)(temp_buff0[2][1]);
	pData[4] =(temp_buff0[2][2]<0?1:0);
	pData[5]=(BYTE)(temp_buff0[2][2]);
//731401###
//	CAdjustSetsRGBBhue();
	CAdjustSetYpbprBhue();

	CScalerSetBit(_COLOR_CTRL_62, 0xff, 0x80);			// cftsai 20061031 added, ready to write
}

INT16 CAdjustCosine(INT16 fDegree)
{
	//Lewis, the curve value table have multiplied by 1024
	UINT16 code fCosCurveAngle[13] = {   0,   6,  12,  18,  24,  30,  37,  44,  52,  60,  68,  78, 90};
	UINT16 code fCosCurveValue[13] = {1024, 1018, 1002, 974, 935, 887, 818, 737, 630, 512, 384, 213,  0};
	UINT8 i,cQuadrant;
	INT16 fDegreeTemp, fDegreeSpan, fCosValueSpan, fCosValue;

	if (fDegree < 0)
		fDegree += 360;

	fDegree = fDegree%360;

	//locate degree on which quadrant
	cQuadrant = (UINT8)(fDegree / 90);
	cQuadrant++;
	if (cQuadrant==1) //first quadrant
		fDegree = fDegree;
	else if(cQuadrant==2) //second quadrant
		fDegree = 180 - fDegree;
	else if(cQuadrant==3) //third quadrant
		fDegree = fDegree - 180;
	else if(cQuadrant==4) //forth quadrant
		fDegree = 360 -fDegree;
	//locate degree on which quadrant

	if (fDegree<=fCosCurveAngle[0])
		fCosValue = fCosCurveValue[0];
	else
	{
		for (i=0;fCosCurveAngle[i] < fDegree; i++);

		i--;
		fDegreeTemp = fDegree-fCosCurveAngle[i];
		fDegreeSpan = fCosCurveAngle[i+1]-fCosCurveAngle[i];
		fCosValueSpan = fCosCurveValue[i+1]-fCosCurveValue[i];
		fCosValue = fCosCurveValue[i]+fDegreeTemp*fCosValueSpan/fDegreeSpan;
	}

	if (cQuadrant==2 || cQuadrant==3)
		fCosValue = fCosValue*(-1);

	return fCosValue;
}

INT16 CAdjustSine(INT16 fDegree)
{
	//Lewis, this table have multiplied by 1024
	UINT16 code fSinCurveAngle[13] = {0,   6,  12,  18,  24,  30,  37,  44,  52,  60,  68,  78, 90};
	UINT16 code fSinCurveValue[13] = {0, 107, 213, 316, 416, 512, 616, 711, 807, 887, 949, 1002,  1024};
	UINT8 i,cQuadrant;
	INT16 fDegreeTemp,fDegreeSpan,fSinValueSpan,fSinValue;

	if (fDegree < 0)
		fDegree += 360;

	fDegree = fDegree%360;

	//locate degree on which quadrant
	cQuadrant = (UINT8)(fDegree / 90);
	cQuadrant++;
	if (cQuadrant==1) //first quadrant
		fDegree = fDegree;
	else if(cQuadrant==2) //second quadrant
		fDegree = 180 - fDegree;
	else if(cQuadrant==3) //third quadrant
		fDegree = fDegree - 180;
	else if(cQuadrant==4) //forth quadrant
		fDegree = 360 -fDegree;
	//locate degree on which quadrant

	if (fDegree<=fSinCurveAngle[0])
		fSinValue = fSinCurveValue[0];
	else
	{
		for (i=0;fSinCurveAngle[i] < fDegree; i++);

		i--;
		fDegreeTemp = fDegree-fSinCurveAngle[i];
		fDegreeSpan = fSinCurveAngle[i+1]-fSinCurveAngle[i];
		fSinValueSpan = fSinCurveValue[i+1]-fSinCurveValue[i];
		fSinValue = fSinCurveValue[i]+fDegreeTemp*fSinValueSpan/fDegreeSpan;
	}

	if (cQuadrant==3 || cQuadrant==4)
		fSinValue = fSinValue*(-1);

	return fSinValue;
}

void CAdjustMatrixMultiply(INT16 (*arrayA)[3], INT16 (*arrayB)[3], INT16 (*arrayC)[3])
{
	BYTE i, j;
	INT32 Temp[3][3];

	for(i=0; i<3; i++)
	{
		for(j=0; j<3; j++)
		{
			Temp[i][j] = ((INT32)arrayA[i][0]*arrayB[0][j]>>2)
						+ ((INT32)arrayA[i][1]*arrayB[1][j]>>2)
						+ ((INT32)arrayA[i][2]*arrayB[2][j]>>2);

			//arrayC[i][j] = (INT16)(Temp[i][j]>>8);//731401
		}
	}

	for(i=0; i<3; i++)
	{
		for(j=0; j<3; j++)
		{
			arrayC[i][j] = (INT16)(Temp[i][j]>>8);
		}
	}

}

#endif



BYTE code SatPlus[8]  = { 41, 44, 43, 39, 31, 22, 11, 0 }; // by 1/256
BYTE code SatMinus[8] = { 24, 35, 40, 41, 36, 28, 16, 0 }; // by 1/256

int CAdjustColorGammaCal(BYTE color, BYTE n) // n = 1~8
{
	BYTE temp;

	if (color == 0)		//R
		temp = GET_ICM_SAT_R();
	else if (color== 1)	//G
		temp = GET_ICM_SAT_G();
	else if (color == 2)//B
		temp = GET_ICM_SAT_B();
	else if (color == 3)//Y
		temp = GET_ICM_SAT_Y();
	else if (color == 4)//C
		temp = GET_ICM_SAT_C();
    temp *= 2;  //Since the scale for OSD(from 0~16) and cloor(from 0~32) is different, we will have to multiply
			   //temp by 2 to make up the difference
    if (temp >= 16)
    {
		return ((int)(512*n) + (int)((temp-16)*(int)SatPlus[n-1])) / 64 ;
    }
    else
    {
		return ((int)(512*n) - (int)((16-temp)*(int)SatMinus[n-1])) / 64 ;
    }
}

#define CENTER    0x00
#define RIGHT     0x10
#define LEFT      0x20

void CAdjustMZHueSat(BYTE color)
{
	//Value  0~4095 => angle 0~359
	//R / G / B / Y /C
	//range  256 => 22.5  degree
	//buffer 128 => 11.25 degree
	//R / G / B
	//range  512 => 45    degree
	//buffer 128 => 11.25 degree
	CTimerWaitForEvent(_EVENT_DEN_STOP);
	CAdjustSetHueUVDelta(color, CENTER);
	CAdjustSetHueUVDelta(color, RIGHT);
	CAdjustSetHueUVDelta(color, LEFT);

	CScalerPageSelect(_PAGE7);
	CScalerSetBit(_P7_ICM_CTRL_D0, ~_BIT7, _BIT7);

}


⌨️ 快捷键说明

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