📄 dsae.c
字号:
/* Copyright 1996, ESS Technology, Inc. *//* SCCSID @(#)dsae.c 1.16 03/03/05 *//* * This is based on version 1.131 of dsa.c(3/25/98) *//* * Many of the DSA routines are actual SERVO routines if -DSERVO * * NOTE: This file is used with servom.c as well as servos.c. */#include <stdio.h>#include <stdlib.h>#include <ctype.h>#include "vcxi.h"#include "buffer.h"#include "const.h"#include "cd.h"#include "debug.h"#include "display.h"#include "dsa.h"#include "micro.h"#include "tdm.h"#include "timedef.h"#include "util.h"#include "play.h"#include "vscale.h"#include "xport.h"#include "vp.h"#include "echo.h"#ifdef TWO_FIELDS_OSD#include "cg.h"#else#include "fsosd.h"#endif#ifdef FRACTINT#include "fractint.h"#endif#ifdef SERVO#include "servo.h"#include "gpio.h"#endif SERVO#ifdef MP3#include "mp3.h"#endif MP3#ifdef ANTI_SHOCK#include "recorder.h"#endif ANTI_SHOCK/*------------------------------------------------------------------------ * Debugging macros *------------------------------------------------------------------------*/#ifdef DEBUG_OSDextern int osdreg;#define CPRINTF(a,b) {osdreg+=3;if(osdreg>13)osdreg=1;debug_osd(a,b,osdreg);}#else#define CPRINTF(a,b)#endif#if 0int bpt;#define BREAKPOINT(x) {bpt=x;while(bpt) VCX_service();}#else#define BREAKPOINT(x)#endif/************************************************************************ * DSA variables , for CD control * ************************************************************************/#ifdef SERVOIMPORT char servo_focus_on, kickfg, SERVO_new_Qcode, SERVO_mode;IMPORT unsigned char SERVO_Qarray_new[], SERVO_Qarray_current[];IMPORT uint SERVO_target_msf;IMPORT int SERVO_stop(int);IMPORT int SERVO_search();IMPORT void SERVO_delay_n_ms(int n_ms);#endif /* SERVO *//************************************************************************ * Global variables * ************************************************************************/#ifdef SONY3Dint TrayStatus;extern char int_eject;extern int cd_disc_slot;#endifCDINFO 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. */int currentTVmode; /* TV_NTSC or TV_PAL */int bcd_num_of_track; /* used in OSD */unsigned char *CDI_ptr;#ifdef NO_DSP_RESET/* Don't change the followings unless you know what that means */ /* 1 means enable, 0 means disable */char servo_init_reset_high = 0; /* enable/disable initial high */ /* pulse at SERVO_init() to */ /* reset the servo */char servo_dsp_reset = 0; /* enable/disable reset to the */ /* CXD at SERVO_DSP_init() */#elsechar servo_init_reset_high = 1; /* enable/disable initial high */ /* pulse at SERVO_init() to */ /* reset the servo */char servo_dsp_reset = 1; /* enable/disable reset to the */ /* CXD at SERVO_DSP_init() */#endif NO_DSP_RESET/* Added by Andy Ho to ease customer to adjust the following settings */char focus_lost_retry = 6; /* retry how many times when */ /* focus is lost during play */char disc_detect_retry = 6; /* try how many times to detect */ /* if no disc is present */#if (defined(GBPINS_SHARE) || defined(COMMON_OPEN_CLOSE))char share_open_close = 0; /* 0 means use separate AUX pins*/ /* for OPEN and CLOSE */ /* 1 OPEN/CLOSE share open pin */ /* 2 OPEN/CLOSE share close pin */#elsechar share_open_close = 0;#endifchar use_shutter = 0; /* 1 to use shutter pickup */char use_antiphase = 0; /* 1 to antiphase LDON and AUTOAGC */char use_dig_out = 0; /* 1 to enable digital mute */#define SHUTTER_TIMER1 300 /* These timer are for TA2188 Driver adjust*/#define SHUTTER_TIMER2 400 /* Please don't modify if you use BA6392 */short shutter_timer = SHUTTER_TIMER1+SHUTTER_TIMER2;char limit_sw_active_high = 1;#ifdef ESS3721/*MEMOA) I added sled_out_flag for jumping over a large area which has even no SUBQ, at this time,NO subq for checking current position,if we jump as bellew: " r_tmp = logical2physical(375*ptrLshift[emr_search_cnt<<1]); r_tmp = adjCDtime(SERVO_target_msf, r_tmp, 1);" this will exit quickly,we can not jump over this bad area,I debug this over and over,sled out is the better method.So I added a flag for searching and seeking.B) I added checking focusing at seeking,this will avoid servo-abnormal while shocking is happened.C) Please update these code if you have time,Beacuse do this at least will avoid servo unsteadiness. maor--2004-06-10*/#include "keydef.h"extern unsigned char sled_out_flag;unsigned char servo_back_retry_default = 10;unsigned char servo_back_retry;unsigned char servo_kick_first = 1;unsigned char open_sledin_first = 0;unsigned char focus_up_time = 6;/* 600ms */unsigned char focus_down_time = 4; /* 300ms */unsigned char check_cdrw_first = 1;unsigned char M_trackmove_CLVAPC_ON= 1;unsigned char auto_focus_gain_set=0;unsigned char auto_track_gain_set=0;/* some one need kick servo before focus,but others need focus before kick We add a varible to select this */#endifIMPORT int open_delay;IMPORT unsigned char servo_next_m ;/************************************************************************ * 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. */PRIVATE unsigned int CDDA_play_time; /* Play time for current track */PRIVATE unsigned int CDDA_track_start_time;/* States in dsa_go_step_by_step */#define DSA_GO_INIT 0#define DSA_GO_STILL_SEARCHING 1#define DSA_GO_FOUND_TARGET 2PRIVATE int dsa_go_state = DSA_GO_INIT;/************************************************************************ * Debug variables * ************************************************************************/DEBUGVAR(go_time, 0); /* The last dsa_go time */DEBUGVAR(dbgDSAclose, 0); /* Debug variable for dsa_close routine */DEBUGVAR(dbgDSAgo, 0); /* Debug variable for dsa_go routine */DEBUGVAR(dbgDSAmode, 0); /* Debug variable for dsa_mode routine */DEBUGVAR(dbgDSAopen, 0); /* Debug variable for dsa_open routine */DEBUGVAR(dbgDSApause, 0); /* Debug variable for dsa_pause routine */DEBUGVAR(dbgDSApauserelease, 0);/* Debug variable for dsa_pauserelease */DEBUGVAR(dbgDSArelease, 0); /* Debug variable for dsa_release */DEBUGVAR(dbgDSArcv, 0); /* Debug variable for receive_dsa */DEBUGVAR(dbgDSAstop, 0); /* Debug variable for dsa_stop routine */#ifdef SERVO_7DEBUGVAR(dbgDSAcleartoc,0); /* Debug variable for dsa_cleartoc routine */#endifDEBUGVAR(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(dbgTransDsa, 0); /* Debug variable for trans_dsa */DEBUGVAR(dbgReceiveDsa, 0); /* Debug variable for receive_dsa */DEBUGVAR(dbgServiceVcxi, 0); /* Number of time service_vcxi is called*/DEBUGVAR(dbgSafeServiceVcxi, 0);/* Number of "save" service_vcxi calls */DEBUGVAR(dbgMaxRDSA, 0); /* Max. RDSATimeCount */DEBUGVAR(dbgMaxRcvAll, 0); /* Max. number of receive_dsa calls * * before we get a full piece of data */DEBUGVAR(dbgMaxRcvElapse, 0); /* Max. elapsed time for receive_dsa_all*/DEBUGVAR(dbgMaxTran, 0); /* Max. number of trans_dsa loop count */DEBUGVAR(dbgMaxTranElapse, 0); /* Max. elapsed time for trans_dsa */DEBUGVAR(dbgServoRcv, 0); /* receive_dsa_all time out */DEBUGVAR(dbgServoTran, 0); /* trans_dsa time out */DEBUGVAR(dbgMaxLtocCnt, 0); /* Max. number of LTOC replies *//************************************************************************ * Global functions ************************************************************************/PUBLIC int dsa_go(unsigned int);/************************************************************************ * Functions declared and used within this module only. * ************************************************************************/PRIVATE int dsa_go_step_by_step(unsigned int);PRIVATE void init_dsa(void);PRIVATE int receive_dsa_all(int);PRIVATE void trans_dsa(int, int);IMPORT int SERVO_close();IMPORT int SERVO_open();void reset_dsa_go(void);void SERVO_filter_setting(void);/************************************************************************ * New defined functions to check 74ls244 input port status * ************************************************************************/#ifdef SONY3Dint servo_check_rssw();int servo_check_stsw();int servo_check_ior3();int servo_check_up();int servo_check_down();void TRAY_init();PRIVATE void searchDisc1();PRIVATE void process_eject();PRIVATE void process_up_down();#endif /* SONY3D *//************************************************************************ * Imported functions * ************************************************************************/IMPORT void DISP_cigam(int);IMPORT void DISP_naicigam(void);void CUST_init(){ vcx_cd_drive = CD_TOSHIBA;#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];*/IMPORT 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_stop();/* 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, 0x1e2, 2324); begCDtime = 0x500; endCDtime = 0x3500; break; case 11: fill_screen(1); break;#ifdef 0 case 12: digestPage(0); q = 9; break;#endif case 13: TDM_off = 1; while (TDM_off) ; 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 */#ifdef SONY3D process_eject();#endif 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;#ifdef MP3CDG int beg1, end1, end_status; int cur_time, stop_time;#endif /* target time check.. * make sure it's larger than Leadin + "adjustment". */ if (CDtime_check(begin) || (begin < 0x204)) return(0);#ifdef MP3CDG if (MP3CDG_started){ beg1 = begCDtime; end1 = endCDtime; cur_time = currCDtime; stop_time = stopCDtime; end_status = end_of_play; }#endif begCDtime = begin; endCDtime = adjCDtime(begCDtime, logical2physical(num), 1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -