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

📄 w99av.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 4 页
字号:
#include "winav.h"
#include "cdinfo.h"
#include "ucode.h"
#include "w99av.h"
#include "servo.h"
#include "osd.h"

#ifdef USE_INITIAL_FILE
#include "readini.h"
#endif


// LLY.171, add two global variables
DWORD   __dwW99AVAudioFreq;
WORD    __wW99AVSamplesPerFrame;

#if  IO == IO_PCI
WORD    __wW99AVPCIIO;          // Base I/O     for     PCI     brideg
WORD    __wW99AVBaseIO;         // Base I/O     address for     W9922QF
WORD    __wW99AVDACIO;          // Base I/O     for     audio DAC
WORD    __wW99AVTVIO ;
WORD    __wW99AVBaseIOByte;     // Base I/O     address for      W9922QF byte access
#endif  // IO == IO_PCI

#ifdef USE_INITIAL_FILE
char    __strW99AVIni[50];      // the ini file name
DWORD   __dwW99AVDSPArg=0x0;    // record the DSP argument
BYTE    __bMpegType;            // 1:Still , 0:Motion
BYTE    __bW99AVAudioType = 2; //CoCo.051
#endif

// LLY2.80, create one pointer and two buffer to access the command argument of W99AV_CommandN()
// Let W99AV_CommandN() can be call by ISR and normal API, and don't destroy __dwW99AVCmdArg[]
// record command arguments(ARG0~ARG15)
// __dwW99AVCmdArg[0] is the number of arguments
//DWORD __dwW99AVCmdArg[17];
// A memory-specific pointer, and put in "data" space
// Thus, the code size is small and performance is better
DWORD   xdata *  DATA  __dwW99AVCmdArg;

// Chuan2.80, Move all initial to W99AV_Initial()
// LLY2.80, declare two command argument buffer
// "+1" means __dwW99AVCmdBuffer[0], used to keep desired number
DWORD   __dwW99AVCmdBuffer[MAX_CMD_ARG_NO+1];  // for normal API usage
DWORD   __dwW99AVCmdBuffer_ISR[MAX_CMD_ARG_NO+1]; // for ISR usage
DWORD   __dwW99AVVDRR;
DWORD   __dwW99AVABUFFSIZE, __dwW99AVVBUFFSIZE;
WORD    IDATA __wW99AVPCRLow;  // Chuan0.91, Must use IDATA/DATA, because internal 12K SRAM is not available when total reset assert for 908 IC.
WORD    IDATA __wW99AVPCRHigh;  // Chuan0.91, Must use IDATA/DATA, because internal 12K SRAM is not available when total reset assert for 908 IC.
WORD    __wW99AVVCRLow, __wW99AVVCRHigh;
WORD    __wW99AVCAR;
WORD    __wW99AVHDSR, __wW99AVHDWR;
WORD    __wW99AVSPVDS, __wW99AVSPHDS;
WORD    __wW99AVPARCTLRLow, __wW99AVPARCTLRHigh;
WORD    __wW99AVPARFIFOCTLRLow, __wW99AVPARFIFOCTLRHigh;
WORD    __wW99AVAVIDRLow, __wW99AVAVIDRHigh;
WORD    __wW99AVNVSUBIDRLow, __wW99AVNVSUBIDRHigh;
WORD    __wW99AVBSFORMATR;
WORD    __wW99AVGPCRLow, __wW99AVGPCRHigh;

static DWORD   _dwTemp ;
static WORD    _wCnt ;
static WORD    _wTemp ;
static WORD    _wLeft ;

//Kevin1.22CACHE, for osdfont0 use
static BYTE    _bTemp;
static BYTE    * _bIdx ;
//BYTE    _bTemp;
//BYTE    * _bIdx ;
   
BIT     _btRet ;

//Kevin1.24, comment
/*
#ifndef CACHE_RW_ONLY ///SUPPORT_CACHE_RW //Kevin1.22CACHE
// Chuan 172r 2002/03/26: The following variable just for W99AV_ReadDRAMBurst()/W99AV_WriteDRAMBurst()
DWORD   dwTmpAdd, *pdwTmpData ;
#endif
*/

// ***********************************************************************
//      Function        :       W99AV_ReadRegW
//      Description     :       Read a value (only WORD) from a register 
//                              except those whose index range from 0x80 to 0x95
//      Arguments       :       bReg: register index (only BYTE is valid)
//      Return          :       Content of the register
//      Side Effect     :
// ***********************************************************************
#pragma NOAREGS // called in ISR
#pragma DISABLE // will disable all interrupt for the duration of function
                // can't use when function return is BIT
WORD W99AV_ReadRegW(BYTE bReg)
{
    if(bReg>=0x80 && bReg<=0x95) // System Operation Registers 
    {
#if  IO == IO_PCI
        _dwTemp=W99AV_AIRID_SYSREG | bReg;
        // Chuan0.81, Use PCI Delay
        //_Delay(DELAY);
        _outpdw((WORD)AIR0,_dwTemp);
        //_Delay(DELAY);
        _wTemp=(WORD)_inpdw((WORD)DPR0);  // discard this value of first time reading
        // Chuan0.83a, EPP don't need read back twice and delay.
#ifndef   IO_EPP
        //_Delay(DELAY);
        _wTemp=(WORD)_inpdw((WORD)DPR0);  // the valid value
#endif	// IO_EPP
#else
        // Set address and space id to AIR
        OUTB(AIR3,0x00);
        OUTB(AIR2,0x00);
        OUTB(AIR1,0x00);
        OUTB(AIR0,bReg);
        _bIdx = &_wTemp ;
        *_bIdx = INPB(DPR1) ;
        *(_bIdx+1) = INPB(DPR0) ;
#endif
    }
    else    // Internal RISC Operating Registers
    {
        return W99AV_ReadInternalRegW(bReg);
    }
    return _wTemp;
}


// ***********************************************************************
//      Function        :       W99AV_ReadRegDW
//      Description     :       Read a value (DWORD) from a register 
//                              via AIR, DPR, disable interrupt during R/W
//      Arguments       :       bReg: register index (only BYTE is valid)
//      Return          :       Content of the register
//      Side Effect     :
// ***********************************************************************
#pragma NOAREGS // called in ISR
#pragma DISABLE // will disable all interrupt for the duration of function
                // can't use when function return is BIT
DWORD W99AV_ReadRegDW(BYTE bReg)
{
    if(bReg>=0x80 && bReg<=0x95)   // System Operation Registers
    {
#if  IO == IO_PCI
        _dwTemp=W99AV_AIRID_SYSREG | bReg;
        // Chuan0.81, Use PCI Delay
        //_Delay(DELAY);
        _outpdw((WORD)AIR0,_dwTemp);
        //_Delay(DELAY);
        _dwTemp=_inpdw((WORD)DPR0);  // discard this value of first time reading
        // Chuan0.83a, EPP don't need read back twice and delay.
#ifndef   IO_EPP
        //_Delay(DELAY);
        _dwTemp=_inpdw((WORD)DPR0);  // the valid value
#endif	// IO_EPP
        return _dwTemp; // Chuan 275 2002/06/26: Reture the value.
#else
       // Set address and space id to AIR
        OUTB(AIR3,0x00);
        OUTB(AIR2,0x00);
        OUTB(AIR1,0x00);
        OUTB(AIR0,bReg);
        return W99AV_InData () ;
#endif
    }
    else       // Internal RISC Operating Registers
    {
        return W99AV_ReadInternalRegDW(bReg);
    }
}


// ***********************************************************************
//      Function        :       W99AV_WriteRegW
//      Description     :       Write a value (WORD) to a register 
//      Arguments       :       bReg: register index (only BYTE is valid)
//                              wLo:the Low Word of the desired value
//      Return          :       none
//      Side Effect     :
// ***********************************************************************
#pragma NOAREGS // called in ISR
#pragma DISABLE // will disable all interrupt for the duration of function
                // can't use when function return is BIT
void W99AV_WriteRegW(BYTE bReg, WORD wLo)
{
    if(bReg>=0x80 && bReg<=0x95)  // System Operation Registers 
    {
#if  IO == IO_PCI
        _dwTemp=W99AV_AIRID_SYSREG | bReg;
        // Chuan0.81, Use PCI Delay
        //_Delay(DELAY);
        _outpdw((WORD)AIR0,_dwTemp);
        //_Delay(DELAY);
        _outpdw((WORD)DPR0,(DWORD)wLo);
        // Chuan 276 2002/08/12: Delay a while to wait stable(500us) when Prograrm PLLCR
        if (bReg==MCCR)
        {
            // Chuan0.81, Use PCI Delay
            W99AV_PCIDelay();
        }
#else
        // Set address and space id to AIR
        OUTB(AIR3,0x00);
        OUTB(AIR2,0x00);
        OUTB(AIR1,0x00);
        OUTB(AIR0,bReg);
        // Write desired into DPR
        OUTB(DPR1,HIBYTE(wLo));
        OUTB(DPR0,LOBYTE(wLo));

        //Kevin2.34, delay 500us to wait stable when programming MCCR
        if (bReg==MCCR)
        {
            extern void Delay100us(void);
			for ( _bTemp=0; _bTemp<5; _bTemp++)
				Delay100us();		
        }

#endif
    }
    else   // Internal RISC Operating Registers
    {
        W99AV_WriteInternalRegW(bReg, wLo);
    }
}


// ***********************************************************************
//      Function        :       W99AV_WriteRegDW
//      Description     :       Write a value (DWORD) to a register 
//      Arguments       :       bReg: register index (only BYTE is valid)
//                              wLo:the Low Word of the desired value
//                              wHi:the high Word of the desired value
//      Return          :       none
//      Side Effect     :
// ***********************************************************************
#pragma NOAREGS // called in ISR
#pragma DISABLE // will disable all interrupt for the duration of function
                // can't use when function return is BIT
void W99AV_WriteRegDW(BYTE bReg, WORD wLo, WORD wHi)
{
    if(bReg>=0x80 && bReg<=0x95)  // System Operation Registers
    {
#if  IO == IO_PCI
        _dwTemp=W99AV_AIRID_SYSREG | bReg;
        // Chuan0.81, Use PCI Delay
        //_Delay(DELAY);
        _outpdw((WORD)AIR0,_dwTemp);
        //_Delay(DELAY);
        _dwTemp=MAKELONG(wLo,wHi);
        _outpdw((WORD)DPR0,_dwTemp);
        // Chuan 276 2002/08/12: Delay a while to wait stable(500us) when Prograrm PLLCR
        if (bReg==MCCR)
        {
            // Chuan0.81, Use PCI Delay
            W99AV_PCIDelay();
        }
#else
        // Set address and space id to AIR
        OUTB(AIR3,0x00);
        OUTB(AIR2,0x00);
        OUTB(AIR1,0x00);
        OUTB(AIR0,bReg);
        // Write desired into DPR
        OUTB(DPR3,HIBYTE(wHi));
        OUTB(DPR2,LOBYTE(wHi));
        OUTB(DPR1,HIBYTE(wLo));
        OUTB(DPR0,LOBYTE(wLo));

        //Kevin2.34, delay 500us to wait stable when programming MCCR
        if (bReg==MCCR)
        {
            extern void Delay100us(void);
			for ( _bTemp=0; _bTemp<5; _bTemp++)
				Delay100us();
        }
#endif
    }
    else    // Internal RISC Operating Registers
    {
        W99AV_WriteInternalRegDW(bReg, wLo, wHi);
    }
}


// ***********************************************************************
//      Function        :       W99AV_OutIndex
//      Description     :       write a specified register's index to AIR
//                              AIR is used to specify the index value of the DM spaces
//                              and the internal registers to be accessed by the host
//      Arguments       :       dwIdx:the index of specified register
//      Return          :       none
//      Side Effect     :
// ***********************************************************************
#pragma NOAREGS
#pragma DISABLE // will disable all interrupt for the duration of function
                // can't use when function return is BIT
void W99AV_OutIndex(DWORD dwIdx)
{
#if  IO == IO_PCI
    // Chuan0.81, Use PCI Delay
    //_Delay(DELAY);
    _outpdw((WORD)AIR0,dwIdx);
#else
    _bIdx = &dwIdx ;
    OUTB(AIR3, *_bIdx) ;
    OUTB(AIR2, *(_bIdx+1)) ;
    OUTB(AIR1, *(_bIdx+2)) ;
    OUTB(AIR0, *(_bIdx+3)) ;
#endif
}


// ***********************************************************************
//      Function        :       W99AV_OutData
//      Description     :       write a value to Data port register DPR 
//                              when the host access DPR, the
//                              internal register or DM space indexed by AIR is read
//                              or written, and AIR is incremented by 1
//      Arguments       :       dwVal:the desired value to be written
//      Return          :       none
//      Side Effect     :
// ***********************************************************************
#pragma NOAREGS
#pragma DISABLE // will disable all interrupt for the duration of function
                // can't use when function return is BIT
void W99AV_OutData(DWORD dwVal)
{
#if  IO == IO_PCI
    // Chuan0.81, Use PCI Delay
    //_Delay(DELAY);
    _outpdw((WORD)DPR0,dwVal);
#else
    _bIdx = &dwVal ;
    OUTB(DPR3, *_bIdx) ;
    OUTB(DPR2, *(_bIdx+1)) ;
    OUTB(DPR1, *(_bIdx+2)) ;
    OUTB(DPR0, *(_bIdx+3)) ;
#endif
}

// ***********************************************************************
//      Function        :       W99AV_InData
//      Description     :       read a value from Data port register DPR 
//                              when the host access DPR, the 
//                              internal register or DM space indexed by AIR is read
//                              or written, and AIR is incremented by 1
//      Arguments       :       none
//      Return          :       register content
//      Side Effect     :
// ***********************************************************************
#pragma NOAREGS
#pragma DISABLE // will disable all interrupt for the duration of function
                // can't use when function return is BIT
DWORD W99AV_InData(void)
{
#if  IO == IO_PCI
    //DWORD   dwVal;
    // Chuan0.81, Use PCI Delay
    //_Delay(DELAY);
    //Kevin1.23, modify    
    //dwVal=_inpdw((WORD)DPR0);      // discard the value of first time reading
    _dwTemp=_inpdw((WORD)DPR0);
    // Chuan0.83a, EPP don't need read back twice and delay.
#ifndef   IO_EPP
    //_Delay(DELAY);
    //Kevin1.23, modify 
    //dwVal=_inpdw((WORD)DPR0);      // valid value
    _dwTemp=_inpdw((WORD)DPR0);      // valid value
#endif	// IO_EPP
    //Kevin1.23, modify 
    //return dwVal;
    return _dwTemp ;
#else
    // TCC026, for better performance, don't use macros
    _bIdx = &_dwTemp ;
    *_bIdx = INPB (DPR3) ;
    *(_bIdx+1) = INPB (DPR2) ;
    *(_bIdx+2) = INPB (DPR1) ;
    *(_bIdx+3) = INPB (DPR0) ;
    return _dwTemp ;
#endif
}

// ************************************************************************
//      Function        :       W99AV_GetPSR
//      Description     :       This function will get the current PSR value
//      Arguments       :       None
//      Return          :       The actual PSR value (only WORD is valid)
//      Side Effect     :
// ************************************************************************
#pragma NOAREGS

⌨️ 快捷键说明

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