csaa7114.c

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

C
806
字号
QRESULT Csaa7114__Write( IVideoDecoder* pIVideoDecoder, BYTE Address, BYTE* pData ){	Csaa7114* this = (Csaa7114*) pIVideoDecoder;	BOOL bRet;	bRet = II2C_Write(this->m_pII2C, Address, pData, 1);	QDbgLog((QLOG_TRACE, QDebugLevelTrace,		TEXT("   Write7114 at %x = %x"), Address, *pData));	return bRet? Q_OK:Q_FAIL;}/****f* HwLib/IVideoDecoder_Read * USAGE *	QRESULT IVideoDecoder_Read(IVideoDecoder* pIVideoDecoder, BYTE Address, BYTE* pData) *	QRESULT Csaa7114__Read(IVideoDecoder* pIVideoDecoder, BYTE Address, BYTE* pData) * PARAMETERS *	IN IVideoDecoder* pIVideoDecoder - pointer to the VideoDecoder object *	IN BYTE Address - address of the I2C register to read *	IN BYTE* pData - pointer where the BYTE data is read/********************************************************************************************/QRESULT Csaa7114__Read( IVideoDecoder* pIVideoDecoder, BYTE Address, BYTE* pData ){	Csaa7114* this = (Csaa7114*) pIVideoDecoder;	BOOL bRet;	bRet = II2C_Read(this->m_pII2C, Address, pData, 1);	QDbgLog((QLOG_TRACE, QDebugLevelTrace,		TEXT("   Read7114 at %x = %x"), Address, *pData));	return bRet? Q_OK:Q_FAIL;}/****f* HwLib/Csaa7114__SetAudioClock * USAGE *	QRESULT Csaa7114__SetAudioClock(IVideoDecoder* pIVideoDecoder, DWORD AudioRate, DWORD FieldFreq, DWORD CrystalFreq ) * PARAMETERS *	IN IVideoDecoder* pIVideoDecoder - pointer to the VideoDecoder object *	IN DWORD AudioRate - one of normal audiosample rates: 32000, 44100, 48000. *	IN DWORD FieldFreq - field frequency in mHz = 59940 for NTSC, 50000 for PAL/********************************************************************************************/static QRESULT Csaa7114__SetAudioClock( IVideoDecoder* pIVideoDecoder, DWORD AudioRate, DWORD FieldFreq){	Csaa7114* this = (Csaa7114*) pIVideoDecoder;	BYTE* pAudioTable;	int i;	// default initialization 	pAudioTable = SAA7114_Pal_44k;	switch(FieldFreq)	{	case 59940:		switch(AudioRate)		{		case 48000:			pAudioTable = SAA7114_Ntsc_48k;			break;		case 44100:			pAudioTable = SAA7114_Ntsc_44k;			break;		case 32000:			pAudioTable = SAA7114_Ntsc_32k;			break;		}		break;	case 50000:		switch(AudioRate)		{		case 48000:			pAudioTable = SAA7114_Pal_48k;			break;		case 44100:			pAudioTable = SAA7114_Pal_44k;			break;		case 32000:			pAudioTable = SAA7114_Pal_32k;			break;		}		break;	}	for( i=0; i< sizeof(SAA7114_Ntsc_48k); i+=2)		II2C_Write(this->m_pII2C, pAudioTable[i], &pAudioTable[i+1], 1 );	return Q_OK;}/****f* HwLib/Csaa7114__SetTVStandard * USAGE *	QRESULT Csaa7114__SetTVStandard(IVideoDecoder* pIVideoDecoder, DWORD TvStandard ) * PARAMETERS *	IN IVideoDecoder* pIVideoDecoder - pointer to the VideoDecoder object *	IN DWORD TvStandard - one of SET_NTSC, SET_PAL./********************************************************************************************/static QRESULT Csaa7114__SetTVStandard(IVideoDecoder* pIVideoDecoder, DWORD TvStandard){	Csaa7114* this = (Csaa7114*) pIVideoDecoder;	BYTE Byte;	this->evdTvStandard_value=TvStandard;	switch(TvStandard)	{	case evTvStandard_NTSC:		Byte = 0x40; Csaa7114__Write(pIVideoDecoder, 0x09, &Byte);		Byte = 0x2a; Csaa7114__Write(pIVideoDecoder, 0x0f, &Byte);		Byte = 0x40;	// ITU656		Csaa7114__Write(pIVideoDecoder, 0x13, &Byte);		Byte = 0x89;		Csaa7114__Write(pIVideoDecoder, 0x0e, &Byte);#ifdef SONY_HAC_PFGP	// set input source for saa7115// Added 2002-11-29 by k.hirose 		Byte = 0x8d;		Csaa7114__Write(pIVideoDecoder, 0x0a, &Byte);#endif		Byte = 0x0e;		Csaa7114__Write(pIVideoDecoder, 0x10, &Byte);		break;	case evTvStandard_PAL:		Byte = 0x40; Csaa7114__Write(pIVideoDecoder, 0x09, &Byte);		Byte = 0x2a; Csaa7114__Write(pIVideoDecoder, 0x0f, &Byte);		Byte = 0x41;	// ITU656 modified - use regs 0x15,0x16,0x17		Csaa7114__Write(pIVideoDecoder, 0x13, &Byte);		Byte = 0x81;		Csaa7114__Write(pIVideoDecoder, 0x0e, &Byte);		Byte = 0x06;		Csaa7114__Write(pIVideoDecoder, 0x10, &Byte);		break;	case evTvStandard_SECAM:		Byte = 0x1b; Csaa7114__Write(pIVideoDecoder, 0x09, &Byte);		Byte = 0x80; Csaa7114__Write(pIVideoDecoder, 0x0f, &Byte);		Byte = 0x41;	// ITU656 modified - use regs 0x15,0x16,0x17		Csaa7114__Write(pIVideoDecoder, 0x13, &Byte);		Byte = 0xd0;		Csaa7114__Write(pIVideoDecoder, 0x0e, &Byte);		Byte = 0x00;		Csaa7114__Write(pIVideoDecoder, 0x10, &Byte);		break;	default:		return Q_FAIL;		break;	}	return Q_OK;}// taken from Pascal code in Tobago. Don't expose, expose only thru SetPropertystatic QRESULT Csaa7114__SetInputSource(IVideoDecoder* pIVideoDecoder,evdInputSource_type evdInputSource_value) {//XXX: The input modes really depend of how the inputs pins are connected on a particular// board and not which tv decoder is used.// The following modes reflects the configuration on Harmony (SAA7114) and Jasper PVR (SAA7118)#ifndef SAA7118#define COMPOSITE_INPUT    0xC0 // addr 0x02#define SVIDEO_INPUT       0xC7 // addr 0x02#define ONBOARDTUNER_INPUT 0xC5 // addr 0x02#else /* SAA7118 */#define COMPOSITE_INPUT        (0xC0 | 0x00) #define SVIDEO_INPUT           (0xC0 | 0x16)#define ONBOARDTUNER_INPUT     (0xC0 | 0x01)//XXX - Not supported yet.#define COMPONENT_INPUT        (0xC0 | 0x2F) #define SCART_COMPONENT_INPUT  (0xC0 | 0x3E)#define SCART_COMPOSITE_INPUT  (0xC0 | 0x0E)#endif /* SAA7118 */	#define SUB_TYPE_COMPOSITE 0x40 // addr 0x09#define SUB_TYPE_TUNER     0x40 // addr 0x09#define SUB_TYPE_SVIDEO    0xC0 // addr 0x09#define SUB_TYPE_COMPONENT 0xC0 // addr 0x09 ???			BYTE source_type=0;	BYTE source_sub_type=0;		switch(evdInputSource_value) {	case evdInputSource_COMPOSITE:		source_type = COMPOSITE_INPUT;		source_sub_type = SUB_TYPE_COMPOSITE;		break;	case evdInputSource_SVIDEO:		source_type = SVIDEO_INPUT;		source_sub_type = 0;		Csaa7114__Write(pIVideoDecoder,0x03, &source_sub_type);		source_sub_type = 0;		Csaa7114__Write(pIVideoDecoder,0x05, &source_sub_type);		source_sub_type = SUB_TYPE_SVIDEO;		break;	case evdInputSource_ONBOARDTUNER:		source_type = ONBOARDTUNER_INPUT;		source_sub_type = SUB_TYPE_TUNER;		break;#ifdef SAA7118			case evdInputSource_COMPONENT:		source_type = COMPONENT_INPUT;		source_sub_type = 0;		Csaa7114__Write(pIVideoDecoder,0x03, &source_sub_type);		source_sub_type = 0;		Csaa7114__Write(pIVideoDecoder,0x05, &source_sub_type);		source_sub_type = SUB_TYPE_COMPONENT;		break;			case evdInputSource_SCART_COMPONENT:		source_type = SCART_COMPONENT_INPUT;		source_sub_type = SUB_TYPE_COMPONENT;		break;			case evdInputSource_SCART_COMPOSITE:		source_type = SCART_COMPOSITE_INPUT;		source_sub_type = SUB_TYPE_COMPOSITE;		break;#endif			default:		source_type = evdInputSource_value & 0x3F;		source_sub_type = SUB_TYPE_COMPOSITE;				break;	}		Csaa7114__Write(pIVideoDecoder,0x09, &source_sub_type);	Csaa7114__Write(pIVideoDecoder,0x02, &source_type);	return Q_OK;}void Csaa7114__InitPropertySet(IVideoDecoder* pIVideoDecoder, void* pPropSet, DWORD dwSize){	Csaa7114* this = (Csaa7114*) pIVideoDecoder;	if(dwSize != sizeof(PROPERTY_SET_ITEM))		return;	InitPropSet(pIVideoDecoder, pPropSet, VIDEO_DECODER_SET, evdMax,\		this->VideoDecoderPropertyList, Csaa7114__SetProperty, Csaa7114__GetProperty)}/****f* HwLib/IVideoDecoder_SetProperty * USAGE *	QRESULT IVideoDecoder_SetProperty(IVideoDecoder* pIVideoDecoder, *		DWORD PropSet, DWORD PropId, DWORD Flags, void* pData, DWORD dwSizeIn, DWORD* pdwSizeOut) *	QRESULT Csaa7114__SetProperty(IVideoDecoder* pIVideoDecoder, *		DWORD PropSet, DWORD PropId, DWORD Flags, void* pData, DWORD dwSizeIn, DWORD* pdwSizeOut) * PARAMETERS *	IN IVideoDecoder* pIVideoDecoder - pointer to the VideoDecoder object/********************************************************************************************/#define CASE_SET_VIDEODECODER_PROPERTY(x, y)\case x:\	IVideoDecoder_Write(pIVideoDecoder, FS400_##y, (WORD*)&Value);\	break;QRESULT Csaa7114__SetProperty( IVideoDecoder* pIVideoDecoder,	DWORD PropSet, DWORD PropId, DWORD Flags, void* pData, DWORD dwSizeIn, DWORD* pdwSizeOut){	// VIDEO_DECODER_SET use DWORD for changing information and size condition is already checked	Csaa7114* this = (Csaa7114*) pIVideoDecoder;	DWORD Value = *(DWORD*)pData;	//	QRESULT qr = Q_OK;	QDbgLog((QLOG_TRACE, QDebugLevelTrace,		TEXT("   --> Csaa7114__SetProperty: set=%x id=%x flags=%x sz=%x value=%x"),		PropSet, PropId, Flags, dwSizeIn, Value));	switch(PropId)	{	case evdAccessRegister:		if(pdwSizeOut)			*pdwSizeOut = sizeof(ADDR_DATA);		if( dwSizeIn < sizeof(ADDR_DATA) )			return E_INVALID_PROPERTY_BUFFER;		IVideoDecoder_Write(pIVideoDecoder,			(BYTE)((ADDR_DATA*)pData)->Addr,			(BYTE*)&((ADDR_DATA*)pData)->Data);		return Q_OK;		break;	case evdTvStandard:		CHECK_SIZE(evdTvStandard)		Csaa7114__SetTVStandard(pIVideoDecoder,*(evdTvStandard_type *)pData);		return Q_OK;		break;	case evdAudioClock:		{			DWORD FieldFreq=0;			CHECK_SIZE(evdAudioClock) 							switch (this->evdTvStandard_value)			{			case evTvStandard_NTSC:				FieldFreq = 59940;				break;			case evTvStandard_PAL:				FieldFreq = 50000;				break;			case evTvStandard_SECAM:				FieldFreq = 50000;				break;			default:				return Q_FAIL;				break;			}						if (FieldFreq==0)				return Q_FAIL;						Csaa7114__SetAudioClock(pIVideoDecoder,						*(evdInputSource_type *)pData,						FieldFreq);			return Q_OK;			}	case evdInputSource:		CHECK_SIZE(evdInputSource)		Csaa7114__SetInputSource(pIVideoDecoder,*(evdInputSource_type *)pData);		return Q_OK;		default:		return E_NOT_SUPPORTED;	}	return Q_OK;}/****f* HwLib/IVideoDecoder_GetProperty  * USAGE *	QRESULT IVideoDecoder_GetProperty(IVideoDecoder* pIVideoDecoder, *		DWORD PropSet, DWORD PropId, DWORD Flags, void* pData, DWORD dwSizeIn, DWORD* pdwSizeOut) *	QRESULT Csaa7114__GetProperty(IVideoDecoder* pIVideoDecoder, *		DWORD PropSet, DWORD PropId, DWORD Flags, void* pData, DWORD dwSizeIn, DWORD* pdwSizeOut) * PARAMETERS *	IN IVideoDecoder* pIVideoDecoder - pointer to the VideoDecoder object/********************************************************************************************/#define CASE_GET_VIDEODECODER_PROPERTY(x, y)\case x:\	IVideoDecoder_Read(pIVideoDecoder, FS400_##y, (WORD*)&Value);\	break;QRESULT Csaa7114__GetProperty( IVideoDecoder* pIVideoDecoder,	DWORD PropSet, DWORD PropId, DWORD Flags, void* pData, DWORD dwSizeIn, DWORD* pdwSizeOut){	// VIDEO_DECODER_SET use DWORD for changing information and size condition is already checked	//	Csaa7114* this = (Csaa7114*) pIVideoDecoder;	DWORD Value;	switch(PropId)	{	case evdAccessRegister:		if(pdwSizeOut)			*pdwSizeOut = sizeof(ADDR_DATA);		if( dwSizeIn < sizeof(ADDR_DATA) )			return E_INVALID_PROPERTY_BUFFER;		IVideoDecoder_Read(pIVideoDecoder,			(BYTE)((ADDR_DATA*)pData)->Addr,			(BYTE*)&((ADDR_DATA*)pData)->Data);		return Q_OK;	default:		return E_NOT_SUPPORTED;	}	*(DWORD*)pData = Value;	QDbgLog((QLOG_TRACE, QDebugLevelTrace,		TEXT("   <-- Csaa7114__GetProperty: set=%x id=%x flags=%x sz=%x value=%x"),		PropSet, PropId, Flags, dwSizeIn, Value));	return Q_OK;}QRESULT Csaa7114__Test(IVideoDecoder* pIVideoDecoder){	//	Csaa7114* this = (Csaa7114*) pIVideoDecoder;	BYTE wData, wOldData;	int Error = 0;	if( QFAILED(IVideoDecoder_Read(pIVideoDecoder, SAA7114_LUMINANCE, &wOldData)) )		Error++;	wData = 0x55;	if( QFAILED(IVideoDecoder_Write(pIVideoDecoder, SAA7114_LUMINANCE, &wData)) )		Error++;	wData = 0;	if( QFAILED(IVideoDecoder_Read(pIVideoDecoder, SAA7114_LUMINANCE, &wData)) )		Error++;	if( wData != 0x55)		Error++;	if( QFAILED(IVideoDecoder_Write(pIVideoDecoder, SAA7114_LUMINANCE, &wOldData)) )		Error++;	if (Error)		OSsprintf(g_InfoError, TEXT("Error Saa7114 ") );	return Error ? E_TEST_VIDEO_DECODER_FAILED : Q_OK;}#else // ! SAA7114_OBJECTvoid Csaa7114__CreateInstance(void **ppv, DWORD dwInstance){	*ppv = NULL;}#endif	// SAA7114_OBJECT

⌨️ 快捷键说明

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