?? servo.c
字號:
// Arguments : None
// Return : TRUE/FALSE
// Side Effect :
// ***********************************************************************
BIT SERVO_Init()
{
//LJY2.80, initialize some global variables
bThreshold = 1;
_dwVBThreshold = SERVO_DEFAULT_VIDEO_THRESHOLD;
_dwABThreshold = SERVO_DEFAULT_AUDIO_THRESHOLD;
cpinfo.bCPS_Type = 0 ;
cpinfo.bRegionInfo = 0 ;
// TCC276, move from SERVO_SetSectors so that the performance is better.
// SYNC mode, STC rising edge, REQ & ACK hight active
// disable ERROR, STC high/low width > 20ns,
// none_SYNC , 2064 format
// W99AV_WriteRegDW(DICR, 0x242f, 0x0);
W99AV_WriteRegDW(DICR, 0x2423, 0x0); // W99420
// W99AV_WriteRegDW(DICR, 0x2421, 0x0); // W99420
// disable SYNC & DATA & EDC error interrupt
W99AV_WriteRegDW(DIENR, 0x0, 0x0);
//REQ enable & disable EDC
W99AV_WriteRegDW(DCR, 0x1, 0x0);
//LJY0.90, remove "W99AV_DM_UDE_CDDA" setting for non-byte swap.
// W99AV_WriteDM (W99AV_DM_UDE_CDDA, 0) ;
return TRUE;
}
// ***********************************************************************
// Function : SERVO_OpenTray
// Description : Open the tray of dvd-rom
// Arguments : None
// Return : TRUE/FALSE
// Side Effect :
// ***********************************************************************
//DWORD __dwOpenCloseCheckStart = 0 ;
BYTE __bCloseCommand = 1 ;
BIT SERVO_OpenTray()
{
cpinfo.bCPS_Type = 0 ;
cpinfo.bRegionInfo = 0 ;
gbServoRunning = FALSE ; // TCC172r, disable servo running after open
// UDE open command
//UDE_ClearPacket () ; //LJY2.31, remove UDE_ClearPacket
aPacket[0] = 0x00 ; //none paramater
aPacket[1] = UDE_COMMAND_OPENTRAY ; //open
if (UDE_SendUDECmd(aPacket) != TRUE)
return ERROR;
//__dwOpenCloseCheckStart = UTL_GetSysTimer () ;
__bCloseCommand = 0 ;
return TRUE;
}
// ***********************************************************************
// Function : SERVO_CloseTray
// Description : Close the tray of dvd-rom
// Arguments : None
// Return : TRUE/FALSE
// Side Effect : None
// ***********************************************************************
BIT SERVO_CloseTray()
{
//UDE_ClearPacket () ; //LJY2.31, remove UDE_ClearPacket
aPacket[0] = 0x00 ; // none paramater
aPacket[1] = UDE_COMMAND_CLOSETRAY ; // close
if (UDE_SendUDECmd(aPacket) != TRUE)
return ERROR;
//__dwOpenCloseCheckStart = UTL_GetSysTimer () ;
__bCloseCommand = 1 ;
return TRUE ;
}
// ***********************************************************************
// Function : SERVO_CheckTrayStatus
// Description : Used to check if cd/dvd-rom tray is closed
// Arguments : None
// Return : tray status
// Side Effect :
// ***********************************************************************
//LJY1.25, change SERVO_CheckTrayCLosed() to SERVO_CheckTrayStatus() for more general usage.
BYTE SERVO_CheckTrayStatus ()
{
_bSERVOTmp1 = (UDE_GetStatus () & UDE_STATUS_TRAY) ;
if (_bSERVOStatus == UDE_STATUS_COMMAND_ERROR)
{
return SERVO_COMMAND_FAIL ;
}
else
{
return _bSERVOTmp1;
}
}
// ***********************************************************************
// Function : SERVO_CheckTrayClosed
// Description : Used to check if cd/dvd-rom tray is closed
// Arguments : None
// Return : TRUE : Tray closed
// FALSE : Tray is not closed
// Side Effect :
// ***********************************************************************
#ifdef SUPPORT_PORTABLE_PROJECT //LJY2.37, port KCHong's code
#pragma NOAREGS // called in ISR
#pragma DISABLE // will disable all interrupt for the duration of function
#endif
BYTE SERVO_CheckTrayClosed ()
{
#ifdef SUPPORT_PORTABLE_PROJECT
// TCC172, must check if command fail.
if(__bTopInitial)
{
__bTopOpen=FALSE;
return TRUE;
}
// Modified for portable, begin, KCHong, 20031117
__bTopOpen =__sbInSwitch;
if(__bTopOpen)
return FALSE;
else
return TRUE;
// Modified for portable, end, KCHong, 20031117
#endif
return FALSE;
}
// ***********************************************************************
// Function : SERVO_GetDiscStatus
// Description : Used to check if there's title in dvd-rom.
// Will check if tray is closed first.
// Arguments : pStatus : Not used
// Return : SERVO_HAVEDISC : Have disc in tray
// SERVO_NODISC : No disc in tray
// Side Effect : If return SERVO_NODISC, maybe due to some command fail rather than really no disc.
// ***********************************************************************
BYTE SERVO_GetDiscStatus(PBYTE pStatus)
{
//LJY1.25, no need.
#if 0
// TCC274, if from H/W booting we will do once time to avoid detect as NO_DISC.
if (__bBootFromHW)
{
#ifndef COUNTING_BY_LOOP
_dwSERVOCnt1 = UTL_GetSysTimer() ;
while (1)
{
// check if IR keys pressed
//LJY1.21, use UTL_QueryCapability() instead of "if ( ( __bISRKey == KEY_OPEN_CLOSE ) || (__bISRKey==KEY_POWER) )"
if(UTL_QueryCapability(QUERY_ABORT_MAINFLOW))
{
__bSERVOErrMsg = SERVO_ERROR_USERABORT ;
return SERVO_NODISC ;
}
if (SERVO_CheckTrayStatus () == TRAY_CLOSED)
{
#if defined(_DEBUG_INFO) && defined(SERIAL_DEBUG)
printf ("\nTray Closed !\n") ;
#endif
break ;
}
// TCC161, check if dvdrom tray opened by outer forces.
if ((UTL_GetSysTimer() - _dwSERVOCnt1) >= COUNT_5_SEC)
{
return SERVO_NODISC ;
}
}
#else
_dwSERVOCnt1 = 0 ;
while (_dwSERVOCnt1++ < LOOP_COUNT)
if (SERVO_CheckTrayStatus () == TRAY_CLOSED)
{
#ifdef SUPPORT_PRINTF
printf ("Tray Closed !\n") ;
#endif
break ;
}
#endif
// wyc.274j-2-nodisc, set this vairable to FLASE to make next time will not do this function here again.
__bBootFromHW = FALSE;
}
#endif
// TCC019, move to here
if (!_WaitStable (WAITSTABLE_SHOW_INFO))
{
//LJY1.05, wiatstable failed amy caused by time-out or no disc
if(__bSERVOErrMsg == SERVO_ERROR_NODISC)
return SERVO_NODISC;
else if(__bSERVOErrMsg == SERVO_ERROR_USERABORT) //LJY1.05-2, add the judgement of user abort(IR key)
return SERVO_USER_ABORT;
else if(__bSERVOErrMsg == SERVO_ERROR_LOADDISC) //LJY1.25, support opentray when servo fails to close tray.
return SERVO_LOADDISC_FAILED;
else
return SERVO_WAITSTABLE_TIMEOUT ;
}
else
return SERVO_HAVEDISC;
}
// ***********************************************************************
// Function : SERVO_ReadTOC
// Description : [To DVD title]
// - Read Copy Information and read disc key if css protected.
// [To Other Title]
// Read TOC and store to External memory
// Force the CD-module to read the TOC of the CD
// The CD-Module pass all track info .This track info
// consist of TRACK NUMBER , CONTROL & ADDRESS,
// ABSOLUTE START TIME (min:sec:frame)
// Arguments : total session (No-use now)
// Return : TRUE/FALSE
// Side Effect :
// ***********************************************************************
BIT SERVO_ReadTOC(BYTE TotalSession)
{
BYTE bLength, bSession_end, bTrackLastSession; // LJY275, for multisession
BYTE bRxd, bNum ;
extern DWORD __dwTimeTorelence; // TCC171, for cdrom decoding torelence time
_bSERVODiscType = DISC_TYPE_DVD;
_bDMASector = 64 ;
__bCurrentIF=BITSTREAM_DVDIF ;
__bServoAutoCtrl=TRUE; // TCC171
__dwTimeTorelence = 0 ;
// TCC1.73, initial __dwSectorLastSession to 0. Or dvd will fail after playing the Polydor CDDA title(Start position of 1st track in not 0)
__dwSectorLastSession = 0 ;
_bLastSession = 0; //LJY275, for multisession
// TCC277, set default SCMS
cpinfo.bCGMS = SERVO_CGMS_NONE ;
W99AV_WriteDM (W99AV_DM_SCMS, 1) ; // No copyright restriction for non-CSS title
//UDE_ClearPacket () ; //LJY2.31, remove UDE_ClearPacket
aPacket[0] = 0x00; // paramater length is 0
aPacket[1] = UDE_COMMAND_GETDISCTYPE ; // UDE : GetDiscType Command
//use have return function
if (!UDE_SendUDECmd(aPacket))
{
return ERROR;
}
if (_bUDEData[0]==0x02)
{
// CD title
#ifdef SUPPORT_PRINTF
printf("\nCD Type Title ");
#endif
goto TocRead ;
}
else if (_bUDEData[0] != 0x01)
{
// No Valid Disc Type title
#ifdef SUPPORT_PRINTF
printf("\nNo Valid Disc Type (%x) ",_bUDEData[0]);
#endif
return ERROR;
}
//DVD title
#ifdef SUPPORT_PRINTF
printf("\nDVD Title ");
#endif
if(!SERVO_ReadCopyInfo())
{
#ifdef SUPPORT_PRINTF
printf ("Read Copy Info. Fail !\n") ;
#endif
}
#ifdef SUPPORT_PRINTF
else
{
int i, j ;
printf ("CPS Type = %u\n", cpinfo.bCPS_Type) ;
printf ("Region [") ;
i = 1 ;
for (j=1;j<7;j++)
{
if (!(cpinfo.bRegionInfo & i))
printf ("%d, ", j) ;
i<<=1 ;
}
printf ("]\n") ;
}
#endif
if (cpinfo.bCPS_Type) // CSS Title
{
// SERVO_ReadDiscKey ();
if (!SERVO_ReadDiscKey ())
{
#ifdef SUPPORT_PRINTF
printf ("Read Disc Key fail !\n") ;
#endif
return FALSE ;
}
// Added by Chern Shyh-Chain, 08-30-2001, BEGIN
// Reinitialize the variables for title key store when a new DVD title was inserted.
for( _bSERVOTmp2 = 0; _bSERVOTmp2 < MAX_TITLE_KEY_NUM; _bSERVOTmp2 ++ )
{
_TitleKeyCopyInfoStore[_bSERVOTmp2].dwTitleKey32Bit = NULL_TITLE_KEY;
_TitleKeyCopyInfoStore[_bSERVOTmp2].bTitleKey8Bit = NULL_TITLE_KEY;
}
_CurrentTitleKeyCopyInfo.dwTitleKey32Bit = NULL_TITLE_KEY;
_CurrentTitleKeyCopyInfo.bTitleKey8Bit = NULL_TITLE_KEY;
// Added by Chern Shyh-Chain, 08-30-2001, END
}
#ifdef SUPPORT_PRINTF
printf ("Disc Type is DVD\n") ;
#endif
return TRUE;
TocRead:
//VCD
#ifdef SUPPORT_PRINTF
printf("\nInto TOC ...");
#endif
_bSERVODiscType = DISC_TYPE_VCD;
// LLY.273, change the desired IRAM extension code -- CSS
// UCODE_LoadCode(UCODE_IRAMEXT, UCODE_IRAMEXT_OGT); //LJY1.24a, unnecessary.
_dwDiscKey [0] = 0 ; // TCC276, reset value
//LJY1.00, share TOC buffer with servo
#ifndef TOC_SHARE
_trk_TOC = (TRKINFO*)&__bPool [LENGTH_SHAREPOOL-512] ;
#endif
_sessioninfo_TOC = (SESSIONINFO*) &__bPool [LENGTH_SHAREPOOL-512 -600] ; // LJY275, for multi-session
_bDMASector = 32 ;
// TCC170, w99420 use cdif when not dvd title
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -