⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsas.c

📁 ESS3890+SL原代码(1*16内存)
💻 C
📖 第 1 页 / 共 5 页
字号:
		    || (!first_session_cdda && (CDinfo.firsttrack >1)))){/*two closed sessions*/		    if (first_session_retry_cnt < 20) { /*11 normally*/			pt_A0 = pt_A1 = pt_A2 = pt_B0 = pt_C0 =0;			/* Anti-shock off, brake on, TG up */			SERVO_tracking_control((AS_ON|BRK_ON|TG_UP),					       (BRK_ON|TG_UP));			SERVO_2N_trackjump(0, 64);			/* Anti-shock off, brake off, TG normal */			SERVO_tracking_control((AS_ON|BRK_ON|TG_UP),0);			last_session_msf_1 =last_session_msf=0;			track_rd_num =0;			multi_session=0;			num_of_track =0;			first_session_cdda = 0;			for (i = 0; i < szTk; i++)			    pTk[i] = xff000000;			break;		    } else {  /*first session locate error*/			last_session_msf= last_session_msf_1;			multi_session=0;		    }		}		track_rd_num =0;		pt_C0 =0;		/* if 1st session is CDDA then set disc type		 * as CDDA, else let last track of last session		 * decide the CD type		 */		tk1_ctl_adr = (first_session_cdda)		    ? 0x01 : (pTk[CDinfo.lasttrack] >> 24);#else		/* set tk1_ctl_adr after getting all toc info */		tk1_ctl_adr = pTk[CDinfo.firsttrack-1] >> 24;#endif /* MULTI_SESSION */		pt_A0 = pt_A1 = pt_A2 = pt_B0 = 0;		if ((tk1_ctl_adr & 0xcf) == 0x01)		    CDinfo.type = CD_CDDA;		else if (pt_A0_PSEC != 0 &&			 (tk1_ctl_adr == 0x41 ||			  tk1_ctl_adr == 0x61))		    CDinfo.type = CD_VCD;                                /* Note: Photo-CD will also pass as VCD */		else {#ifdef DATA_CD		    if (!pt_A0_PSEC)			CDinfo.type = CD_DATA;		    else#endif			CDinfo.type = CD_UNKNOWN;		}		if (!multi_session || first_session_cdda){                        ltoc_done = 1;		}#ifdef MULTI_SESSION		else {		    return_val = SERVO_go_next_session();		    if ((return_val ==3 )||			(return_val ==1 )) { /*due to time out*/			last_session_msf=last_session_msf_1;			ltoc_done = 1;		    } else if (!return_val) {			goto SERVO_ltoc_retry;		    } else {			multi_session = 0;			loopcnt=0;			num_of_session++;			/*debug_osd("SESS ", num_of_session, 7);*/		    }		}#endif MULTI_SESSION	    }	    break;	default:	    /* Anti-shock off, brake on, TG up */	    SERVO_tracking_control((AS_ON|BRK_ON|TG_UP),				   (BRK_ON|TG_UP));	    SERVO_2N_trackjump(0, 64);	    /* Anti-shock on, brake off, TG normal */	    SERVO_tracking_control((AS_ON|BRK_ON|TG_UP), 0 /*AS_ON*/);            break;        }    }	/* end of while(ltoc_done) */#if defined(CD_TEXT) && !defined(ANTI_SHOCK)    CD_text_init(0);#endif    dsa_mode(MODE_ATTI_REL | MODE_CDROM | MODE_SPEED_NORMAL);#ifdef CXD3059    SERVO_EQ_setting(1);#endif    CDinited = 1;    CPRINTF("LTOC", retry_cnt);    DISP_cigam(CDinfo.type != CD_CDDA);    return(1);ltoc_err_return:    cd_stop = CDinited = 1;    dsa_stop();    return(0);}#endif /* MSERVO (dsa_ltoc) *//* * Goto time. This command forces the CD-module to jump to the requested * absolute time location. * * Input: *	time:	CD sector time in MMSSFF format where each of MM/SS/FF *		is a BCD number. * * Return: *	1:	successful *	0:	otherwise */int dsa_go(unsigned int time){    int return_val;    int r_tmp;    dsa_go_state = DSA_GO_INIT;    do {        return_val = dsa_go_step_by_step(time);#ifdef ECHO	MIC_service();#endif        MP3CDG_service();    } while (return_val==1);    VCX_service();    return ((return_val == 2));}int SERVO_dsa_go_state(void){    return (dsa_go_state);}void reset_dsa_go(void){    dsa_go_state = DSA_GO_INIT;}/**************************************************************************** Step by step go time. Returns 0 if failed, 1 if don't know, 2 if succeed. ****************************************************************************/PRIVATE int dsa_go_step_by_step(unsigned int time){    int return_val, r_tmp;    static int search_timer;    switch (dsa_go_state) {      case DSA_GO_INIT:	if (!kickfg) {	    forceDSAabort = 0;	    SERVO_sledin();	    servo_task = SERVO_focus;	    SERVO_schedule();	    /* Do not continue if focus failed or user key input */	    if (!servo_focus_on || forceDSAabort)		return (0);	}	SERVO_target_msf = time;	Do_mute();	/* For bad discs limit search time..	 * more consistent than retry limits used before.	 */#ifdef CXDSERVO	SERVO_search_timeout =#endif	    search_timer = glbTimer + 10*ONE_SECOND;        SERVO_mode = SERVO_SEARCH;	SERVO_search_init();	SERVO_search_request(); /* do early request */	dsa_go_state = DSA_GO_STILL_SEARCHING;	return_val = 1;	break;      case DSA_GO_STILL_SEARCHING:	return_val = SERVO_search_request();	if (return_val == 2) dsa_go_state = DSA_GO_FOUND_TARGET;	check_user_input();	/* derek */	if(!return_val || forceDSAabort || (glbTimer > search_timer)) {	    /* failed..goto idle */	    dsa_go_state = DSA_GO_INIT;	    return_val = 0;    	} else {	    return_val = 1;	}	break;      case DSA_GO_FOUND_TARGET:        servo_info=0;        if(CDinfo.type != CD_CDI) {            servo_info = (SERVO_Qarray_new[SERVO_QPOINT] << 16) |		(SERVO_Qarray_new[SERVO_QRMIN] << 8) |		    SERVO_Qarray_new[SERVO_QRSEC];        }        else            servo_info = currCDtime >> 8;        r_tmp = bcd2hex[SERVO_Qarray_new[SERVO_QTRACK]];        if (CDinfo.type != CD_CDDA)            r_tmp --;        servo_info |= (hex2bcd[r_tmp]<<24) & xff000000;        for(r_tmp=0; r_tmp<SUBQ_LEN; r_tmp++)            SERVO_Qarray_current[r_tmp] = SERVO_Qarray_new[r_tmp];#if 0	/* the Sub-Q we get here is most likely from the end of the	 * last track.	 */        updateLCDtime();        OSD_update_info();      /* OSD info needs to update */#endif        SERVO_mode = SERVO_PLAY;        Undo_mute();	dsa_go_state = DSA_GO_INIT;	return_val = 2;	break;    }    SERVO_service(1);    return (return_val);}#ifdef CXDSERVOvoid SERVO_tray_idle(void){    /* changed to idle state, otherwise the circuit will conduct     * and draw a lot of current..i.e. overheat the tray motor.     */#ifdef IDLE_LOW    CLEAR_SERVO_REV;	/* init is low to disable the REV movement of			 * the door */    CLEAR_SERVO_FWD;	/* init is low to disable the FWD movement of			 * the door */#else    SET_SERVO_REV;	/* init is high to disable the REV movement of			   the door */    SET_SERVO_FWD;	/* init is high to disable the FWD movement of			   the door */#endif /* IDLE_LOW */}/* * subroutine to close the tray, even if the tray in any position */int SERVO_close(){    int timeout;    volatile int tray_closed = 0;    servo_next_m = STOP_M;    /* drive tray motor to close */#ifndef IDLE_LOW    SET_SERVO_REV;    CLEAR_SERVO_FWD;#else    SET_SERVO_FWD;    CLEAR_SERVO_REV;#endif /* IDLE_LOW */    timeout = glbTimer + FIVE_SECOND;    if (UTIL_debounce(Servo_OPEN_HIGH, 250)) { /* tray is closing */	do {	    if (SERVO_CLOSE_LOW || (glbTimer > timeout)) {		tray_closed++;	    }	    if (SERVO_check_key_new()) break;	} while (!tray_closed);    } else {	/* assume tray is already closed, if haven't moved after delay */	tray_closed = 1;    }    SERVO_tray_idle();#ifdef CXD3059    SERVO_delay_n_ms(100);#if 0 /* Is this needed for 3059?..since we already called it in top.c */    SERVO_DSP_init() ;        //3059 Tony#endif#endif /* CXD3059 */    SERVO_mode = SERVO_CLOSE;    if (tray_closed) {	cd_tray_closed();	return (1);    } else	return (0);}/* * Open the tray, need to stop the motor first if it is playing */int SERVO_open(){    int timeout;    volatile int flag = 0;    SERVO_stop(1);    servo_pres_m = OPEN_10;    /* drive tray motor to open */#ifndef IDLE_LOW    SET_SERVO_FWD;    CLEAR_SERVO_REV;#else    SET_SERVO_REV;    CLEAR_SERVO_FWD;#endif /* IDLE_LOW */    timeout = glbTimer + FIVE_SECOND;    if (UTIL_debounce(Servo_CLOSE_HIGH, 250)) { /* tray is opening */	do {	    if (SERVO_OPEN_LOW || (glbTimer > timeout)) {		flag++;	    }	    if (SERVO_check_key_new()) break;	} while (!flag);    } else {	/* assume tray is already open, if haven't moved after delay */	flag = 1;    }    SERVO_tray_idle();   // SERVO_DSP_init(); /* update 1/13/2005 */    if (flag) {	SERVO_mode = SERVO_OPEN;	/* if SHARE_CLOSE, don't check the open switch..set open_delay to	 * a large value.	 */	open_delay = (share_open_close == SHARE_CLOSE)	    ? xINFINITY : glbTimer+20;	return (1);    }    return (0);}#endif /* CXDSERVO */#ifdef THREE_CDSint dsa_get_disc_status(unsigned char *status){    int	tmp;    int	retry = 2;    int force_quit;	/* 1: force abort; 0: receive OK		*/    do {	trans_dsa(DSA_GET_DISC_STATUS, 0);	do {	    force_quit = !receive_dsa_all(0);	    tmp = (dsa_word >> 8) & 0xff;	    if ((tmp == SERVO_DISC_STATUS) || force_quit) {		*status = dsa_word & 0xff;		return(1);	    } else		break;	} while (1);    } while (--retry);	/* Retry if we get unexpected result */    /* Shall never get here! */    return(0);}#endif#ifdef SONY3Dint dsa_rotate_disk(int direction){    int tmp;    int rotation;    int retry = 2;    int force_quit;	/* 1: force abort; 0: receive OK		*/    int Timer,Timer1;#ifdef SONY3D    unsigned char disc_status;#endif#ifdef SERVO_7    /* we have to send a dsa_stop here before rotate. */    dsa_stop();#endif        /*SERVO_7 */#ifdef SONY3D   if (SERVO_DOWN_HIGH) {       TRAY_CLOSE;       while(SERVO_DOWN_HIGH);       TRAY_STOP;       process_up_down();   }   if (direction) {       ROTATE_CLOCK_ANTI_MOVE;   }   else {       ROTATE_CLOCK_MOVE;   }   Timer = glbTimer;   while ((glbTimer - Timer) < 20);   while (SERVO_STSW_HIGH);   ROTATE_STOP;   if (direction) {       ROTATE_CLOCK_MOVE;   }   else {       ROTATE_CLOCK_ANTI_MOVE;   }   SERVO_delay_n_ms(2); /*for (i = 0; i < 0x5fff;i++);*/   ROTATE_STOP;   if (SERVO_UP_HIGH && !cd_opened) {       TRAY_CLOSE;       while(SERVO_UP_HIGH);       TRAY_STOP;       process_up_down();   }   if (direction) {        if (cd_disc_slot == 3)            cd_disc_slot = 1;        else            cd_disc_slot++;   }    else {         if (cd_disc_slot == 1)             cd_disc_slot = 3;        else             cd_disc_slot--;   }    panel_disc_slot(cd_disc_slot);    return(1);#else    rotation = (direction) ? DSA_ROTATE_ANTI_CLOCKWISE: DSA_ROTATE_CLOCKWISE;    do {	trans_dsa(rotation, 0);	do {	    force_quit = !receive_dsa_all(0);	    tmp = (dsa_word >> 8) & 0xff;	    if ((tmp == SERVO_CAROUSEL_STOPPED) || force_quit) {		return(1);	    } else if (tmp == SERVO_CAROUSEL_MOVING) /* Intermediate */		continue;	    else		break;	} while (1);    } while (--retry);	/* Retry if we get unexpected result */#endif    /* Shall never get here! */    return(0);}#endif#ifdef SONY3Dint servo_check_up(){    unsigned char p;    p = * (unsigned char *) 0x18000000;    if (p & 0x02) return(1);    else return(0);}int servo_check_down(){    unsigned char p;    p = * (unsigned char *) 0x18000000;    if (p & 0x01) return(1);    else return(0);}int servo_check_stsw(){    unsigned char p;    p = * (unsigned char *) 0x18000000;    if (p & 0x10) return(1);    else return(0);}int servo_check_rssw(){    unsigned char p;    p = * (unsigned char *) 0x18000000;    if (p & 0x20) return(1);    else return(0);}int servo_check_ior3(){    unsigned char p;    p = * (unsigned char *) 0x18000000;    if (p & 0x40) return(1);    else return(0);}PRIVATE void searchDisc1(void){    int Timer;again:    ROTATE_CLOCK_MOVE;    Timer = glbTime

⌨️ 快捷键说明

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