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

📄 decoder.cpp

📁 focus FS45x windows CE driver
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    0xce, 0x20,
    0xcf, 0x01,
#else /*PAL*/
    0xca, 0x38,
    0xcb, 0x01,
    0xcc, 0xd0,
    0xcd, 0x02,
    0xce, 0x35,
    0xcf, 0x01,
#endif
    0xd0, 0x01,
    0xd1, 0x00,
    0xd2, 0x00,
    0xd4, 0x80,
    0xd5, 0x40,
    0xd6, 0x40,
    0xd8, 0x00,
    0xd9, 0x04,
    0xda, 0x00,
    0xdc, 0x00,
    0xdd, 0x02,
    0xde, 0x00,
    0xe0, 0x00,
    0xe1, 0x04,
    0xe2, 0x00,
    0xe3, 0x04,
    0xe4, 0x00,
    0xe8, 0x00,
    0xe9, 0x00,
    0xea, 0x00,
    0xeb, 0x00,
    0xec, 0x00,
    0xed, 0x00,
    0xee, 0x00,
    0xef, 0x00,
    0x88, 0xf0
};

#if	1
BYTE_ Phil7113_NTSC[P7113_Count * 2]=
{
	0x01, 0x08,
	0x02, 0xc0,
	0x03, 0x23,
	0x04, 0x00,
	0x05, 0x00,
	0x06, 0xe9,
	0x07, 0x0d,
	0x08, 0xB8,
	0x09, 0x00,	// Luminance Control
	0x0a, 0x80,	// Luminance Brightness
	0x0b, 0x47,	// Luminance Contrast
	0x0c, 0x40,	// Chroma Saturation
	0x0d, 0x00,	// Chroma Hue Control
	0x0e, 0x01,	// Chroma Control
	0x0f, 0x2a,	// Chroma Gain Control

	0x10, 0x00,
	0x11, 0x0c,
	0x12, 0x01,
	0x13, 0x00,
	0x14, 0x00,
	0x15, 0x00,
	0x16, 0x00,
	0x17, 0x00,
	0x18, 0x00,
	0x19, 0x00,
	0x1a, 0x00,
	0x1b, 0x00,
	0x1c, 0x00,
	0x1d, 0x00,
	0x1e, 0x00,
	0x1f, 0x00,

	0x20, 0x00,
	0x21, 0x00,
	0x22, 0x00,
	0x23, 0x00,
	0x24, 0x00,
	0x25, 0x00,
	0x26, 0x00,
	0x27, 0x00,
	0x28, 0x00,
	0x29, 0x00,
	0x2a, 0x00,
	0x2b, 0x00,
	0x2c, 0x00,
	0x2d, 0x00,
	0x2e, 0x00,
	0x2f, 0x00,

	0x30, 0x00,
	0x31, 0x00,
	0x32, 0x00,
	0x33, 0x00,
	0x34, 0x00,
	0x35, 0x00,
	0x36, 0x00,
	0x37, 0x00,
	0x38, 0x00,
	0x39, 0x00,
	0x3a, 0x00,
	0x3b, 0x00,
	0x3c, 0x00,
	0x3d, 0x00,
	0x3e, 0x00,
	0x3f, 0x00,

	0x40, 0x02,
	0x41, 0xff,
	0x42, 0xff,
	0x43, 0xff,
	0x44, 0xff,
	0x45, 0xff,
	0x46, 0xff,
	0x47, 0xff,
	0x48, 0xff,
	0x49, 0xff,
	0x4a, 0xff,
	0x4b, 0xff,
	0x4c, 0xff,
	0x4d, 0xff,
	0x4e, 0xff,
	0x4f, 0xff,

	0x50, 0xff,
	0x51, 0xff,
	0x52, 0xff,
	0x53, 0xff,
	0x54, 0xff,
	0x55, 0xff,
	0x56, 0xff,
	0x57, 0xff,
	0x58, 0x00,
	0x59, 0x54,
	0x5a, 0x07,
	0x5b, 0x83,
	0x5c, 0x00,
	0x5d, 0x00,
	0x5e, 0x00,
	0x5f, 0x00,

	0x60, 0x00,
	0x61, 0x00,
	0x62, 0x00
} ;
#else
/*register:value table used to initialize philips 7111 decoder*/
BYTE_ Phil7113_NTSC[P7113_Count * 2]=
{ 
#if	1
    0x01, 0x08,
    0x02, 0xc0,
    0x03, 0x23,
    0x04, 0x00,
    0x05, 0x00,
    0x06, 0xe9,
    0x07, 0x0d,
    0x08, 0xb8,
    0x09, 0x00,
    0x0a, 0x80,
    0x0b, 0x47,
    0x0c, 0x40,
    0x0d, 0x00,
    0x0e, 0x01,
    0x0f, 0x2A,
    0x10, 0x00,
    0x11, 0x0c,
    0x12, 0x01
#else
	0x01, 0x08, //01 0x08  //01 00
	0x02, 0xC2, //02 0xC0  //02 c0
	0x03, 0x33, //03 0x33  //03 04
	0x04, 0x00, //04 0x00  //04 10
	0x05, 0x00, //05 0x00  //05 74
	0x06, 0xEB, //06 0xEB  //06 EB
	0x07, 0xE0, //07 0xE0  //07 E0
	0x08, 0x98, //08 0x68  //08 D8
	0x09, 0x01, //09 0x01  //09 40
	0x0a, 0x80, //0a 0x80  //0a 80
	0x0b, 0x47, //0b 0x47  //0b 40
	0x0c, 0x40, //0c 0x40  //0c 38
	0x0d, 0x00, //0d 0x00  //0d 00
	0x0e, 0x01, //0e 0x01  //0e 00
	0x0f, 0x2A, //0f 0x2a  //0f AF
	0x10, 0x00, //10 0x00  //10 05
	0x11, 0x0C, //11 0x0c  //11 0C
	0x12, 0x01  //12 0x01  //12 0E
#endif
}; /*reg_02 to reg_12*/
#endif
     
BYTE_ Phil7113_PAL[P7113_Count * 2]=
{ 
	0x01, 0x08,
	0x02, 0xc0,
	0x03, 0x33,
	0x04, 0x00,
	0x05, 0x00,
	0x06, 0xeb,
	0x07, 0xe0,
	0x08, 0x08,
	0x09, 0x01,
	0x0a, 0x80,
	0x0b, 0x47,
	0x0c, 0x40,
	0x0d, 0x00,
	0x0e, 0x01,
	0x0f, 0x2A,
	0x10, 0x00,
	0x11, 0x0c,
#if	1
	0x12, 0x01
#endif
}; /*reg_01 to reg_12*/


//for Micronas Audio decoder
static BYTE_ MSP0[2]=
	    {0x80,0x00};

static BYTE_ MSP1[2]=
	    {0x00,0x00};

static BYTE_ MSP2[4]=
//		{0x00,0x30,0x00,0x03};	// korea
		{0x00,0x30,0x20,0x03};	// BTSC
//		{0x00,0x30,0x40,0x03};	// Japan	(老夯)

//		start Automatic Standard Detection
static BYTE_ MSP3[4]=
	    {0x00,0x20,0x00,0x20};	// BTSC-Stereo
//	    {0x00,0x20,0x00,0x03};	// B/G-DUAL-FM
//		{0x00,0x20,0x00,0x01};	// auto
//		{0x00,0x20,0x00,0x02};	// M-Dual	/ Korea
//		{0x00,0x20,0x00,0x30};	// M-EIA-J Japan Stereo	(老夯)

static BYTE_ MSP4N[4]=
	    {0x00,0x0E,0x30,0x02};	// 75KHz // Automatic Sound Select = on老 版快, 磊悼利栏肺 技泼等促. 窍瘤父 02(Korean stero/BTSC/EIA-J/FM Radio)甫 急琶
//	    {0x00,0x0E,0x24,0x03};	// 100KHz

static BYTE_ MSP5N[4][4]=
{
	    {0x00,0x08,0x00,0x20},	// Default
//		{0x00,0x08,0x04,0x20};	// Language A / B (only defined for Automatic Sound Select), Mono/Stero

	    {0x00,0x08,0x03,0x20},	// Default(A)
//		{0x00,0x08,0x04,0x20};	// Language A / B (only defined for Automatic Sound Select), Mono/Stero

	    {0x00,0x08,0x04,0x20},	// Default(B)
//		{0x00,0x08,0x04,0x20};	// Language A / B (only defined for Automatic Sound Select), Mono/Stero

	    {0x00,0x08,0x01,0x20}	// Default(A/B)
//		{0x00,0x08,0x04,0x20};	// Language A / B (only defined for Automatic Sound Select), Mono/Stero
} ;

BYTE_ MSP6N[4]=
	    {0x00,0x00,0x7C,0x00};	// 0x7F	(Maximum Volume) ;
/*
static BYTE_ MSP6N[4]=
	    {0x00,0x00,0x7C,0x00};	// 0x7F	(Maximum Volume) ;
*/
static BYTE_ MSP7N[4]=
	    {0x00,0x13,0x29,0x00};


/*
static BYTE_ MSP4P[4]=
	    {0x00,0x00,0x7F,0x00};	// Volume Loudspeaker

static BYTE_ MSP5P[4]=
	    {0x00,0x0D,0x19,0x00};	// SCART Input Prescale

static BYTE_ MSP6P[4]=
	    {0x00,0x13,0x29,0x00};	// MONO

static BYTE_ MSP7P[4]=
	    {0x00,0x08,0x02,0x30};
*/

// added by esok
// in 2003.03.21
static BYTE_ ESOKP3[4]=
	    {0x00,0x30,0x20,0x03};	// Automatic Sound Select
static BYTE_ ESOKP4[4]=
	    {0x00,0x20,0x00,0x01};	// Automatic Sound Detecting
static BYTE_ ESOKP5[4]=
	    {0x00,0x08,0x03,0x20};	// Language A / Stero
static BYTE_ ESOKP6[4]=
	    {0x00,0x0E,0x24,0x03};	// 100kHz FM / Automatic
		//{0x00,0x0E,0x7C,0x03};	// 100kHz FM / Automatic
static BYTE_ ESOKP7[3][4] =
{
		{0x00,0x20,0x00,0x03},	// BGH
		{0x00,0x20,0x00,0x04},	// DK
		{0x00,0x20,0x00,0x0A}	// I
} ;
	    //{0x00,0x20,0x00,0x03};	// B/G-Dual FM-Stero
		//{0x00,0x20,0x00,0x08};	// B/G-NICAM-FM			// in Automatic Sound Select Mode, 0x3 and 0x8 are equivalent.
		//{0x00,0x20,0x00,0x04};	// D/K1-Dual FM-Stero
		//{0x00,0x20,0x00,0x05};	// D/K2-Dual FM-Stero
		//{0x00,0x20,0x00,0x07};	// D/K3-Dual FM-Stero
		//{0x00,0x20,0x00,0x0B};	// D/K-NICAM-FM			// in Automatic Sound Select Mode, 0x4, 0x5, 0x7 and 0xB are equivalent.
		//{0x00,0x20,0x00,0x0A};	// I-NICAM-FM
		//{0x00,0x20,0x00,0x09};	// L-NICAM-AM
BYTE_ ESOKP8[4]=
	    {0x00,0x00,0x7C,0x00};	// 0x7F	(Maximum Volume) ;

int g_nWhichDecoder = Philips7113 ;

///////////////////////////////////////////////////////////////////////////////
BOOL IniDecod(int nWhichDecoder, int nVideoSys, int nTuner, int nVBI)
{
	// by eykim
	return TRUE;


    BYTE_ bSubAddr = 0x02;
    int nCounter;

    InitI2C(); /*Initialize I2C first*/
	//InitMSP34_0G() ;
	g_nWhichDecoder = nWhichDecoder ;

    if(DetectI2C(I2CPort[nWhichDecoder]) == 0) /*detect whether or not there 
                                               is such a I2C device*/
    {
        //printf("Can not detect this I2C device with I2C addr=%x\n", 
        //    I2CPort[nWhichDecoder]);
		//printf("DetectI2C FAILED\n") ;
		//RETAILMSG(1, (_T("DetectI2C FAILED\r\n"))) ;
        return FALSE;
    }

    return TRUE;
} /*end of main()*/

BOOL DeDecod7114(int nWhichDecoder)
{
    BYTE_ bSubAddr = 0x02;
//    int nCounter;

    InitI2C(); /*Initialize I2C first*/

    if(DetectI2C(I2CPort[nWhichDecoder]) == 0) /*detect whether or not there 
                                               is such a I2C device*/
    {
        //printf("Can not detect this I2C device with I2C addr=%x\n", 
        //    I2CPort[nWhichDecoder]);
        return FALSE;
    }

    if (SendOneByte(I2CPort[nWhichDecoder], 0x83, 0x00) && 
        SendOneByte(I2CPort[nWhichDecoder], 0x87, 0x00))
        return TRUE;

    return FALSE;
} /*end of main()*/

void sleep(int ntime)
{
/*
	This assembly code was original code which met the delay requirment
	and had been tested on variety of Intel/AMD/Cyrix mother boards.
*/

#if 0
	int i;
	for (i=0; i<ntime; i++)
	{
		_asm {
			nop
			nop
			nop
			nop
			nop
			nop
			nop
			nop
			nop
			nop
			nop
			nop
			nop
			nop
			nop
		}
	}
#else
	int i, iTmp1, iTmp2=0;
	for (i=0; i<ntime; i++)
	{
		iTmp1 = i;
		iTmp2 += iTmp1;
	}
#endif
}

//const BYTE cTunerAddr = 0xC0 ;
BYTE cTunerAddr = 0xC0 ;

/*
VOID TunerAddrSet(BYTE addr)
{
	cTunerAddr = addr ;
}
*/
BOOL SetFrequency_512(DWORD dwTrueFrequency) //ian
{
/*
	const DWORD c_dwLowest=55250*1000;//55.25MHz
	const DWORD c_dwBetweenVHFs=174000*1000;//160MHz
	const DWORD c_dwBetweenVHFUHF=454000*1000;//454MHz
	//const DWORD c_dwHighest=801250*1000*1000;//801.25GHz
	const DWORD c_dwHighest=801250*1000;//801.25MHz
	//const WORD c_wPictureCarrierDivider=45750*1000/62500;//45750*1000;//45.75MHz;//Default
	const WORD c_wPictureCarrierDivider=38900*1000/62500;//45750*1000;//45.75MHz;	= 622.4
*/

	if ((dwTrueFrequency<g_dwLowest) || (dwTrueFrequency>g_dwHighest))
	{
		//RETAILMSG(1,(TEXT("return false because dwTrueFrequency=%x < %x or >%x\r\n"),dwTrueFrequency,c_dwLowest,c_dwHighest));
		return FALSE;
	}

	WORD wScalingFactor=(WORD)((dwTrueFrequency/62500)+g_dwPictureCarrierDivider);
	WORD wControl;

#ifdef USE_OLD_TUNER
	if(dwTrueFrequency < g_dwBetweenVHFs)
		wControl = 0x8EA0;//8E means select RSA=1, RSB=1,that is :use ReferenceDivider=512
	else if(dwTrueFrequency < g_dwBetweenVHFUHF)
		wControl = 0x8E90;
	else
		wControl = 0x8E30;
#else
	if(dwTrueFrequency < g_dwBetweenVHFs)
		wControl = 0xCE01;	// CP = 1 : fastest tuning, T2 = T1 = 0, T0 = 1, RSA = RSB = 1, 
	else if(dwTrueFrequency < g_dwBetweenVHFUHF)
		wControl = 0xCE02;
	else
		wControl = 0xCE04;
#endif


	if (Tvia_GetTVMode() == PAL)
		wControl += 0x9 ;

	BYTE cTmpTunerAddr = cTunerAddr ;

	if (0)
	{
		CHAR szCP[10] ;
		BOOL bCP = FALSE ;
		if (DBFGetRecord("TVCP", szCP) != DBF_FAIL)
			bCP = atoi(szCP) ;
		if (bCP) wControl += 0x4000 ;

		int nMA = 0 ;
		CHAR szMA[10] ;
		if (DBFGetRecord("TVMA", szMA) != DBF_FAIL)
			nMA = atoi(szMA) ;
		nMA &= 0x6 ;
		cTmpTunerAddr += nMA ;
	}

	//RETAILMSG(1,(TEXT("WriteTVTunerT2C,cTunerAddr=%x,wScalingFactor=%x,wControl=%x\r\n"),cTunerAddr,wScalingFactor,wControl)); //Ian Enable
	if (WriteTVTunerI2C(cTmpTunerAddr, wScalingFactor, wControl) == 0)
	{
		return FALSE ;
	}
//	sleep(0x1000000);
	if (Tvia_GetTVMode() == PAL)
		SendMoreByte(0x80, 0x12, ESOKP8, 4) ;
	else
		SendMoreByte(0x80, 0x12, MSP6N, 4) ;


}//SetFrequency_512

BOOL TVGoodChannel()
{
	return bIsGoodChn(cTunerAddr) ;
}

DWORD SearchChannelByStep(DWORD dwRFFreq,DWORD dwStep)
{
	//because each step means 62.5KHz
	//then the biggest step value is 4MHz/62.5KHz-1=64
	//we recommended the dwStep value=10,then the width is 10*2*62.5KHz=1.25MHz
	if (dwStep>64)
		return 0;//Failed
	if (dwRFFreq<g_dwLowest)
		return 0;//make sure dwRFFreq-62.5KHz*dwStep>0
	else if (dwRFFreq>801250*1000)//impossible bigger than 1GHz
		return 0;

	//printf("SearchChannelBySteop\n") ;	
	if (SetFrequency_512(dwRFFreq))
	{
//		RETAILMSG(1, (_T("SearchChannelBySteop 0\r\n"))) ;
		return dwRFFreq;
	}
	else
		return -1; // Error

	for(unsigned long i=1; i<=dwStep; i++)//use 10 to substitute the original value 32, can get rid of "noise channel", that means, increase the "GoodChannel" accuracy.
	{
		if (SetFrequency_512(dwRFFreq+i*62500))
		{
			RETAILMSG(1, (_T("SearchChannelBySteop +%d\r\n"), i)) ;
			return dwRFFreq+i*62500;
		}
		if (SetFrequency_512(dwRFFreq-i*62500))
		{
			RETAILMSG(1, (_T("SearchChannelBySteop -%d\r\n"), i)) ;
			return dwRFFreq-i*62500;
		}
	}
	return 0;
}

// 父距 NTSC牢 版快 Tvia_GetTVMode()甫 捞侩窍咯 备盒
// nMode绰 窜瘤 PAL葛靛老 版快俊父 吝夸窃
BOOL InitMSP34_0G(int nMode, int nLanguage)
{
	// Reset
	if (SendMoreByte(0x80, 0x00, MSP0, 2) == FALSE)
		return FALSE ;

	if (SendMoreByte(0x80, 0x00, MSP1, 2) == FALSE)
		return FALSE ;
	if (Tvia_GetTVMode() == PAL)
	{
		if (SendMoreByte(0x80, 0x10, ESOKP3, 4) == FALSE)
			return FALSE ;

		if (SendMoreByte(0x80, 0x10, ESOKP4, 4) == FALSE)
			return FALSE;

		if (SendMoreByte(0x80,0x12,ESOKP5,4) == FALSE)
			return FALSE;

		if (SendMoreByte(0x80,0x12,ESOKP6,4) == FALSE)
			return FALSE;

		if (SendMoreByte(0x80,0x10,ESOKP7[nMode],4) == FALSE)
			return FALSE;

		if (SendMoreByte(0x80,0x12,ESOKP8,4) == FALSE)
			return FALSE;

		return TRUE ;
	}
	else
	{
		if (SendMoreByte(0x80, 0x10, MSP2, 4) == FALSE)
			return FALSE ;
		if (SendMoreByte(0x80, 0x10, MSP3, 4) == FALSE)
			return FALSE ;
		if (SendMoreByte(0x80, 0x12, MSP4N, 4) == FALSE)
			return FALSE ;
		if (SendMoreByte(0x80, 0x12, MSP5N[nLanguage], 4) == FALSE)
			return FALSE ;
		if (SendMoreByte(0x80, 0x12, MSP6N, 4) == FALSE)
			return FALSE ;
//		RETAILMSG(1, (_T("MSP5N[%d]\r\n"), nLanguage)) ;
	}

// SCART mono input
//    if (sendMoreByte(0x80,0x12,MSP7,4) == FALSE)
//	return FALSE;

	return TRUE;
}

BOOL DeInitMSP34_0G(void)
{
	// Reset
	if (SendMoreByte(0x80, 0x00, MSP0, 2) == FALSE)
		return FALSE ;

	if (SendMoreByte(0x80, 0x00, MSP1, 2) == FALSE)
		return FALSE ;
	return TRUE ;
}

VOID WriteVideoCodec(BYTE_ subaddr, BYTE_ val)
{
	SendOneByte(I2CPort[g_nWhichDecoder], subaddr, val) ;
}

BYTE_ ReadVideCodec(BYTE_ subaddr)
{
	BYTE_ bByte ;
	ReadOneByte(I2CPort[g_nWhichDecoder], subaddr, &bByte) ;
	return bByte ;
}

VOID SetValue(BYTE_ subaddr, BYTE_ val)
{
	SendOneByte(I2CPort[g_nWhichDecoder], subaddr, val) ;
}
#undef	SendMoreByte

⌨️ 快捷键说明

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