📄 servo.c
字号:
for( bIndex=0; bIndex<_sessioninfo_TOC[0].bLastSession; bIndex++ ) { if( (bTrackNum >= _sessioninfo_TOC [bIndex].bFirstTrack) && (bTrackNum <= _sessioninfo_TOC [bIndex].bLastTrack) ) { break ; } } if( bIndex == _sessioninfo_TOC[0].bLastSession ) { bIndex=0; //use the first session as default } _bSrvDiscType = _sessioninfo_TOC[bIndex].bDiscType; bIndex = bTrackNum - _sessioninfo_TOC[0].bFirstTrack; // Set track type to DATA TRACK if disc type is DVD. // prevent stop->play fast/slow become invalid problem// if (_bSrvDiscType == DISC_TYPE_DVD) if( !(_bSrvDiscType & DISC_TYPE_CD) ) //LJY0.75, to conform with servo's definition { *pbTrackCtl = DATA_TRACK; return TRUE; } else if( _bSrvDiscType == DISC_TYPE_CDI ) { *pbTrackCtl = 0x40; return FALSE; } *pbTrackCtl = _trk_TOC[bIndex].Ctl; // ADR/Ctl read from ude dvdrom // cdda -> 1 // vcd -> 41 // MP3 m1 -> 61 // MP3 m2 -> 41 //if (*pTrackCtl & 40) if( *pbTrackCtl & 0x40 ) *pbTrackCtl = DATA_TRACK; // ** DVD-TCH0.19; else // Audio Track { *pbTrackCtl = 0x0; }/// *pStartPos = _MSFtoHSG (_trk_TOC[bIndex].Min, _trk_TOC[bIndex].Sec, _trk_TOC[bIndex].Frm) ; *pdwStartPos = COMUTL_MSFtoHSG( MAKE_MSF(_trk_TOC[bIndex].Min, _trk_TOC[bIndex].Sec, _trk_TOC[bIndex].Frm)) ; return TRUE;}//LJY278, for pre-start servo// wyc1.06-909, add parameter, when bResumeRead is TRUE, then SERVO will resume to read data when seek command is issued.BYTE SERVO_Seek( ULONG_UNION ulunSeekLBA, BYTE bResumeRead ){ BYTE bRst; OS_LockMutex( &_mServoCmd ); aCMDPacket[0] = SERVO_CMD_SEEK ; aCMDPacket[1] = ulunSeekLBA.b8bit[1]; //LOBYTE(HIWORD(dwSeekLBA)); aCMDPacket[2] = ulunSeekLBA.b8bit[2]; //HIBYTE(LOWORD(dwSeekLBA)); aCMDPacket[3] = ulunSeekLBA.b8bit[3]; //LOBYTE(LOWORD(dwSeekLBA)); aCMDPacket[4] = bResumeRead; bRst = _IssueNewCommand( COUNT_10_SEC ); OS_UnlockMutex( &_mServoCmd ); return bRst;}// F100CSC101a, Set the SERVO cache flush flagvoid SERVO_EnableCacheFlush( void ){ _bFlushServoCache = 0x02; return;}// ***********************************************************************// Function : SERVO_ReadData// Description : Used to read data from ude// 1. Send command according to the disc type// 2. Check if transfer complete// Arguments : dwStartLBA : The starting sector number to read// wSectorNum : number of sectors to read// Return : TRUE/FALSE// Side Effect : // ***********************************************************************BYTE SERVO_ReadData( ULONG_UNION ulunStartLBA, DWORD dwSectorNum, BYTE bBuf ){ BYTE bRst; ULONG_UNION ulunTmp; OS_LockMutex( &_mServoCmd ); ulunTmp.dw32bit = ulunStartLBA.dw32bit + dwSectorNum - 1; aCMDPacket[1] = ulunStartLBA.b8bit[1]; //LOBYTE(HIWORD(dwStartLBA)); aCMDPacket[2] = ulunStartLBA.b8bit[2]; //HIBYTE(LOWORD(dwStartLBA)); aCMDPacket[3] = ulunStartLBA.b8bit[3]; //LOBYTE(LOWORD(dwStartLBA)); aCMDPacket[4] = bBuf; aCMDPacket[5] = ulunTmp.b8bit[1]; //LOBYTE(HIWORD(dwSrvTmp1)); aCMDPacket[6] = ulunTmp.b8bit[2]; //HIBYTE(LOWORD(dwSrvTmp1)); aCMDPacket[7] = ulunTmp.b8bit[3]; //LOBYTE(LOWORD(dwSrvTmp1)); // LLY0.91, tell parser the item as M2F2 format // while playback VCD/ CVD/ SVCD title bitstream. if( ((__wDiscType & BOOK_2X) || (__wDiscType & BOOK_VCD)) && ((__bModePlay == MODE_PLAYMOTION) || (__bModePlay & MODE_STILL)) ) { aCMDPacket[9] = 1; //M2F2 } else { aCMDPacket[9] = 0; } // F100CSC101a, Enable SERVO to do cache flush and re-read data aCMDPacket[9] |= _bFlushServoCache; _bFlushServoCache = 0; // [F100CSC_TODO] This variable will be initiated at SERVO_GetTrackInfo and // SERVO_GetDiscType. It is a must to call this function at first. ???? RISKY // For mini-DVD issue???? (recognized as BOOK_DVD)// if (_bSrvDiscType == DISC_TYPE_DVD) if( !(_bSrvDiscType & DISC_TYPE_CD) ) //LJY0.75, to conform with servo's definition { aCMDPacket[0] = SERVO_CMD_READ_DVD; // UDE : Read_DVD command } else // for non-DVD type, all use cd type if (_bSrvDiscType == DISC_TYPE_VCD) { aCMDPacket[0] = SERVO_CMD_READ_CD; // UDE : Read_CD command if( __bAttrPlay == ATTR_CDDA ) { if( (__bCDDA_DTS == CDDA_PURE) || (__bCDDA_DTS == CDDA_HDCD) ) { aCMDPacket[8] = AUDIO_DATA; } else if( __bCDDA_DTS == CDDA_CDG ) { aCMDPacket[8] = SUBCHANNEL_ENABLE; } else if( __bCDDA_DTS == CDDA_DTS ) //LJY0.90, for non-interpolation { aCMDPacket[8] = INTERPOLATION_DISABLE; // for CD_DTS non-interpolation, w/O subcode } } else { // wyc1.02-909, CD disc all need to disable INTERPOLATION. aCMDPacket[8] = CONTINUOUS_DATA | INTERPOLATION_DISABLE; // for digital data, w/O subcode } } bRst = _IssueNewCommand( COUNT_400_MSEC ); OS_UnlockMutex( &_mServoCmd ); return bRst;}/*--CoCo1.20, reduce code size.#ifndef CSC_MASKBYTE SERVO_ReadDVDCtrlData( BYTE bNum ){ BYTE bRst; cyg_mutex_lock(&_mServoCmd); aCMDPacket[0] = SERVO_CMD_READ_DVD_CTRL_DATA; aCMDPacket[1] = bNum; // servo dump-in buffer number bRst = _IssueNewCommand( COUNT_400_MSEC ); cyg_mutex_unlock(&_mServoCmd); return bRst;}BYTE SERVO_ReadDVDBCAData( BYTE bNum ){ BYTE bRst; cyg_mutex_lock( &_mServoCmd ); aCMDPacket[0] = SERVO_CMD_READ_DVD_BCA; aCMDPacket[1] = bNum; // servo dump-in buffer number bRst = _IssueNewCommand( COUNT_400_MSEC ); cyg_mutex_unlock( &_mServoCmd ); return bRst;}#endif // CSC_MASK*/// ***********************************************************************// Function : SERVO_GetDiscType// Description : Used to get the type of disc// Arguments : None// Return : The disc type of current disc// Side Effect : Must be called after SERVO_ReadTOC// ***********************************************************************WORD SERVO_GetDiscType( void ){ WORD wTmp; //LJY0.76, refer to "_sessioninfo_TOC[0].bDiscType" instead of issuing GetDiscType CMD. _bSrvDiscType = _sessioninfo_TOC[0].bDiscType; switch (_bSrvDiscType) { case DISC_TYPE_DVD : case DISC_TYPE_DVD_RAM: case DISC_TYPE_DVD_R: case DISC_TYPE_DVD_RW: case DISC_TYPE_DVD_PLUS_RW: case DISC_TYPE_DVD_PLUS_R: //LJY0.85 // wyc2.38a-909s, add one mode for DVD plus R dual layer disc. case DISC_TYPE_DVD_PLUS_R_DUAL: wTmp = BOOK_DVD ; SERVO_ReadCopyInfo( ); //LJY0.81, read copyright info for CSS break ; case DISC_TYPE_VCD : wTmp = BOOK_VCD ; break ; case DISC_TYPE_CDI : wTmp = BOOK_CDI ; break ; case DISC_TYPE_CDDA : wTmp = BOOK_CDDA ; break ; default : wTmp = BOOK_UNKNOW ; break ; } return wTmp;}/*--CoCo1.20, reduce code size.BOOL SERVO_EnableRunning ( BIT bGo ){ return TRUE;}*/// ***********************************************************************// Function : SERVO_ReadCopyInfo// Description : Will read the copy information of the dvd title// cpinfo.bCPS_Type = 1 if copy protected// cpinfo.bRegionInfo store the region code information// Arguments : None// Return : TRUE/FALSE// Side Effect :// ***********************************************************************BYTE SERVO_ReadCopyInfo( void ){ BYTE bRst; OS_LockMutex( &_mServoCmd ); aCMDPacket[0] = SERVO_CMD_GET_STATUS; aCMDPacket[1] = GETCOPYRIGHTINFORMATION; // GetCopyrightInformation bRst = _IssueNewCommand( COUNT_400_MSEC ); cpinfo.bCPS_Type = aRETPacket[2]; cpinfo.bRegionInfo = aRETPacket[3]; OS_UnlockMutex( &_mServoCmd ); return bRst;}/*--CoCo1.20, reduce code size.BYTE SERVO_ReadDiscKey( void ){#if 0 // marked by F100CSC_107 DWORD dwTmp; if (!cpinfo.bCPS_Type) // non CSS title return TRUE ; // clear all save title key information since new title inserted for( dwTmp = 0; dwTmp < MAX_TITLE_KEY_NUM; dwTmp ++ ) { _TitleKeyCopyInfoStore[dwTmp].ulunTitleKey.ull64bit = NULL_TITLE_KEY; } // get new disc key PARSER_Command( 0, PARSER_CMD_DISC_KEY, NULL );#endif // 0#if 0//def SUPPORT_PRINTF { 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 return TRUE;}*/BYTE SERVO_ReadTitleKey( DWORD dwStart, BYTE bStore ){#define NO_OF_SECTOR 16 DWORD dwTmp; ULONGLONG_UNION ullunTitleKey; PARSER_ActionFilter( 0, PARSER_ENABLE_COPY_PROTECTION, FALSE ); if (!cpinfo.bCPS_Type) // non CSS title return TRUE ; // Check if the parameter "bStore" overs the boundary, MAX_TITLE_KEY_NUM (defined in "cdinfo.h"). if( bStore > MAX_TITLE_KEY_NUM ) return FALSE; // If this title need to be stored and has been read, we just return TRUE directly. if( bStore && (_TitleKeyCopyInfoStore[bStore - 1].ulunTitleKey.ull64bit != NULL_TITLE_KEY) ) { PARSER_WriteTitleKey( _TitleKeyCopyInfoStore[bStore - 1].ulunTitleKey ); cpinfo = _TitleKeyCopyInfoStore[bStore - 1].CopyInfo; if( cpinfo.bCPS_Type == 1 ) { PARSER_ActionFilter( 0, PARSER_ENABLE_COPY_PROTECTION, TRUE ); } return TRUE; } // wyc2.53-909P, SrcFilter_ReadSectors(__dwSFStreamID, dwStart, dwStart + NO_OF_SECTOR ); dwTmp = PARSER_PRESCAN_TITLE_KEY;// if( PARSER_Command(0, PARSER_CMD_PRESCAN, &dwTmp) ) PARSER_Command( 0, PARSER_CMD_PRESCAN, &dwTmp ); while( !PARSER_QueryEvent(0, PARSER_EVENT_COMPLETED, FALSE) ) { OS_YieldThread( ); } if( !PARSER_QueryEvent(0, PARSER_EVENT_ERROR, FALSE) ) { dwTmp = PARSER_ReadCPRMAI( ); // Need to save this title key???? PARSER_ReadTitleKey( &ullunTitleKey ); if( dwTmp & 0x08 ) // it contains copyrighted information { if( ullunTitleKey.ull64bit == 0 ) { // incorrect title key was fouund and treat this as no CSS protected cpinfo.bCPS_Type = 2; // indicate this title is CSS scrambled but current play range is not CSS protected } else { cpinfo.bCPS_Type = 1; // indicate this title is CSS scrambled but current play range is CSS protected PARSER_ActionFilter( 0, PARSER_ENABLE_COPY_PROTECTION, TRUE ); } } else { cpinfo.bCPS_Type = 2; // indicate this title is CSS scrambled but current play range is not CSS protected } if( bStore ) { _TitleKeyCopyInfoStore[bStore - 1].ulunTitleKey.ull64bit = ullunTitleKey.ull64bit; _TitleKeyCopyInfoStore[bStore - 1].CopyInfo = cpinfo; } } else { cpinfo.bCPS_Type = 2; // indicate this title is CSS scrambled but current play range is not CSS protected } return TRUE;#if 0#define NO_OF_SECTOR 10 DWORD dwTimeNow ; extern WORD __wCDROMReadingOffset ; // Added by Chern Shyh-Chain, 08-30-2001, BEGIN // Check if the parameter "bStore" overs the boundary, MAX_TITLE_KEY_NUM (defined in "cdinfo.h"). if( bStore > MAX_TITLE_KEY_NUM ) return FALSE; // If this title need to be stored and has been read, we just return TRUE directly. if( bStore && ((_TitleKeyCopyInfoStore[bStore - 1].dwTitleKey32Bit != NULL_TITLE_KEY) || (_TitleKeyCopyInfoStore[bStore - 1].bTitleKey8Bit != NULL_TITLE_KEY)) ) { return TRUE; }// Added by Chern Shyh-Chain, 08-30-2001, END if (!cpinfo.bCPS_Type) // non CSS title return TRUE ; __bSERVOErrMsg = SERVO_ERROR_AUTH ; //UTL_ReadSectors (dwSectorNumber, NO_OF_SECTOR, (BYTE)NULL) ; //--CoCo1.20, reduce code size. // TCC275, must add __wCDROMReadingOffset dwTimeNow = __dwW99AVECCBASE + __wCDROMReadingOffset*2064L/4 ; RETRY_TITLEKEY: W99AV_ReadDRAMData (dwTimeNow+1, &_dwSERVOTmp) ; cpinfo.bCGMS = (BYTE) (_dwSERVOTmp & 0x3000) >> 12 ; // TCC2.79, CGMS in bit 4~5 if ((HIBYTE(LOWORD(_dwSERVOTmp)) & 0x80) != 0x80) // This sector is not scrambled { dwTimeNow += 516; //2064/4 if (dwTimeNow >= __dwW99AVECCBASE +5160)//2064/4*10 return FALSE ; goto RETRY_TITLEKEY ;}#ifdef USE_LITTLE_ENDIAN _pbSERVOTmp1 = (BYTE *) &_dwTitleKey[0] ; *(_pbSERVOTmp1+3) = LOBYTE(LOWORD(_dwSERVOTmp)) ; W99AV_ReadDRAMData (dwTimeNow+2, &_dwSERVOTmp) ; *(_pbSERVOTmp1+2) = HIBYTE(HIWORD(_dwSERVOTmp)) ; *(_pbSERVOTmp1+1) = LOBYTE(HIWORD(_dwSERVOTmp)) ; *(_pbSERVOTmp1+0) = HIBYTE(LOWORD(_dwSERVOTmp)) ; _pbSERVOTmp1 = (BYTE *) &_dwTitleKey[1] ; *(_pbSERVOTmp1+3) = LOBYTE(LOWORD(_dwSERVOTmp)) ; *(_pbSERVOTmp1+2) = 0 ; *(_pbSERVOTmp1+1) = 0 ; *(_pbSERVOTmp1+0) = 0 ;#else _pbSERVOTmp1 = (BYTE *) &_dwTitleKey[0] ; *(_pbSERVOTmp1+0) = LOBYTE(LOWORD(_dwSERVOTmp)) ; W99AV_ReadDRAMData (dwTimeNow+2, &_dwSERVOTmp) ; *(_pbSERVOTmp1+1) = HIBYTE(HIWORD(_dwSERVOTmp)) ; *(_pbSERVOTmp1+2) = LOBYTE(HIWORD(_dwSERVOTmp)) ; *(_pbSERVOTmp1+3) = HIBYTE(LOWORD(_dwSERVOTmp)) ; _pbSERVOTmp1 = (BYTE *) &_dwTitleKey[1] ; *(_pbSERVOTmp1+0) = LOBYTE(LOWORD(_dwSERVOTmp)) ; *(_pbSERVOTmp1+1) = 0 ; *(_pbSERVOTmp1+2) = 0 ; *(_pbSERVOTmp1+3) = 0 ;#endif _dwTitleKey[2] = 0 ;// Added by Chern Shyh-Chain, 05-11-2001, BEGIN // TCC099, for CGMS //if (cpinfo.bCGMS & 0x80) { switch (cpinfo.bCGMS){ case 0: // Copying is permitted without restriction cpinfo.bCGMS = SERVO_CGMS_NO_RESTRICTION ;#ifdef ENABLE_SCMS W99AV_WriteDM (W99AV_DM_SCMS, 1) ;#endif break ; case 1: // reserved cpinfo.bCGMS = SERVO_CGMS_RESERVED ; break ; case 2: // One generation of copies may be made cpinfo.bCGMS = SERVO_CGMS_ONE_COPY ;#ifdef ENABLE_SCMS W99AV_WriteDM (W99AV_DM_SCMS, 0) ;#endif break ; case 3: // No copping is permitted cpinfo.bCGMS = SERVO_CGMS_NO_COPY ;#ifdef ENABLE_SCMS W99AV_WriteDM (W99AV_DM_SCMS, 2) ;#endif break ; } }// Added by Chern Shyh-Chain, 05-11-2001, END // TCC2.79-2, for checking the title ("ATTILA(R2)" from GBM) that report as CSS enabled but not scrambled. // The title has a disc key but title keys are all 0. { // Check if all title keys are 0 if ((_dwTitleKey[0]==0 && _dwTitleKey[1]==0)) { cpinfo.bCPS_Type = 2 ; } else { cpinfo.bCPS_Type = 1 ; } } // End// Added by Chern Shyh-Chain, 08-30-2001, BEGIN if( bStore ) { bStore -= 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -