📄 hal.c
字号:
break;
}
}
// LLY.276p, re-arrage the control procedure
//#######################################################################
// Function : HAL_AdjustTVMode
// Description : Set the video output to match the current TV mode
// after the first I is detected.
// : need do the setting to video output and Video DAC
// Parameters : none, but reference global variable
// __SetupInfo.bTVSystem, current TV mode selection
// __btNTSCBitStream, current bitstream format
// Return : None
// Changed : __wW99AVVCRLow, __dwW99AVVDRR,
// __wW99AVHDSR, __wW99AVHDWR, __bTVType
// Side Effect :
// Notice : Calculate all necessary info. first,
// Then, do all setting together to avoid delay transition
//#######################################################################
// Notice: Must add "#pramga NOAREGS" w/ each APIs if it will be called by HAL_AdjustTVMode()
// So, if anyone add any function with HAL_AdjustTVMode(), please check it more
// Current sub-APIs with will be called by HAL_AdjustTVMode()
// [1] HAL_PreFillBuffer() : It's unnecessary, because it will be called while CDDA playing
// And, INT_IFD don't happen for CDDA playing
// [2] W99AV_WriteDRAMData() : Done !!
// [3] PANEL_Output() : Done !!
// [4] _GetVideoModeInfo() : Done !!
// [5] _ZoomVideo() : Done !!
// [6] _AspectRatioSetting() : Done !!
// [7] _TVModeSet() : Done !!
// [8] OSD_FillHeadtoDRAM() : Done !!
#pragma NOAREGS // may be called in ISR
void HAL_AdjustTVMode(void)
{
// LLY.047P-1, an indicator for TV mode switching of SPVA
// DRAM[0x94]: W99AV_DRAM_TV_SWITCHING
// 0x0: keep original SPVA value;
// 0x10000: SPVA=SPVA-96, original SPVA will keep in DRAM (P->N)
// 0x20000: SPVA=SPVA+96, original SPVA will keep in DRAM
DWORD dwSPVA=0x0;
BYTE bSPVAWrite=FALSE;
BYTE bNewTarget;
// Step 1 : Initialize some varialbe -- LLY.051
// LLY.276p, it's unnecessary to gvie default value of bNewTarget
// Becaue step 7 will give correspond value base on setup info.
//bNewTarget=SETUP_SCREEN_TV_SYSTEM_PAL;
_wVBICTLR=NULL; // only P2N or N2P will be given value, so need default value
_dwFrameRateCTL=NULL; // only P2N or N2P will be given value, so need default value
__bMPEGVideoMode=MPEG_VIDEO_MODE_PAL; // LLY.102p
// Step 2: Prefill audio buffer near fullness before TV encoder programming
// wyc.101 ,to fix the problems of after adjusting TV mode, the CDDA audio
// will not continuous, so before executing adjusting TV mode, we execute
// SERVO_Monitor() to make the audio buffer full to avoid the audio buffer empty.
// LLY.274, checking playing mode method has updated
//if ((__bModePlay == MODE_PLAYCDDA) && __btPlaying && (__bKey == KEY_TVMODE))
if((__bAttrPlay==ATTR_CDDA) && __btPlaying && (__bKey == KEY_TVMODE))
{
HAL_PreFillBuffer(HAL_FILL_AUDIO_BUFFER, FILL_CDDA_BUFFER_FULL);
}
// Step 3 : tell RISC for TV mode switching in SPVA
// LLY.276p, initial with zero for dwSPVA value
W99AV_WriteDRAMData(W99AV_DRAM_TV_SWITCHING, 0x0); // dwSPVA);
// Step 4 : Base on __SetupInfo.bTVSystem to decide bNewTarget/ __bMPEGVideoMode
switch(__SetupInfo.bTVSystem)
{
case SETUP_SCREEN_TV_SYSTEM_NTSC:
// change target to NTSC TV
// LLY.276p, it's unnecessary to gvie value of bNewTarget
// Becaue step 7 will give correspond value base on setup info.
//bNewTarget=SETUP_SCREEN_TV_SYSTEM_NTSC; // LLY.046, rename NTSC_TV to SETUP_SCREEN_TV_SYSTEM_NTSC
__bMPEGVideoMode=MPEG_VIDEO_MODE_NTSC; // LLY.102p
break;
case SETUP_SCREEN_TV_SYSTEM_AUTO:
// LLY2.80, enable this define again.
// Because, we expand __bLOGO meaning w/ bit[7] to tell LOGO display from open/close action
// And, remove the extra procedure from _OSD_ShowMPEG()
// LLY.276p, don't use this method because the checking condition is not robust
// ex. TV mode switching to AUTO mode will fail while CDDA/ MP3 playing w/ LOGO
// And, remove the procedure into _OSD_ShowMPEG() -- only do frame rate conversion
// while enable this definition.
#ifdef LET_LOGO_TVMODE_SAME_AS_PREVIOUS_VIDEO
// LLY.161-1, don't re-program TV mode while KEY_OPEN_COLSE
// ie. let it same as previous video TV type
//if(_bLOGO)
//if(_bLOGO && __bFMMenuID==FM_MENU_NONE)
if( (__bLOGO & LOGO_FROM_OPEN) && (__bLOGO & LOGO_DEFAULT) )
{
bNewTarget=__bTVType;
if(bNewTarget==SETUP_SCREEN_TV_SYSTEM_NTSC)
__bMPEGVideoMode=MPEG_VIDEO_MODE_NTSC;
else
__bMPEGVideoMode=MPEG_VIDEO_MODE_PAL;
}
else
#endif // #ifdef LET_LOGO_TVMODE_SAME_AS_PREVIOUS_VIDEO
{
if (__btNTSCBitStream)
{
// change target to NTSC TV(same as bitstream format)
bNewTarget=SETUP_SCREEN_TV_SYSTEM_NTSC; // LLY.046, rename NTSC_TV to SETUP_SCREEN_TV_SYSTEM_NTSC
__bMPEGVideoMode=MPEG_VIDEO_MODE_NTSC; // LLY.102p
// Send the information when system is in Auto-mode
PANEL_Output ( MSG_PALTITLE, FALSE);
}
else
{
// LLY.276p, give bNewTarget value while AUTO TVMODE
bNewTarget=SETUP_SCREEN_TV_SYSTEM_PAL;
// Send the information when system is in Auto-mode
PANEL_Output ( MSG_PALTITLE, TRUE);
}
}
break;
// LLY.102p, change target to PAL TV but MPEG must set as NTSC mode
case SETUP_SCREEN_TV_SYSTEM_PAL_M:
// LLY.276p, it's unnecessary to gvie value of bNewTarget
// Becaue step 7 will give correspond value base on setup info.
//bNewTarget=SETUP_SCREEN_TV_SYSTEM_PAL;
__bMPEGVideoMode=MPEG_VIDEO_MODE_NTSC;
break;
// LLY.101-2, assign default TV mode as PAL
case SETUP_SCREEN_TV_SYSTEM_PAL:
case SETUP_SCREEN_TV_SYSTEM_PAL_N: // LLY.102p
default:
break;
}
// LLY2.80, clear bit[7] immediately because nobody will refer it
__bLOGO &= ~(LOGO_FROM_OPEN);
// Step 5: Re-calculate video configure relative info., ex VDS/VDW/HDS/HDW/VCR
_GetVideoModeInfo();
// LLY.276p, Remove "set VCR command" in last stage and issue all command together
// To avoid the delay transition pheonomenon
// Step 6: Calculate some info relative to SPST display
switch(__bMPEGVideoMode)
{
case MPEG_VIDEO_MODE_PAL:
// DVD022, fix SP/OGT display position is too low bug
// enable VBICTLR[8]:N2P for SP/OGT control
if(__btNTSCBitStream) // N2P
{
_wVBICTLR=0x0100; // enable bit[8] in VBICTLR
_dwFrameRateCTL=0x00010000; // DRAM[0x9f]: NTSC --> PAL
}
break;
case MPEG_VIDEO_MODE_NTSC:
// DVD022, fix SP/OGT display position is too low bug
if(!__btNTSCBitStream) // P2N
{
// LLY0.86, Splite CT9928AF & CT908 mode
// CT9928AF: VBICTLR[9] has different meaning for N2P or P2N mode
// CT908: VBICTLR[9] has same value for N2P or P2N mode
// Notice: RISC code will assign this value to VCR[17:15] directly
_wVBICTLR = 0x0100;
_dwFrameRateCTL = 0x00020000; // DRAM[0x9f]: PAL --> NTSC
// DVD.037, fix DVD's SP is abnormal while TV mode switch bug
if(__wDiscType & BOOK_DVD)
{
// LLY.047P-1, it's unnecessary to calculate desired SPVA
// only to let RISC know how to do
dwSPVA = 0x10000;
bSPVAWrite=TRUE;
}
}
break;
}
// Step 7: Must assign corrent TV target base on __SetupInfo.bTVSystem
// while TVMODE is not TVMODE_AUTO -- LLY.101-2
if(__SetupInfo.bTVSystem!=SETUP_SCREEN_TV_SYSTEM_AUTO)
bNewTarget=__SetupInfo.bTVSystem;
// LLY.276p, Remove "program TV encode action" in last stage
// and issue all command together to avoid the delay transition pheonomenon
// Step 8 : always read-back HLI status, because other API will refer it -- LLY.103-1
// don't put this procedure only within DVD title
// LLY2.78b-3, using pre-define name instead of dram address
//W99AV_ReadDRAMData(0x47, &_dwHLIState);
W99AV_ReadDRAMData(W99AV_DRAM_HLI_STATE, &_dwHLIState);
// LLY.276p begin ...
// Step 9: Collect all setting action together to avoid delay transition pheonomeon
// Notice : Can't insert any procedure which will take more time between
// [9-4] and [9-6], otherwise, the delay transition phenomenon will happen
// [9-1]: Write some DRAM value for SPST problem -- DVD.037
// Fix DVD's SP is abnormal while TV mode switch
if(__wDiscType & BOOK_DVD)
{
// Set "W99AV_DRAM_TV_SWITCHING" value as dwSPVA
// Notice: BA5580E need reference FullSP flag too.
// [1] SPVA value is update : bSPVAWrite==TRUE
// [2] No HLI exist : _dwHLIState == FALSE
if(bSPVAWrite && !HIWORD(_dwHLIState) ) // DVD.039
{
// LLY.047P-1, it's unnecessary to set desired SPVA value
// only to let RISC know how to do
W99AV_WriteDRAMData(W99AV_DRAM_TV_SWITCHING, dwSPVA); // DRAM[0x94]
}
}
// [9-2] Always specify this value, then SVCD flash problem can be fixed -- DVD0.40-2
W99AV_WriteDRAMData(W99AV_DRAM_NTSC_PAL, _dwFrameRateCTL); // DRAM[0x9f]: frame rate/ sp control
// [9-3] Do zoom video and aspect ratio setting by "set video configure 1"
// & "clip command"
// Notice: Don't delay too long between [9-4] & [9-5] to make sure
// "set video configure 1 & 2" command can be done nearly
_ZoomVideo();
// Micky2.32, add a function to decide switching for HD/ FD
// Must pur after _ZoomVideo, as the function will reference _bVideoDisplayMode
HAL_SetDecodeMode();
_AspectRatioSetting(__SetupInfo.bAspectRatio);
// LLY0.86, swap the [9-3] & [9-4] procedure
// Because, F/W maybe control _wVBICTLR value within _AspectRatioSetting()
// [9-4] Fix OGT/SP position wrong bug -- DVD0.36
W99AV_WriteDRAMData(W99AV_DRAM_VBICTL_98, _wVBICTLR); // DRAM[0x9b],
W99AV_WriteDRAMData(W99AV_DRAM_VBICTL_CHANGE, 0xFFFFFFFF); // DRAM[0x9a]
// [9-5] Set correct video timing generator mode to PAL/NTSC in VCR
// Notice: Issue SVC2 command instead of "write REG command"
// because some info. must tell RISC by "SVC2" command
__dwW99AVCmdArg [0] = 2 ;
__dwW99AVCmdArg [1] = CMDARG_SVC2 ;
__dwW99AVCmdArg [2] = MAKELONG (__wW99AVVCRLow, __wW99AVVCRHigh) ;
W99AV_CommandN (COMMAND_SVC2) ;
// [9-6] Programming TV encoder depending on your choice -- LLY.101-2
// Assign __bTVType value for TVModeSet() base on bNewTarget
// --> the new TV mode is same as previous mode or
// --> the new video output is same as previous mode
// LLY0.84a, need check how to integrate the checking for progressive scan
// Now, always disable this checking for temp solution
// Otherwise, progressive scan can't work w/o calling _TVModeSet()
//if(bNewTarget!=__bTVType || _bVideoOutput!=__SetupInfo.bVideoOutput)
{
__bTVType=bNewTarget;
_TVModeSet();
}
// LLY.276p end ...
// Step 12: Prefill audio buffer near fullness before reload osd header -- wyc.101
// LLY.274, checking playing mode method has updated
//if ((__bModePlay == MODE_PLAYCDDA) && __btPlaying && (__bKey == KEY_TVMODE))
if((__bAttrPlay==ATTR_CDDA) && __btPlaying && (__bKey == KEY_TVMODE))
{
HAL_PreFillBuffer(HAL_FILL_AUDIO_BUFFER, FILL_CDDA_BUFFER_FULL);
}
// Step 13: Re-load OSD header to adjust start line for each region -- LLY.101
// And, redraw VCD3.0 area if necessary -- LLY.275
// Notice: Must put HAL_RedrawVCD30Area() into OSD_FillHeadtoDRAM()
// Because, OSD module will keep current and new desired TV mode
// And, check if do redraw VCD30 area
// CoCo1.21, modify function prototype
OSD_FillHeadtoDRAM(OSD_FILLHEADER_RUNTIME); // LLY.101
// Step 14: Prefill audio buffer near fullness before exit HAL_AdjustTVMode() -- wyc.101
// LLY.274, checking playing mode method has updated
//if ((__bModePlay == MODE_PLAYCDDA) && __btPlaying && (__bKey == KEY_TVMODE))
if((__bAttrPlay==ATTR_CDDA) && __btPlaying && (__bKey == KEY_TVMODE))
{
HAL_PreFillBuffer(HAL_FILL_AUDIO_BUFFER, FILL_CDDA_BUFFER_FULL);
}
#ifdef TFT_CONTROL //yhtang_0603
{
if(bTFT_TVMode!=__bMPEGVideoMode)
{
UTL_DelayTime(COUNT_100_MSEC, FALSE);
_TFT_Set_TvMode(__bMPEGVideoMode);
}
#ifdef YHTANG_DEBUG
_printf("\n hal.c dvd status ,change tv mode");
#endif
}
#endif
}
// *********************************************************************
// Function : HAL_TVSetAPS
// Description : Program the desired APS function and keep it's value.
// Arguments : bType, the desired APS type
// Return : none
// Side Effect :
// *********************************************************************
void HAL_TVSetAPS ( BYTE bType )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -