cd7.c

来自「ESS3890+SL原代码(1*16内存)」· C语言 代码 · 共 699 行 · 第 1/2 页

C
699
字号
/* Copyright 1998, ESS Technology, Inc.                                 *//* SCCSID @(#)cd7.c	4.14 11/29/04 *//* based on SVCD CD7II cd7.c1.9 6/17/99 *//* * $Log$ */#include "vcxi.h"#include "const.h"#include "debug.h"#include "dsa.h"#include "echo.h"#include "micro.h"#include "cd.h"#include "xport.h"#include "buffer.h"#include "av_play.h"#include "play.h"#include "tdm.h"#include "timedef.h"#include "servo.h"#include "servop.h"#ifdef TWO_FIELDS_OSD#include "cg.h"#else#include "fsosd.h"#endif#if 0#define DPRINTF(a) printf a#else#define DPRINTF(a)#endifIMPORT char     SERVO_new_Qcode, SERVO_mode;IMPORT unsigned char SERVO_Qarray_new[], SERVO_Qarray_current[];IMPORT int      target_min, target_sec, target_frame;IMPORT int leadin_state;IMPORT unsigned int CDDA_play_time;IMPORT unsigned int CDDA_track_start_time;IMPORT int ServoState;IMPORT int open_tray_timer;IMPORT unsigned char servo_error_type;IMPORT int SERVO_stop(int);IMPORT int SERVO_close();IMPORT int SERVO_open();IMPORT int SERVO_search();IMPORT int SERVO_search_request();IMPORT void servo_jump ( short JumpSize);IMPORT int next_session();/************************************************************************ * Variables local to this module                                       * ************************************************************************//* States in dsa_go_step_by_step */#define DSA_GO_INIT             0#define DSA_GO_MINUTE           1#define DSA_GO_SECOND           2#define DSA_GO_FRAME            3#define DSA_GO_RECEIVE_INIT     4#define DSA_GO_RECEIVE          5#define DSA_GO_ALMOST_DONE      6PRIVATE int     dsa_go_state = DSA_GO_INIT;PRIVATE int     open_delay;/************************************************************************ * Debug variables                                                      * ************************************************************************/DEBUGVAR(dbgMaxLtocCnt, 0);     /* Max. number of LTOC replies          */void init_dsa(void){    /* clear all flags */    CDinited = 0;}/************************************************************************ ************************************************************************//* receive information from CD */void receive_dsa(void){    int CDDA_intro_time;        /*     * Talk with uP while receiving from DSA. Otherwise, uP may be     * left out for long period of time, and it may think E3204 is     * dead.     */    check_user_input();     if (OSD_update_time) {        OSD_update_time=0;          /* use servo time to check end of play */        if (TDM_isCDDA) {            /* only do it when we received second */            int passtime;             passtime = ((servo_info & 0xffff) << 8);            if (second_endCDtime != xMAX_CDTIME) /* intro mode */ {                CDDA_intro_time = adjCDtime(second_endCDtime,                                            CDDA_track_start_time, -1);            } else {                CDDA_intro_time = xMAX_CDTIME;            }             /* victor: because of the ATTI_REL mode and some wrongly    *             * encoded CD might have incorrect track info, there is     *             * a possibility that CDDA_play_time hasn't been reached    *             * before a new track occurs(ABEX), we add a check on the   *             * new track here. */            if ((passtime >= CDDA_play_time) ||                (passtime >= CDDA_intro_time) ||                (servo_track_changed)) {#ifdef ANTI_SHOCK				/* Set RISC stat bit to stop XPORT data(CDDA) */		mvd[xport_input_mode] = XPORT_input_mode | 0x4;		XPORT_active = 0;		XPORT_data_end = 1;		    #else		end_of_play = 1;#endif ANTI_SHOCK		servo_track_changed = 0; /* reset it, very important */            }        }        OSD_update_info();      /* OSD info needs to update */    }     return;}/**************************************************		DSA operation function***************************************************//********************************************************************* subroutine to close the tray, even if the tray in any position.* close-tray is requested by SERVO_close(), a command-handler call* tray_close() to implement closing tray.*********************************************************************/int SERVO_close(){    SERVO_set_speed(CLOSE_TRAY);    return(1);}int tray_close(){    int timeout, tray_closed = 0;        SET_TRAY_CLOSE;#if L1210_63    SERVO_delay_n_ms(400);    SERVO_delay_n_ms(400);#endif    timeout = glbTimer + TEN_SECOND;#if L1210_63    if(TRAY_OPEN_LOW)#else    if(TRAY_CLOSE_LOW)#endif          {	tray_closed=1;	CLEAR_TRAY_CLOSE;    } else {	do {#if L1210_63	    if(TRAY_OPEN_LOW)#else	    if(TRAY_CLOSE_LOW)#endif        	    {				tray_closed = 1;		break;	    }	    if ((glbTimer > timeout) || SERVO_check_key_new())		break;	} while (!tray_closed);    }     CLEAR_TRAY_CLOSE;    CLEAR_TRAY_OPEN;        SERVO_mode = SERVO_CLOSE;        if (tray_closed) {	cd_tray_closed();	return (1);    } else	return (0);}/********************************************************************** * Open the tray by requestrvo first if it is playing* open-tray is requested by SERVO_open (), a command-handler call* tray_open() to implement opening tray. **********************************************************************/int SERVO_open(){    unsigned int timeout, flag = 0;#if 1    SERVO_stop(1);    open_tray_timer=open_tray_timeout;    SERVO_set_speed(OPEN_TRAY);    return(1);#else    if(ServoState==INITIALISE_SERVO){	SERVO_start_up();	timeout=glbTimer + FIVE_SECOND;	while ((ServoState!=SERVO_MONITOR) && (glbTimer < timeout)){	    SERVO_service(1);	}    }    /*if ( (SERVO_mode != SERVO_STOP) || (ServoState != SERVO_IDLE)) { */       if ( (SERVO_mode >= SERVO_PLAY ) || (ServoState > SERVO_IDLE)) {	SERVO_stop(1);	open_tray_timer=open_tray_timeout;    } else open_tray_timer=0;    SERVO_set_speed(OPEN_TRAY);    return(1);#endif}int tray_open(){    unsigned int timeout, flag = 0;         SET_TRAY_OPEN;#if L1210_63    SERVO_delay_n_ms(250);    SERVO_delay_n_ms(250);#endif    timeout = glbTimer + TEN_SECOND;#if L1210_63    SERVO_delay_n_ms(150);    SERVO_delay_n_ms(500);#endif    if (TRAY_OPEN_HIGH) {	do {	    if (TRAY_OPEN_LOW)		flag = 1;	    if ((glbTimer > timeout) || SERVO_check_key_new())		break;	} while (!flag);    } else {        flag = 1;    }        CLEAR_TRAY_OPEN;    CLEAR_TRAY_CLOSE;    if (flag) {	SERVO_mode = SERVO_OPEN;	open_delay = glbTimer;	servo_error_type=0;	SERVO_force_stop();	return (1);    }    return (0);}/* * Close the tray. Servo answers with TRAY MOVING (which we ignore) * and TRAY CLOSED command. */int dsa_close(int power_down){    forceDSAabort = 0;    return(SERVO_close());}/* * Opens the tray. If the CD-module is in PLAY mode, it first performs * a STOP procedure before the tray opens. When the moving of the tray * starts, the CD-module send the TRAY MOVING command (we ignore). Then * we we'll get TRAY OPENED. This command clears the internal 'pause mode * indicator. */int dsa_open(void){    return(SERVO_open());}/* * Stops playing the disk and brakes. This command also clears the * internal 'pause mode indicator' */int dsa_stop(void){    forceDSAabort = 0;    SERVO_stop(1);        return 0;}/* * Pause. This is for CDDA. */int dsa_pause(void){    target_min   = SERVO_Qarray_current[SERVO_QPMIN];    target_sec   = SERVO_Qarray_current[SERVO_QPSEC];    target_frame = SERVO_Qarray_current[SERVO_QPFRAME];    SERVO_mode   = SERVO_PAUSE;    /*Do_mute();*/    return(1);}/* * Pause release. This is for CDDA. */int dsa_pauserelease(void){    int found;    if (SERVO_mode == SERVO_PAUSE) {        SERVO_mode = SERVO_PLAY;        found = SERVO_search();	if (!found )            SERVO_stop(1);    }    /*    Undo_mute();*/    /* We need this for MP3 and WMA in case when we pause after all      * the file's data is already in..we'll restart at "paused" location     * saved in "previous_sector".     */    end_of_play = 0;    return(1);}/* * Read the table of content. CD-module passes all track info. Information

⌨️ 快捷键说明

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