📄 t101_util.c
字号:
I2CWriteByte(TW101,0x19, uiaSrcMux[(m_cSource&0x0F)*2]&0xFF); // cMux2);
if(uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeSVIDEO) ///itypeSVIDEO =0x01;
{
I2CWriteByte(TW101,0x11, 0x22);
I2CWriteByte(TW101+4,0x07, 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) ///itypeCVBS=0x00;
{
I2CWriteByte(TW101,0x11, 0x00);
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);
else
I2CWriteByte(TW101+4,0x03, I2CReadByte(TW101+4,0x03)&0xfc);
}
else if (uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeYPBPR) ///itypeYPBPR=0x02;
{
I2CWriteByte(TW101,0x11, 0x55);
I2CWriteByte(TW101+4,0x07, 0x20);
I2CWriteByte(TW101+4,0x01, I2CReadByte(TW101+4,0x01)|ENYPbPr);
}
twdDelay(500);
if(I2CReadByte(TW101+4, 0x3A)&0x06)
{ ///判断H/V——LOCK是否
NoSignal=0;
I2CWriteByte(TW101, 0xC2, I2CReadByte(TW101, 0xC2)&~(PSYNC_STR|IGNORE_VSYNC));
I2CWriteByte(TW101, PATTERN_CTRL, 0x00);
}
I2CWriteByte(TW101, 0xE2, 0x11); //shadow control
}
void DetectSignalStd(void) ////涉及到m_cStandard & m_cChroma两个参数,探测标准信号
{
uCHAR index=0,SlaveAddr,RegAddrShift;//,line_525;//,tmp;
SlaveAddr=0x54;
RegAddrShift=0x00;
m_cBuff[0]=m_cStandard; ///m_cStandard=S_NTSC;
if(I2CReadByte(SlaveAddr, 0x3A+RegAddrShift)&0x06) // Judge vlock and hlock
{
//~~~~~~~ set OPTiming ~~~~~~~~~~~~~~~~~~~//
if(I2CReadByte(TW101,0x59) <= 0xd6)
m_cBuff[0]=S_NTSC;
else
m_cBuff[0]=S_PAL;
if((m_cStandard!=m_cBuff[0]))
{ // signal std was changed,and output timing must be set again
m_cStandard=m_cBuff[0];
SetOPTiming();
}
//~~~~~~~ End of set OPTiming ~~~~~~~~~~~~~~~~~~~//
//~~~~~~~ set Chroma ~~~~~~~~~~~~~~~~~~~//
m_cBuff[4]=m_cChroma; ///m_cChroma=S-NTSC;
twdDelay1(25);
// Set Chroma lock configration
if(I2CReadByte(TW101,0x59) <= 0xd6)
I2CWriteByte(SlaveAddr, 0x83+RegAddrShift, 0x39);//6f); // NTSC // change by Sherman 06'02'07
else
I2CWriteByte(SlaveAddr, 0x83+RegAddrShift, 0x39); // PAL
twdDelay1(50);
if(I2CReadByte(TW101,0x59) <= 0xd6)
{ // NTSC-M,NTSC-4,PAL-M
m_wBuff[2]=0;
m_cBuff[1]=m_cChroma; // Preserve previous status for signal std
twdDelay1(150); // add by Sherman 06'01'16
while (1)
{ // NTSC-M=1,NTSC-4=4,PAL-M=5
if (m_cChroma == S_NTSC_4)
{
if ((I2CReadByte(SlaveAddr, 0x3a+RegAddrShift)&0x08)&&(I2CReadByte(SlaveAddr, 0x7a+RegAddrShift)<0x80))
break;
}
if ((m_cChroma == S_NTSC)|(m_cChroma == S_PAL_M))
{
if ((I2CReadByte(SlaveAddr, 0x3a+RegAddrShift)&0x08))
break;
}
if (m_cChroma == S_NTSC)
#ifndef Signal_NTSC_4
#ifndef Signal_PAL_M
m_cChroma=S_NTSC;
#else
m_cChroma=S_PAL_M;
#endif
#else
m_cChroma=S_NTSC_4;
#endif
else if (m_cChroma == S_NTSC_4)
#ifndef Signal_PAL_M
m_cChroma=S_NTSC;
#else
m_cChroma=S_PAL_M;
#endif
else //if (m_cChroma == S_PAL_M)
m_cChroma=S_NTSC;
SetSignalStd(); // Set Signal flag and DTO
twdDelay1(50);
if ((++m_wBuff[2]) >4) break; // Avoid while setting, input switch to NTSC
}
}
else
{ // PAL-BD,PAL-CN,SECAM
#if ((defined T100A)|(defined T101A)|(defined T101))&(defined YPbPr)
if(m_cSource == isrYPbPr)
m_cBuff[4]=S_PAL;
else
{
#endif
m_wBuff[2]=0;
m_cBuff[1]=m_cChroma; // Preserve previous status for signal std
twdDelay1(150); // add by Sherman 06'01'16
while (1){ // PAL-BD=2,PAL-CN=6,SECAM=3
if ((m_cChroma == S_PAL)|(m_cChroma == S_PAL_CN))
{
if ((I2CReadByte(SlaveAddr, 0x3a+RegAddrShift)&0x08) && (I2CReadByte(SlaveAddr, 0x3c+RegAddrShift)&0x01==1))//&& (I2CReadByte(SlaveAddr, 0x7d+RegAddrShift)>0xf0))
break;
}
if (m_cChroma == S_SECAM)
{
if ((I2CReadByte(SlaveAddr, 0x3a+RegAddrShift)&0x08) && (I2CReadByte(SlaveAddr, 0x7d+RegAddrShift)>0xf0))
break;
}
if (m_cChroma == S_PAL)
#ifndef Signal_SECAM
#ifndef Signal_PAL_CN
m_cChroma=S_PAL;
#else
m_cChroma=S_PAL_CN;
#endif
#else
m_cChroma=S_SECAM;
#endif
else if (m_cChroma == S_SECAM)
#ifndef Signal_PAL_CN
m_cChroma=S_PAL;
#else
m_cChroma=S_PAL_CN;
#endif
else //if (m_cChroma == S_PAL_CN)
m_cChroma=S_PAL;
SetSignalStd(); // Set Signal flag and DTO
twdDelay1(50);
if ((++m_wBuff[2]) >4) break; // Avoid while setting, input switch to NTSC
}
#if ((defined T100A)|(defined T101A)|(defined T101))&(defined YPbPr)
}
#endif
}
if (m_cBuff[1] != m_cChroma)
{
if ((I2CReadByte(SlaveAddr, 0x3a+RegAddrShift)&0x08))
m_cBuff[4] = m_cChroma;
m_cChroma=m_cBuff[1] ;
}
if((m_cChroma!=m_cBuff[4]))
{
m_cChroma=m_cBuff[4];
}
}//register debug
}
void SetSignalStd(void) ///设置标准信号制式(的选择)
{
uCHAR RegIdx,ValIdx,ChromaIdx;
if(m_cChroma==S_NTSC)
ChromaIdx=0;
else if(m_cChroma==S_PAL)
ChromaIdx=1;
else if(m_cChroma==S_SECAM)
ChromaIdx=2;
else if(m_cChroma==S_NTSC_4)
ChromaIdx=3;
else if(m_cChroma==S_PAL_M)
ChromaIdx=4;
else //(m_cChroma==S_PAL_CN)
ChromaIdx=5;
I2CWriteByte(TW101+4, 0x3f, 0x01); // reset comb filter //add by Sherman 06'01'16
ValIdx=(ChromaIdx)*SignalStdRegP2Cnt; // S_NTSC=0x01
for (RegIdx=0; RegIdx<SignalStdRegP2Cnt; RegIdx++, ValIdx++){
I2CWriteByte(TW101+4, ucaSignalStdRegP2[RegIdx], ucaSignalStdValP2[ValIdx]);
}
twdDelay1(100); // add by Sherman 06'01'16
I2CWriteByte(TW101+4, 0x3f, 0x00); // add by Sherman 06'01'16
SetIPVideoType();
}
void SetOPTiming(void) ////T10x Output timing Register Adress and Value for static condition
{
uWORD ucAdrIdx,ucDataIdx;
if((m_cStandard==S_NTSC)|(m_cStandard==S_NTSC_4)|(m_cStandard==S_PAL_M)){
ucDataIdx=m_cScaleratio*P0ScaleAdrCnt;
for (ucAdrIdx=0; ucAdrIdx<P0ScaleAdrCnt; ucAdrIdx++, ucDataIdx++){
I2CWriteByte(TW101, ucaZoomAdrP0[ucAdrIdx], ucaZoomDataP0_NTSC[ucDataIdx]);
}
ucDataIdx=m_cScaleratio*P2ScaleAdrCnt;
for (ucAdrIdx=0; ucAdrIdx<P2ScaleAdrCnt; ucAdrIdx++, ucDataIdx++){
I2CWriteByte(TW101+4, ucaZoomAdrP2[ucAdrIdx], ucaZoomDataP2_NTSC[ucDataIdx]);
}
// Add by Sherman 06'01'06
#ifdef SimulateSTH
ucDataIdx=m_cScaleratio*P1ScaleAdrCnt;
for (ucAdrIdx=0; ucAdrIdx<P1ScaleAdrCnt; ucAdrIdx++, ucDataIdx++){
I2CWriteByte(TW101+2, ucaZoomAdrP1[ucAdrIdx], ucaZoomDataP1_NTSC[ucDataIdx]);
}
#endif
// end of add by Sherman
}
else{
ucDataIdx=m_cScaleratio*P0ScaleAdrCnt;
for (ucAdrIdx=0; ucAdrIdx<P0ScaleAdrCnt; ucAdrIdx++, ucDataIdx++){
I2CWriteByte(TW101, ucaZoomAdrP0[ucAdrIdx], ucaZoomDataP0_PAL[ucDataIdx]);
}
ucDataIdx=m_cScaleratio*P2ScaleAdrCnt;
for (ucAdrIdx=0; ucAdrIdx<P2ScaleAdrCnt; ucAdrIdx++, ucDataIdx++){
I2CWriteByte(TW101+4, ucaZoomAdrP2[ucAdrIdx], ucaZoomDataP2_PAL[ucDataIdx]);
}
// Add by Sherman 06'01'06
#ifdef SimulateSTH
ucDataIdx=m_cScaleratio*P1ScaleAdrCnt;
for (ucAdrIdx=0; ucAdrIdx<P1ScaleAdrCnt; ucAdrIdx++, ucDataIdx++){
I2CWriteByte(TW101+2, ucaZoomAdrP1[ucAdrIdx], ucaZoomDataP1_PAL[ucDataIdx]);
}
#endif
// end of add by Sherman
}
I2CWriteByte(TW101, 0xe2, 0x11);
}
void SetIPVideoType(void) ///设定VIDEO类型
{
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);
I2CWriteByte(TW101+4,0x39, 0x8a); //lchc+
if(uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeSVIDEO)
I2CWriteByte(TW101+4,0x03, 0x03);
else I2CWriteByte(TW101+4,0x03, 0x00);
}
#ifdef Signal_PAL
else if(m_cChroma==S_PAL){
//m_wVTotal=625;
I2CWriteByte(TW101+4,0x00, I2CReadByte(TW101+4,0x00)&0x01|0x32);
I2CWriteByte(TW101+4,0x01, I2CReadByte(TW101+4,0x01)|0x08);
I2CWriteByte(TW101+4,0x03, I2CReadByte(TW101+4,0x03)&0x01|0x02);
I2CWriteByte(TW101+4,0x39, 0x0a); //lchc+
}
#endif
#ifdef Signal_SECAM
else if(m_cChroma==S_SECAM){
//m_wVTotal=625;
I2CWriteByte(TW101+4,0x00, I2CReadByte(TW101+4,0x00)&0x01|0x28);
I2CWriteByte(TW101+4,0x03, I2CReadByte(TW101+4,0x03)&0x01|0x02);
}
#endif
#ifdef Signal_PAL_M
else if(m_cChroma==S_PAL_M){
//m_wVTotal=525;
I2CWriteByte(TW101+4,0x00, I2CReadByte(TW101+4,0x00)&0x01|0x04);
}
#endif
#ifdef Signal_PAL_CN
else if(m_cChroma==S_PAL_CN){
//m_wVTotal=625;
I2CWriteByte(TW101+4,0x00, I2CReadByte(TW101+4,0x00)&0x01|0x26);
}
#endif
#ifdef Signal_NTSC_4
else if(m_cChroma==S_NTSC_4){
//m_wVTotal=525;
I2CWriteByte(TW101+4,0x00, I2CReadByte(TW101+4,0x00)&0x01|0x00);
//I2CWriteByte(TW101+4,0x07, 0x0c);
if(uiaSrcMux[(m_cSource&0x0F)*2+1]==itypeSVIDEO)
I2CWriteByte(TW101+4,0x03, 0x03);
else I2CWriteByte(TW101+4,0x03, 0x03);
}
#endif
}
void Detect_Sig(bit detect) ///探测有无信号
{
uCHAR tmp;
tmp=I2CReadByte(TW101+4, 0x3A)&0x01;
if(tmp) // No signal
{
if((detect)||(NoSignal!=tmp)) // When switch to signal lost input or Signal lost
{ //NoSignal=0;
// OSDShowSource();
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);
}
}
else
{
if(detect) //When video switch and signal is normal
OpenPanel();
else if (NoSignal!=tmp) //Not video switch and signal recover
{
I2CWriteByte(TW101, 0xC2, I2CReadByte(TW101, 0xC2)&~(PSYNC_STR|IGNORE_VSYNC));
SourceSelect();
// OpenPanel();// 2005-07-13, bruce
I2CWriteByte(TW101, 0x9d, 0x10);
I2CWriteByte(TW101, 0x9e, 0xff);
I2CWriteByte(TW101, 0x9f, 0x40);
I2CWriteByte(TW101, PATTERN_CTRL, I2CReadByte(TW101, PATTERN_CTRL)&~0x80);
// reset comb filter // add by Sherman 06'02'06
I2CWriteByte(TW101+4, 0x3f, 0x01);
twdDelay1(100);
I2CWriteByte(TW101+4, 0x3f, 0x00);
}
}
NoSignal= tmp;
}
///#define GAMMA_TABLE_DATA_SIZE 10
void LoadGammaTable(uCHAR cGammaModeID)
{
uCHAR i;
#ifdef GAMMADAT_Default
uCHAR c;
uCHAR *p=pcGammaData[cGammaModeID];
//disable I2C Auto_Inc_Address
I2CWriteByte(TW101,TW_INTERFACE,I2CReadByte(TW101,TW_INTERFACE)&~AUTO_INC);
//I2CWriteByte(TW101,IMG_FUN_CTRL,I2CReadByte(TW101,IMG_FUN_CTRL)&GAMMA_RGB); // mark by Sherman 06'01'11
I2CWriteByte(TW101,GAMMA_ADDR,0x00);
for(i=0;i<GAMMA_TABLE_DATA_SIZE;i++) {
c=*p++;
I2CWriteByte(TW101,GAMMA_DATA,c);
}
//11.13 I2CWriteByte(TW101,GAMMA_DATA,pcGammaDataRGB[cGammaModeID][i]);
#else
uCHAR j,k;
//uCHAR code **ppcGm;
uCHAR *pcGm;
for(j=0,k=3;j<3;j++,k--)
{
pcGm=pcGammaData[j+cGammaModeID*GAMMA_PNUM];
I2CWriteByte(TW101,IMG_FUN_CTRL,(I2CReadByte(TW101,IMG_FUN_CTRL)& ~GAMMA_CTL_MSK)|(k<<6));
I2CWriteByte(TW101,GAMMA_ADDR,0x00);
for(i=0;i<33;i++)
I2CWriteByte(TW101,GAMMA_DATA,pcGm[i]);
}
#endif // GM_RGB_ALL_SAME
I2CWriteByte(TW101,TW_INTERFACE,I2CReadByte(TW101,TW_INTERFACE)|AUTO_INC);
#ifdef EnableGamma
I2CWriteByte(TW101,IMG_FUN_CTRL,I2CReadByte(TW101,IMG_FUN_CTRL)|ENGAMMA);
#else
I2CWriteByte(TW101,IMG_FUN_CTRL,I2CReadByte(TW101,IMG_FUN_CTRL)&~ENGAMMA); //Disable Gamma
#endif
return;
}
/*****************************************************************************************************************************
void PowerManage(void)
{
if(auto_power)//m_bKyPowerOn) //Power on
{
// LED_RED = 1; //Turn Off
// LED_GREEN = 0; //Turn On
I2CWriteByte(TW101, 0xE0, I2CReadByte(TW101, 0xE0)|TPDB); //TPDB=0X40;
// m_bChipPowerOn=1;
twdDelay(100);
OpenPanel();
}
else //Forced Power Off
{
//if(m_bChipPowerOn)
//{
// LED_RED =0; //Turn On
// LED_GREEN = 1; //Turn Off
twdDelay(100);
OSDExit();
//if(m_bBKPowerOn)
ClosePanel(0x00,0x40,0x8a);
twdDelay(200);
I2CWriteByte(TW101, 0xE0, I2CReadByte(TW101, 0xE0)&~TPDB|PDMD);
//m_bChipPowerOn=0;
//}
}
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -