csaa7114.c

来自「这是一个SIGMA方案的PMP播放器的UCLINUX程序,可播放DVD,VCD,」· C语言 代码 · 共 806 行 · 第 1/2 页

C
806
字号
/********************************************************************************************//*  Csaa7114.c : Implementation of video decoder interface*  REALmagic Quasar Hardware Library*  Created by Aurelia Popa-Radu*  Copyright Sigma Designs Inc*  Sigma Designs Proprietary and confidential*  Created on 2/5/01*  Description:/********************************************************************************************//****h* HwLib/IVideoDecoder_implementation * NAME *	IVideoDecoder_implementation * DESCRIPTION *  Csaa7114 implementation of the IVideoDecoder interface. * COPYRIGHT *  Copyright Sigma Designs Inc *  Sigma Designs Proprietary and confidential/********************************************************************************************/#include "pch.h"#if defined SAA7114_OBJECT#include "ci2c.h"#include "csaa7114.h"BYTE SAA7114_REG[]={#ifdef SONY_HAC_PFGP/* * Change Input Source(S or CVBS) *--------------------------------------------- * INPUT|SUB ADDRESS  |	 DATA *------+-------------+---------------- * S	|	0x02 |	 0xc9(mode9) * 	|	0x09 |	 0x80 *------+-------------+---------------- *CVBS	|	0x02 |	 0xc0 *	|	0x09 |	 0x40 *------+----------------+----------------*/#endif#ifndef SAA7118	0x01,      0x08,#else /* SAA7118 */	0x01,      0x47,    // WPOFF=1 , IDEL = 7 (recommended)#endif /* SAA7118 */	0x02,      0xc0,	// mode composite	0x03,      0x10,    // CPOFF=1	0x04,      0x90,	0x05,      0x90,	0x06,      0xd0,	//* 0xeb	0x07,      0xf6,	//* 0xe0	0x08,      0x98,	0x09,      0x40,	0x0a,      0x80,	0x0b,      0x44,	0x0c,      0x40,	0x0d,      0x00,	0x0e,      0x89,	// 0x89 for Ntsc 0x91 for Pal	0x0f,      0x2a,	0x10,      0x0e,	// 0x0e for Ntsc 0x06 for Pal	0x11,      0x10,	//* 0x00 (0x58 invert polarity for HSync VSync ?)	0x12,      0xC9,	//* 0x00 (0xC9 for 601, 0x00 for 656 ?)	0x13,      0x40,	// 0x40 for NTSC(ITU656) and 0x41 for PAL(ITU656 modified)	0x14,      0x00,	0x15,      0x11,	// VGATE start - used only if reg0x13[2:0]=1=ITU656 modified	0x16,      0x36,	// VGATE stop - used only if reg0x13[2:0]=1=ITU656 modified	0x17,      0x02,	// enable LLC, LLC2 outputs; last2 bits used only if reg0x13[2:0]=1=ITU656 modified	0x18,      0x40,	0x19,      0x80,	0x1a,      0x00,#ifdef SONY_HAC_PFGP	// set passthrough for saa7115 (and SA:0x13=>0x40)// Updated 2002-11-29 by k.hirose 	0x1b,	   0x10,#else	0x1b,	   0x00,#endif	0x1c,      0x00,	0x1d,      0x00,	0x1e,      0x00,#ifdef SAA7118 	//component control - as per saa7118 spec section 16.2	0x23,      0x00,	0x24,      0x90,	0x25,      0x90,	0x26,      0x00,	0x27,      0x00,	0x28,      0x00,	0x29,      0x00,	0x2A,      0x80,	0x2B,      0x40,	0x2C,      0x47,	0x2D,      0x00,	0x2E,      0x00,	0x2F,      0x00,#endif	#ifdef SONY_HAC_PFGP // // audio programming 44.1k for NTSC 59.94Hz when crystal=32.11MHz// Updated 2002-11-29 by k.hirose 	0x30,	   0xde,	0x31,	   0x6f,	0x32,	   0x01,	0x34,	   0x66,	0x35,	   0x66,	0x36,	   0x1d,	0x38,	   0x00,	0x39,	   0x00,	0x3a,	   0x80,#else	// audio programming 44.1k for NTSC 59.94Hz when crystal=32.11MHz	0x30,      0xbc,	0x31,      0xdf,	0x32,      0x02,	0x34,      0xf2,	0x35,      0x00,	0x36,      0x2d,	0x38,      0x01,	0x39,      0x20,	0x3a,      0x00,#endif	// VBI data slicer	0x40,      0x00,	0x41,      0xff,	0x42,      0xff,	0x43,      0xff,	0x44,      0xff,	0x45,      0xff,	0x46,      0xff,	0x47,      0xff,	0x48,      0xff,	0x49,      0x77,	0x4a,      0x77,	0x4b,      0x77,	0x4c,      0x77,	0x4d,      0x77,	0x4e,      0x77,	0x4f,      0x77,	0x50,      0x77,	0x51,      0x77,	0x52,      0x77,	0x53,      0x77,	0x54,      0x77,	0x55,      0xff,	0x56,      0xff,	0x57,      0xff,	0x58,      0x00,	0x59,      0x47,	0x5a,      0x06,	0x5b,      0x03,	0x5c,      0x00,	0x5d,      0x00,	0x5e,      0x00,	0x5f,      0x00,	0x63,      0x00,	0x64,      0x00,	0x65,      0x00,	0x66,      0x00,	0x67,      0x00,	0x68,      0x00,	// register interface and scaler part	0x80,      0x00,		// initial 0x10; ?? possible values 0x00, 0x01, 0x10,0x21	0x83,      0x01,		// Xport enable	0x88,      0xf0			// power};BYTE SAA7114_Ntsc_48k[] = {#ifdef SONY_HAC_PFGP	// SAA7114_Ntsc_48k// Updated 2002-11-29 by k.hirose 	0x30,	   0x66, 	0x31,	   0x90,	0x32,	   0x01,	0x34,	   0x00,	0x35,	   0x00,	0x36,	   0x20,#else	// audio programming 48k for NTSC 59.94Hz when crystal=32.11MHz	0x30,      0xcd,	0x31,      0x20,	0x32,      0x03,	0x34,      0xce,	0x35,      0xfb,	0x36,      0x30#endif};BYTE SAA7114_Ntsc_44k[] = {#ifdef SONY_HAC_PFGP	// SAA7114_Ntsc_44k// Updated 2002-11-29 by k.hirose 	0x30,	   0xde, 	0x31,	   0x6f,	0x32,	   0x01,	0x34,	   0x66,	0x35,	   0x66,	0x36,	   0x1d,#else	// audio programming 44.1k for NTSC 59.94Hz when crystal=32.11MHz	0x30,      0xbc,	0x31,      0xdf,	0x32,      0x02,	0x34,      0xf2,	0x35,      0x00,	0x36,      0x2d#endif};BYTE SAA7114_Ntsc_32k[] = {	// audio programming 32k for NTSC 59.94Hz when crystal=32.11MHz	0x30,      0xde,	0x31,      0x15,	0x32,      0x02,	0x34,      0xdf,	0x35,      0xa7,	0x36,      0x20};BYTE SAA7114_Pal_48k[] = {	// audio programming 48k for PAL 50Hz when crystal=32.11MHz	0x30,      0x00,	0x31,      0xc0,	0x32,      0x03,	0x34,      0xce,	0x35,      0xfb,	0x36,      0x30};BYTE SAA7114_Pal_44k[] = {	// audio programming 44.1k for PAL 50Hz when crystal=32.11MHz	0x30,      0x00,	0x31,      0x72,	0x32,      0x03,	0x34,      0xf2,	0x35,      0x00,	0x36,      0x2d};BYTE SAA7114_Pal_32k[] = {	// audio programming 32k for PAL 50Hz when crystal=32.11MHz	0x30,      0x00,	0x31,      0x80,	0x32,      0x02,	0x34,      0xdf,	0x35,      0xa7,	0x36,      0x20};////////////////////////////////////////////////////////////////////////////****f* HwLib/Csaa7114__CreateInstance * USAGE *	NOT PRESENT in IVideoDecoder interface *	void Csaa7114__CreateInstance(void **pv, DWORD dwInstance) * DESCRIPTION *	Csaa7114__CreateInstance allocates memory for VideoDecoder object, specific in *	this code Philips7114H * PARAMETERS *	IN DWORD dwInstance - instance passed down by CreateInstance. *	OUT void** pv - Points to a 32-bit variable that receives the pointer to object *SEE ALSO *	Csaa7114__CreateInstance/********************************************************************************************/void Csaa7114__CreateInstance(void **pv, DWORD dwInstance){	Csaa7114__New((Csaa7114**)pv, TEXT("Ph7114"), TRUE, dwInstance);}/****f* HwLib/Csaa7114__New * USAGE *	NOT PRESENT in IVideoDecoder interface *	void Csaa7114__New(Csaa7114** ppCsaa7114, TCHAR *pName, BOOL bAllocate, DWORD dwInstance) * DESCRIPTION *	Csaa7114__New - allocates memory for a new VideoDecoder object and plays the role of *	the constructor in C++. * PARAMETERS *	OUT Csaa7114** ppCsaa7114 - Points to a 32-bit variable that receives the pointer to object *	IN TCHAR *pName - pointer to string containing the name of the object - debug purposes. *	BOOL bAllocate - usually called with TRUE to allocate memory for object. *		- if FALSE ppCsaa7114 should point to an object already created. *	IN DWORD dwInstance - instance passed down by CreateInstance. * SEE ALSO *	IVideoDecoder_Delete/********************************************************************************************/void Csaa7114__New ( Csaa7114** ppCsaa7114, TCHAR *pName, BOOL bAllocate, DWORD dwInstance){	Csaa7114* this = *ppCsaa7114;	if (bAllocate)	{		// Allocate Csaa7114		*ppCsaa7114 = OSmalloc(sizeof(Csaa7114));		this = (Csaa7114*) *ppCsaa7114;		if(this == NULL)			return;		OSmemset(this, 0, sizeof(Csaa7114));	}	// Call CObject constructor with bAllocate = FALSE	CObject__New ((CObject**)ppCsaa7114, pName, FALSE, dwInstance);	// Call CI2C constructor	CI2C__New ( (CI2C**)(&this->m_pII2C), pName, TRUE, dwInstance );	if(this->m_pII2C == NULL)	{		if (bAllocate)			OSfree(*ppCsaa7114);		*ppCsaa7114 = NULL;		return;	}	// Initialize virtual table	this->VTable.Delete					= Csaa7114__Delete;	this->VTable.Init					= Csaa7114__Init;	this->VTable.Write					= Csaa7114__Write;	this->VTable.Read					= Csaa7114__Read;	this->VTable.InitPropertySet		= Csaa7114__InitPropertySet;	this->VTable.SetProperty			= Csaa7114__SetProperty;	this->VTable.GetProperty			= Csaa7114__GetProperty;	this->VTable.Test					= Csaa7114__Test;	this->lpVtbl = &this->VTable;}/****f* HwLib/IVideoDecoder_Delete * USAGE *	IVideoDecoder_Delete(IVideoDecoder* pIVideoDecoder, BOOL bDeleteObject) *	Csaa7114__Delete(IVideoDecoder* pIVideoDecoder, BOOL bDeleteObject) * DESCRIPTION *	IVideoDecoder_Delete - frees memory for the specified VideoDecoder object. *	IVideoDecoder_Delete plays the role of the destructor in C++. * PARAMETERS *	IN IVideoDecoder* pIVideoDecoder - pointer to the object created by a previous *		call to Csaa7114__CreateInstance or Csaa7114__New. *	BOOL bDeleteObject - usually called with TRUE to free memory for object. *		- if FALSE doesn't free any memory. * SEE ALSO *   Csaa7114__CreateInstance, Csaa7114__New/********************************************************************************************/void Csaa7114__Delete ( IVideoDecoder* pIVideoDecoder, BOOL bDeleteObject ){	Csaa7114* this = (Csaa7114*) pIVideoDecoder ;	if (this == NULL)		return;	// Release what we were using	// Call CI2C Destructor	II2C_Delete ( this->m_pII2C, bDeleteObject );	// Call CObject Destructor	CObject__Delete ((IObject*)this, FALSE);	if (bDeleteObject)	{		// Delete Csaa7114		OSfree(pIVideoDecoder);	}}/****f* HwLib/IVideoDecoder_Init * USAGE *	void IVideoDecoder_Init(IVideoDecoder* pIVideoDecoder) *	void Csaa7114__Init(IVideoDecoder* pIVideoDecoder) * DESCRIPTION *	IVideoDecoder_Init - initialize the VideoDecoder object *	It is called by CreateInstance. * PARAMETERS *	IN IVideoDecoder* pIVideoDecoder - pointer to the VideoDecoder object/********************************************************************************************/void Csaa7114__Init ( IVideoDecoder* pIVideoDecoder ){	Csaa7114* this = (Csaa7114*) pIVideoDecoder;	int i = 0;	BYTE ver;	// delay for ?	II2C_SetI2CAddress( this->m_pII2C, SAA7114_WRITE_ADDR,  SAA7114_READ_ADDR, 6);	II2C_Init( this->m_pII2C );	// read Chip Version	II2C_Read(this->m_pII2C, 0, &ver, 1);	QDbgLog((QLOG_TRACE, QDebugLevelWarning, TEXT("Csaa7114/8: ver=%02x"), ver));		for( i=0; i< sizeof(SAA7114_REG); i+=2)		II2C_Write(this->m_pII2C, SAA7114_REG[i], &SAA7114_REG[i+1], 1 );	}/****f* HwLib/IVideoDecoder_Write * USAGE *	QRESULT IVideoDecoder_Write(IVideoDecoder* pIVideoDecoder, BYTE Address, BYTE* pData) *	QRESULT Csaa7114__Write(IVideoDecoder* pIVideoDecoder, BYTE Address, BYTE* pData) * PARAMETERS *	IN IVideoDecoder* pIVideoDecoder - pointer to the VideoDecoder object *	IN BYTE Address - address of the I2C register to write *	IN BYTE* pData - pointer to the BYTE data to write/********************************************************************************************/

⌨️ 快捷键说明

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