📄 hal.c
字号:
// LLY2.05, combine packet ID + index for parser directly.
// ie. it's un-necessary to assign value to __wHALAVIDRLow
#if 0
// VIDEO_ID bit(7-0)
__wHALAVIDRLow &= 0xff00;
__wHALAVIDRLow |= (0xE0 | bID);
PARSER_ChangeID( 0, PARSER_ES_VIDEO, (__wHALAVIDRLow&0x00FF) );
#endif // #if 0
PARSER_ChangeID( 0, PARSER_ES_VIDEO, (0xE0 | bID) );
}
// enable video stream ID filter and video stream parse
__wHALAVIDRHigh |= 0x0004; //kevin0.70, bit[2]
PARSER_ActionFilter( 0, PARSER_ENABLE_VIDEO, TRUE );
}
break;
case HAL_PARSER_AUDIO_ID:
#ifdef NO_PROC2
if(1)//bID == HAL_THROW_AUDIO)
#else
if(bID == HAL_THROW_AUDIO)
#endif
{
__wHALAVIDRHigh &= ~0x0008; //kevin0.70, bit[3]
PARSER_ActionFilter( 0, PARSER_ENABLE_AUDIO, FALSE );
}
else
{
// LLY0.72, don't specify packet ID for AVI/ DivX file.
// Notice: Need to check how to do DSP reset for multi-audio switching
if(__bAttrPlay == ATTR_AVI)
{
PARSER_ChangeID( 0, PARSER_ES_AUDIO, bID );
}
else
{
//kevin0.70-2,
WORD wTemp;
// LLY.047-3, fix MPEG multi-audio switch noise
// and only reset audio while different audio ID
//Kevin1.24, fix DVD-DTS pause->play audio discont. (due to audio is reset erroneously)
//if( (__wW99AVAVIDRLow&0x1F00) != (((WORD)bID)<<8) )
// for AC3/ DTS, bits 12~14 is 0.
if(__wHALAVIDRLow&0x7000) // non-AC3 and non-DTS
wTemp=0x1F00; //ID field: bit[12:8]
else
wTemp=0x0700; //ID field: bit[10:8]
if( (__wHALAVIDRLow&wTemp) != (((WORD)bID)<<8) )
{
HAL_Reset(HAL_RESET_AUDIO);
}
// LLY.048-2,
// if AUDIO type is AC3 or DTS, only clear bit[10:8]
// otherwise, clear bit[12:8]
// DVD039, AUDIO_ID bit (15-8): [15:13], specify audio type & [12:8], audio ID
// But AC3 and DTS share same audio stream package ID: 0x8?
// AC3: 0x80 ~ 0x87; DTS: 0x88 ~ 0x8F
if(__wHALAVIDRLow&0x7000) // non-AC3 and non-DTS
__wHALAVIDRLow &= 0xE0FF; // clear bit[12:8]
else // AC3 or DTS type
__wHALAVIDRLow &= 0xF8FF; // only clear bit[10:8] and keep bit[15:11]
// assign desired audio ID
__wHALAVIDRLow |= ((WORD)bID) << 8;
PARSER_ChangeID( 0, PARSER_ES_AUDIO, (__wHALAVIDRLow>>8) );
}
//enable audio stream ID filter and audio stream parse
__wHALAVIDRHigh |= 0x0008; //kevin0.70, bit[3]
PARSER_ActionFilter( 0, PARSER_ENABLE_AUDIO, TRUE );
}
break;
case HAL_PARSER_VIDEO_ONLY:
__wHALAVIDRHigh &= ~0x0008; //kevin0.70, bit[3]
__wHALAVIDRHigh |= 0x0004; //kevin0.70, bit[2]
PARSER_ActionFilter( 0, PARSER_ENABLE_VIDEO, TRUE );
PARSER_ActionFilter( 0, PARSER_ENABLE_AUDIO, FALSE );
break;
case HAL_PARSER_AUDIO_ONLY:
__wHALAVIDRHigh &= ~0x0004; //kevin0.70, bit[2]
__wHALAVIDRHigh |= 0x0008; //kevin0.70, bit[3]
PARSER_ActionFilter( 0, PARSER_ENABLE_VIDEO, FALSE );
PARSER_ActionFilter( 0, PARSER_ENABLE_AUDIO, TRUE );
break;
case HAL_PARSER_CDROM:
PARSER_ActionFilter( 0, PARSER_ENABLE_DATA, TRUE );
break;
case HAL_PARSER_SP_ID: // SP for DVD, and OGT for CVD/SVCD
// LLY1.11, parser support CVD OGT from v1.10
/*
if(__wDiscType & BOOK_CVD)
{
PARSER_ActionFilter( 0, PARSER_ENABLE_SP1, FALSE );
break;
}
*/
PARSER_ChangeID( 0, PARSER_ES_SP1, bID );
//Parser does necessary stuff
PARSER_ActionFilter( 0, PARSER_ENABLE_SP1, TRUE );
// LLY2.36, need to SPU initial otherwise SP display maybe abnormal
// while internal and external SP switching.
SPU_Reset(__dwSPType);
// LLY2.13, for char-based subpicture initial SPU procedure
// Since, SPU_Reset() will always reset SP type as DVD mode
#ifdef SUPPORT_CHAR_SUBPICTURE
CHAR_SP_Reset();
#endif // #ifdef SUPPORT_CHAR_SUBPICTURE
break;
// Chuan0.75, Add SP2 Case
case HAL_PARSER_SP2_ID:
PARSER_ChangeID( 0, PARSER_ES_SP2, bID );
//Parser does necessary stuff
PARSER_ActionFilter( 0, PARSER_ENABLE_SP2, TRUE );
break;
case HAL_PARSER_NV_ID:
// LLY0.66, base on input argument to enable or disable NV parsing.
PARSER_ActionFilter( 0, PARSER_ENABLE_NV, bID );
break;
// LLY2.10, remove HAL_PARSER_DISABLE/ HAL_PARSER_RESET since nobody use it.
#if 0
case HAL_PARSER_DISABLE:
PARSER_ActionFilter( 0, PARSER_ENABLE_ALL, FALSE );
break;
#endif // #if 0
case HAL_PARSER_ENABLE:
break;
#if 0
case HAL_PARSER_RESET:
PARSER_ActionFilter( 0, PARSER_ENABLE_ALL, FALSE );
break;
case HAL_PARSER_JPEG_DECODE:
break;
#endif // #if 0
}
return TRUE;
}
void HAL_Display(BYTE bDispType, BYTE bDispAction)
{
switch(bDispType)
{
case HAL_DISPLAY_SPST_DEC: // subpicture or subtitle
DISP_DisplayCtrl(DISP_SPDEC, bDispAction);
break;
case HAL_DISPLAY_SPST1: // subpicture or subtitle
DISP_DisplayCtrl(DISP_SP1, bDispAction);
break;
// Chuan0.75, Add SP2 Case
case HAL_DISPLAY_SPST2:
DISP_DisplayCtrl(DISP_SP2, bDispAction);
break;
//case HAL_DISPLAY_JPEG:
// break;
}
}
//**************************************************************************
// Description : Configure the necessary setting for different title
// Arguments : wDiscType, the specified disc type
// Return : None
// Notice : The function will be done after title detection done
//**************************************************************************
void HAL_SetDiscType(WORD wDiscType)
{
// LLY0.66, Enable Parser NV packet control for DVD title
// And disable it for other title
// Also set SP and NV buffer for DVD title
if(__wDiscType & BOOK_DVD)
{
HAL_ControlParser(HAL_PARSER_NV_ID, TRUE);
// Set NV buffer for parser
PARSER_SetOutBufferAddress(PARSER_ES_NV, DS_NV_BUF_ADDR_ST, DS_NV_BUF_ADDR_END);
}
else
{
HAL_ControlParser(HAL_PARSER_NV_ID, FALSE);
}
// Set SP1/ SP2 buffer address.
PARSER_SetOutBufferAddress(PARSER_ES_SP1, DS_SP1BUF_ADDR_ST, DS_SP1BUF_ADDR_END);
PARSER_SetOutBufferAddress(PARSER_ES_SP2, DS_SP2BUF_ADDR_ST, DS_SP2BUF_ADDR_END);
// LLY2.01, don't configure parser/ servo dump in buffer here.
// Now, it will be set during power-on/ open_close/ title detection
#if 0
// Set parser and servo dump-in buffer
SrcFilter_ConfigBuffer( 0, DS_INPUT_BITBUF_ST,
((DS_INPUT_BITBUF_END-DS_INPUT_BITBUF_ST)/SERVO_BUFSIZE_ALIGN_UNIT) );
#endif // #if 0
}
//*********************************************************************
// Description : Control A/V sync
// Arguments : bType: sync type
// dwParam: STC parameter or V/A master mode
// Return : None
//********************************************************************
void HAL_ControlAVSync(BYTE bType, DWORD dwParam)
{
// LLY2.05, remove HAL_AVSYNC_STEP since decoder will hold STC when pause/ step from CT909
switch(bType)
{
case HAL_AVSYNC_RESYNC:
// DVD_278Micky, fix pause->play video will shake(N->N)[Helbon's DVD title]
// as the STC is reset to a smaller value, cause VOBU_E_PTM control is active.
// the caller must give correct STC value.
DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_AVSYNC, "\n# HAL_AVSYNC_RESYNC !");
// Chuan1.05, Call function to update STC.
// REG_PLAT_TIMER3_VALUE = dwParam;
DISP_UpdateSTC( dwParam, FALSE);
// Resync Video PTS.
__dwDISP_PTS = dwParam;
break;
case HAL_AVSYNC_RESETSYNC: //may not need in 909
// LLY.160, swap the sequence, ie. let "Reset STC" action in the last time
// otherwise, last coming PTS maybe update the STC
// during those two action period
// LLY.105, reset STC and clear audio PTS to reset A/V sync. control
// to fix highlight disappear while repeat DVD-Menu for "Bone Collector"
// [1] Clear audio PTS only while non-SPDIF mode
DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_AVSYNC, "\n#HAL_AVSYNC_RESETSYNC !");
if(__SetupInfo.bAudioDigitalOut !=SETUP_AUDIO_DIGITAL_OUT_SPDIF_RAW&&
__SetupInfo.bAudioDigitalOut !=SETUP_AUDIO_DIGITAL_OUT_SPDIF_PCM)
{
if(__bAudioType==HAL_AUDIO_AC3 || __bAudioType==HAL_AUDIO_MPG || __bAudioType==HAL_AUDIO_LPCM )
{
HAL_WriteAM(HAL_AM_RESET_PTS, 1);
}
}
// [2] Reset STC
// Chuan1.05, Call function to update STC.
// REG_PLAT_TIMER3_VALUE = dwParam;
DISP_UpdateSTC( dwParam, FALSE);
// Reset Video PTS.
__dwDISP_PTS = dwParam;
break;
case HAL_AVSYNC_VIDEOMASTER:
//kevin0.80-2, fix CD-DTS video master => audio hangs
// Chuan0.80a, DivX must do Audio Master.
// LLY1.01, don't do video master while video stream has been skip.
if ( (dwParam) &&
(!(__bAttrPlay & TYPE_CDROM_AUDIO)) &&
(!(__bAttrPlay==ATTR_CDDA)) &&
( (__bVideoID!=HAL_THROW_VIDEO)) )
{
DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_AVSYNC, "\n#HAL_AVSYNC_VIDEOMASTER !");
// LLY2.56, porting Chuan's code to give a offset value for DVD title
// while control Video master or Audio master period
// Otherwise, the audio outptu is easy break from SPDIF-RAW (ex. Panasonic title, "瑈ē")
if (__wDiscType & BOOK_DVD)
{
DISP_VideoMaster(TRUE, 9000); // 9000 means 100msec
}
else
{
DISP_VideoMaster(TRUE, 0);
}
HAL_WriteAM( HAL_AM_VIDEO_UPDATED_STC, 0);
HAL_WriteAM( HAL_AM_VIDEO_MASTER, 1);
if (__bAttrPlay == ATTR_AVI)
HAL_WriteAM( HAL_AM_PROC2_WAIT_STC, 1); //otherwise, audio updates STC immediately, and video will skip
else
HAL_WriteAM( HAL_AM_PROC2_WAIT_STC, 0);
}
else //HAL_AVSYNC_AUDIOMASTER
{
DBG_Printf(DBG_THREAD_CHEERDVD, DBG_INFO_AVSYNC, "\n#HAL_AVSYNC_AUDIOMASTER !");
// LLY2.56, porting Chuan's code to give a offset value for DVD title
// while control Video master or Audio master period
// Otherwise, the audio outptu is easy break from SPDIF-RAW (ex. Panasonic title, "瑈ē")
if (__wDiscType & BOOK_DVD)
{
DISP_VideoMaster(FALSE, 9000); // 9000 means 100msec
}
else
{
DISP_VideoMaster(FALSE, 0);
}
// Chuan0.70, HAL_AM_VIDEO_UPDATED_STC is no use now.
// HAL_WriteAM( HAL_AM_VIDEO_UPDATED_STC, 1);
HAL_WriteAM( HAL_AM_VIDEO_MASTER, 0);
}
// Chuan1.00, Always report Audio STC updated at first time.
HAL_WriteAM( HAL_AM_RESET_PTS, 1);
break;
// LLY2.77, add new case to disable the mechanism: audio STC - STC > 2sec,
// then audio buffer will be reset when play command
case HAL_AVSYNC_2SEC_LIMIT:
// Grievous2.77, fix A/V sync control for audio STC is great than STC 2 second
// will clean audio buffer while playing .avi file.
HAL_WriteAM(HAL_AM_AV_SYNC_2SEC_CONDITION,0);
break;
default:
break;
}
}
//************************************************************************
// Description : Issue some action once at initial time
// 1.Issue total S/W reset
// 2.Download micro-code and initialize chip
// 3.Initial Video
// 4.Inital Audio
// Arguments : None
// Return : None
//************************************************************************
void HAL_PowerOnInit(void)
{
// Step 9 : Total s/w reset
// wyc1.24a, code to decide doing W99AV_RESET_TOTAL or not. Add it is because now we will move display LOGO code to the place that before
// W99AV_PowerOnInitial, so not need to H/W reset to avoid video become black.
HAL_Reset(HAL_RESET_TOTAL); // ?? remvoe it since nobody implement it ??
// Step 10 : Initial Video and Audio
HAL_InitVideo();
HAL_InitAudio();
// Micky2.14,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -