📄 cem847x.c
字号:
/********************************************************************************************//* cem847x.c : Implementation of the EM8470/EM8475 interface* REALmagic Quasar Hardware Library* Created by Aurelia Popa-Radu* Copyright Sigma Designs Inc* Sigma Designs Proprietary and confidential* Created on 8/1/01* Description:/********************************************************************************************/#include "pch.h"#if defined EM847X_OBJECT#include "cquasar.h"UCHAR UCodeQuasar4[] = { #ifdef MICROCODE_NO_DOLBY #include "quasar4/tst_no_dolby.h" // doesn't play dolby no matter the bonding of the chip #else #include "quasar4/tst.h" // play dolby no matter the bonding of the chip #endif};#ifdef EM848X_MICROCODEUCHAR UCodeEM848x[] = { #ifdef MICROCODE_NO_DOLBY #include "em848x/tst_no_dolby.h" // doesn't play dolby no matter the bonding of the chip #else #include "em848x/tst.h" // play dolby no matter the bonding of the chip #endif};#endif#ifdef EM847X_REVC_MICROCODEUCHAR UCodeEM847xC[] = { #ifdef MICROCODE_NO_DOLBY #include "em847xc/tst_no_dolby.h" // doesn't play dolby no matter the bonding of the chip #else #include "em847xc/tst.h" // play dolby no matter the bonding of the chip #endif};#endif/****v* HwLib/Q4 * NAME * Q4 * DESCRIPTION * Global array of symbols used to send commands and data to EM847x through microcode./********************************************************************************************/Q4SymbolTable Q4;#undef DEFINE_ENTRY#define DEFINE_ENTRY(Symbol) Q4.Symbol.str = #Symbol;#include "symbols.h"QRESULT InitializeQ4SymbolsTable( IDecoder* pIDecoder ){ SymbolEntry* pSymbolEntry = (SymbolEntry*)&Q4; int i; CommonSymbols Q4Mpeg4SymbolsTable Q4AudioNewSymbolsTable Q4ReverseGOPSymbolsTable VideoCaptureSymbolTable for( i=0;i<( sizeof(Q4SymbolTable)/sizeof(SymbolEntry) );i++ ) { if( !CQuasar__SearchSymbol(pIDecoder, pSymbolEntry->str, &pSymbolEntry->addr)) { pSymbolEntry->addr = 0; QDbgLog((QLOG_TRACE, QDebugLevelError, TEXT("Symbol %s not found"), pSymbolEntry->str )); OSsprintf(g_InfoError, TEXT("Symbol %s not found"), pSymbolEntry->str ); return E_GET_SYMBOLS_FAILED; } pSymbolEntry++; } return Q_OK;}#ifdef EM848X_MICROCODEQ4SymbolTable Q8; // 8MB#undef DEFINE_ENTRY#define DEFINE_ENTRY(Symbol) Q8.Symbol.str = #Symbol;#include "symbols.h"QRESULT InitializeQ8SymbolsTable( IDecoder* pIDecoder ){ SymbolEntry* pSymbolEntry = (SymbolEntry*)&Q8; int i; CommonSymbols Q4Mpeg4SymbolsTable Q4AudioNewSymbolsTable Q4ReverseGOPSymbolsTable VideoCaptureSymbolTable for( i=0;i<( sizeof(Q4SymbolTable)/sizeof(SymbolEntry) );i++ ) { if( !CQuasar__SearchSymbol(pIDecoder, pSymbolEntry->str, &pSymbolEntry->addr)) { pSymbolEntry->addr = 0; QDbgLog((QLOG_TRACE, QDebugLevelError, TEXT("Symbol %s not found"), pSymbolEntry->str )); OSsprintf(g_InfoError, TEXT("Symbol %s not found"), pSymbolEntry->str ); return E_GET_SYMBOLS_FAILED; } pSymbolEntry++; } return Q_OK;}#endif // EM848X_MICROCODE#ifdef EM847X_REVC_MICROCODEQ4SymbolTable Q4C; // 4MB#undef DEFINE_ENTRY#define DEFINE_ENTRY(Symbol) Q4C.Symbol.str = #Symbol;#include "symbols.h"QRESULT InitializeQ4CSymbolsTable( IDecoder* pIDecoder ){ SymbolEntry* pSymbolEntry = (SymbolEntry*)&Q4C; int i; CommonSymbols Q4Mpeg4SymbolsTable Q4AudioNewSymbolsTable Q4ReverseGOPSymbolsTable VideoCaptureSymbolTable for( i=0;i<( sizeof(Q4SymbolTable)/sizeof(SymbolEntry) );i++ ) { if( !CQuasar__SearchSymbol(pIDecoder, pSymbolEntry->str, &pSymbolEntry->addr)) { pSymbolEntry->addr = 0; QDbgLog((QLOG_TRACE, QDebugLevelError, TEXT("Symbol %s not found"), pSymbolEntry->str )); OSsprintf(g_InfoError, TEXT("Symbol %s not found"), pSymbolEntry->str ); return E_GET_SYMBOLS_FAILED; } pSymbolEntry++; } return Q_OK;}#endif // EM847X_REVC_MICROCODE/****f* HwLib/IDecoder_SetMicrocode * USAGE * QRESULT IDecoder_SetMicrocode(IDecoder* pIDecoder, DWORD Id) * QRESULT CEM840X__SetMicrocode(IDecoder* pIDecoder, DWORD Id) * QRESULT CEM847X__SetMicrocode(IDecoder* pIDecoder, DWORD Id) * DESCRIPTION * IDecoder_SetMicrocode - choose the appropiate microcode and initialize the symbol table Q4. * Q3 is CommonSymbolTable structure, Q4 is Q4SymbolTable structure. * They contain the name and the corresponding address of the symbols from microcode. * Any symbol can be read through IDecoder_ReadDM(pQ->SymbolName.addr), where pQ can * be obtain calling IDecoder_GetSymbolTable. * It is called by CreateInstance. * PARAMETERS * IN IDecoder* pIDecoder - pointer to the decoder object * IN DWORD Id - identifier for microcode * RETURN VALUE * If the function succeeds, the return value is Q_OK. * If the function fails, the return value is: * E_GET_SYMBOLS_FAILED - the microcode array is corrupted or the version is old. * To get extended error information, call GetLastQError. /********************************************************************************************/QRESULT CEM847X__SetMicrocode(IDecoder* pIDecoder, DWORD Id){ CQuasar *this = (CQuasar*) pIDecoder; if(Id == ebiUcode_MpegDecode) {#ifdef EM848X_MICROCODE if(this->QuasarVersion == EM848XA_Q4) { this->pUCode = (BYTE*)UCodeEM848x; this->UCodeSize = sizeof(UCodeEM848x); this->pQ = (void*)&Q8; // symbol table this->SymbolTableSize = sizeof(Q8); return InitializeQ8SymbolsTable(pIDecoder); } else#endif#ifdef EM847X_REVC_MICROCODE if(this->QuasarVersion == EM847XC_Q4) { this->pUCode = (BYTE*)UCodeEM847xC; this->UCodeSize = sizeof(UCodeEM847xC); this->pQ = (void*)&Q4C; // symbol table this->SymbolTableSize = sizeof(Q4C); return InitializeQ4CSymbolsTable(pIDecoder); } else#endif // EM847X_REVC_MICROCODE { this->pUCode = (BYTE*)UCodeQuasar4; this->UCodeSize = sizeof(UCodeQuasar4); this->pQ = (void*)&Q4; // symbol table this->SymbolTableSize = sizeof(Q4); return InitializeQ4SymbolsTable(pIDecoder); } } else return E_NOT_SUPPORTED;}void CEM847X__InitVtable(IDecoder* pIDecoder){ CQuasar *this = (CQuasar*) pIDecoder; this->VTable.SetMicrocode = CEM847X__SetMicrocode; this->VTable.InitPtsFifo = CEM847X__InitPtsFifo; this->VTable.PtsFifoEmptiness = CEM847X__PtsFifoEmptiness; this->VTable.WritePTS = CEM847X__WritePTS; this->VTable.WritePCR = CEM847X__WritePCR; this->VTable.SetPIODir = CEM847X__SetPIODir; this->VTable.WritePIO = CEM847X__WritePIO; this->VTable.ReadPIO = CEM847X__ReadPIO; if ((this->QuasarVersion == EM848XA_Q4) || (this->QuasarVersion == EM847XC_Q4)) this->VTable.SetAudioSampleRate = CEM848X__SetAudioSampleRate; else this->VTable.SetAudioSampleRate = CEM847X__SetAudioSampleRate; this->VTable.ReadDramSlave = CEM847X__ReadSlaveDramToHost; this->VTable.InitPropertySet = CEM847X__InitPropertySet; this->VTable.SetProperty = CEM847X__SetProperty; this->VTable.GetProperty = CEM847X__GetProperty; this->VTable.SetDisplayFilter = CEM847X__SetDisplayFilter; this->VTable.ProgramVClk = CEM847X__ProgramVClk; this->VTable.ReadLbcReg = CEM847X__ReadLbcReg; this->VTable.WriteLbcReg = CEM847X__WriteLbcReg; this->VTable.WriteDataToLBC = CEM847X__WriteDataToLBC; this->VTable.ReadDataFromLBC = CEM847X__ReadDataFromLBC;}#endif // EM847X_OBJECT#if defined EM847X_OBJECT || defined EM85XX_OBJECT#include "cquasar.h"#include "em847x.h"#include "regs840x.h"#include "regs847x.h"char Default4TapDisplayFilter[] ={/*// Olivier filter 1:: maximum details but more aliasing prone 64, 64, 62, 60, 57, 53, 48, 44, 38, 33, 28, 22, 17, 12, 8, 4, 0, -2, -4, -6, -7, -7, -7, -7, -6, -6, -5, -4, -3, -2, -2, -2*////*// Olivier filter 2: intermediate between filter 1 and 3 58, 58, 57, 55, 52, 49, 46, 42, 37, 33, 28, 24, 20, 15, 11, 8, 3, 2, -1, -3, -4, -5, -5, -6, -5, -5, -5, -4, -4, -3, -3, -4//*//*// Olivier filter 3: lower bandwidth but very reduced aliasing 52, 52, 51, 50, 48, 46, 43, 40, 36, 33, 29, 25, 21, 17, 14, 10, 6, 5, 2, 1, -1, -2, -3, -4, -4, -5, -5, -5, -4, -4, -3, -3*//*// default 4-tap filter sinx/x 60, 59, 57, 55, 52, 48, 44, 39, 34, 29, 24, 19, 15, 11, 7, 4, 2, 1, 0, -1, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, 0, 0*/};char DefaultJpg4TapDisplayFilter[] ={ 64, 64, 64, 64, 64, 64, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};BOOL CEM847X__SetMp4Speed(IDecoder* pIDecoder, DWORD SpeedRatio){ CQuasar *this = (CQuasar*) pIDecoder; Q4SymbolTable* pQ4 = (Q4SymbolTable*)this->pQ; DWORD temp = this->FixedTimeIncrResVal * SpeedRatio/256; temp = min(temp, 0xFFFF); IDecoder_WriteDM(pIDecoder, pQ4->FixedTimeIncrResVal.addr, temp); return TRUE;}QRESULT CEM848x__SetAudioInOutConfig(IDecoder* pIDecoder, AudioInOutConfig_type AudioInOutConfig, eAudioInConfig_type AudioInConfig){ CQuasar *this = (CQuasar*) pIDecoder; CommonSymbolTable* pQ = (CommonSymbolTable*)this->pQ; this->SerialCtrl0Config = Q3_ASctrl0_CkoutInverted | Q3_ASctrl0_MSbitfirst; this->SerialCtrl1Config = Q3_ASctrl1_Irclkin; // Bit15=0 - AudioIn master - bit clock and LR clock are generated internaly if( AudioInConfig != eAudioInConfig_Master_MSBFirst) { this->SerialCtrl1Config |= 0x8000; // Bit15=1 - AudioIn slave - bit clock and LR clock are generated externaly this->SerialCtrl1Config |= 0x2000; // Bit13 - AudioIn MSB first } switch(AudioInOutConfig) { case eAudioInOut_BitClockACLK: this->SerialCtrl0Config |= Q3_ASctrl0_FrameInverted; break; case eAudioInOut_BitClockDAMCK: // I2S_SCkinDAMCK_ScinOUT_DamckIN this->SerialCtrl0Config |= Q3_ASctrl0_FrameInverted; this->SerialCtrl1Config |= 0x0400; break; case eAudioInOut_BitClockInternDivMClk: // I2S_SCkinInternDivMclk_ScinOUT_DamckOUT this->SerialCtrl0Config |= Q3_ASctrl0_FrameInverted; this->SerialCtrl1Config |= 0x0800; this->AudioSampleRateSupport_96kHz = 1; break; case eAudioInOut_BitClockInternDivDAMCK: this->SerialCtrl0Config |= Q3_ASctrl0_FrameInverted; this->SerialCtrl1Config |= 0x0C00; break; default: return E_NOT_SUPPORTED; } CQuasar__SetAudioModeOrFormat(pIDecoder); return Q_OK;}QRESULT CEM847xC__SetAudioInOutConfig(IDecoder* pIDecoder, EM847xAudioInOutConfigEnum AudioInOutConfig){ CQuasar *this = (CQuasar*) pIDecoder; this->SerialCtrl0Config = Q3_ASctrl0_CkoutInverted | Q3_ASctrl0_MSbitfirst; this->SerialCtrl1Config = 0x0000 | Q3_ASctrl1_Irclkin; switch(AudioInOutConfig) { case I2SInv_SCkinSCIN_ScinIN_DamckIN: // I2SInv_SCkinSCIN_Jda1CkinGCK_ScinIN_DamckIN: break; case I2S_SCkinSCIN_ScinIN_DamckIN: // I2S_SCkinSCIN_Jda1CkinGCK_ScinIN_DamckIN: this->SerialCtrl0Config |= Q3_ASctrl0_FrameInverted; break; case I2S_SCkinDAMCK_ScinOUT_DamckIN: // I2S_SCkinDAMCK_Jda1CkinGCK_ScinOUT_DamckIN: this->SerialCtrl0Config |= Q3_ASctrl0_FrameInverted; this->SerialCtrl1Config |= 0x0400; break; case I2S_SCkinInternDivMclk_ScinOUT_DamckOUT: // I2S_SCkinJDA1CK_Jda1CkinGCK_ScinOUT_DamckOUT: this->SerialCtrl0Config |= Q3_ASctrl0_FrameInverted; this->SerialCtrl1Config |= 0x0800; this->AudioSampleRateSupport_96kHz = 1; break; case I2S_SCkinInternDivDAMCK_ScinOUT_DamckIN: // I2S_SCkinJDA1CK_Jda1CkinDAMCK_ScinOUT_DamckIN: this->SerialCtrl0Config |= Q3_ASctrl0_FrameInverted; this->SerialCtrl1Config |= 0x0c00; break; default:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -