www.pudn.com > 6027_HD65.rar > common.h


/***************    MTK CONFIDENTIAL & COPYRIGHTED     ****************/ 
/***************                                       ****************/ 
/***************  $Modtime:: 04/08/02 5:59p    $       ****************/ 
/***************  $Revision:: 4                $       ****************/ 
/***************                                       ****************/ 
/*************** Description : all constant definition ****************/ 
/***************               used for Channel decoder****************/ 
/***************                                       ****************/ 
/***************     Company : MediaTek Inc.           ****************/ 
/***************  Programmer : Joseph Lin              ****************/ 
/***************               Alan Hsu                ****************/ 
/**********************************************************************/ 
 
#ifndef _H_COMMON_ 
#define _H_COMMON_ 
 
 
//=================================================================== 
//===============            Common constants         =============== 
//=================================================================== 
#define TRUE          1 
#define FALSE         0 
 
 
//=================================================================== 
//===============      constants for CD/DVD CMD       =============== 
//=================================================================== 
#define CMD_RESET                       0x01 
#define CMD_STARTUP                     0x02 
#define CMD_READ_CD                     0x03 
#define CMD_READ_CD_MSF                 0x04 
#define CMD_READ_DVD                    0x05 
#define CMD_ABORT                       0x06 
#define CMD_OPEN_TRAY                   0x08 
#define CMD_CLOSE_TRAY                  0x09 
#define CMD_SET_SPEED                   0x0A 
#define CMD_SET_MODE                    0x0B 
#define CMD_SET_POWER                   0x0C 
#define CMD_GET_STATUS                  0x0D 
#define CMD_SET_PARAM                   0x0E 
#define CMD_RISC_WAKEUP                 0x10 
#define CMD_SET_SCLK                    0x11 
#define CMD_READ_REG                    0x21 
#define CMD_WRITE_REG                   0x22 
#define CMD_SET_AUDIO                   0x30 
 
#define CMD_PSP_KEY_DECT                0x40 
#define CMD_READ_DVD_LEADIN             0x41 
 
#define CMD_SEEK_CDVD                   0x50 
#define CMD_SEEK_DVD                    0x51 
#define CMD_GET_PIPO_C1C2               0x52 
 
#define CMD_REBOOT                      0x60 
 
#define CMD_UPGRADE                     0x80 
#define CMD_WRITE_LOGO                  0x81 
 
 
// Channel decoder status code 
#define ST_READY                        0x00 
#define ST_BUSY                         0x01 
#define ST_READ_TOC                     0x02 
#define ST_READ_DATA                    0x03 
#define ST_OPEN_TRAY                    0x04 
#define ST_CLOSE_TRAY                   0x05 
 
// Channel decoder error code 
#define ERR_NOERR                       SV_SK_NOERR     
#define ERR_DATA_MODE                   SV_SK_DATA_MODE 
#define ERR_READ_TOC                    SV_SK_READ_TOC  
#define ERR_CMD_FAIL                    SV_SK_CMD_FAIL  
#define ERR_CMD_ABORT                   SV_SK_CMD_ABORT 
 
 
// Channel decoder tray status code 
#define TRAY_ST_OUT                     SV_TRAY_ST_OUT 
#define TRAY_ST_IN                      SV_TRAY_ST_IN 
#define TRAY_ST_MIDDLE                  SV_TRAY_ST_MIDDLE 
#define TRAY_ST_ERROR                   SV_TRAY_ST_ERROR 
 
 
// Host Expected Type for CD decoding 
#define HOST_ANY_TYPE                   0x00 
#define HOST_CDDA                       0x01 
#define HOST_MODE1                      0x02 
#define HOST_MODE2                      0x03 
#define HOST_MODE2FORM1                 0x04 
#define HOST_MODE2FORM2                 0x05 
 
 
// Disc loading state 
#define DISC_LOAD_INIT                  0x00 
#define DISC_LOAD_STARTUP               0x01 
#define DISC_LOAD_TOC                   0x02 
#define DISC_LOAD_IDENT                 0x03 
 
 
//=================================================================== 
//===============       constants for DISCINFO        =============== 
//=================================================================== 
#define PHYSICAL      1  // use physical address for sector type check 
#define LOGICAL       0  // use  logical address for sector type check 
 
#define AUDIO_TRACK           1         // control = x0x1 
#define DATA_TRACK            2         // control = x1x0 
#define DATA_TRACK_FIXED_PKT  3         // control = x1x1,method 2 address 
#define DATA_TRACK_VAR_PKT    4         // control = x1x1,method 1 address 
#define LEADOUT_LEADIN        5         // Lead Out/Lead In 
 
// Disc Type definition 
#define DT_NO_DISC            0x00 
#define DT_CDROM_DISC         0x01 
#define DT_CDR_DISC           0x02 
#define DT_CDRW_DISC          0x03 
#define DT_DVD_DISC           0x04 
#define DT_DVDR_DISC          0x05 
#define DT_DVDRW_DISC         0x06 
#define DT_DVDRAM_DISC        0x07 
#define DT_INVALID_DISC       0xFE 
#define DT_UNKNOWN_DISC       0xFF 
 
// internal DISC TYPE REPORT SETTING 
#define CDROM_DISC     0x00  /* CD-DA or CD-ROM Disc (1st Track in Mode 1)*/ 
#define CDI_DISC       0x10  /* CDI  Disc                                 */ 
#define CDXA_DISC      0x20  /* CD-ROM XA Disc (1st Track in Mode 2)      */ 
#define ENHANCECD_DISC 0x40  /* SPECIFIC : ENHANCE CD Disc                */ 
                             /* Hidden Data Tracks First,Then AUDIO Tracks*/ 
#define CDPLUS_DISC    0x80  /* SPECIFIC : CD+ Disc                       */ 
                             /* AUDIO Tracks First, Then DATA Tracks      */ 
#define CDDA_DISC      0xC0  /* Audio Track Only */ 
 
#define DVDROM_DISC    0x01  /* DVD Disc  */ 
#define DVD_VIDEO_DISC 0x02  /* DVD Video Disc  */ 
#define DVDRAM_DISC    0x05  /* DVDRAM Disc */ 
//=================================================================== 
//===============      constants for INIT             =============== 
//=================================================================== 
// MT1369 DVD/CD-ROM DECODER CHIP DRAM MAPPING 
#define CD_BLK_SIZE           0xB00 
#define DVD_BLK_SIZE          0x980 
 
 
/*====================================================================== 
                      TOC TABLE AREA DEFINITION 
======================================================================*/ 
#define TOC_START_OFFSET      TOC_BUF_ADDR 
#define TOC_LEN               0x300 
 
 
//==================================================================== 
//            DISC KEY OFFSET (DVD) related to TOC_START_OFFSET 
//==================================================================== 
#define DISC_KEY_OFFSET       4 
#define DISC_KEY_LEN          10 
 
 
//==================================================================== 
//                 CPPM KEY OFFSET (DVD) related to TOC_START_OFFSET 
//==================================================================== 
#define CPPM_KEY_OFFSET       (DISC_KEY_OFFSET + DISC_KEY_LEN) 
#define CPPM_KEY_LEN          8 
 
 
//==================================================================== 
//                 BCA DATA OFFSET (DVD) related to TOC_START_OFFSET 
//==================================================================== 
#define BCA_DATA_OFFSET       (CPPM_KEY_OFFSET + CPPM_KEY_LEN) 
#define BCA_DATA_LEN          32 
 
 
//==================================================================== 
//                      DISC MAP TABLE AREA DEFINITION 
//==================================================================== 
#define DISC_MAP_OFFSET       (TOC_START_OFFSET + TOC_LEN) 
#define DISC_MAP_LEN          0x200 
 
 
#ifdef VCODAC_IN_DRAM 
//==================================================================== 
//                 VCODAC MEM OFFSET 
//==================================================================== 
#define VCODAC_MEM_OFFSET     (DISC_MAP_OFFSET + DISC_MAP_LEN) 
#define VCODAC_MEM_LEN        0x80 
#endif 
 
/*====================================================================== 
                      DISC MAP TABLE AREA DEFINITION 
======================================================================*/ 
#define CDTEXT_MEM_OFFSET     CDTXT_BUF_ADDR 
#define CDTEXT_MEM_LEN        (CDTXT_BUF_SIZE - 4)  // prevent overwrite 
 
