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

📄 hal.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 5 页
字号:


////////////////////////////////////////////////////////////////
// Micky1.21, support C3 retry
// Always exist these constant code, because it will be used for HAL_PUSHDATA_IFIFO
// add last 4 bytes for C3 identify 0x00000080
BYTE code aSyncCode[16]=
{
0x00, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x80 //CoCo.C3-retry, add it for C3 identify.
};

//  **************************************************************************
//  Following variables are new defined for some external global variable
// LLY.161, keep CDDA format is DTS or PCM
// bit[3:0]: indicate the bitstream format -- for parser setting reference
// bit[7:4]: indicate the disc format -- for OSD display info. reference
BYTE    __bCDDA_DTS;
// LLY.102p, keep MPEG video mode: NTSC/ PAL
BYTE    __bMPEGVideoMode;
// LLY.049, add global variable to keep VCD3.0 feature
RECT    __rcHALVCD30Area; //LLY.275 ={0, 0, 0, 0}; // VCD3.0 area
DWORD   __dwHALVCD30Color;
BYTE    __bHALVCD30CR;
// LLY.275, a flag to keep if redraw VCD3.0 Area
// TRUE: redraw VCD3.0 Area while this area are used to cover OSD font
// FALSE: don't need to redraw VCD3.0 Area
BIT     __btRedrawVCD30;
// LLY0.86, keep rectangle area for "Pre-Set Frame Buffer" command
RECT    __rcHAL_PSFBArea;

//  **************************************************************************
//  Following variables are new defined for some internal global variable
// LLY.103, keep video display mode: WIDE/ LB/ PS
// It's the real setting value of display mode
// which is relative to bitstream supporting: LB/PS/WIDE
// So, it's may different from __SetupInfo.bAspectRatio value
BYTE    _bVideoDisplayMode;
// LLY.051, keep desired VBICTLR value used to control SP scale
// CT9928AF: 0x0: Auto mode; 0x0100: N2P; 0x0200: P2N
// CT908: 0x0: Auto mode; 0x0100: N2P or P2N mode
WORD    _wVBICTLR; // =NULL;
// DRAM[0x9f]: frame rate/sp control --> 0x0: Auto, 0x10000: NTSC->PAL, 0x20000:PAL->NTSC
DWORD   _dwFrameRateCTL; // =NULL;
// LLY.102p, remove "TV_OUTPUT_MODE" item,
// and the default value will be given by HAL_TVEncoderInitial()
// LLY.051-1, must give default value depending on WINAV.H,
// because INITIAL.C will call _TVModeSet() first time
// LLY.048-2, must give unexist type for __bTVType to make sure
// that TV encoder will be programmed at 1st _TVModeSet() calling
// LLY.046, rename PAL_TV to TVMODE_PAL, and __btTVType to __bTVType
BYTE    __bTVType; //TV_OUTPUT_MODE;  // keep the current TV type
// LLY.050a, some internal global variable
BYTE    _bSampleFreq; //=0xFF; // one internal variable to keep sample frequency of audio
//BYTE    _bDownSample; //=HAL_DOWNSAMPLE_NONE; // keep downsample type
// LLY.048-3, one internal variable to keep provious _bVideoOutput
BYTE    _bVideoOutput; //=0xFF;  // reference __SetupInfo.bVideoOutput

// LLY2.80, remove the initial action within INITIAL_Variables_PowerON()
// Must give default value for APS type, otherwise 1st _TVModeSet() will fail
BYTE    _bAPSType;//=0;    // APS Type: 0, 1, 2, 3
// LLY.278-5, the initial action is unnecessary
// Becasue, F/W will give the correspond value before using (within HAL_GetStreamInfo())
WORD    __wPicVsize;//=240; // keep picture vertical size
WORD    __wPicHsize;//=352; // keep picture horizontal size
WORD    __wPicHStart;//=0;
WORD    __wPicHEnd;//=352;
WORD    __wHCW, __wVCW;  // keep picture hor. & ver. size while clip command
// LLY2.80, X/Y start point for Zoom Clipping, and removed from CC module
WORD    __wXStart,__wYStart;

// Micky1.20, 4M flash 
#ifndef NO_DIGEST
// for HAL_DigestInitial()
BYTE    __bFrames;   // keep the frame number
int     __iDigestHor;  // digest horizontal size
int     __iDigestVer;  // digest vertical size
int     __iDigestHStart; // the picture start point in horizontal
int     __iDigestVStart; // the picture start point in vertical
#endif

// LLY.276p-4, keep current A/V buffer mode usage, give default value in INITIAL module
BYTE    __bAVBufferMode; //=0xFF;  // default is unknown value

// LLY2.80, the initial action is unnecessary
// Because HAL_IsNeedCDROMDecoding() & UTL_ReadSector() will set correct value
// for HAL_DumpUserData() & HAL_DumpUserDatabyOffset() reference
// ** DVD-TCH0.25; The variable is for the usage HAL_DumpUserData....
WORD    __wCDROMReadingOffset;//= NULL;

DWORD   _dwHLIState;  // define a variable to keep HLI state
// DVD.039, define temp variable for HAL module usage
DWORD   _dwHALTemp, _dwHALTemp1, _dwHALTemp2;
WORD    _wHALTemp, _wHALTemp1;
BYTE    _bHALTemp, _bHALTemp1, _bHALTemp2;
BIT     _btHALTemp;


// LLY.050, define it in HAL1.C
// LLY.277a, it's unnecessary becasue it can share _REG[] array
//BYTE    _bHALArray[9]; // Register value
//  **************************************************************************

//  **************************************************************
//  Following variables are defined in other module
extern  BIT     __btNTSCBitStream;  // define in CC module
// current video buffer words
// the W99AV must keep this value
extern  WORD    __wCurrentVBuffer;
extern  BYTE    _bLOGO; // *** DVD.038, in OSD module
extern  void    _SetAudType(BYTE bType);  // in CHIPS module
//extern  void    _SetPCMLen(BYTE bSampleRate);   // LLY.050a, in CHIPS module
//LJY0.87b,
//extern  BIT    _CSS_SentDiscKey(void);  // LLY.103e-XQ and LLY.160a-1, in SER_ATA.C module

// keep min, sec, frame value
// LLY.045-1, don't declare them because it has declared on UTL.C
extern  BYTE    IDATA   __bMin, __bSec, __bFrame;

// Micky2.32, add a function to decide switching for HD/ FD
BYTE    _bAction;
//  **************************************************************
//  Following API are defined in HAL1.C and will be used by HAL.C
extern  void    _ProgramAudioDAC(BYTE bSampleFreq);


/////////////////////////////////////////////////////////////////////////
// LLY.049, protected: Internal function
//# [1-1] Aspect ratio setting relative function
void    _AspectRatioSetting(BYTE bMode);
//# [1-2] Get video configure relative info. : VDS/HDS/VDW/HDW/VCR function
void    _GetVideoModeInfo(void);
//# [1-3] Get real video display mode info. : WIDE/ PS/ LB mode
void    _GetRealVideoDisplayMode(void);
//# [3-1] Change SPST ID -- LLY.276-4
void    _ChangeSPST_ID(BYTE bID);
//# [2-1] Audio DAC setting relative function
BYTE    _ControlDownSample(BYTE bSampleFreq); //kevin2.39a
//# [5-1] CDIF relative function
//# [12-1] Zoom control relative function
void    _ZoomVideo(void);
////////////////////////////////////////////////////////////////////
//#######################################################################
//  Function    :   HAL_Variables_PowerON
//  Description :   H/W PowerOn Initial
//  Arguments   :  NONE
//  Return      :   none
//  Change      :
//  Side Effect :
//  Global      :   
//#######################################################################
void HAL_Variables_PowerON (void)
{
// ** TCH1.00-908;         extern  WORD    _wVBICTLR;
// ** TCH1.00-908;         extern  DWORD   _dwFrameRateCTL;
// ** TCH1.00-908;         extern  BYTE    _bVideoOutput;
// ** TCH1.00-908;         extern  BIT     __btRedrawVCD30;
// ** TCH1.00-908;         extern  BYTE    _bAPSType;

        _wVBICTLR=NULL;
        _dwFrameRateCTL=NULL;
        _bVideoOutput=0xFF;

        // LLY.275, initialize VCD3.0 relative info.
        __rcHALVCD30Area.wTop=0;
        __rcHALVCD30Area.wBottom=0;
        __rcHALVCD30Area.wRight=0;
        __rcHALVCD30Area.wLeft=0;
        __btRedrawVCD30=FALSE;

        // LLY.276p-4, keep current A/V buffer mode: Normal/ Default/ MP3/ LPCM/ PCM/ JPEG
        __bAVBufferMode=HAL_BUFFERMODE_NORMAL;  // default is normal A/V mode

        _bAPSType=0; // LLY2.80
    
        //LJY1.26, initialize it earlier or antishock mode would be abnormal.
        // as when unzip, it uses small iram code, doesn't support the COMMAND_CDDA_ANTISHOCK is not supported. 
        __bCDDA_DTS=CDDA_FORMAT_UNKNOWN; 

        // Micky2.32, add a function to decide switching for HD/ FD
        _bAction = 0;       
}


