BYTE m_cStandard;
BYTE m_cChroma;
void set_t112_pal_ntsc(UINT8 panelfmt)
{
if (panelfmt==TV_FORMAT_PAL)
{
m_cStandard=S_PAL;
m_cChroma=S_PAL;
}
else if (panelfmt==TV_FORMAT_NTSC)
{
m_cStandard=S_NTSC;
m_cChroma=S_NTSC;
}
}
BYTE Dis_Mode=TOP_LEFT;
void SET_Dismod(void)
{
switch (Dis_Mode){
case TOP_LEFT: //Start from top-left
I2CWriteByte(TW101,0xE1, ScanMode[0]);
break;
case TOP_RIGHT: //Start from top-right
I2CWriteByte(TW101,0xE1, ScanMode[1]);
break;
case BOTTOM_RIGHT: //Start from bottom-right
I2CWriteByte(TW101,0xE1, ScanMode[2]);
break;
case BOTTOM_LEFT: //Start from bottom-left
I2CWriteByte(TW101,0xE1, ScanMode[3]);
break;
}
return;
}
void Initial_sub(void)//InitT10x
{
BYTE RegIndex,RegAdr;
RegIndex=0;
RegAdr=stInitT10xP0[0].ucRegAdr;
while (RegAdr != 0xFF) // bruce, 2006/01/09
{
if(RegAdr==0x30){
I2CWriteByte(TW101,RegAdr,(I2CReadByte(TW101,0x30)|0x01)); // enable Shadow
I2CWriteByte(TW101,RegAdr,(I2CReadByte(TW101,0x30)&(~0x02))| DEINTERLACE); //Bruce, 2006/01/10
}
else{
I2CWriteByte(TW101,RegAdr,stInitT10xP0[RegIndex].ucRegVal);
}
RegAdr=stInitT10xP0[++RegIndex].ucRegAdr;
}
RegIndex=0;
RegAdr=stInitT10xP2[0].ucRegAdr;
while (RegAdr != 0xFF) // bruce, 2006/01/09
{
if(RegAdr==0x01)
I2CWriteByte(TW101+4,RegAdr,(I2CReadByte(TW101+4,0x01)|0x01));// enable black level correction for 10 blank-to-black pedestal
else
I2CWriteByte(TW101+4,RegAdr,stInitT10xP2[RegIndex].ucRegVal);
RegAdr=stInitT10xP2[++RegIndex].ucRegAdr;
}
printf_w(".....__%d__(%s:%s)\n",__LINE__,__FILE__,__FUNCTION__);
for(RegIndex=0;RegIndex < PanelSpecP0Cnt;RegIndex++)
{
I2CWriteByte(TW101,ucaPanelSpecAdrP0[RegIndex],ucaPanelSpecDataP0[RegIndex]);
}
for(RegIndex=0;RegIndex < PanelSpecP2Cnt;RegIndex++)
{
I2CWriteByte(TW101+4,ucaPanelSpecAdrP2[RegIndex],ucaPanelSpecDataP2[RegIndex]);
}
SET_Dismod();
}
void TconInit(void)
{
BYTE TconIndex;
for(TconIndex=0;TconIndex < P1TconCnt;TconIndex++)
I2CWriteByte(TW101+2, TconAddress+TconIndex, TconP1Data[TconIndex]);
}
void LoadGammaTable(BYTE cGammaModeID)
{
BYTE i;
BYTE c;
BYTE *p=pcGammaData[cGammaModeID];
//disable I2C Auto_Inc_Address
I2CWriteByte(TW101,TW_INTERFACE,I2CReadByte(TW101,TW_INTERFACE)&~AUTO_INC);
I2CWriteByte(TW101,GAMMA_ADDR,0x00);
for(i=0;i<GAMMA_TABLE_DATA_SIZE;i++) {
c=*p++;
I2CWriteByte(TW101,GAMMA_DATA,c);
}
I2CWriteByte(TW101,TW_INTERFACE,I2CReadByte(TW101,TW_INTERFACE)|AUTO_INC);
I2CWriteByte(TW101,IMG_FUN_CTRL,I2CReadByte(TW101,IMG_FUN_CTRL)|ENGAMMA);
return;
}
void SourceSelect(void)
{
I2CWriteByte(TW101, 0xC2, I2CReadByte(TW101, 0xC2)|(PSYNC_STR|IGNORE_VSYNC));
I2CWriteByte(TW101, 0x9d, 0x10);
I2CWriteByte(TW101, 0x9e, 0xff);
I2CWriteByte(TW101, 0x9f, 0x40);
I2CWriteByte(TW101, PATTERN_CTRL, 0x87);
I2CWriteByte(TW101,0x0f,0x70); //2005-03030 for position shift
I2CWriteByte(TW101,0x0f,0x00); //2005-03030 for position shift
I2CWriteByte(TW101,0x31,0x00);
I2CWriteByte(TW101,0x1a, 0x87);
I2CWriteByte(TW101,0x18, uiaSrcMux[(m_cSource&0x0F)*2]>>8); // cMux1);
I2CWriteByte(TW101,0x19, uiaSrcMux[(m_cSource&0x0F)*2]&0xFF); // cMux2);
if(uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeSVIDEO)
{
I2CWriteByte(TW101,0x11, 0x22);
I2CWriteByte(TW101+4,0x07, 0x26);//0x24);//0x05|0x22);
I2CWriteByte(TW101+4,0x00, I2CReadByte(TW101+4,0x00)|0x01);
I2CWriteByte(TW101+4,0x01, I2CReadByte(TW101+4,0x01)&~ENYPbPr);
I2CWriteByte(TW101+4,0x03, I2CReadByte(TW101+4,0x03)|0x03);
}
else if (uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeCVBS)
{
I2CWriteByte(TW101,0x11, 0x22);
I2CWriteByte(TW101+4,0x07, 0x21);//0x05|0x22);
I2CWriteByte(TW101+4,0x00, I2CReadByte(TW101+4,0x00)&0xfe);
I2CWriteByte(TW101+4,0x01, I2CReadByte(TW101+4,0x01)&~ENYPbPr);
if(m_cChroma==S_NTSC_4) // temporarily add by Sherman 06'01'27
I2CWriteByte(TW101+4,0x03, ((I2CReadByte(TW101+4,0x03)&0xf8)|0x03));//tcf
else
I2CWriteByte(TW101+4,0x03, I2CReadByte(TW101+4,0x03)&0xfc);
}
else if (uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeYPBPR)
{
I2CWriteByte(TW101,0x11, 0x55);
I2CWriteByte(TW101+4,0x07, 0x20);
I2CWriteByte(TW101+4,0x01, I2CReadByte(TW101+4,0x01)|ENYPbPr);
}
delay_1ms(5);
if(I2CReadByte(TW101+4, 0x3A)&0x06){
NoSignal=0;
I2CWriteByte(TW101, 0xC2, I2CReadByte(TW101, 0xC2)&~(PSYNC_STR|IGNORE_VSYNC));
I2CWriteByte(TW101, PATTERN_CTRL, 0x00);
}
I2CWriteByte(TW101, 0xE2, 0x11);
}
UINT16 m_wVTotal;
void SetIPVideoType(void)
{
if(m_cChroma==S_NTSC){
m_wVTotal=525;
I2CWriteByte(TW101+4,0x00, I2CReadByte(TW101+4,0x00)&0x01);
I2CWriteByte(TW101+4,0x01, I2CReadByte(TW101+4,0x01)|0x09);
if(uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeSVIDEO)
I2CWriteByte(TW101+4,0x03, 0x03);
else I2CWriteByte(TW101+4,0x03, 0x00);
}
else if(m_cChroma==S_PAL){
m_wVTotal=625;
I2CWriteByte(TW101+4,0x00, (I2CReadByte(TW101+4,0x00)&0x01)|0x32);//tcf
I2CWriteByte(TW101+4,0x01, I2CReadByte(TW101+4,0x01)|0x08);
I2CWriteByte(TW101+4,0x03, (I2CReadByte(TW101+4,0x03)&0x01)|0x02);//tcf
}
else if(m_cChroma==S_SECAM){
m_wVTotal=625;
I2CWriteByte(TW101+4,0x00, (I2CReadByte(TW101+4,0x00)&0x01)|0x28);//tcf
I2CWriteByte(TW101+4,0x03, (I2CReadByte(TW101+4,0x03)&0x01)|0x02);//tcf
}
else if(m_cChroma==S_PAL_M){
m_wVTotal=525;
I2CWriteByte(TW101+4,0x00, (I2CReadByte(TW101+4,0x00)&0x01)|0x04);//tcf
}
else if(m_cChroma==S_PAL_CN){
m_wVTotal=625;
I2CWriteByte(TW101+4,0x00, (I2CReadByte(TW101+4,0x00)&0x01)|0x26);//tcf
}
else if(m_cChroma==S_NTSC_4){
m_wVTotal=525;
I2CWriteByte(TW101+4,0x00, (I2CReadByte(TW101+4,0x00)&0x01)|0x00);//tcf
if(uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeSVIDEO)
I2CWriteByte(TW101+4,0x03, 0x03);
else I2CWriteByte(TW101+4,0x03, 0x03);
}
}
void SetSignalStd(void)
{
BYTE RegIdx,ValIdx;
I2CWriteByte(TW101+4, 0x3f, 0x01);
ValIdx=0;
for (RegIdx=0; RegIdx<SignalStdRegP2Cnt; RegIdx++, ValIdx++){
I2CWriteByte(TW101+4, ucaSignalStdRegP2[RegIdx], ucaSignalStdValP2[ValIdx]);
}
delay_1ms(10);
I2CWriteByte(TW101+4, 0x3f, 0x00);
SetIPVideoType();
}
void SetOPTiming(void)
{
UINT16 ucAdrIdx,ucDataIdx;
if((m_cStandard==S_NTSC)|(m_cStandard==S_NTSC_4)|(m_cStandard==S_PAL_M)){
ucDataIdx=0;
for (ucAdrIdx=0; ucAdrIdx<P0ScaleAdrCnt; ucAdrIdx++, ucDataIdx++){
I2CWriteByte(TW101, ucaZoomAdrP0[ucAdrIdx], ucaZoomDataP0_NTSC[ucDataIdx]);
}
ucDataIdx=0;
for (ucAdrIdx=0; ucAdrIdx<P2ScaleAdrCnt; ucAdrIdx++, ucDataIdx++){
I2CWriteByte(TW101+4, ucaZoomAdrP2[ucAdrIdx], ucaZoomDataP2_NTSC[ucDataIdx]);
}
}
else{
ucDataIdx=0;
for (ucAdrIdx=0; ucAdrIdx<P0ScaleAdrCnt; ucAdrIdx++, ucDataIdx++){
I2CWriteByte(TW101, ucaZoomAdrP0[ucAdrIdx], ucaZoomDataP0_PAL[ucDataIdx]);
}
ucDataIdx=0;
for (ucAdrIdx=0; ucAdrIdx<P2ScaleAdrCnt; ucAdrIdx++, ucDataIdx++){
I2CWriteByte(TW101+4, ucaZoomAdrP2[ucAdrIdx], ucaZoomDataP2_PAL[ucDataIdx]);
}
}
I2CWriteByte(TW101, 0xe2, 0x11);
}
void init_t112(void)
{
set_t112_pal_ntsc(tv_format);
Initial_sub();//t112 init
TconInit();
LoadGammaTable(0);
delay_1ms(5);
m_cSource=3; //svideo
SourceSelect();
SetSignalStd();
SetOPTiming();
delay_1ms(5);
I2CWriteByte(0x50,0x1a,0x42);//set adc-agc
I2CWriteByte(0x50,0x69,0x80);
I2CWriteByte(0x52,0x21,0x71);
I2CWriteByte(0x54,0x08,0x3c);
}
void set_t112_format(UINT8 panelfmt) //set pal or ntsc register map
{
if (panelfmt==TV_FORMAT_PAL)
{
//PAL
I2CWriteByte(0x54,0x00,0x33);
I2CWriteByte(0x50,0x40,0x0C);
I2CWriteByte(0x54,0x0c,0x67);
I2CWriteByte(0x54,0x18,0x2a);
I2CWrit
评论1