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

📄 t101_util.c

📁 宏芯T102芯片驱动(51单片机作主控)
💻 C
📖 第 1 页 / 共 2 页
字号:
	#ifdef	PVI_35_960 // for PVI 3.5' 960*234 ,change by cwyong 2005-9-1
		I2CWriteByte(TW101,0xc7,0x32); 
		I2CWriteByte(TW101,0xe0,0x9f); 
		I2CWriteByte(TW101,0xe1,0xf4); 
		I2CWriteByte(TW101,0xe2,0x11);
	#endif
#endif
#if 0 //#ifdef PVI_35
    I2CWriteByte(TW101+2, 0x20, 0x21);
    I2CWriteByte(TW101+2, 0x21, 0x7d);
    I2CWriteByte(TW101, 0xe0, 0xbf);
    I2CWriteByte(TW101, 0xe1, 0xf0);
#endif


}
#endif



/////////////////////////
//This function setup the display direction
///////////////////////////
#ifdef ROTATE
void SET_Dismod(void)
{
#ifdef AU_7
	switch (Dis_Mode)
    { 
		case  TOP_LEFT: //Start from top-left
              LEFT_RIGHT = RIGHT;
			  UP_DOWN	=DOWN;
			  I2CWriteByte(TW101,0xE1, 0xf4);
              break;
		case  TOP_RIGHT: //Start from top-right
              LEFT_RIGHT = LEFT;
			  UP_DOWN	=DOWN;
			  I2CWriteByte(TW101,0xE1, 0xe0);
              break;
		case  BOTTOM_LEFT: //Start from bottom-left
              LEFT_RIGHT = RIGHT;
			  UP_DOWN	=UP;
			  I2CWriteByte(TW101,0xE1, 0xbc);
              break;
        case  BOTTOM_RIGHT:  //Start from bottom-right
              LEFT_RIGHT = LEFT;
			  UP_DOWN	=UP;
			  I2CWriteByte(TW101,0xE1, 0xa8);
              break;
    }
#else
#ifdef OUT_PIN_CONF
	I2CWriteByte(TW101,0xE1, OUT_PIN_CONF);
#endif     
#endif

	return;
}
#endif


bit IRScaleratioCtrl(void)
{
uCHAR Hcut=0;
	Hcut=12;
    m_wHRes=720-2*Hcut;

	if(m_cStandard==S_PAL)
	{
		m_wVRes=285;  //230 //ruby 2004-08-18
    }
	else if(m_cStandard==S_NTSC)
	{	
		m_wVRes=234;  //ruby 2004-08-18
   }

   else if(m_cStandard==S_SECAM)
   {	
		m_wVRes=289;  //ruby 2004-08-18
   }

  I2CWriteByte(TW101,0x54,m_wHRes);
  I2CWriteByte(TW101,0x55,m_wHRes>>8);
 

 switch(m_cScaleratio)
  {
   case Scale4_3:  
       if(!NoSignal)
	   {
     		I2CWriteByte(TW101, 0x9d, 0x00);//0x10);
	  		I2CWriteByte(TW101, 0x9e, 0x00);//0x80);
	  		I2CWriteByte(TW101, 0x9f, 0x00);//0x80);
			I2CWriteByte(TW101,0x88, ((H_Size-(H_Size43))/2)); 
			I2CWriteByte(TW101,0x89, 0x00);  
			I2CWriteByte(TW101,0x8a, (((H_Size43))+((H_Size-(H_Size43))/2))-2); 
			I2CWriteByte(TW101,0x8b, ((H_Size43)>>8)); 
       }
            I2CWriteByte(TW101+4,0x2E,0x82);
			I2CWriteByte(TW101+4,0x2F,0x50); //0x50); //Setup video decoder h active 720
		 break;
  case ScaleFULL:

			I2CWriteByte(TW101+4,0x2E,0x88); //0x82); //setup video decoder h start == 130
        	I2CWriteByte(TW101+4,0x2F,0x50); //0x50); //Setup video decoder h active 720 玡狠
		 break;
  }

#ifdef T515
	if((m_cSource&0x0F)<isrc_T515_CVIDEO1)
	{
#endif
  	  I2CWriteByte(TW101, INT_STATUS, 0x3F); 	
	  while(!(I2CReadByte(TW101, INT_STATUS)&0x20))
	  {
		twdDelay(1);
	   }
	   I2CWriteByte(TW101, INT_STATUS, 0x3F);
#ifdef T515
    }
#endif
  switch(m_cScaleratio)
  {
  case ScaleFULL:
            Scaling();
	   if(!NoSignal)
	   {
			I2CWriteByte(TW101,0x88, 00); 
		    I2CWriteByte(TW101,0x89, 00);  
		    I2CWriteByte(TW101,0x8a, 00); 
		    I2CWriteByte(TW101,0x8b, 00);
 	   }
      		I2CWriteByte(TW101,0x40,Hcut); //Hcut put picture position in center 2004-10-16 //For Foxconn
            I2CWriteByte(TW101,0xD8,0x00);//  Horizontal Main Display Start
  			I2CWriteByte(TW101,0xDC, (H_Size&0xFF));// 
			I2CWriteByte(TW101,0xDD, (H_Size>>8)); 
			
        break;
  case Scale4_3:
  			I2CWriteByte(TW101,0x40,Hcut);  //Ruby 2004-08-23  0x00);
        	I2CWriteByte(TW101,0xD8,((H_Size-H_Size43)/2)); // 0x53);//  Horizontal Main Display Start
 			I2CWriteByte(TW101,0xDC, (H_Size43));
			I2CWriteByte(TW101,0xDD, (H_Size43>>8)); 
            Scaling();
		break;
  }

	DisplayProcess_new();  
  return 1;
}


void SetNTSC_PAL(void)//0:NTSC
{ 			
  IRScaleratioCtrl();  
  Set_Reslolution();	
#ifdef T515
 if ( (m_cSource&0x0F)<  isrc_T515_CVIDEO1)             
 {
#endif
 I2CWriteByte(TW101+4,0x3F, 0x01);   //Ruby 2004-10-10  for left side black bar
	if(m_cStandard==S_NTSC)
	{
	I2CWriteByte(TW101+4,0x01, 0x09);// 2004-10-16 0x03); //0x03
	I2CWriteByte(TW101+4,0x0c, 0x8a);
	I2CWriteByte(TW101+4,0x18, 0x21);
	I2CWriteByte(TW101+4,0x19, 0xf0);
	I2CWriteByte(TW101+4,0x1a, 0x7c);
	I2CWriteByte(TW101+4,0x1b, 0x0f);// 0x1f);

	#ifdef PVI_5
		#ifdef	PVI_35_960 // for PVI 3.5' 960*234 ,change by cwyong 2005-9-1
			 I2CWriteByte(TW101+4,0x30, 0x22);
		#endif
	#endif
	#ifdef AU_7
		I2CWriteByte(TW101+4,0x30, 0x28);// 2004-10-16 0x24);// 0x22 0x28);//+DELAY_LINES);
	#endif
	I2CWriteByte(TW101+4,0x31, 0x61);
	I2CWriteByte(TW101+4,0x82, 0x42);
	}
	else if(m_cStandard==S_PAL)
	{
	I2CWriteByte(TW101+4,0x01,0x08);//Color
//	I2CWriteByte(TW101+4,0x01, 0x00);
	I2CWriteByte(TW101+4,0x0c, 0x67);
	I2CWriteByte(TW101+4,0x18, 0x2a);
	I2CWriteByte(TW101+4,0x19, 0x09);
	I2CWriteByte(TW101+4,0x1a, 0x8a);
	I2CWriteByte(TW101+4,0x1b, 0xcb);

	I2CWriteByte(TW101+4,0x30,0x2e);//10 //2e 0x2a);//+DELAY_LINES);

	I2CWriteByte(TW101+4,0x31, 0xc1);
	I2CWriteByte(TW101+4,0x82, 0x52);
	}

	else if(m_cStandard==S_SECAM)
	{
	I2CWriteByte(TW101+4,0x01,0x00);//Color
	I2CWriteByte(TW101+4,0x0c, 0x80);
	I2CWriteByte(TW101+4,0x0f, 0x05);
	I2CWriteByte(TW101+4,0x18, 0x28);
	I2CWriteByte(TW101+4,0x19, 0xb3);
	I2CWriteByte(TW101+4,0x1a, 0x3b);
	I2CWriteByte(TW101+4,0x1b, 0xb2);

	I2CWriteByte(TW101+4,0x30,0x28);// 0x2a);//+DELAY_LINES);

	I2CWriteByte(TW101+4,0x31, 0xc1);
	//I2CWriteByte(TW101+4,0x3f, 0x00);
	I2CWriteByte(TW101+4,0x82, 0x52);
	}
    I2CWriteByte(TW101+4,0x3F, 0x00);
#ifdef T515
}
else
T515_NTSC_PAL();
#endif

	Scaling();
	DisplayProcess_new();

}

void Scaling(void)
{

switch(m_cScaleratio)
  {
  case ScaleFULL:
	m_wBuff[0] = (float)m_wHRes/DWHSZ * 8192;
	break;

  case Scale4_3:
	m_wBuff[0] = (float)m_wHRes/H_Size43 * 8192;
	break;
  }
  	m_wBuff[1] = (float)m_wVRes/DWVSZ * 8192;

#ifdef AU_35
	m_wBuff[0]=0x8e00;
	m_wBuff[1]=0x1f90;
#endif

#ifdef PVI_35
	m_wBuff[0]=0x4600;
	m_wBuff[1]=0x2040;
#endif

	I2CWriteByte(TW101, SC_HOR_H1, (uCHAR)m_wBuff[0]);
   	I2CWriteByte(TW101, SC_HOR_H2, (uCHAR)(m_wBuff[0]>>8));


	I2CWriteByte(TW101, SC_VER_V1, (uCHAR)m_wBuff[1]);
	I2CWriteByte(TW101, SC_VER_V2, (uCHAR)(m_wBuff[1]>>8)); 

}


void Set_Reslolution(void)
{
	if(m_cStandard==S_NTSC)
	{
			if(cSVideo)
			{
				I2CWriteByte(TW101+4,0x00, 0x01);
				I2CWriteByte(TW101+4,0x03, 0x03);
			}
			else
			{
				I2CWriteByte(TW101+4,0x00, 0x00);
				I2CWriteByte(TW101+4,0x03, 0x00);
				I2CWriteByte(TW101+4,0x04, 0xdd);
			}

			m_wVTotal=525;
	}
	else if(m_cStandard==S_PAL)
	{	
			m_wVTotal=625;
			//if(cSVideo)
			//{
			//	I2CWriteByte(TW101+4,0x00, 0x33);
			//	I2CWriteByte(TW101+4,0x03, 0x03);
			//}
			//else
			//{
				I2CWriteByte(TW101+4,0x00, 0x32);
				I2CWriteByte(TW101+4,0x03, 0x02);
				I2CWriteByte(TW101+4,0x04, 0xdc);
			//}
	}

	else if(m_cStandard==S_SECAM)
	{	

			m_wVTotal=625;
			if(cSVideo)
			{
				I2CWriteByte(TW101+4,0x00, 0x29);
				I2CWriteByte(TW101+4,0x03, 0x03);
			}
			else
			{
				I2CWriteByte(TW101+4,0x00, 0x28);
				I2CWriteByte(TW101+4,0x03, 0x02);
				I2CWriteByte(TW101+4,0x04, 0xdc);
			}

	}

}

void Detect_NTSCPAL(void)
{
uCHAR index=0,temp = 0;
//PAL_NTSC Changed Detect----2004.5.11

 //
 /*
     if(I2CReadByte(TW101+4, 0x3A)&0x06)
	{
#ifdef T515
                if((m_cSource&0x0f) >= isrc_T515_CVIDEO1)
                    m_cBuff[0] = I2CReadByte(TW515, 0x5c)&0x04;
				else
#endif

                for(index=0;index<10;index++)
				{
				    m_cBuff[0] = I2CReadByte(TW101+4, 0x3c)&0x04;
				    if(I2CReadByte(TW101+4, 0x3c)&0x04!=m_cBuff[0])
					   return;
				}
#ifdef T515
                if((m_cSource&0x0f) >= isrc_T515_CVIDEO1)
				{
					if((I2CReadByte(TW515, 0x5c)&0x07)==0)
					  m_cBuff[0]=S_NTSC;
                    else if(I2CReadByte(TW515, 0x5c)&0x02)
					  m_cBuff[0]=S_SECAM;
       				else if(I2CReadByte(TW515, 0x5c)&0x04)
					  m_cBuff[0]=S_PAL;
					else  m_cBuff[0]=0xff;
			  	}
				else

#endif
#ifdef T102    
               {
    			if((I2CReadByte(TW101+4, 0x3c)&0x07)==0)
    			{
					  m_cBuff[0]=S_NTSC; 
                    }else {
				for(index=0;index<10;index++)
				{
					if(I2CReadByte(TW101+4, 0x3c)&0x02)
					{
						m_cBuff[0]=S_SECAM;
						break;
					}
				}
				if (m_cBuff[0]!=S_SECAM)
				{
					if(I2CReadByte(TW101+4, 0x3c)&0x04)
					  m_cBuff[0]=S_PAL;
					else  m_cBuff[0]=0xff;
				}
                    }
                }
#endif
			if((m_cStandard!=m_cBuff[0])&&m_cBuff[0]!=0xff)
    		{
				m_cStandard=m_cBuff[0];
				SetNTSC_PAL();
            }

     }// 癹伴い

⌨️ 快捷键说明

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