//# [1] Video relative function part begin
//#######################################################################
//  Function    :   HAL_Display
//  Description :   Control on/off action for desired display type,
//                  ex. video or subpicture
//  Arguments   :   bDispType, the display type
//                  bDispOn, the flag control display on/off
//                           NULL, means no meaning
//  Return      :   none
//  Change      :
//  Side Effect :
//  Global      :   _dwHALTemp
//#######################################################################
// Notice: Must add "#pramga NOAREGS" w/ each APIs if it will be called by HAL_Display()
// So, if anyone add any function with HAL_Display(), please check it more
// Current sub-APIs with will be called by HAL_Display()
// [1] _ChangeSPST_ID : Done !! (Can't call HAL_ControlParser() directly !!)
// [2] _JPEGBackupDisplayValues() : ??
// [3] _JPEGZoom() : ??
#pragma NOAREGS          // may be called in ISR
void HAL_Display(BYTE bDispType, BYTE bDispAction)
{
    switch(bDispType)
    {
    case    HAL_DISPLAY_VIDEO: // general video
    // enable or disable the video display, may be change the __wW99AVVCRLow
    // VCR bit7, VDE=1, force video output to border color
    //           VDE=0, enable video output
    // LLY.050, it's unnecessary to care VCR value will be modified by RISC
    // because RISC only accept VCR[14:0] while F/W issuing COMMAND_SVC2
        if(bDispAction) // enable video output
            __wW99AVVCRLow &= 0xff7f;

        else  // disable video display and show border colore
            __wW99AVVCRLow |= 0x0080;

        // LLY.050, issue SVC2 command instead of "write REG command"
        // because some info. must tell RISC by "SVC2" command
        //W99AV_WriteRegDW(VCR, __wW99AVVCRLow, __wW99AVVCRHigh);
        __dwW99AVCmdArg [0] = 2 ;
        __dwW99AVCmdArg [1] = CMDARG_SVC2 ;
        __dwW99AVCmdArg [2] = MAKELONG (__wW99AVVCRLow, __wW99AVVCRHigh) ;
        W99AV_CommandN (COMMAND_SVC2) ;
        break;

    case    HAL_DISPLAY_SPST: // subpicture or subtitle
        // LLY.100, re-consider the control flow while turn-on/off SPST
        // Enable SPST condition -- bDispOn==TRUE
        // only BA5580E need to check ZoomFactor,
        // because it can't turn on SP in non-Zoom normal mode
        if(bDispAction)
        {
            if( __wDiscType & BOOK_DVD )
            {
                // Only turn on sp while nobody set sp off
                // __bSP_Disp_OFF: 1 ~ 127 means sp off
                //                 0, 128 ~ 255 means sp on
                if( (__bSP_Disp_OFF==0) || (__bSP_Disp_OFF&0x80) )
                {
                    W99AV_WriteDRAMData(W99AV_DRAM_SP_OFF, 0x0); // DRAM[0x59]
//                    printf("             @@@@@ Enable SP !!\n");
                }
            }
            else
            {
                // Recover to current OGT ID
                // LLY.276-4, can't call HAL_ControlParser()
                // because it will be called by ISR
                // HAL_AdjustTVMode() --> _ZoomVideo() --> HAL_Display() --> HAL_ControlParser()
                //HAL_ControlParser(HAL_PARSER_SP_ID, __bSPSTID);
                _ChangeSPST_ID(__bSPSTID);
                // must set DRAM[0x59]=0 for OGT display
                // otherwise, OGT will flash: on/off everytime
                W99AV_WriteDRAMData(W99AV_DRAM_SP_OFF, 0x0);    // DRAM[0x59]
//                printf("             @@@@@ Enable SP !!\n");
            }
        }

        // Disable SPST condition -- bDispOn==FALSE
        else if(!bDispAction) // disable SPST
        {
            if(__wDiscType & BOOK_DVD)
                W99AV_WriteDRAMData(W99AV_DRAM_SP_OFF, 0x10000); // DRAM[0x59]
            else
            {
                // change to unexist OGT ID
                // LLY.276-4, can't call HAL_ControlParser()
                // because it will be called by ISR
                // HAL_AdjustTVMode() --> _ZoomVideo() --> HAL_Display() --> HAL_ControlParser()
                //HAL_ControlParser(HAL_PARSER_SP_ID, 0x9);
                _ChangeSPST_ID(0x9);
                //printf("             @@@@@ Disable SP !!\n");
            }
        }
        break;

    // LLY.100, keep one field diplay only while non-frame rate control
    case    HAL_DISPLAY_ONE_FIELD:
        // Micky0.87, uCode will reference this DRAM for JPEG display
        // but the resolution will be worse
        // so don't set the flag when JPEG play
        if ( __bAttrPlay == ATTR_JPG )
            break;

        // only keep one field display while
        // [1] non-frame rate control: AUTO mode, and
        // [2] non-still mode
        if(!_dwFrameRateCTL)
        {
//            if( !HAL_QueryStream(HAL_QUERY_STILL) ) // non-still mode
            {
                W99AV_WriteDRAMData(W99AV_DRAM_ONE_FIELD, 0x10000);
#ifdef  SUPPORT_PRINTF
                printf("#### Keep one field display !!\n");
#endif  // #ifdef SUPPORT_PRINTF
            }
        }
        break;
    case HAL_DISPLAY_JPEG:
        _JPEGDisplay(bDispAction);

⌨️ 快捷键说明

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