📄 saa7115.c
字号:
{0x30, 0x00},//7115 PAL table
{0x31, 0xb9},//7115 PAL table
{0x5a, 0x03},//7115 PAL table
{0x66, 0xa0},//7115 PAL table
{0x67, 0xff},//7115 PAL table
{0x68, 0xff},//7115 PAL table
{0x6b, 0xa0},//7115 PAL table
{0x72, 0xa1},//7115 PAL table
{0x77, 0xa1},//7115 PAL table
{0x84, 0xa0},//7115 PAL table
{0x85, 0x10},//7115 PAL table
{0x98, 0x01},//7115 PAL table
{0x9a, 0x38},//7115 PAL table
{0x9b, 0x01},//7115 PAL table
{0x9e, 0x38},//7115 PAL table
//{0xA4, 0x80},//7115 PAL table//88
//{0xb4, 0x40},//7115 PAL table//00
{0x0e, 0x03},//7115 PAL table//for the PAL wangh zhuang gan rao
{0x0e, 0x83},//7115 PAL table
{0xff, 0xff}
};
#define _SAA7115_HLCK_ (0x01<<0x06)
BOOL bSaa7115SignalDetect(void) //always return TRUE
{
WORD wSignal;
BOOL bSignal;//bVLock,bHLock,bNoSignal;
BYTE ucLock, ucT, ucT1;
BYTE ucCount,ucLoop;
ucCount = 0;
for(ucLoop = 0; ucLoop < 5; ucLoop ++)
{
if(!(dev_saa7115Read(0x1E) & _SAA7115_HLCK_))
ucCount++;
if((ucCount >= 3))// &&(dev_saa7115Read(SAA7115_DEC_STAT_ADDR) & SAA7115_VID_MODE_STAT_MASK))
{
return _TRUE_;
}
}
return _FALSE_;
}
BOOL bSaa7115SignalDetectFine(void)
{
WORD wSignal;
BOOL bSignal;//bVLock,bHLock,bNoSignal;
BYTE ucLock, ucT1;
BYTE ucCount,ucLoop;
ucCount = 0;
for(ucLoop = 0; ucLoop < 10; ucLoop ++)
{
SleepDelay(1);
if((!(dev_saa7115Read(0x1E) & _SAA7115_HLCK_)))// && (!(dev_saa7115Read(0x1F) & 0x02)))
ucCount++;
if( (ucCount >= 7) )// && (dev_saa7115Read(SAA7115_DEC_STAT_ADDR) & SAA7115_VID_MODE_STAT_MASK))
{
return _TRUE_;
}
}
return _FALSE_;
}
void dev_saa7115ConfigVideoMode(BYTE B_VideoMode)
{
/* if (B_Mode == VDD_MODE_PAL_M)
{
B_PalItuMode = 0x81;
B_Mode = VDD_MODE_PAL;
}
*/
BYTE uc;
switch (B_VideoMode)
{
case VDD_MODE_INIT:
Dlp_Saa7115WriteParameter((LPCBYTE)Saa7115INTTable,sizeof(REGVALUESTRUCT), 0x00);
break;
case TV_SYSTEM_SIGNAL_NTSC:
dev_saa7115Write(0x09, (dev_saa7115Read(0x9) & 0x80) | 0x57);
Dlp_Saa7115WriteParameter((LPCBYTE)Saa7115NTSCTable,sizeof(REGVALUESTRUCT), 0x00);
break;
#ifdef _USA_DLP_FUNC_
case TV_SYSTEM_SIGNAL_SECAM:
case TV_SYSTEM_SIGNAL_PAL60:
#endif
case TV_SYSTEM_SIGNAL_PAL:
// Set Luma filter setting for PAL
// without overwriting the filter
// bypass bit for S-Video or
// Component input.
uc = 0x00;
dev_saa7115Write(0x09, (dev_saa7115Read(0x9) & 0x80) | 0x57);
Dlp_Saa7115WriteParameter((LPCBYTE)Saa7115PALTable,sizeof(REGVALUESTRUCT), 0x00);
SleepDelay(200);
dev_saa7115Write(0x0e, 0x03);
SleepDelay(200);
dev_saa7115Write(0x0e, 0x83);
break;
#ifndef _USA_DLP_FUNC_
case TV_SYSTEM_SIGNAL_SECAM:
// Set luma filter settings based
// upon s-video or composite input.
// Values are from Philips data sheet.
// Also, preserve the bypass setting (bit 7).
if (dev_saa7115Read(0x09) & 0x80)
{
// S-Video -- bypass on.
dev_saa7115Write(0x09, 0x90);
}
else
{
// Component -- bypass off.
dev_saa7115Write(0x09, 0x1b);
}
dev_saa7115Write(0x0e, 0xd2); // Philips suggests 0xd4
// 0xd6 in our case
dev_saa7115Write(0x10, 0x00);
dev_saa7115Write(0x13, 0x80);
//dev_saa7115Write(0x0a, 0x80);
break;
#endif
default:
dev_saa7115Write(0x09, (dev_saa7115Read(0x9) & 0x80) | 0x57);
Dlp_Saa7115WriteParameter((LPCBYTE)Saa7115PALTable,sizeof(REGVALUESTRUCT), 0x00);
// SleepDelay(200);
// Dlp_Saa7115WriteParameter((LPCBYTE)Saa7115PALTable,sizeof(REGVALUESTRUCT), 0x00);
break;
} // end switch - mode
}
BYTE dev_Saa7115SignalExchange(BYTE ucColorMode, BYTE ucClock)
{
BYTE ucSignal;
switch (ucColorMode)
{
case 0x01:
ucSignal = TV_SYSTEM_SIGNAL_NTSC;
break;
case 0x02:
if(ucClock != 0x20) //the BIT for Vclock
{
ucSignal = TV_SYSTEM_SIGNAL_PAL;
}
else
{
ucSignal = TV_SYSTEM_SIGNAL_PAL60;
}
break;
case 0x03:
ucSignal = TV_SYSTEM_SIGNAL_PAL;
break;
default:
if(bSaa7115SignalDetect())
{
if(ucClock != 0x20)
{
ucSignal = TV_SYSTEM_SIGNAL_PAL;//TV_SYSTEM_SIGNAL_NOSIGNAL;//no color?
}
else
{
ucSignal = TV_SYSTEM_SIGNAL_NTSC;
}
}
else
{
ucSignal = TV_SYSTEM_SIGNAL_NOSIGNAL;//TV_SYSTEM_SIGNAL_NOSIGNAL;//no color?
}
break;
}
return ucSignal;
}
//******************************************************************************
//
// FUNCTION : BYTE dev_saa7115GetVideoMode(BYTE VidDecId)
// USAGE : This function returns the current input video mode
// INPUT : video decoder id
// OUTPUT : returns the mode - NO_VIDEO, NTSC, PAL, SECAM
// GLOBALS : None
// USED_REGS :
//******************************************************************************
BYTE dev_saa7115GetVideoMode(void)
{
BYTE B_Status, B_ClockStatus, uc;
BYTE ucPALCount,ucNTSCCount,ucSECAMCount,ucNOColor,ucPAL60Count;
ucPALCount = ucNTSCCount = ucSECAMCount = ucPAL60Count = ucNOColor = 0x00;
// SleepDelay(600);
B_Status = dev_saa7115Read(SAA7115_DEC_STAT_ADDR) & SAA7115_VID_MODE_STAT_MASK; //get the color status
B_ClockStatus = dev_saa7115Read(SAA7115_DEC_STAT_ADDR2) & SAA7115_VID_MODE_CLOCK_MASK; //get the Vsync frequence
// if(dev_Saa7115SignalExchange(B_Status, B_ClockStatus) == PIPStatus.ucSignalMode)
// {
// return;
// }
for(uc = 0x00; uc < SAA7115_ADJUSTSIGNAL_TOTALTIME; uc++)
{
SleepDelay(10);//test the 7115 detect the color mode
B_Status = dev_saa7115Read(SAA7115_DEC_STAT_ADDR) & SAA7115_VID_MODE_STAT_MASK; //get the color status
B_ClockStatus = dev_saa7115Read(SAA7115_DEC_STAT_ADDR2) & SAA7115_VID_MODE_CLOCK_MASK; //get the Vsync frequence
switch (B_Status)
{
case 0x01:
ucNTSCCount++;
ucPALCount = 0;
ucSECAMCount = 0;
ucPAL60Count = 0;
if(ucNTSCCount > SAA7115_ADJUSTSIGNAL_TIME)
{
gmv_VideoDecoder[VIDEO_DECODER_1].Mode = TV_SYSTEM_SIGNAL_NTSC;
#if 0//xuli test
tdGotoXY(6, 4);
tdSetColor(_VBIATTR_YELLOW_);
tdPrintf("%02x", gmv_VideoDecoder[VIDEO_DECODER_1].Mode);
#endif
return (gmv_VideoDecoder[VIDEO_DECODER_1].Mode);
}
break;
case 0x02:
if(B_ClockStatus != 0x20) //the BIT for Vclock
{
ucPALCount++;
ucPAL60Count = 0;
ucNTSCCount = 0;
ucSECAMCount = 0;
}
else
{
ucPAL60Count++;
ucNTSCCount = 0;
ucSECAMCount = 0;
ucPALCount = 0;
}
if(ucPALCount > SAA7115_ADJUSTSIGNAL_TIME)
{
gmv_VideoDecoder[VIDEO_DECODER_1].Mode = TV_SYSTEM_SIGNAL_PAL;
#if 0//test xuli
tdGotoXY(6, 4);
tdSetColor(_VBIATTR_YELLOW_);
tdPrintf("%02x", gmv_VideoDecoder[VIDEO_DECODER_1].Mode);
#endif
return (gmv_VideoDecoder[VIDEO_DECODER_1].Mode);
}
else if(ucPAL60Count > SAA7115_ADJUSTSIGNAL_TIME)
{
gmv_VideoDecoder[VIDEO_DECODER_1].Mode = TV_SYSTEM_SIGNAL_PAL60;
#if 0//test xuli
tdGotoXY(6, 4);
tdSetColor(_VBIATTR_YELLOW_);
tdPrintf("%02x", gmv_VideoDecoder[VIDEO_DECODER_1].Mode);
#endif
return (gmv_VideoDecoder[VIDEO_DECODER_1].Mode);
}
break;
case 0x03:
ucSECAMCount++;
ucPALCount = 0;
ucNTSCCount = 0;
ucPAL60Count = 0;
if(ucSECAMCount > SAA7115_ADJUSTSIGNAL_TIME)
{
gmv_VideoDecoder[VIDEO_DECODER_1].Mode = TV_SYSTEM_SIGNAL_PAL;//TV_SYSTEM_SIGNAL_SECAM;
#if 0//test xuli
tdGotoXY(6, 4);
tdSetColor(_VBIATTR_YELLOW_);
tdPrintf("%02x", gmv_VideoDecoder[VIDEO_DECODER_1].Mode);
#endif
return (gmv_VideoDecoder[VIDEO_DECODER_1].Mode);
}
break;
default:
ucNOColor++;
if(ucNOColor > SAA7115_ADJUSTSIGNALISNOCOLOR_TIME)
{
if(bSaa7115SignalDetect())
{
if(B_ClockStatus != 0x20)
{
gmv_VideoDecoder[VIDEO_DECODER_1].Mode = TV_SYSTEM_SIGNAL_PAL;//TV_SYSTEM_SIGNAL_NOSIGNAL;//no color?
}
else
{
gmv_VideoDecoder[VIDEO_DECODER_1].Mode = TV_SYSTEM_SIGNAL_NTSC;
}
}
else
{
gmv_VideoDecoder[VIDEO_DECODER_1].Mode = TV_SYSTEM_SIGNAL_NOSIGNAL;//TV_SYSTEM_SIGNAL_NOSIGNAL;//no color?
}
#if 0//test xuli
tdGotoXY(6, 4);
tdSetColor(_VBIATTR_RED_);
tdPrintf("%02x", gmv_VideoDecoder[VIDEO_DECODER_1].Mode);
#endif
return (gmv_VideoDecoder[VIDEO_DECODER_1].Mode);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -