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

📄 utl.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 5 页
字号:
// ******  Big modification History Area  ******
// Micky1.21, CodeReview
//  - Remove __btFreeze.
// Micky1.07, remove CHIP_W9928 for 28AF related codes
// Micky1.07, remove DVD28C_xxx reference
// Micky1.07, remove CDDA_WAITSERVO

// LLY.274p, some big modification
// [1] rename all MP3 relative info. because module name has changed !!
//     - "mp3.h"  -->  "fmanager.h"
//     - MP3_GetRange()  -->  FM_GetRange()
// Micky2.80a
//  - remove all COMMAND_AUDIO codes.
//  - remove MULTI_DISC_SYSTEM codes
//  - remove unused codes from UTL_GetCurrentTime(), DiffOfTwo(), UTL_ReadSectors()
// LLY2.80a, the modification history
//  - remove the code while un-define UNRESET_AFTER_CDROM_DECODING,
//    ie. always go "unreset" path
///////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////
// ***** Global Define Area *****
// ifdef _DUMP_SHOWTIME, will display some information for UTL_OutputShowTime
// It's debug only.
// #define   _DUMP_SHOWTIME

// if define it, will print STC time when STC>celltime 2 seconds.
//#define _DEBUG_TIME

// ifdef _USE_DEBUG_CMD, will use SP_Ptr to check the sucess of CDROM Decoding > 1.60
// #define  _USE_DEBUG_CMD
/////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////
// *****  Include header file Area  *****
// The file "winav.h" must be included in first line
#include "winav.h"
//DVD_039-1
#include "cell.h"
#include "cc.h"     // for variable reference
#include "utl.h"
#include "comutl.h"
#include "servo.h"
#include "hal.h"
#include "cdinfo.h"
//#include "vcd20.h"
// wyc.172r, need to include digest define.
#include "digest.h"

#include "input.h"  // for KEY_xxx reference
#include "chips.h"
#include "osd.h"
#include "monitor.h"
#include "avsys.h" // LLY.277a-2
#include "amp.h"
#include "linear.h"     //Kevin0.86, add

#include "isr.h"
#include "servo.h"
// wyc.277a-AVSys
#include "initial.h"
#include "ucode.h"
#ifdef    _WINDVD
#include    "navigate.h"
#endif    // _WINDVD

#ifndef NO_MP3
// MP3DISC016
#include  "fmanager.h" //  "mp3.h"
//DVD016-1extern  BIT __btMP3Disc;
#endif  // #ifndef NO_MP3
// Micky2.80, include "thumb.h" for reference __bThumbnailMode.
#include    "thumb.h"
///////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////
// ***** Extern other module's global variable Area *****
extern  WORD    __wXStart,__wYStart;        // *** 0.46(TCH); For Zoom Clipping
extern  WORD    __wSlowSpeed;                   // in "cc.c"
extern  DWORD   __dwSTCValue;  // LLY.0991
// wyc.172r, reduce SRAM
#ifndef NO_DVDDIGEST
extern  BYTE    __bPreDVDDigest;
extern  BYTE    __bDigestStop;
#endif // NO_DVDDIGEST
//wyc.100
extern  BYTE    __bDVDDigest;
//end..
//Kevin0.86, comment
//extern BYTE     __bInputNumIndex ;
//extern BYTE     __bProgramCurrentIndex;
//end ..

//MICKY041 begin
extern DWORD   __dwTimeTorelence;
//MICKY041 end
extern  BYTE    __bSTCRunning;
// wyc1.10, rename this variable for supporting KEY_NEXT w/o reset video.
extern  BYTE    __bNextHWReset;
//////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////
// ***** Declare Global Variable Area *****
#ifdef  INPUT_PATH_HOSTIF
DWORD   __dwUTLReadSector;
#endif  // #ifdef  INPUT_PATH_HOSTIF

// wyc.277a-AVSys, record the DVD system status when exit DVD system to AV1. 
#ifdef  SUPPORT_AV_SYSTEM
BYTE    __bDVDStatus;
#endif // #ifdef  SUPPORT_AV_SYSTEM

//DWORD   __dwAudioType=3;     // assume as MPEG mono audio data for safety
//LLY.101, extend CheckAudioType flag from BIT to BYTE unit
//BIT     __btCheckAudioType=FALSE;
// Micky2.80, review global variables init.
BYTE    __bCheckAudioType;// Micky2.80, review global variables init=CHECK_NONE;
BIT     __btCheckVideoType;// Micky2.80, review global variables init=FALSE;
WORD    wRISCArg;

BYTE    __bModePlay;//Micky2.80, review global variables init.= MODE_PLAYUNKNOW;      //
BYTE    __bLastModePlay;
// LLY.038, keep the previous play mode before enter CDROM decoding
BYTE    __bModePlayPreCDROM;// Micky2.80, review global variables init= MODE_PLAYUNKNOW;
// LLY.274p, keep the current and new desired playing mode attribute
BYTE    __bAttrPlay;
BYTE    __bAttrPlayNew;

BYTE  IDATA     __bMin, __bSec, __bFrame;
// wyc1.24, SFR for control booting from SRAM or FLASH.
#if  IO == IO_8051
sfr UTL_RUN_PROGRAM = 0xc3;   // Chuan0.86, used to control PC to 4K SRAM
#endif
WORD    __wFMJPGPlayCount;
extern  BYTE    __bFMJPGNext;
extern  DWORD   __dwFMJPGNextGap;

//BIT __btPreMPEGtoCDDA=FALSE;          // TCC276-2nd, removed since not used.

//MICKY modify for CDDA channel swap begin
//BIT __btMPEGtoFirstCDDA=FALSE;                // TCC276-2nd, removed since not used
//MICKY modify for CDDA channel swap end

// f/w 0.45
#ifdef _TIME_CIRCLE             // TCC172r, these 2 variables are only used if defined _TIME_CIRCLE
DWORD   __dwPreTimeCircle;
BYTE    __bNormalCount;
#endif  // #ifdef _TIME_CIRCLE

#if defined(WMA_DEBUG) || defined(MP3_DEBUG) //Kevin1.22a, add
DWORD    __dwPlayFileTime;
#endif

//DVD_050SRAM
DWORD   _dwUTLTemp;
DWORD   _dwUTLTemp1; // LLY.161-2
//DVD_051Micky
// it records the stable time value
// to prevent the time value is undated by interrupt
DWORD   data    __dwSysTime;
// support a function to read stable time

DWORD   _dwTriggerShowTime;// Micky2.80, review global variables init= NULL;       // Next TRIGGER OSD/PANEL time
BYTE    __bGap_TriggerShowTime;// Micky2.80, review global variables init= COUNT_500_MSEC+ COUNT_200_MSEC;       // Next TRIGGER OSD/PANEL time
// ** TCH1.60-1; DWORD           _dwTimePrev= NULL;        // ** TCH0.99-1; record the previous show time
DWORD   _dwTimePrev;        // ** TCH0.99-1; record the previous show time
DWORD   _dwUTLNextTriggerCount;   // ** TCH1.70-2; record SysTimer for next Trigger.

// DVD_170Micky, enhance MP3 display time method
// accumulate frames count.
DWORD    _dwTotalFrameCount;   // total decoded frames count for current track
DWORD    _dwPreFrameCount;     // previous frame count number
// wyc.172-CDDA, support a flag to represent playing across tracks automatically.
BYTE    __bCDDAAutoChTrk;

// DVD_172Micky, add two variables for UTL while loop use only!!!
// As _dwUTLTemp/_dwUTLTemp1 can't be used when cross function.
DWORD   _dwTimeStart;   // record the start time for while loop
WORD    _wTimeOutCount; // record the time out count for while loop
// wyc.275-PicCD, a variable to check if need to record the PARSER status and set DVDCTLR to connect bitstream in audio buffer.
// wyc2.85, rename __bJPGVar
BYTE    __bJPGVar;
#ifdef PRESTOP_BEFORE_SETUP_AND_PROGRAM //xuli0909
extern BYTE __bSetupMode,__bProgramStop;
#endif

//  *********************************************************************
//  Function    :   UTL_ReadSectors
//  Description :   Input the CD-ROM data, then control MPEG to decode
//                              :       CD-ROM data
//  Arguments   :   hsgTime     : starting sector for decoding
//                  NoOfSector  : read sector NO. (max is 40 ? )
//                  bSectorFormat:The sector mode, the definition is the
//                                same as HAL_SetSectorFromat parameter
//  Return      :   TRUE is successful
//  Side Effect :   it'll change MPEG status
//  *********************************************************************
BYTE    UTL_ReadSectors ( DWORD hsgTime, BYTE NOofSector, BYTE bSectorFormat)
{
#ifdef  _USE_DEBUG_CMD
    DWORD       dwPtr_SP;   // ** TCH1.60a;
#endif  //      _USE_DEBUG_CMD

#ifdef  INPUT_PATH_HOSTIF

    // ** TCH0.25; begin...
    // Need to check the valid of range
    if ( ! HAL_IsNeedCDROMDecoding ( hsgTime, NOofSector ) )
    {
#ifdef    _DUMP_CDINFO

#endif    // _DUMP_CDINFO
        return TRUE;
    }
#ifdef    _DUMP_CDINFO  // ** TCH0.39;
    PRINTF ( "\n [UTL:UTL_ReadSectors] [%ld-%ld]...", hsgTime, hsgTime+ NOofSector-1 );
#endif    // _DUMP_CDINFO

    // ** DVD-TCH0.25; Suppose to read EXTRA Sectors if possible
    if ( NOofSector< __wCDROMReadingRange )
        NOofSector= (BYTE)__wCDROMReadingRange;

    __dwSectorCDROMBegin= hsgTime;
    __dwSectorCDROMEnd= __dwSectorCDROMBegin+ NOofSector- 1;

#ifdef    _DUMP_CDINFO
    PRINTF ( "--> Real  [%ld-%ld]...", __dwSectorCDROMBegin, __dwSectorCDROMEnd );
#endif    // _DUMP_CDINFO
    // ** TCH0.25; end...

    __dwUTLReadSector= hsgTime;
    // ** TCH0.39; Simulate the same value for ATAPI/ CDIF
    UTL_SetPlayMode ( MODE_PLAYCDROM );
    // Micky2.81_host, support host I/F
    {
        // force data to be ready in DRAM
        // Chuan0.83, missing BYTE declaration, compile fail @Keil
        void SERVO_CDROMRead(BYTE NOofSector);
        __dwW99AVECCBASE=ECCBASE_BYPASS;
        SERVO_CDROMRead(NOofSector);
    }


    return  TRUE;

#else   //#ifndef  INPUT_PATH_HOSTIF
        // TCC276-2nd, move common part of ATAPIIF/DVDIF/CDIF together.
    // ** TCH0.25; begin...
    if ( ! HAL_IsNeedCDROMDecoding ( hsgTime, NOofSector ) )
    {
        return TRUE;
    }
#ifdef    _DUMP_CDINFO      // ** TCH0.39;
    PRINTF ( "\n [UTL:UTL_ReadSectors] [%ld-%ld]...", hsgTime, hsgTime+ NOofSector-1 );
#endif    // _DUMP_CDINFO

#ifdef  _USE_DEBUG_CMD
    // ** TCH1.60a; begin...
    W99AV_Command1(COMMAND_RDEBUGINFO,CMDARG_RDEBUGINFO);  // Chuan2.80p, Use define instead of number
    W99AV_OutIndex ( 0x10000000 ); // set AIR(31:0)=0x10000000
    dwPtr_SP= W99AV_InData ();

#ifdef    _DUMP_CDINFO
    {
        DWORD       dwTCH, dwTCH1;

        W99AV_Command1(COMMAND_RDEBUGINFO,CMDARG_RDEBUGINFO);  // Chuan2.80p, Use define instead of number
        for ( dwTCH=0; dwTCH<2; dwTCH++)
        {
          W99AV_OutIndex(0x10000000+dwTCH); // set AIR(31:0)=0x10000000
          if ( ! dwTCH )
            dwPtr_SP= W99AV_InData ();
          dwTCH1=W99AV_InData();
          PRINTF ( "\n **** COM_DEBUG [%ld]= [%lx]..", dwTCH, dwTCH1 );
        }

        dwTCH= 0;

        if ( dwTCH == 1 )
        {
extern           void _CC_DumpDRAM(char* strFile, DWORD dwStart, DWORD dwEnd);  // LLY.046OSD

            for ( dwTCH1= 0x4800; dwTCH1< 0x4900; dwTCH1++ )
            {
               W99AV_WriteDRAMData ( dwTCH1, 0x12345678 );
            }

            _CC_DumpDRAM ( "CDROM_B.TXT", 0x4800, 0x7200 );
        }
    }
#endif    // _DUMP_CDINFO
    // ** TCH1.60a; end...
#endif  //      _USE_DEBUG_CMD

    // wyc0.87, fix pathtable start+ NOofSector may exceed DiscEnd.
    // need to check if read range is over disc end.
    // DVD needn't to do this check because it is control by servo, not parser.
    /*
    if ( NOofSector< __wCDROMReadingRange )
        NOofSector= (BYTE)(__wCDROMReadingRange);
    */
    if ( NOofSector< __wCDROMReadingRange )
    {
        NOofSector= (BYTE)(__wCDROMReadingRange);
        if ( (__bCurrentIF == BITSTREAM_CDIF) && ((hsgTime + NOofSector) >= __dwTimeDiscEnd) )
            NOofSector= (BYTE)(__dwTimeDiscEnd - hsgTime -2);   // don't know why it's 2??
    }
    // ** TCH0.25; end...

// f/w 0.45(f/w 0.42, 11.20.97)
// can solve play CD-DA->Open->Close->audio noise???
    CHIPS_OpenAudio( FALSE );
    // close CD-IF
    HAL_ControlCDIF(HAL_CDIF_CLOSE);

    // LLY.160, don't keep previous play mode while it's MODE_PLAYCDROM
    // LLY.038, keep the previous play mode before enter CDROM decoding
    if(__bModePlay != MODE_PLAYCDROM)
        __bModePlayPreCDROM= __bModePlay;

    __bModePlay= MODE_PLAYCDROM;        // ** S-TCH;
    // LLY.274p, must assign playing mode attribute to None
    // Because, it don't call UTL_SetPlayMode(MODE_PLAYCDROM)
    // Notice: Must check more ???
    __bAttrPlay= ATTR_NONE;
#ifdef  SUPPORT_CDIF
if (__bCurrentIF == BITSTREAM_CDIF)
{
    // DVD_172Micky, use _dwUTLTemp/_dwUTLTemp1 for temporary variable use.
    // remove dwTemp/dwCount/wTemp/bTemp.
    DWORD       dwHSG;
    WORD        i;
    BYTE        bRet;   //= FALSE;
    //bCMCR is not used now, use bECCEnable to replace it.
    BYTE        bECCEnable; //=TRUE;

    // TCC276, move to below.
    // bRet = FALSE;
    bECCEnable = TRUE;

    dwHSG= hsgTime;
    // the jump CDROM time will be earlier than the dedicated starting sector
    if ( hsgTime > __dwTimeTorelence+15L )
        dwHSG-= (__dwTimeTorelence+15L);
    else
        dwHSG= NULL;

// for a disc Terasa Teng can't find MSF(00:04:00)
// the Gotime will be over the specified position
for ( i= 0; i< 2; i++ )
{
    if (bECCEnable)
    {
        // clear the CDF status bit

⌨️ 快捷键说明

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