📄 hal.c
字号:
//#define _DEBUG_DWORD_REPLACE_FLOAT
// ***** Modification history list area ***** //
// Brian1.10, move video to center
// LJY1.10, add CD-G setting
// Micky1.07, remove CHIP_W9928 for 28AF related codes
// Micky0.90, fix the CT908 SP+HL don't match with main video
// H/W: if SPVA start line < 4, will pull the whole SPVA down 4 lines.
// else do nothing.
// RISC: if SPVA start line < 4, use Hiword(DRAM_SPVDSHDS)-3 to be real SPVDS value
// else do nothing.
// LLY0.83b-2, remove the JPEG relative variable and API to HALJPEG.C/ .H
// LLY2.80a, the modification history
// - porting JPEG relative code for CT908 by CoCo
// - remove the code while un-define UNRESET_BEFORE_CDROM_DECODING,
// ie. always go "unreset" path
// - remove the code while un-define "SUPPORT_48K_DAC",
// ie. default go "48K DAC" path
// - remove the code "_WaitCDIFEnd()"
// LLY2.80, the modification history
// [1] Review global variables initial action
// [2] Merge HAL_ZOOM_XXX into VIEW_ZOOM_XXX
// [3] Use mnemonic instead number to specify DM address -- Chuan2.80
// LLY.170, Review the initial action for global variable
// . Remove the initial value if it's necessary
// [1] __bMPEGVideoMode: the value will be given in HAL_TVEncodeInitial() first
// [2] _bSampleFreq: the value will be given in HAL_SetAudioDAC() first
// [3] _bDownSample: the value will be given in _CheckDACAbility() first
// . Remove the initial action for global variable to INITIAL_Variables_PowerON()
// Thue, the code size of commom bank can be reduced
// [1] _wVBICTLR: HAL_VCD30_Area() will refer it, too.
// And we can't make sure it will be called after HAL_AdjustTVMode()
// [2] _dwFrameRateCTL: HAL_VCD30_Area() will refer it, too.
// And we can't make sure it will be called after HAL_AdjustTVMode()
// [3] _bVideoOutput: Will be used to compare with __SetupInfo.bVideoOutput first
// Then, decide if call _TVModeSet() -- the value will be given within it
// LLY.105, compatible with W9928AF -- AVIDR index is same as system register
// LLY.103, Something need re-modify
// [1] "_bLBMode==TRUE" --> "_bVideoDisplayMode==SETUP_SCREEN_TV_TYPE_LB"
// [2] Avoid "22QF078.DOC: __dwCountSystem accessing trap" problem
// Using UTL_GetSysTimer() instead of __dwCountSystem
// LLY.102p, some item modification for TVMode integration
// [1] "__bTVMode" --> __SetupInfo.bTVSystem
// [2] "TVMODE_PAL" --> SETUP_SCREEN_TV_SYSTEM_PAL
// [3] "TVMODE_NTSC" --> SETUP_SCREEN_TV_SUSTEM_NTSC
// [4] "TVMODE_PAL_M" --> SETUP_SCREEN_TV_SUSTEM_PAL_M
// [3] "TVMODE_PAL_N" --> SETUP_SCREEN_TV_SUSTEM_PAL_N
// [4] "__bTVType" --> __bMPEGVideoMode (keep real MPEG video mode)
// LLY.101b, using __bTVType instead of __bTVMode
// LLY.101-2, merge PAL_M/ PAL_N/ PAL
// LLY.099, adjust and give some DRAM variable name
// [1] "W99AV_DRAM_DIGEST_SHOW" --> "W99AV_DRAM_DIG_SHOW"
// [2] "W99AV_DRAM_DIGEST_CONT" --> "W99AV_DRAM_CONT_DIG_SHOW"
// [3] "W99AV_DRAM_DIGEST_HVSTART" --> "W99AV_DRAM_DIG_HVSTART"
// [4] "W99AV_DRAM_DIGEST_SHSV" --> "W99AV_DRAM_DIG_SHSV"
// [5] "W99AV_DRAM_STILL" --> "W99AV_DRAM_STILL_MODE"
// [6] "W99AV_DRAM_SKIP_VIDEO_DATA" --> "W99AV_DRAM_SKIP_PIC"
// [7] "W99AV_DRAM_SKIP_B_DATA" --> "W99AV_DRAM_IPDECED"
// [8] "W99AV_DRAM_UPDATE_SEQUENCE" --> "W99AV_DRAM_UPDATE_SEQ"
// [9] "WPXL_COLOR_ADDR" --> "W99AV_DRAM_WPXL_YADR"
// [10]"W99AV_DRAM_SP_OFF" --> DRAM[0x59]
// [11]"W99AV_DRAM_SP_TOP" --> DRAM[0x5e]
// [12]"W99AV_DRAM_SKIP_MOSAIC" --> DRAM[0x6d]
// [13]"W99AV_DRAM_VINI_ADJUST" --> DRAM[0x80]
// [14]"W99AV_DRAM_TV_SWITCHING" --> DRAM[0x94]
// [15]"W99AV_DRAM_SP_CHANGE" --> DRAM[0x95]
// [16]"W99AV_DRAM_SUB_ID" --> DRAM[0x96]
// [17]"W99AV_DRAM_LETTER_BOX" --> DRAM[0x97]
// [18]"W99AV_DRAM_VBICTL_CHANGE" --> DRAM[0x9a]
// [19]"W99AV_DRAM_VBICTL_98" --> DRAM[0x9b]
// [20]"W99AV_DRAM_FULL_SP" --> DRAM[0x9d]
// [21]"W99AV_DRAM_NTSC_PAL" --> DRAM[0x9f]
// LLY.045-1, porting for new define depending on 22QF055.DOC
// all original include file will be put in "winav.h"
// LLY.045, use new setup info. definition
// SETUP_SCREEN_TV_TYPE_WIDE/LB/PS
///////////////////////////////////////////////////////////////
//#########################################################################
//# Function blocks:
//# [1] Video relative function
//# [2] Audio relative function
//# [3] Parser relative function
//# [4] DIGEST relative function
//# [5] CD-IF relative function
//# [6] CDROM decoding relative function
//# [7] Interrupt /event relative function
//# [8] Clear frame buffer relative function
//# [9] Get bitstream info. relative function
//# [10]Set play mode relative function
//# [11]Power on/off relative function
//# [12]Zoom relative function
//# [13]A/V buffer control relative function
//# [14]Disc change relative function
//# [15]Reset relative function
//# [16]A/V sync. control relative function
//# [17]Debug relative function
//# [18]A/V buffer setting relative function
//# [19]EEPROM read/write relative function
//# [20]FIFO relative function
//# [21]GPIO relative function
//# [1-1]Aspect Ratio setting relative function
//# [1-2]Get video configure relative info. : VDS/HDS/VDW/HDW/VCR function
//# [1-3]Get real video display mode info. : WIDE/ PS/ LB mode
//# [2-1]Audio DAC setting relative function
//# [5-1]CDIF relative function
//# [12-1]Zoom control relative function
//#######################################################################
#include "winav.h"
// LLY.043-2, if RISC support command to support fill fifo with zero data
// F/W can define it after 20000718 RISC code
#define SUPPORT_FILL_FIFODATA_BY_COMMAND
// LLY.045, if define it, F/W will support VCD3.0 feature
//#define SUPPORT_VCD30_FEATURE // Brian2.37a, RISC doesn't support VCD30 command
// LLY.101b, enlarge horizontal direction
#define ENLAGER_HORIZONTAL_DIRECTION_FOR_ZOOM_IN_LB_MODE
/*
#ifdef NO_DIGEST
#undef NO_DIGEST
#endif
*/
// LLY.105, define gerenal data number within one sector (in DWORD unit)
#define DATANO_ONE_SECTOR (2352/4)
// LLY.171, if define it, F/W will change parser code while CDROM decoding
//#define CHANGE_PARSER_CODE_FOR_CDROM_DECODING
// LLY.172q, fix "non-give argument type of function prototype" for "ARM" warnning message
// LLY.278, 20021028 RISC code will disable AD_INT automatically
// Notice: only support for 28AF chip
//#define DISABLE_AD_INT_BY_RISC
// LLY2.79-2, if define it, DSP will clear DM[0x27f, 0x280, 0x281, 0x4dd]
// while issue DM[0x7ff]=1 automatically
// Otherwise, F/W will clear them by ourself
// Notice: Need 20030129 DSP code (IEC_PRAM.INC/ IEC_ERAM.INC)
#define CLEAR_DM_VALUE_BY_DSP
// LLY2.80, if define it F/W will issue SCAN/ NPF command
// within HAL_RESET_VIDEO to accelerate bitstream buffer empty
// Otherwise, RISC will do it by itself
// Notice: must use > 20030321 RISC code
// #define ACCELERATE_BUFFER_EMPTY_BY_SCAN
// LLY0.81, Set PCM buffer starting address to RISC/DSP by F/W
// Notice: Need RISC/ DSP code support; and only support for CT908 chip
#define SUPPORT_PCM_ADDRESS_SETTING_BY_FIRMWARE
// only for testing mode
//#define _DEBUG_AUDIO_RESET // dump some info. for audio reset
//#define _DEBUG_CDROM_DECODING // dump some info. for cdrom decoding
//#define _DEBUG_AVBUFFER_SETTING // dump some info. for A/V buffer setting
//#define _DEBUG_DOWNSAMPLE // dump some info. for downsample setting
//#define _DEBUG_SPST_CHOOSE // dump some info. for LB SPST choice
//DVD_037BUFFERCONTROL
#include "input.h"
#include "ucode.h"
#include "w99av.h"
#include "cc.h"
#include "hal.h"
#include "osd.h"
#include "cdinfo.h"
#include "comutl.h"
#include "utl.h"
#include "chips.h"
#include "servo.h"
#include "setup.h"
#include "digest.h"
#include "fmanager.h"
#include "thumb.h"
#include "amp.h"
#ifdef _WINDVD
#include "navigate.h"
#include "dvdinfo.h"
#endif // #ifdef _WINDVD
#include "tft.h" //yhtang_0910
// ****** Add some define Area ******* //
// Brian.276q, DRAM variables for set clip information in JPEG Display command
#define HCS_0 0xc9
#define VCS_0 0xca
#define HCW_0 0xcb
#define VCW_0 0xcc
// Brian1.10, begin---
// Move video to center
// define the value for VDS/HDS/VDW/HDW
// adjust these XXX_OFF (offset) to center the Video on TV screen
#define VDS_PAL_PSCAN_OFF (4)
#define VDS_NTSC_PSCAN_OFF (2)
#define VDS_PAL_OFF (3)
#define VDS_NTSC_OFF (2) //(1)
#define HDS_NTSC_PSCAN_OFF (-12) // must be 2n
#define HDS_PAL_PSCAN_OFF (10) // must be 2n
#define HDS_NTSC_OFF (-12) // must be 4n
#define HDS_PAL_OFF (0) // must be 4n
// HDS and HDW is supposed to be the same no matter NTSC/PAL, PScan/Interlaced
#define HDS_NTSC (246L + HDS_NTSC_OFF)
#define HDS_PAL (246L + HDS_PAL_OFF)
#define HDS_NTSC_PSCAN (246L + HDS_NTSC_PSCAN_OFF)
#define HDS_PAL_PSCAN (246L + HDS_PAL_PSCAN_OFF)
#define HDW 1440L
// PScan case
#define VDS_PAL_PSCAN (38L + VDS_PAL_PSCAN_OFF)
#define VDW_PAL_PSCAN 576L
// [19:10]:VDS, [9:0]:VDW
#define VDSVDW_PAL_PSCAN (((DWORD)(VDS_PAL_PSCAN) << 10)+VDW_PAL_PSCAN)
#define VDS_NTSC_PSCAN (32L + VDS_NTSC_PSCAN_OFF)
#define VDW_NTSC_PSCAN 483L
// [19:10]:VDS, [9:0]:VDW
#define VDSVDW_NTSC_PSCAN (((DWORD)(VDS_NTSC_PSCAN) << 10)+VDW_NTSC_PSCAN)
// Interlaced case
#define VDS_PAL (23L + VDS_PAL_OFF)
#define VDW_PAL 288L
// [19:10]:VDS, [9:0]:VDW
#define VDSVDW_PAL (((DWORD)(VDS_PAL) << 10)+VDW_PAL)
#define VDS_NTSC (21L + VDS_NTSC_OFF)
#define VDW_NTSC 240L
// [19:10]:VDS, [9:0]:VDW
#define VDSVDW_NTSC (((DWORD)(VDS_NTSC) << 10)+VDW_NTSC)
// Brian1.10, end ---
#ifdef SUPPORT_CARD_READER
extern BYTE _bPramCur;
#endif
////////////////////////////////////////////////////////////////
// ***** code define area *****
WORD code Sequence[28+5]=
{
#ifndef NO_DIGEST
#ifndef NO_CDDADIGEST
0x4D4D, 0x1C, 0x0020, 0x0020, 0x0020,
0x0000, 0xB301, 0x0116, 0x1520, 0xFFFF, 0x80E0, 0x0000, 0xB801, 0x0800, 0x4000,
0x0000, 0x0001, 0x0F00, 0xF8FF, 0x0000, 0x0101, 0xE443, 0x9452, 0x54BF, 0x6ABF,
0x4AB9, 0x2252, 0x29E5, 0x8B48, 0xA594, 0x2022, 0x0000, 0xB701
#else // #ifndef NO_CDDADIGEST
0
#endif // #ifndef NO_CDDADIGEST
#else // #ifndef NO_DIGEST
0
#endif // #ifndef NO_DIGEST
};
WORD code aGPIOValue[]=
{
0x0001, // GPCR[0]=1, PH GP0
0x0002, // GPCR[1]=1, PH GP1
0x0004, // GPCR[2]=1, PH GP2
0x0008, // GPCR[3]=1, PH GP3
0x0010, // GPCR[4]=1, PH GP4
0x0020, // GPCR[5]=1, PH GP5
0x0040, // GPCR[6]=1, PH GP6
0x0080, // GPCR[7]=1, PH GP7
0x0100, // GPCR[8]=1, PH GP8
0x0200, // GPCR[9]=1, PH GP9
0x0400, // GPCR[10]=1, PH GP10
0x0800, // GPCR[11]=1, PH GP11
0x1000, // GPCR[12]=1, PH GP12
0x2000, // GPCR[13]=1, PH GP13
0x4000, // GPCR[14]=1, PH GP14
0x8000, // GPCR[15]=1, PH GP15
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -