⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 servo.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 3 页
字号:
//////////////////////////////////////////////////////////////// ***** Big Modification History Area *****// LLY2.80a,//  - remove the codes while define "_ALONE",// ** TCH0.95; define _DUMP_INFO, will show playing range setting + each play range./// #define     _DUMP_INFO// F100CSC_108// Added time-out mechanism: SERVO will response soon, almost immediately,// except SEEK command. The SEEK command will trap the caller.// The Time-out value for all commands except SEEK command is 400ms.// We applied 10s for SEEK command now.#include "winav.h"#ifdef SUPPORT_SERVO_SOURCE //++CoCo2.37p#include <string.h>#include "srcfilter.h"#include "cc.h"#include "infofilter.h"#include "servo.h"#include "osd.h"#include "utl.h"#include "input.h"#include "hal.h"#include "parser.h"//LJY275e#include "comutl.h"#include "servo\srvudeif.h"#define CSC_MASK        // F100CSC_108, for removing uncessary functions //LJY0.68, for CMDIF handshake.MUTEX_T     _mServoAbort;MUTEX_T     _mServoCmd;extern FLAG_T servo_flag_var;//BYTE    __bCurrentIF=BITSTREAM_DVDIF; //--CoCo1.20, reduce code size.TRKINFO _trk_TOC[100];//TRKINFO *_trk_TOC;// LJY275, for multi-session, gdwLeadOutPos removedSESSIONINFO _sessioninfo_TOC[25] ;//SESSIONINFO *_sessioninfo_TOC ;//DWORD   _dwTitleKey [3], _dwDiscKey [4] ;// F100CSC101a,record if SERVO cache needed to flush or not BYTE    _bFlushServoCache = 0;      // default is not need to do flushCOPYINFO    cpinfo ;// Brian0.67extern BYTE aCMDPacket[];extern BYTE aRETPacket[];//BYTE __bCDDA_DTS;BYTE __bCloseCommand = 1 ;BYTE _bSrvDiscType;BYTE _bSRVStatus;// Brian0.66//DWORD   gdwNextLBA; //--CoCo1.20, reduce code size.// Brian0.67BYTE    _bSERVODiscType;BYTE    _bFirstTrack, _bLastTrack, _bFirstSession, _bLastSession;DWORD   _dwStartSector, _dwLeadOutPos;// Added by Chern Shyh-Chain, 08-30-2001, BEGIN// Define the structure to keep the title key (40 bit) and relative copyright informationtypedef struct  tagTITLE_KEY_COPY_INFO_LOG{    ULONGLONG_UNION ulunTitleKey;       // Keep the Title Key    COPYINFO    CopyInfo;       // Keep the relative Copyright Information} TITLE_KEY_COPY_INFO_LOG, *PTITLE_KEY_COPY_INFO_LOG;// Record the multiple title keys and copyright information for special title.// The maximum title keys can be recorded is defined by MAX_TITLE_KEY_NUM (infofilter.h).TITLE_KEY_COPY_INFO_LOG _TitleKeyCopyInfoStore[MAX_TITLE_KEY_NUM];// Keep cuurent title key and copyright information.//TITLE_KEY_COPY_INFO_LOG _CurrentTitleKeyCopyInfo; //--CoCo1.20, reduce code size.#define NULL_TITLE_KEY      0  // This is a empty title key value// Added by Chern Shyh-Chain, 08-30-2001, ENDBYTE    _IssueNewCommand( DWORD dwTimeOut );// ***********************************************************************//  Function    :   SERVO_Reset//  Description :   Will do nothing for ude dvdrom//  Arguments   :   None//  Return      :   TRUE/FALSE//  Side Effect :// ***********************************************************************/*--CoCo1.20, reduce code size.BYTE    SERVO_Reset( void ){    return TRUE;}*/// ***********************************************************************//  Function    :   SERVO_Init//  Description :   Will do configure loader command//  Arguments   :   None//  Return      :   TRUE/FALSE//  Side Effect :// ***********************************************************************/*--CoCo1.20, reduce code size.#ifndef CSC_MASKBYTE  SERVO_Init(void){    SERVO_InitialMutexFlag(); // Brian0.66        return TRUE;}#endif  // CSC_MASK*/// ***********************************************************************//  Function    :   SERVO_OpenTray//  Description :   Open the tray of dvd-rom//  Arguments   :   None//  Return      :   TRUE/FALSE//  Side Effect :// ***********************************************************************BYTE    SERVO_OpenTray( void ){    BYTE    bRst;    OS_LockMutex( &_mServoCmd );    aCMDPacket[0] = SERVO_CMD_OPEN_TRAY ;     //open    bRst = _IssueNewCommand( COUNT_400_MSEC );    __bCloseCommand = 0 ;    OS_UnlockMutex( &_mServoCmd );    return bRst;}// ***********************************************************************//  Function    :   SERVO_CloseTray//  Description :   Close the tray of dvd-rom//  Arguments   :   None//  Return      :   TRUE/FALSE//  Side Effect :   None// ***********************************************************************BYTE    SERVO_CloseTray( void ){      BYTE    bRst;    OS_LockMutex( &_mServoCmd );    aCMDPacket[0] = SERVO_CMD_CLOSE_TRAY ;    // close    bRst = _IssueNewCommand( COUNT_400_MSEC );        __bCloseCommand = 1 ;    OS_UnlockMutex( &_mServoCmd );    return bRst;}#ifdef SUPPORT_SERVO_SOURCE //CoCo1.20, reduce code size.// SERVO return immediately but caller needs to poll the SERVO status.BYTE    SERVO_StartUnit( void ){      BYTE    bRst;    OS_LockMutex( &_mServoCmd );    aCMDPacket[0] = SERVO_CMD_START_UNIT;    bRst = _IssueNewCommand( COUNT_400_MSEC );        __bCloseCommand = 1 ;    OS_UnlockMutex( &_mServoCmd );    return bRst;}#endif// wyc2.17a-909S, add new function to assign DRAM address for servo.// ***********************************************************************//  Function    :   SERVO_CFGEDCBuff//  Description :   Config the SERVO EDC buffer.//  Arguments   :   dwStartAddr: The start address. wSize: The size of buffer, unit is WORD.//  Return      :   TRUE/FALSE//  Side Effect :// ***********************************************************************BYTE    SERVO_CFGEDCBuff( ULONG_UNION dwStartAddr, WORD_UNION wSize ){    BYTE    bRst;    OS_LockMutex( &_mServoCmd );    aCMDPacket[0] = SERVO_CMD_CFG_EDC_BUFF;    aCMDPacket[2] = dwStartAddr.b8bit[0];  //HIBYTE(HIWORD(dwStartAddr)); //buffer startH    aCMDPacket[3] = dwStartAddr.b8bit[1];  //LOBYTE(HIWORD(dwStartAddr)); //buffer startH    aCMDPacket[4] = dwStartAddr.b8bit[2];  //HIBYTE(LOWORD(dwStartAddr)); //buffer startL    aCMDPacket[5] = dwStartAddr.b8bit[3];  //LOBYTE(LOWORD(dwStartAddr)); //buffer startL    aCMDPacket[6] = wSize.b8bit[0]; //buffer szie    aCMDPacket[7] = wSize.b8bit[1]; //buffer szie    bRst = _IssueNewCommand( COUNT_400_MSEC );    OS_UnlockMutex( &_mServoCmd );    return bRst;}BYTE    SERVO_ConfigServoBuffer( BYTE bNum, BYTE bBufSize, ULONG_UNION ulunBufStart ){        BYTE    bRst;    OS_LockMutex( &_mServoCmd );    aCMDPacket[0] = SERVO_CMD_CONFIG_BUF;    aCMDPacket[1] = bNum; //buffer number    aCMDPacket[2] = ulunBufStart.b8bit[0];  //HIBYTE(HIWORD(dwBufStart)); //buffer startH    aCMDPacket[3] = ulunBufStart.b8bit[1];  //LOBYTE(HIWORD(dwBufStart)); //buffer startH    aCMDPacket[4] = ulunBufStart.b8bit[2];  //HIBYTE(LOWORD(dwBufStart)); //buffer startL    aCMDPacket[5] = ulunBufStart.b8bit[3];  //LOBYTE(LOWORD(dwBufStart)); //buffer startL    aCMDPacket[6] = bBufSize; //buffer szie(unit: 0xA000 bytes)    bRst = _IssueNewCommand( COUNT_400_MSEC );    OS_UnlockMutex( &_mServoCmd );    return bRst;}// ***********************************************************************//  Function    :   SERVO_Stop//  Description :   Used to stop the dvd-rom//  Arguments   :   None.//  Return      :   TRUE/FALSE//  Side Effect :// ***********************************************************************/*--CoCo1.20, reduce code size.#ifndef CSC_MASKBYTE  SERVO_Stop(void){//    if (!__btPowerDown)//        return TRUE ;    return (SERVO_PowerMode (SERVO_POWER_STOP));}#endif  // CSC_MASK*/// ***********************************************************************//  Function    :   SERVO_PowerMode//  Description :   Used to let cd/dvd-rom enter power down mode//  Arguments   :   bMode ://                  SERVO_POWER_STOP : Enter stop state//                  SERVO_POWER_IDLE : Enter idle state//                  SERVO_POWER_STANDBY : Enter standby mode//                  SERVO_POWER_SLEEP : Enter sleep mode//  Return      :   TRUE/FALSE//  Side Effect :// ***********************************************************************BYTE    SERVO_PowerMode( BYTE bMode ){    BYTE    bRst;    if( bMode == SERVO_POWER_START )    {        return 1 ;    }    OS_LockMutex( &_mServoCmd );    aCMDPacket[0] = SERVO_CMD_POWER_MANAGEMENT;    // power mode    aCMDPacket[1] = bMode ;     // enter stop mode    bRst = _IssueNewCommand( COUNT_400_MSEC );    OS_UnlockMutex( &_mServoCmd );    return bRst;}// LJY275e// ***********************************************************************//  Function    :   SERVO_GetServoDebugInfo//  Description :   Used to get servo debug information//  Arguments   :   None//  Return      :   version number//  Side Effect :// ***********************************************************************/*--CoCo1.20, reduce code size.#ifndef CSC_MASKBYTE SERVO_GetServoDebugInfo (void){    //to be added...    return TRUE;}#endif  // CSC_MASK*/// **********************************************************// ** TCH0.27; begin...//  *********************************************************************//  Function    :   SERVO_SetSectors    // ** TCH0.27;//  Description :   Record the play range//  Arguments   :   dwStartPos  : the starting sector//                  dwEndPos    : the ending sector//  Return      :   FALSE if ( End < Start )//  Side Effect :   It may set (End<Start) conscious sometime. In this condition,//                  Servo will stop to send anything except re-set the range.//  *********************************************************************/*--CoCo1.20, reduce code size.#ifndef CSC_MASKBYTE SERVO_SetSectors (DWORD dwStartPos, DWORD dwEndPos){    if (dwEndPos < dwStartPos)    {        return FALSE;    }    __SF_SourceGBL[0].dwEndSector = dwEndPos ;    __SF_SourceGBL[0].dwWriteSector = dwStartPos ;        return TRUE;}#endif  // CSC_MASK*/// **********************************************************//DVD020LLY, because scan function will call this function to jump to another position// ***********************************************************************//  Function    :   SERVO_JumpGroove//  Description :   Used to get the position for scan function//  Arguments   :   None.//  Return      :   The next scan position//  Side Effect :// ***********************************************************************/*--CoCo1.20, reduce code size.#ifndef CSC_MASKDWORD SERVO_JumpGroove(BYTE bForward, DWORD dwTime){    extern WORD    __wScanGap;    if ( bForward )   // KEY_SCF    {        // the jump time range        dwTime+= __wScanGap;    }    else    {        if ( dwTime > (__wScanGap+ SCB_EXTRA) )            dwTime-= (__wScanGap+ SCB_EXTRA);        else            dwTime= (DWORD) NULL;    }    // the time need jump to    return dwTime;}#endif  // CSC_MASK*/// ***********************************************************************//  Function    :   SERVO_GetDiscInfo//  Description :   Used to get some the following informations from disc (not for DVD)//  Arguments   :   pMinTrack : the minimum track number//                  pMaxTrack : the maximum track number//                  pMaxSector : the maximum sector number of the disc//  Return      :   TRUE/FALSE//  Side Effect :// ***********************************************************************BYTE    SERVO_GetDiscInfo( PBYTE pbMinTrack, PBYTE pbMaxTrack, PDWORD pdwMaxSector ){    BYTE    bSrvTmp, bLastTrk, bLastSession;    *pbMinTrack = _sessioninfo_TOC[0].bFirstTrack;    bLastSession = _sessioninfo_TOC[0].bLastSession;    bLastTrk = _sessioninfo_TOC[bLastSession-1].bLastTrack;//    if ((__wDiscType == BOOK_CDDA) && (_dwDiscKey [0]==0))    if( __wDiscType == BOOK_CDDA )    {//        _dwDiscKey [0] = 1 ;        bSrvTmp = bLastTrk ;        while( bSrvTmp > _sessioninfo_TOC[0].bFirstTrack )        {            if( _trk_TOC[bSrvTmp-1].Ctl & 0x40 )    // Data Track            {                bSrvTmp --;            }            else            {                break;            }        }        bLastTrk = bSrvTmp;    }    *pbMaxTrack = bLastTrk;    *pdwMaxSector = _sessioninfo_TOC [bLastSession-1].dwLeadOutPos; // LJY275    return TRUE;}// ***********************************************************************//  Function    :   SERVO_GetDiscLength//  Description  :   Used to get length for the disc (not for DVD)//                  It will take session information into consideration.//  Arguments   :   pLength : length of the disc//  Return      :   TRUE/FALSE//  Side Effect  :// ***********************************************************************BYTE    SERVO_GetDiscLength( PDWORD pdwLength ){    BYTE    bLastSession;    #ifndef NO_DVD //CoCo2.37p    if( __wDiscType & BOOK_DVD )    {#ifdef SUPPORT_PRINTF                printf ("SERVO_GetDiscLength is not supported for DVD title\n") ;#endif        return FALSE;    }#endif //#ifndef NO_DVD //CoCo2.37p    bLastSession = _sessioninfo_TOC[0].bLastSession;    //LJY0.87, fix the wrong total disc time bug of Abex 721 CDDA test title//    *pLength = _sessioninfo_TOC [bLastSession-1].dwLeadOutPos + TRACK_GAP;    //LJY1.25, WYC1.25, fix CDDA gototime issue. Leadout should be the discend.    *pdwLength = _sessioninfo_TOC [bLastSession-1].dwLeadOutPos;// + TRACK_GAP;    return TRUE;}// ***********************************************************************//  Function    :   SERVO_GetTrackEnd//  Description  :   Used to get length for the track (not for DVD)//  Arguments   :   bTrackNum : the track number you want to get the length//                  pLength : length of the track//  Return      :   TRUE/FALSE//  Side Effect  :// ***********************************************************************BYTE    SERVO_GetTrackEnd( BYTE bTrackNum, PDWORD pdwLength ){    BYTE    i, bLastSession;#ifndef NO_DVD //CoCo2.37p    if( __wDiscType & BOOK_DVD )    {#ifdef SUPPORT_PRINTF                printf ("SERVO_GetTrackLength is not supported for DVD title\n") ;#endif        return FALSE ;    }#endif //#ifndef NO_DVD //CoCo2.37p    bLastSession = _sessioninfo_TOC[0].bLastSession;    // LJY275, for multi-session 2002/6/28    for( i = 0; i < bLastSession; i ++ )    {        if( (bTrackNum >= _sessioninfo_TOC [i].bFirstTrack) && (bTrackNum <= _sessioninfo_TOC [i].bLastTrack) )        {            break ;        }    }    if( i >= bLastSession )    {//LJY0.87, the track end of last track should be the sector of (leadout - 1)        *pdwLength = _sessioninfo_TOC [bLastSession-1].dwLeadOutPos - 1; //real track end//      *pLength = _sessioninfo_TOC [_bLastSession-1].dwLeadOutPos;        return FALSE ;    }    if( bTrackNum == _sessioninfo_TOC [i].bLastTrack )    {//LJY0.87, the track end of last track should be the sector of (leadout - 1)        *pdwLength = _sessioninfo_TOC [i].dwLeadOutPos - 1; //real track end        //        *pLength = _sessioninfo_TOC [_bSERVOTmp2].dwLeadOutPos;    }    else    {///        *pLength = _MSFtoHSG (_trk_TOC[bTrackNum].Min, _trk_TOC[bTrackNum].Sec, _trk_TOC[bTrackNum].Frm)- 1 ;        *pdwLength = COMUTL_MSFtoHSG ( MAKE_MSF(_trk_TOC[bTrackNum].Min, _trk_TOC[bTrackNum].Sec, _trk_TOC[bTrackNum].Frm))- 1 ;    }       return TRUE ;}// ***********************************************************************//  Function    :   SERVO_GetTrackInfo//  Description :   Used to get informations from the track (not for DVD)//  Arguments   :   bTrackNum : the track number you want to get information//                  pTrackCtl : used to distinguish if the track is data or CDDA//                  pStartPos : the starting sector number of the track//  Return      :   TRUE/FALSE//  Side Effect :// ***********************************************************************BYTE    SERVO_GetTrackInfo( BYTE bTrackNum, PBYTE pbTrackCtl, PDWORD pdwStartPos ){    BYTE    bIndex;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -