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

📄 hal.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    //DVD_031, APS
    if (_bAPSType != bType)
    {
        _bAPSType= bType;
        // LLY.051-1, arrgument is unnecessary and will reference __bTVType directly
        _TVModeSet();
        //_TVModeSet(__bTVType); // LLY.046, rename __btTVType to __bTVType
    }
}


//  LLY.102p, for TV Encoder Initialize
//  **************************************************************************
//  Function    :   HAL_TVEncoderInitial
//  Description :   Initialize TV Encoder
//                  [1] Base on setup info. to do 1st TV encoder programming
//                      -- TV system, Video output mode
//                      [1.1] If TV mode is AUTO, TV encoder will be set to same as VCR value
//                      [1.2] If TV mode is non-AUTO mode, TV encoder will be set
//                            base on setup info.
//                  [2] Re-adjust video relative register value
//  Arguments   :   None
//  Return      :   None
//  Side Effect :   __wW99AVVCRLow maybe be modified
//  **************************************************************************
void HAL_TVEncoderInitial(void)
{
    // Step 1: Decide __bTVType value
    // [1] If TV system is AUTO mode, base on __wW99AVVCRLow value
    // [2] If TV system is non-AUTO mode, assign the setup info. to __bTVType
    if(__SetupInfo.bTVSystem==SETUP_SCREEN_TV_SYSTEM_AUTO) // LLY.102-1
    {
        if(__wW99AVVCRLow & 0x0400) // VCR[10]=1: PAL
            __bTVType=SETUP_SCREEN_TV_SYSTEM_PAL;
        else                        // VCR[10]=0: NTSC
            __bTVType=SETUP_SCREEN_TV_SYSTEM_NTSC;
    }
    else
    {
        __bTVType=__SetupInfo.bTVSystem;
    }

    // Step 2: Decide __bMPEGVideoMode value base on __bTVType
    switch(__bTVType)
    {
    case    SETUP_SCREEN_TV_SYSTEM_NTSC:
    case    SETUP_SCREEN_TV_SYSTEM_PAL_M:
        __bMPEGVideoMode=MPEG_VIDEO_MODE_NTSC;
        break;
    case    SETUP_SCREEN_TV_SYSTEM_PAL:
    case    SETUP_SCREEN_TV_SYSTEM_PAL_N:
    default :
        __bMPEGVideoMode=MPEG_VIDEO_MODE_PAL;
        break;
    }

    // Step 3: Program TV encoder base on __bTVType and __SetupInfo.bVideoOutput
    _TVModeSet();

    // Step 4: Re-adjust video relative register value -- VDS/HDS/VDW/HDW/VCR
    // LLY.102, replace following procedure with _GetVideoModeInfo()
    _GetVideoModeInfo();

    // Step 5: Base on new value to initialize video output mode
    _InitialVCR();
}


//  **************************************************************************
//  Function    :   HAL_SetAspectRatio
//  Description :   Set the desired aspect ratio mode to let
//                  16:9 video can display on 4:3 or 16:9 TV
//  Arguments   :   bMode, the desired aspect ratio (define in setup.h)
//  Return      :   none
//  Side Effect :
//  ********************************************************************
void HAL_SetAspectRatio(BYTE bMode)
{
#ifdef  _WINDVD
    // get current picture HV size and
    // modify the picture horizontal start and end which can see in TV
    HAL_GetStreamInfo();
    // re-setting the HCS, HCW, VCS, VCW
    _ZoomVideo();
    // re-setting the HCS, HCW, VCS, VCW, HDS, HDW, VDS, VDW
    // for aspect ratio control and issue "Set Video Configure 1 Command"
    // & "Clip Command"
    _AspectRatioSetting(bMode);
#endif  // #ifdef _WINDVD
}


//  ************************************************************************
//  Function    :   HAL_AdjustBrightView
//  Description :   Adjust the brightview mode of video output
//  Arguments   :   bMode, the desired brightview mode
//  Return      :   none
//  Changed     :   __wW99AVCAR
//  Side Effect :
//  ************************************************************************
void HAL_AdjustBrightView(BYTE bMode)
{
    __wW99AVCAR &= 0xFFCF;  // clear CAR[5:4]: brightness mode select
    switch(bMode)
    {
        case    HAL_BRIGHTVIEW_NORMAL:
            __wW99AVCAR |= 0x0000;
            break;
        case    HAL_BRIGHTVIEW_BRIGHT:
            __wW99AVCAR |= 0x0010;
            break;
        case    HAL_BRIGHTVIEW_SOFT:
            __wW99AVCAR |= 0x0020;
            break;
    }
    __dwW99AVCmdArg[0]=2;
    __dwW99AVCmdArg[1]=CMDARG_SCONADJR;  // command argument is 0x0007
    __dwW99AVCmdArg[2]=(DWORD)__wW99AVCAR;
    W99AV_CommandN(COMMAND_SCONADJR);  // command index is 0x000E
}


// LLY.045 create ....
//  ************************************************************************
//  Function    :   HAL_AdjustContrast
//  Description :   Adjust the contrast effect of video output
//  Argument    :   bLevel, the desired contrast level
//  Return      :   None
//  Changed     :   __wW99AVCAR
//  Side Effect :
//  ************************************************************************
void HAL_AdjustContrast(BYTE bLevel)
{
    __wW99AVCAR &= 0xFFF0;  // clear CAR[3:0]: contrast effect control
    if(bLevel==HAL_CONTRAST_LEVEL4) // Level == 4
    {
        __wW99AVCAR |= 0x0000;  // CAR[0]=0, disable contrast adjustment
    }
    // LLY.172q, it's unnecessary to comparison with zero (HAL_CONTRAST_LEVEL0),
    // because bLevel is "unsign short", and it's always >= 0
    else if(bLevel<=HAL_CONTRAST_LEVEL3) // 0 <= Level <= 3
    {
        // CAR[0]:1, enable contrast adjustment
        // CAR[1]:0, decrease contrast
        // CAR[3:2], contrast level
        __wW99AVCAR = (__wW99AVCAR | 0x0001 | (HAL_CONTRAST_LEVEL3-bLevel)<<2);
    }
    else if(bLevel>=HAL_CONTRAST_LEVEL5 && bLevel<=HAL_CONTRAST_LEVEL8) // 5 <= Level <= 8
    {
        // CAR[0]:1, enable contrast adjustment
        // CAR[1]:1, increase contrast
        // CAR[3:2], contrast level
        __wW99AVCAR = (__wW99AVCAR | 0x0003 | (bLevel-HAL_CONTRAST_LEVEL5)<<2);
    }
    __dwW99AVCmdArg[0]=2;
    __dwW99AVCmdArg[1]=CMDARG_SCONADJR;  // command argument is 0x0007
    __dwW99AVCmdArg[2]=(DWORD)__wW99AVCAR;
    W99AV_CommandN(COMMAND_SCONADJR);  // command index is 0x000E
}


//  ************************************************************************
//  Function    :   HAL_ControlHighlight
//  Description :   Control the highlight button display
//  Arguments   :   bAction, the desired action of highlight button
//                  bBotton, the desired number/direction of highlight button
//  Return      :   none
//  Side Effect :
//  ************************************************************************
void HAL_ControlHighlight(BYTE bAction, BYTE bButton)
{
    // Chuan1.07-2, HLI control need under DVD title. Problem:[SVCD:Mr. OKO] Enter Setup -> Exit Setup -> the color of OGT will be changed.
    if(__wDiscType & BOOK_DVD)
    {
        __dwW99AVCmdArg[0]=2;
        __dwW99AVCmdArg[1]=0xFFFF;  // don't care commnad argument
        __dwW99AVCmdArg[2]=MAKELONG(bButton, bAction);
        W99AV_CommandN(COMMAND_HLI);
    }
}


// LLY.049 create ...
//  ***********************************************************************
//  Function    :   HAL_CoordConvert
//  Description :   Issue Coordinate convertibility
//  Arguments   :   bType, specify the converting type
//                  pRect, specify the rectangle coordinate
//                         and final coordinate will keep in it
//                  max(HDW, VDW) = (1440, 240/288)
//                  the coordinate of left-up corner is (0, 0)
//                  OSD coordinate: (0 ~ HDS+HDW, 0 ~ VDS+VDW)
//                      view of range: (HDS ~ HDS+HDW, VDS ~ VDS+VDW)
//                  Video coordinate: (0 ~ 740, 0 ~ 480/576),
//  Return      :   None
//  Side Effect :
//  **********************************************************************
void HAL_CoordConvert(BYTE bType, PRECT pRect)
{
    // Get VDS
    // LLY.050, can't use __dwW99AVVDRR value, must read-back it.
    // because in LB mode the value is different
    // otherwise, VCD3.0 HLI can't cover OSD in LB mode
    //_dwHALTemp=__dwW99AVVDRR >> 9;
    _dwHALTemp = W99AV_ReadRegDW(VDSVDWR);
    // LLY2.81, split CT9928AF & CT908, because the bit meaning is different
    // CT9928: bit[8:0]=VDW, bit[17:9]=VDS
    // CT908: bit[9:0]=VDW, bit[19:10]=VDS
    _dwHALTemp >>= 10;
    _wHALTemp1 = LOWORD(_dwHALTemp&0x3ff);

    switch(bType)
    {
    case    HAL_COORDCONVERT_OSD2VIDEO:
    default:
        // Video.x=(OSD.x-HDS)/2,  1440 --> 720
        pRect->wLeft=(pRect->wLeft-__wW99AVHDSR)/2;
        pRect->wRight=(pRect->wRight-__wW99AVHDSR)/2;
        // Video.y=(OSD.y-VDS)*2,  240/288 --> 480/576
        // LLY.273, avoid underflow calculation while VDS value is larger w/ LB mode SPST
        if(pRect->wTop < _wHALTemp1)
            pRect->wTop=0;
        else
            pRect->wTop=(pRect->wTop-_wHALTemp1+1)*2;

        // LLY.275a, add protection for calculation underflow
        if(pRect->wBottom < _wHALTemp1)
            pRect->wBottom=0;
        else
            pRect->wBottom=(pRect->wBottom-_wHALTemp1)*2;

        // LLY.275, enable "redraw VCD30" flag
        // Because, this area are used to cover OSD font
        __btRedrawVCD30=TRUE;

        break;
    }
}


// LLY.049 modify ...
//  ********************************************************************************
//  Function    :   HAL_VCD30_Area
//  Description :   Turn on/off the VCD3.0 area depending on __rcHALVCD30Area
//  Arguments   :   bOn, TRUE: reference __rcHALVCD30Area to turn on VCD3.0
//                       FALSE, turn off VCD3.0 directly
//                  __rcHALVCD30Area use Video coordinate: (0 ~ 720, 0 ~ 480/576)
//  Return      :   none
//  Notice      :   [1] Assign correspond value to __rcHALVCD30Area first,
//                      Then, call HAL_VCD30_Area(TRUE) to turn on VCD3.0
//                  [2] Turn off VCD3.0 effect only to call HAL_VCD30_Area(FALSE);
//                      And, it will set __rcHALVCD30Area's member to NULL
//                  [3] The coordinate of __rcHALVCD30Area must be Video coordinate
//                      So, it must call HAL_CoordConvert(XXX) first
//                      if it isn't Video coordinate
//                  [4] The left point value must >= (SPHDS-HBI_HDS)/2,
//                      because the left point of video coordinate:0 means HBI_HDS
//                      And, HBI_HDS = SPHDS+7
//  Side Effect :   __rcHALVCD30Area will be modified
//  ********************************************************************************
void HAL_VCD30_Area(BYTE bOn)
{
#ifdef  SUPPORT_VCD30_FEATURE
    // Get SPHDS == __wW99AVSPHDS --- LLY.103-2
    //_dwHALTemp=W99AV_ReadRegDW(SPVDSHDSR);
    //_wHALTemp=LOWORD(_dwHALTemp&0x0003ff);

    // Get SPVDS
    // In fact, it must use SPVDS
    // But SPVDS will be modified by RISC for SP adjustment
    // In BA5580E, SP_VDS >= HBI_VDS, so choose HBI_VDS
    // Must check how about BB5580A ??
    // LLY2.81, split CT9928AF & CT908, because the bit meaning is different
    // CT9928: bit[8:0]=VDW, bit[17:9]=VDS
    // CT908: bit[9:0]=VDW, bit[19:10]=VDS
    _dwHALTemp=__dwW99AVVDRR >> 10;
    _wHALTemp1=LOWORD(_dwHALTemp&0x3ff);

    // LLY.275, enable "redraw VCD30" flag, only while
    // [1] This VCD3.0 Area is given base on OSD coordination, and
    // [2] Force to enable VCD3.0 Area
    // Otherwise, disable this flag
    if(!bOn || !__btRedrawVCD30)
        __btRedrawVCD30=FALSE;

    if(bOn) // turn on VCD3.0
    {
        // LLY2.80a, remove setting "W99AV_DRAM_NTSC_PAL" as zero action
        // Set "W99AV_DRAM_NTSC_PAL" value as 0, to disable N2P/ P2N adjustment
        // Otherwise, VCD3.0 HLI can't match the desired area
        // There is side effect while set this DRAM as 0:
        //  --> video flash while enter/exit setup menu within DVD-Menu(still)
        // Notice: BA5580E for all title
        //         BB5580A only for MP3 title
        //         Others: nothing need to do

        // turn off the VBICTRL by RISC for SP/OGT
        W99AV_WriteDRAMData(W99AV_DRAM_VBICTL_98, 0); // DRAM[0x9b]
        W99AV_WriteDRAMData(W99AV_DRAM_VBICTL_CHANGE, 0xffffffff); // DRAM[0x9a]

        // Convert Video coordinate to VCD3.0 coordinate
        // VCD30.x=(Video.x+HDS/2-SPHDS/2)
        // Reference real SPHDSVDS value (read-back from register)
        //__rcHALVCD30Area.wLeft=(__rcHALVCD30Area.wLeft+__wW99AVHDSR/2-_wHALTemp/2);
        //__rcHALVCD30Area.wRight=(__rcHALVCD30Area.wRight+__wW99AVHDSR/2-_wHALTemp/2);
        // Reference last kept value (__wW99AVSPHDSR)

⌨️ 快捷键说明

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