//=================================================================== 
//                   POWER ON HARDWARE DIAGNOSTIC 
//=================================================================== 
#define DIAG_NO_ERR      0x00 
#define DIAG_REG_ERR     0x02 
#define DIAG_DRAM_ERR    0x03 
#define DIAG_MEDIA_ERR   0x04 
 
 
//=================================================================== 
//==============   STATE for CD TOC READING STATUS   +=============== 
//=================================================================== 
#define TOC_INIT          0 
#define TOC_SEARCH        1 
#define TOC_OK            2 
#define TOC_OUTOF_RANGE   3 
 
 
//=================================================================== 
//                           POWER MODE 
//=================================================================== 
#define PWR_MODE_MASK            0xC0 
#define PWR_ON_EJECT_FLAG        0x80 
#define PWR_OFF_TRAY_IN_FLAG     0x40 
 
//=================================================================== 
//                           READ DVD STATE 
//=================================================================== 
#define RD_CMD2_IDLE      0 
#define RD_CMD2_RCV       1 
#define RD_CMD2_BUF       2 
 
//============================================================== 
//============          CDTEXT PARAMETR 
//============================================================== 
#ifdef SUPPORT_CD_TEXT 
  #define CDTEXT_INIT     0x00 
  #define CDTEXT_HEADING  0x01 
  #define CDTEXT_COPYING  0x02 
  #define CDTEXT_DONE     0x03 
#endif 
 
 
//=================================================================== 
//=============== Define Constants about 8032 TMOD    =============== 
//=================================================================== 
#define TM0MODE0           0x00 
#define TM0MODE1           0x01 
#define TM0MODE2           0x02 
#define TM0MODE3           0x03 
#define TM0COUNTER         0x04 
#define TM0TIMER           0x00 
#define TM0GATE_ENABLE     0x00 
#define TM0GATE_DISABLE    0x08 
 
#define TM1MODE0           0x00 
#define TM1MODE1           0x10 
#define TM1MODE2           0x20 
#define TM1MODE3           0x30 
#define TM1COUNTER         0x40 
#define TM1TIMER           0x00 
#define TM1GATE_ENABLE     0x00 
#define TM1GATE_DISABLE    0x80 
 
#define TM2COUNTER         0x02 
#define TM2TIMER           0x00 
#define TM2MODE0           0x00    // Auto load 
#define TM2MODE1           0x01    // Capture 
 
#define INT0_LEVEL         0x00 
#define INT0_EDGE          0x01 
#define INT1_LEVEL         0x00 
#define INT1_EDGE          0x04 
 
/*====================================================================== 
                   PLL RELATED DEFINITION 
======================================================================*/ 
#define APLL_AM_M33       625 
#define APLL_AM_M36       375 
 
#define APLL_AN1          AN1_D8 
 
#define APLL_AN2_M33      784 
#define APLL_AN2_M36      512 
 
/*====================================================================== 
                   SECTOR BUFFER COUNT 
======================================================================*/ 
#ifdef MT1379 
  #if (DRAM_SZ == DRAM_2M) 
#ifdef MT1389_512K 
 
    #define SECTOR_BUF_COUNT_DVD  33 
 
    #define SECTOR_BUF_COUNT_CD   28 
 
#else 
 
    #define SECTOR_BUF_COUNT    0x40 
 
#endif 
 
  #elif (DRAM_SZ == DRAM_4M) 
 
#ifdef MT1389_512K 
 
    #define SECTOR_BUF_COUNT_DVD  33 
 
    #define SECTOR_BUF_COUNT_CD   28 
 
#else 
 
    #define SECTOR_BUF_COUNT    50 
 
#endif 
 
  #elif (DRAM_SZ == DRAM_8M) 
#ifdef MT1389_512K 
 
    #define SECTOR_BUF_COUNT_DVD  59 
 
    #define SECTOR_BUF_COUNT_CD   51 
 
#else 
 
    #define SECTOR_BUF_COUNT    59 
 
#endif 
  #elif (DRAM_SZ == DRAM_16M) 
 
    #define SECTOR_BUF_COUNT    79 
 
  #endif 
 
#else // MT1369 
 
  #if (DRAM_SZ == DRAM_2M) 
 
    #define SECTOR_BUF_COUNT    0x40 
 
  #elif (DRAM_SZ == DRAM_4M) 
 
    #define SECTOR_BUF_COUNT    0x32 
 
  #elif (DRAM_SZ == DRAM_8M) 
 
    #define SECTOR_BUF_COUNT    0x32 
 
  #endif 
 
#endif // MT1369 
 
 
 
/*====================================================================== 
 
                   Audio DAC relate definition 
 
======================================================================*/ 
 
#define   VSCK        P13 
 
#define   VSDA        P14 
 
#define   VSDAO       P30 
 
#if (defined(MT1379) && !defined(_AK4357_)) 
 
  #define   ASTB        P30 
 
#else 
 
  #define   ASTB        P15 
 
#endif 
 
#define   ML          P30 
 
 
 
/*====================================================================== 
 
//  Peripheral Device Reset/Mute Control 
 
======================================================================*/ 
 
#define   AVRST     P30 
 
#define   AMUTE     P31 
 
 
/*====================================================================== 
 
                   TV Encoder relate definition 
 
======================================================================*/ 
 
  #define  TV_NTSC          0 
 
  #define  TV_PAL           1 
 
  #define  TV_NTSCJ_BT601   2 
 
  #define  TV_NTSCM_RS170   3 
 
  #define  TV_PAL_M         4 
 
  #define  TV_PAL_N         5 
 
  #define  TV_PAL_NC        6 
 
 
/*====================================================================== 
 
                   I2C relate definition 
 
======================================================================*/ 
 
#define   SCL         P16      // software I2C SCL pin assignment 
 
#define   SET_SCL     P16 = 1 
 
#define   CLR_SCL     P16 = 0 
 
 
#define   SDA         P17      // software I2C SDA pin assignment 
 
#define   SET_SDA     P17 = 1 
 
#define   CLR_SDA     P17 = 0 
 
 
// ********************************************************************* 
 
// Define I2C Read/Write Flag 
 
// ********************************************************************* 
 
#define   FG_SEQREAD    1 
 
#define   FG_RANDREAD   0 
 
 
// ********************************************************************* 
 
// Timing Definition for 12MHz System Clock 
 
// ********************************************************************* 
 
#define   ACK_DELAY  200     // time out for acknowledge check 
 
#define   BUS_DELAY  255     // time out bus arbitration 
 
#define   I2C_DELAY    1     // I2C signal Delay 
 
 
// ********************************************************************* 
 
// Define all I2C Device Address 
 
// ********************************************************************* 
 
#define   EEPROM_ADDR    0x50 
 
 
 
// ********************************************************************* 
 
// For UI service state 
 
// ********************************************************************* 
 
#define UI_WAIT_INIT        0 
 
#define UI_INIT             1 
 
#define UI_INIT_EEPROM      2 
 
#define UI_WAIT_RISC_START  3 
 
#define UI_RUN              4 
 
#define UI_WAIT_RISC_STOP   5 
 
#define UI_STOP             6 
 
#define UI_STANDBY_INIT     7 
 
#define UI_STANDBY          8 
 
#define UI_EEVT_HANDLE      9 
 
#define UI_LOGO_CAPTURE     10 
 
 
// ********************************************************************* 
 
// For Player Error Code, note in BCD format 
 
// ********************************************************************* 
 
#define PLAYER_ERR_NO_ERROR           0x00 
 
 
#define PLAYER_ERR_REG_TEST           0x01 
 
#define PLAYER_ERR_DRAM_TEST          0x02 
 
#define PLAYER_ERR_RCODE_MOV          0x03 
 
 
#define PLAYER_ERR_EEPROM_CONFIG      0x20 
 
#define PLAYER_ERR_SINFO              0x21 
 
#define PLAYER_ERR_DSP_SINFO          0x22 
 
#define PLAYER_ERR_VOL                0x23 
 
#define PLAYER_ERR_EEPROM_SINFO       0x24 
 
#define PLAYER_ERR_LASTMEM_SINFO      0x25 
 
#define PLAYER_ERR_EEPROM_QUEUE       0x26 
 
#define PLAYER_ERR_USER_DATA          0x27 
 
#define PLAYER_ERR_EEPROM_ST          0x28 
 
 
#define PLAYER_ERR_RISC_EEVT          0x40 
 
 
// ********************************************************************* 
 
// For Player Reset Type 
 
// ********************************************************************* 
 
#define PLAYER_HARDWARE_RESET         0 
 
#define PLAYER_SOFTWARE_RESET         1 
 
#define PLAYER_UPGRADE_RESET          2 
 
 
// ********************************************************************* 
 
// For Aux I/O pin control 
 
// ********************************************************************* 
 
#define AUXIO_NULL                    0xff 
 
 
#define AUXIO_TYPE_1336               0 
 
 
#define AUXIO_1336_IO2                ((AUXIO_TYPE_1336 << 4) | 2) 
 
#define AUXIO_1336_IO3                ((AUXIO_TYPE_1336 << 4) | 3) 
 
 
#endif //_H_COMMON_