📄 hdecoder.c
字号:
// ************ Big Modification *************** //// LLY2.20, porting Rock's code to remove the procedure// that F/W will set audio buffer/ audio buffer2 start and length in AM#include "winav.h"#include "ctkav.h"#include "ctkav_mcu.h"#include "comdec.h"#include "hal.h" //because of VERSION_S define#include "hdecoder.h"#include "disp.h" // because of variable#include "utl.h" // because of ATTR_AVI define, TYPE_CDROM_AUDIO#include "parser.h" // because of PARSER_ES_AUDIO define#include "subpict.h"#include "romld.h"extern BYTE __bAttrPlay; //because of HAL_ResetAudioDecoder will reference it, need modificationextern BYTE __bAudioType;//because of HAL_ResetAudioDecoder will reference it, need modificationextern BYTE __bACHN;extern DWORD __dwAspect_Ratio_Info;// LLY2.51, porting Chuan's code since there are WORD unit for chip verion (main + sub)//BYTE __bChipVersion; // record CODE VERSIONWORD __wChipVersion; // record CODE VERSIONBYTE __bPartNo; //Kevin1.05-3, make sure to see definition in chips.h// LLY2.75, expand as DWORD unit since we will support more feature// Kevin1.11a, support features based on __wChipVersion(IC) and __bPartNo(Package)//BYTE __bSupportFeature;DWORD __dwSupportFeature;DWORD _dwHALUserDefinedColor;DWORD __dwClearBuffMode;BYTE _bHALABuf2Def=FALSE;DWORD __dwHALAudioFreq=44100;DWORD __dwHALABUFFSIZE;//, __dwHALVBUFFSIZE;// LLY2.55, add a global variable to keep current using PROC2BYTE __bCurProc2Code=HAL_AUDIO_NONE;// LLY2.35, if define it, it will use audio buffer 0 and 1 for MPEG audio stream// Otherwise, it just use one audio buffer 0//#define USE_2BUFF_FOR_MPEG_AUDIO// LLY2.51, porting Chuan's code to use only one audio buffer from CT909P IC// LLY2.56, CT909G Audio buffer configuration is same as CT909P//#ifdef CT909P_IC_SYSTEM#if defined(CT909P_IC_SYSTEM) || defined(CT909G_IC_SYSTEM)#define USE_1BUFF_ONLY_FOR_AUDIO#endif // #if defined(CT909P_IC_SYSTEM) || defined(CT909G_IC_SYSTEM)// LLY2.31, if define it, it will set A/V buffer base on parser reported ratio#define SET_AVI_BITS_BUFFER_BY_RATIO#ifdef SET_AVI_BITS_BUFFER_BY_RATIO// Define total size for pre-reserved A/V buffer#define AVI_AV_BUF_LEN (DS_VDBUF_END_AVI-DS_AD0BUF_ST_AVI)// Must reserve A0 and A1 buffer at least 4K DW space.#define MIN_LEN_FOR_A0BUF 0x4000L// LLY2.37, give Audio Buffer 1 min size from 4K to 5K DW// Since some WMA files one packet size is 0x22f4 bytes// And, DSP will start decoding after send at least 2 packet WMA data to A1 buffer#define MIN_LEN_FOR_A1BUF 0x5000L // If use audio buffer 1// If define it, it will print out AVI A/V buffer setting issue base on parser reported ratio//#define DEBUG_AVI_BUFFER_RATIO// If define it, A/V buffer calculation only base on A/V buffer ratio// Otherwise, it also reference the minimnu parser suggested audio buffer size//#define PARTITION_JUST_ON_AV_RATIO#endif // #ifdef SET_AVI_BITS_BUFFER_BY_RATIO//********************************************************************// Description : Detect Chip Version and Part No; Decide supported audio features// Arguments : None// Return : None//********************************************************************// LLY2.00, modify the procedure to meet CT909S requirement.void HAL_DetectChipVersion(void){/***** Detect Chip Version *****/ // using macro to get chip version, and it will handle 909 & 909S // LLY2.51, porting Chuan's code since there are WORD unit for chip verion (main + sub) //__bChipVersion = MACRO_PLAT_GET_CHIPVER; __wChipVersion = MACRO_PLAT_GET_CHIPVER; // Add error protection message#ifdef CT909R_IC_SYSTEM if(__wChipVersion != VERSION_BB)#endif // #ifdef CT909R_IC_SYSTEM#ifdef CT909P_IC_SYSTEM if(__wChipVersion != VERSION_P_AB)#endif // #ifdef CT909P_IC_SYSTEM // LLY2.56, add for CT909G IC chip version#ifdef CT909G_IC_SYSTEM if(__wChipVersion != VERSION_G_AA)#endif // #ifdef CT909G_IC_SYSTEM { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Chip version wrong: %lx\n", __wChipVersion); }/***** Detect Part No *****/ // using macro to get part no, and it will handle 909 & 909S __bPartNo = MACRO_PLAT_GET_PARTNO;/***** Decide Supported Featurs *****/ // LLY2.18, re-modify the procedure to detect the supported feature // [1] Always enable WMA //__bSupportFeature = 0; // Initial as none first __dwSupportFeature = SUPPORT_FEATURE_WMA; // [2] Check if support DivX if(MACRO_IC_CAPABILITY & IC_CAP_DIVX) { __dwSupportFeature |= SUPPORT_FEATURE_DIVX; } // [3] Check if support special feature, ex Game if(MACRO_IC_CAPABILITY & IC_CAP_SPECIAL) { __dwSupportFeature |= SUPPORT_FEATURE_SPECIAL; } // LLY2.75, add IC capability checking for CT909G IC#ifdef CT909G_IC_SYSTEM // [4] Check if not support MPEG4 if( (MACRO_IC_CAPABILITY & IC_CAP_MPEG4) != IC_CAP_MPEG4 ) { __dwSupportFeature |= SUPPORT_FEATURE_NOMPEG4; } // [5] Check if not support 5.1 channel if( (MACRO_IC_CAPABILITY & IC_CAP_51CH) != IC_CAP_51CH ) { __dwSupportFeature |= SUPPORT_FEATURE_NO51CH; } // [6] Check if support all feature if(MACRO_IC_CAPABILITY == IC_CAP_ALL) { __dwSupportFeature |= SUPPORT_FEATURE_SPECIAL; __dwSupportFeature &= ~SUPPORT_FEATURE_NOMPEG4; __dwSupportFeature &= ~SUPPORT_FEATURE_NO51CH; }#else // #ifdef CT909G_IC_SYSTEM // [4] Check if support DVB if(MACRO_IC_CAPABILITY & IC_CAP_DVB) { __dwSupportFeature |= SUPPORT_FEATURE_DVB; } // [5] Check if support all feature if(MACRO_IC_CAPABILITY == IC_CAP_ALL) { __dwSupportFeature |= (SUPPORT_FEATURE_DIVX | SUPPORT_FEATURE_DVB | SUPPORT_FEATURE_SPECIAL); } // LLY2.75, enable support multi-media feature for CT95x serial IC if(MACRO_IC_CAPABILITY & IC_CAP_MULTIMEDIA) { __dwSupportFeature |= SUPPORT_FEATURE_MULTIMEDIA; } // LLY2.75, enable support digital panel feature for CT956A IC if(MACRO_IC_CAPABILITY & IC_CAP_DIGITAL_PANEL) { __dwSupportFeature |= SUPPORT_FEATURE_DIGITAL_PANEL; } // LLY2.75, enable support NAND Flash feature for CT956A IC if(MACRO_IC_CAPABILITY & IC_CAP_NAND_FLASH) { __dwSupportFeature |= SUPPORT_FEATURE_NAND_FLASH; }#endif // #ifdef CT909G_IC_SYSTEM/******* Remove the un-necessary part if user disable it *******/ // Disable WMA if user disable it#ifndef SUPPORT_WMA __dwSupportFeature &= ~(SUPPORT_FEATURE_WMA);#endif // #ifndef SUPPORT_WMA // Disable ProLogic if user disable it#ifndef SUPPORT_PROLOGIC __dwSupportFeature &= ~(SUPPORT_FEATURE_PROLOGIC);#endif // #ifndef SUPPORT_PROLOGIC // Disable ProLogic if two channel only#ifdef SUPPORT_2_CHANNEL_ONLY __dwSupportFeature &= ~(SUPPORT_FEATURE_PROLOGIC);#endif // #ifdef SUPPORT_2_CHANNEL_ONLY // Disable DivX if user disable it#ifndef SUPPORT_DIVX __dwSupportFeature &= ~(SUPPORT_FEATURE_DIVX);#endif // #ifndef SUPPORT_DIVX#ifdef DOLBY_CERTIFICATION //kevin0.80 __dwSupportFeature &= ~SUPPORT_FEATURE_PROLOGIC;#endif // #ifdef DOLBY_CERTIFICATION // Support HDCD#ifdef SUPPORT_HDCD //customer may want to disable HDCD //__dwSupportFeature |= SUPPORT_FEATURE_HDCD; //not support HDCD for all part No.#endif // Disable DVB feature if user disable it#ifndef SUPPORT_STB __dwSupportFeature &= ~(SUPPORT_FEATURE_DVB);#endif // #ifndef SUPPORT_STB // LLY2.38, force to enable DivX 4/5 even the IC don't support DivX // LLY2.51, porting CSC modification, ie. current F/W can playback DivX 4/5 even chip not support // And, parser and decoder will control it.#if 0 //def FORCE_ENABLE_DIVX_4_5 __dwSupportFeature |= SUPPORT_FEATURE_DIVX;#endif // #ifdef FORCE_ENABLE_DIVX_4_5 // LLY2.50, always disable DivX if CT95x system#ifdef CT951_PLATFORM __dwSupportFeature &= ~(SUPPORT_FEATURE_DIVX);#endif // #ifdef CT951_PLATFORM DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "__wChipVersion=%hx, __bPartNo=%hx, __dwSupportFeature=%hx\n", __wChipVersion, __bPartNo, __dwSupportFeature);#ifdef CT909G_IC_SYSTEM // Do error protection if using 2 channel IC & configuration as 5.1 channel if(__dwSupportFeature & SUPPORT_FEATURE_NO51CH) {#ifndef SUPPORT_2_CHANNEL_ONLY DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: config 5.1 channel w/ not support 5.1 ch 909G IC\n");#endif // #ifndef SUPPORT_2_CHANNEL_ONLY }#endif // #ifdef CT909G_IC_SYSTEM}void HAL_ResetVideoDecoder(BYTE bDecoders){ DWORD dwSaveInt; OS_DISABLE_INTERRUPTS( dwSaveInt ); // Disable INT to avoid different threads accessing REG_PLAT_RESET_CONTROL_ENABLE = (PLAT_RESET_VDEC_ENABLE | PLAT_RESET_VDEC2_ENABLE); OS_RESTORE_INTERRUPTS( dwSaveInt ); // Restore INT.}// LLY2.51, give desired video buffer mode since we may in different mode.// ************************************************************************************// Function : HAL_FillVideoBuffer// Description : Fill desired data to desired video buffer directly// Arguments : bMode, specify the desired video buffer mode// pdwPtr, the pointer to desired data array// dwSizw, the desired data count (in DWORD unit)// Return : Nonce// ************************************************************************************void HAL_FillVideoBuffer(BYTE bMode, PDWORD pdwPtr, DWORD dwSize){ DWORD dwCnt; DWORD dwAddrStart, dwAddrEnd; if(bMode == HAL_VIDEOBUF_MM) { dwAddrStart = DS_VDBUF_ST_MM; dwAddrEnd = DS_VDBUF_END_MM; } else if(bMode == HAL_VIDEOBUF_NORMAL) { dwAddrStart = DS_VDBUF_ST; dwAddrEnd = DS_VDBUF_END; } else { DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_PRINTF, "Err: not specify desired video buffer mode\n"); return; } // Fill logo data into video buffer by DWORD unit for(dwCnt=0; dwCnt<dwSize; dwCnt++) { (*((volatile DWORD *) (dwAddrStart) + dwCnt))= pdwPtr[dwCnt]; } // LLY0.65, fill the dummp data since some data will be kept within FIFO // VDFIFO: 64bit*16 + DChain FIFO: 16bit*6 + VRem: 64bit*6 = 24 * 64 bit for(dwCnt=dwSize; dwCnt<dwSize+24*2; dwCnt++) { (*((volatile DWORD *) (dwAddrStart) + dwCnt))= 0x0L; } REG_MCU_VREM = MCU_REMAINDER_INIT | (dwSize + 48); // Set Video Buffer // LLY0.68, let the video buffer is same as normal mode MACRO_MCU_SET_VLD_READ_BUFFER(dwAddrStart, dwAddrEnd, dwAddrStart);}// LLY2.22, collect the procedure of clear screen procedure by JPG// *****************************************************************************// Function : _ClearScreen// Description : Base on user given parameter to clear screen by JPG// Arguments :// Return : None// Notice : Only used for HAL_ClearScreen()// *****************************************************************************void _ClearScreen(DWORD dwFrame_Y_Addr, DWORD dwFrame_UV_Addr, BOOL blFBRMode, WORD wFrameWidth, DWORD dwColor){// set value for the REG_JPU_CTL#define TRANS_JPU_CTL(type, op, uv) (((type) << 12) | ((op)) | ((uv) << 3))// calculate value for JPU's heiwid_src and heiwid_dst registers#define TRANS_HEIWID_REG(width,height) (((width) << 16) | (height))// calculate value for JPU's stripe register#define GET_STRIPE(src) (((src) + 15) >> 4)#define GET_STRIPE_UV(src) (((src) + 7) >> 3)#define TRANS_STRIPE_REG(src,dst) ((GET_STRIPE(src) << 16) | (GET_STRIPE(dst)))#define TRANS_STRIPE_REG_UV(src,dst) ((GET_STRIPE_UV(src) << 16) | (GET_STRIPE_UV(dst))) DWORD dwFrame_VSize; extern MUTEX_T __mutexGDIIdle; WORD wSrcWidth; // Source picture width // LLY2.30, collect fill Y part procedure outside since it's same for FBR or non-FBR mode // Chuan1.06, Get the Vertical size of current display picture. dwFrame_VSize = ((dwFrame_UV_Addr - dwFrame_Y_Addr)/wFrameWidth)&0xFFFFFFF8; OS_LockMutex(&__mutexGDIIdle); // reset vpu REG_PLAT_RESET_CONTROL_ENABLE = PLAT_RESET_VPU_ENABLE; REG_PLAT_RESET_CONTROL_DISABLE = PLAT_RESET_VPU_DISABLE; // initialize JPU REG_JPU_CTRL = 0; REG_JPU_STRIPE_RW = 0; REG_JPU_HEIWID_SRC = 0; REG_JPU_HVSC_FACTOR = 0; REG_JPU_ADDR_R_ST = 0; REG_JPU_ADDR_W_ST = 0; // fill Y REG_JPU_CTRL = TRANS_JPU_CTL(0, JPU_FC_Y_OP, 0); //JPEG: FC_Y REG_JPU_FILL_DATA = dwColor; REG_JPU_STRIPE_RW = TRANS_STRIPE_REG(0, wFrameWidth); //JPEG: TRANS_STRIPE_REG(0, 720); REG_JPU_HEIWID_DST = TRANS_HEIWID_REG(wFrameWidth, dwFrame_VSize); //JPEG: TRANS_HEIWID_REG(720, 480); REG_JPU_ADDR_W_ST = dwFrame_Y_Addr; REG_JPU_CTRL |= JPU_GO; while (REG_JPU_CTRL & 1) { // do nothing, just polling
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -