📄 cdctl.c
字号:
/* Copyright 1998, ESS Technology, Inc. *//* SCCSID @(#)cdctl.c 4.20 01/17/05 *//* based on SVCD CD7II cdctl.c 1.55 6/7/99 *//* * $Log$ *//* * This is a generic servo driver. It can drive Philips loader or * direct Sony servo. */ #include "vcxi.h"#include "const.h"#include "debug.h"#include "display.h"#include "dsa.h"#include "echo.h"#include "memmap.h"#include "panel.h"#include "tdm.h"#include "timedef.h"#include "vp.h"#include "xport.h"#include "low.h"#include "util.h"#include "play.h"#ifdef TWO_FIELDS_OSD#include "cg.h"#else#include "fsosd.h"#endif#ifdef FRACTINT#include "fractint.h"#endif#ifdef SERVO #include "servo.h"#endif SERVO#ifdef MP3#include "mp3.h"#endif#if 0#define DPRINTF(a) printf a#else#define DPRINTF(a)#endif/************************************************************************ * Variables local to this module * ************************************************************************/PRIVATE int currDSAmode = 0;/* Current CDROM's DSA mode. We'll only * * issue dsa_mode command if the new * * mode is different from the current * * mode. */unsigned int CDDA_play_time; /* Play time for current track */unsigned int CDDA_track_start_time;CDINFO CDinfo;int power_up = 1; /* Flag is set to 0 after system starts. */int num_of_track; /* # of tracks in the CD */int first_seg_ad; /* BCD sector location for first segment* * address. Comes from INFO.VCD. It is * * always in MM:SS:FF form. Should be * * XXYY00. In most case, XX is 00 and * * YY is 05 but there is no guarantee. * * (From INFO.VCD) */ int CDinited = 0; /* 0: key info of CD has not been read * * 1: CD info has been read/stored */ char forceDSAabort = 0;/* Force DSA to quit and return as if * * command succeed. */unsigned int err_code = 0; /* Error code from DSA routines */unsigned char servo_track_changed; /* A flag indicates a new track * * has come. */ unsigned int servo_info; /* store TTMMSSFF info from servo. */unsigned int last_servo_info;/* store previous TTMMSSFF info from servo. */ int currentTVmode; /* TV_NTSC or TV_PAL */int bcd_num_of_track; /* used in OSD */unsigned char *CDI_ptr; /************************************************************************ * Debug variables * ************************************************************************/DEBUGVAR(dbgPlaySector, 0); /* Can't find the given sector from 20 * * frames ealier. */DEBUGVAR(dbgGetSector, 0); /* Can't get the sector (because SYNC * * pattern is not found). */DEBUGVAR(glbSec, 0); /* Global time in seconds */DEBUGVAR(dbgServiceVcxi, 0); /* Number of time service_vcxi is called*/DEBUGVAR(dbgSafeServiceVcxi, 0);/* Number of "save" service_vcxi calls *//************************************************************************ ************************************************************************/void CUST_init(){ vcx_cd_drive = CD_PHILIPS;#ifdef EXT_INPUT vcx_ext_format = CD_SONY;#endif vcx_xfer_mode = 5; }void dsa_reset(){ servo_info = 0;}#if 0 /* TESTING */int abc;int abc_data[100];extern int q;void test_dsa(){ switch (abc) { case 1: dsa_open(); break; case 2: dsa_close(0); break; case 3: initMicroObject(); break; case 4: initCD(); break; case 5: dsa_ltoc(abc_data, 100); break; case 6: dsa_go(0x120000); system_reset(); system_start(); begCDtime = 0x120030; endCDtime = 0x999999; break; case 7: fuzzyPlaySector(0x120000, 2324); break; case 8: begCDtime = 0x120004; endCDtime = 0x999999; dsa_go(0x120000); system_reset(); system_start(); TDM_isCDDA = 0; XPORT_play20video(XPORT_OFFSET_FUZZY_PLAY, 0xe0); TDM_turn_on(); break; case 9: playSectors(0x120000, 0xe0, 2324); begCDtime = 0x120004; endCDtime = 0x999999; break; case 10: system_reset(); system_start(); playSectors(0x500, 0xe2, 2324); begCDtime = 0x500; endCDtime = 0x3500; break; case 11: fill_screen(1, 0); break;#ifdef DIGEST case 12: digestPage(0); q = 9; break;#endif case 13: begCDtime = 0x120004; endCDtime = 0x999999; dsa_go(0x120000); system_reset(); system_start(); TDM_isCDDA = 0; XPORT_play20video(XPORT_OFFSET_FUZZY_PLAY, 0xe0); TDM_turn_on(); break; case 14: system_reset(); system_start(); playCDDA(0x010000, 0x100000); TDM_turn_on(); break; default: break; } abc = 0;}#endif/* * Service microcontroller, CD ROM (etc) */void CUST_background(){ /* * If the NTSC/PAL switch is changed, then change TV mode * accordingly. * * NOTE: Enable POLL_TV_SWITCH only if your system has * dedicated pin for TV switch. Don't enable POLL_TV_SWITCH * if the TV switch is shared(i.e. VFD). In that case, * the TV mode can only be detected at power-up. */#ifdef POLL_TV_SWITCH#ifdef DSC if (!IS_POWER_DOWN)#endif { PREPARE_DETECTION; if (currentTVmode == TV_NTSC) { if (!DETECT_NTSC) { play_change_tv_mode(); } } else { if (DETECT_NTSC) { play_change_tv_mode(); } } }#endif /* POLL_TV_SWITCH */ if (power_up) { /* if in power-down mode, avoid doing power-up stuff */ if (!IS_POWER_DOWN) { initMicroObject(); init_dsa();#if (defined MP3_LOGO && defined ENABLE_MP3)#ifndef NOLOGO /*moved here from top.c, for slideshow problems due to longjump*/ play_mp3_logo((int *)mp3logo, T_mp3logo_SZ>>2);#endif#ifndef MP3_LOGO_IN_SHARE /* show LOGO after play_mp3_logo() */ show_mpeg_still(0xe1, powerupScreen, T_powerupScreen_SZ>>2);#endif /* !MP3_LOGO_IN_SHARE */#endif /* MP3_LOGO */ initCD(); /* Customize your init CD routine */ } power_up = 0; /* Reset after initCD() */ } else { DEBUGINC(1, dbgServiceVcxi); receive_dsa();/* test_dsa();*/ DEBUGINC(1, dbgSafeServiceVcxi); DEBUGASSIGN(glbSec, (glbTimer / ((currentTVmode == TV_PAL) ? 50 : 60))); #ifdef TWO_FIELDS_OSD CG_service(1);#else OSD_schedule_check();#endif upper_state_machine(1);/* Customize your play state machine */ }}/************************************************************************ * Utility routines * ************************************************************************//* * Read "num" sectors into the start of the system buffer. This routine is * only called to get system information (not MPEG A/V data) * * Inputs: * begin: CD sector time in MMSSFF (each is in BCD) * num: number of CD sectors to copy. This number has to be * smaller than sys_buf_size/size. * dest: * non-zero: data to VBV * 0: data to ABV * * Return: * -2: force abort * -1: failed dsa_go() or servo problem * 0: if failed * 1: if successful */int getSectors(begin, num, dest)unsigned int begin;int num, dest;{ unsigned int dsatime, tmp; unsigned int next_time; int xfer_done; int counter; int timeout; int ii; /* target time check.. * make sure it's larger than Leadin + "adjustment". */ if (CDtime_check(begin) || (begin < 0x210)) return(0); begCDtime = begin; endCDtime = adjCDtime(begCDtime, logical2physical(num), 1); /* Set DSA_GO time to be 10 frames ealier than user specified */ dsatime = adjCDtime(begCDtime, 0x10, -1); forceDSAabort = 0; /* Only change DSA mode if the current mode is not CDROM */ TDM_isCDDA = 0; /* Data is scrambled (as opposed to CDDA) */ XPORT_load_ucode((dest) ? DATA_PS : MP3_PS); SERVO_set_speed(SET_CD_DATA_1X); counter = 0; do { xfer_done = 0; if (counter >= 2) { DEBUGINC(1, dbgGetSector); err_code = ERR_GETSECTOR; return(0); } counter++; if (!dsa_go(dsatime)) { /* DSA_GO command failed */ if ((counter >= 2) ||forceDSAabort) { DEBUGINC(1, dbgGetSector); return(-1); } else { counter++; continue; /* Time not specified, don't go */ } } system_reset(); system_start(); TDM_isCDDA = 0; XPORT_play20video(XPORT_OFFSET_GET_SECTOR, 2048); TDM_turn_on(); next_time = glbTimer + TWO_SECOND; timeout = 0; while (!TDM_found_begCDtime) { /* * There may not be any SYNC pattern (CDDA disk), so we'll * conclude that we are not getting the data if we have * been sitting here for .5 second */ if ((glbTimer > next_time) || (currCDtime > endCDtime)) { /* * Check one more time. In case CDI_get is cleared since * I checked it the last time. If we just turn off TDM, * then there is some chance that nobody will turn * TDM on again (because CDI_get is cleared) */ timeout = 1; break; } check_user_input();#ifdef ECHO MIC_service();#endif#ifdef SERVO SERVO_service(1);#endif } /* check if the data tranfer is done */ if (!timeout) { /* Timeout to avoid hanging */#ifdef FLASH_UPDATE /* we may use getsectors() for "big" files */ tmp = (num>>6 - num>>9 - num>>12); /* ~(num/75) */ tmp = TWO_SECOND + tmp*ONE_SECOND; next_time = glbTimer + tmp;#else next_time = glbTimer + TWO_SECOND;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -