📄 dsasl.c
字号:
REC_4to1_coder_init();
REC_4to1_decoder_init();
#endif /* NO_CDDA_COMPRESS */
#endif /* ANTI_SHOCK */
}
#ifdef ANTI_SHOCK
if (PLAY_set_2x_speed) {
CPRINTF("2X SPEED", CDDA_play_time);
dsa_mode(MODE_AUDIO | MODE_SPEED_DOUBLE);
} else
#endif /* ANTI_SHOCK */
{
CPRINTF("1X SPEED", CDDA_play_time);
dsa_mode(MODE_AUDIO | MODE_SPEED_NORMAL);
}
play_cdda_state = PLAY_CDDA_XPORT_START;
return(1);
case PLAY_CDDA_XPORT_START:
#ifdef ANTI_SHOCK
if (match) {
XPORT_load_cdda_match();
XPORT_restart_at(XPORT_OFFSET_MATCH_DATA, 1);
} else
#endif
{
XPORT_restart_at(XPORT_OFFSET_PLAY_CDDA, 1);
}
retry_cnt=0; /* initialize */
play_cdda_state = PLAY_CDDA_DSA_GO;
dsa_go_state = DSA_GO_INIT;
return(1);
case PLAY_CDDA_DSA_GO:
status = dsa_go_step_by_step(dsa_gotime);
if (!status) {
if (retry_cnt >= 4) {
if (match) {
/* keep trying to jump past errors for
* CDDA anti-shock processing.
*/
retry_cnt = 0;
} else {
DEBUGINC(1, dbgPlaySector);
play_cdda_state = PLAY_CDDA_INIT;
return(0); /* Really dead */
}
} else {
/* attempt to jump past errors..
* retry time adjustments: 5, 10, 20, 40 (seconds)
*/
adjdsa_time =
logical2physical(375*ptrLshift[retry_cnt]);
adjdsa_time = adjCDtime(dsa_gotime, adjdsa_time, 1);
if (adjdsa_time > endCDtime) {
/* give up..we're at end of track! */
end_of_play = 1;
play_cdda_state = PLAY_CDDA_INIT;
return(0); /* Really dead */
}
dsa_gotime = adjdsa_time;
reset_dsa_go();
retry_cnt++;
}
} else if (status==2) {
#if TDM_ON_AT_TRACK_BEGIN
retry_cnt = glbTimer + ONE_SECOND; /* use retry_cnt as timeout */
play_cdda_state = PLAY_CDDA_WAIT_BEGIN;
CPRINTF("CDDA WAIT", SERVO_cdtime);
#else
play_cdda_state = PLAY_CDDA_TDM_ON;
#endif TDM_ON_AT_TRACK_BEGIN
}
return(1);
#if TDM_ON_AT_TRACK_BEGIN
case PLAY_CDDA_WAIT_BEGIN:
if (retry_cnt < glbTimer) {
play_cdda_state = PLAY_CDDA_TDM_ON;
} else {
if (SERVO_cdtime < begin) return(1);
CPRINTF("CDDA BEGIN", SERVO_cdtime);
play_cdda_state = PLAY_CDDA_TDM_ON;
}
#endif TDM_ON_AT_TRACK_BEGIN
case PLAY_CDDA_TDM_ON:
TDM_turn_on();
CPRINTF("TDM ON", retry_cnt);
#ifdef ANTI_SHOCK
if (match) {
/* use "retry_cnt" as timeout */
retry_cnt = glbTimer+TWO_SECOND;
ABV_xfer_flag = 0; /* "1" when CDDA data comes in */
play_cdda_state = PLAY_CDDA_MATCH;
return(1);
} else
#endif
{
XPORT_active = 1;
play_cdda_state = PLAY_CDDA_INIT;
return(2);
}
break;
#ifdef ANTI_SHOCK
case PLAY_CDDA_MATCH:
if (ABV_xfer_flag) {
XPORT_active = 1;
play_cdda_state = PLAY_CDDA_INIT;
CPRINTF("ESP DATA MATCH", c2po);
return(2);
} else {
/* timeout */
if (retry_cnt < glbTimer) { /* "fuzzy" play for CDDA */
if (c2po_timeout > glbTimer) {
/* really scratched up..
* just go to next track.
*/
servo_track_changed = 1;
} else {
/* Kill TDM so when we restart,
* left/right will not swap */
mvd[tdmctl0] = 0x400;
mvd[tdmrcvslots0] = 0;
TDM_force_stop(1);
ABV_stop_filling();
XPORT_restart_at(XPORT_OFFSET_PLAY_CDDA, 1);
TDM_turn_on();
ABV_start_filling();
XPORT_active = 1;
CPRINTF("ESP FUZZY MATCH", c2po);
play_cdda_state = PLAY_CDDA_INIT;
return(3); /* fuzzy */
}
}
return(1);
}
#endif ANTI_SHOCK
}
}
void fill_screen(int color)
{
DISP_Info *dip;
int width;
int height;
dip = DISP_info + DISP_frame;
#if defined(MP3) || defined(WMA_DEC)
/* For MP3/WMA use I-frame for display, since MP3/WMA shares B&P */
if (STREAM_type) vcx_user_video_stream = 0xe1;
#endif
if ((vcx_user_video_stream == 0xe2) || (vcx_user_video_stream == 0x1e2)) {
DISP_frame = E2;
width = 704;
height = DISP_scn_height * 2;
} else {
DISP_frame = I;
width = 352;
height = 288; /* Set as PAL source */
}
vcx_VertSz = height;
DISP_change_resolution(width, height);
DISP_paint_screen(color, 0, DISP_frame);
DISP_count = 0;
}
PRIVATE void init_dsa(void)
{
IMPORT unsigned short *T_initial_table_mirror ;
IMPORT unsigned int *T_special_disc_mirror;
IMPORT unsigned short *T_special_par_mirror;
IMPORT int T_special_disc_SZ_mirror;
T_initial_table_mirror = T_initial_table;
T_special_disc_mirror = T_special_disc;
T_special_par_mirror = T_special_par;
T_special_disc_SZ_mirror = T_special_disc_SZ;
/* clear all flags */
CDinited = 0;
SERVO_DSP_init();
}
/* 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();
SERVO_service(0);
#ifdef DEAL_MP3_DOWN
if((STREAM_type == MP3_ID)&& SERVO_new_Qcode)
updateLCDtime();
#endif DEAL_MP3_DOWN
SERVO_mode_handle();
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 = 0;
/* make sure servo_info is for current track..
* don't need to use "cdda_glbTimer"
*/
if (cur_track_number == bcd2hex[servo_info>>24]) {
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
***************************************************/
/*
* Set CD-module's modes.
*
* NOTE: SERVO has a bug, if it receives 2 trans_dsa(DSA_mode, mode) in
* a "short" period of time, the mode is actually not changed
* even though it will report the mode has been changed.
*
* Therefore, we can't use the standard way to retry dsa_mode.
* At track boundary, we'll get SERVO_TRACK, SERVO_INDEX, SERVO_MIN,
* and receive_dsa_all only retries 3 time, so we many not get
* a chance to see SERVO_MODE_STATUS if we just retry like other
* cases.
*
* When going into DOUBLE speed, the servo usually takes around
* 1 second to respond! When going into NORMAL speed, the response
* time is a lot shorter.
*
* Input:
* mode: set CD's mode
*
* Return:
* 0: fail
* 1: successful
*/
int dsa_mode(int mode)
{
int next_time;
DISP_naicigam();
#if (defined(ANTI_SHOCK) || defined(ABNORMAL_VCD))
if ((currDSAmode&0x7)^(mode&0x7)) {
SERVO_set_speed((mode & MODE_SPEED_DOUBLE) ? SET_CD_2X : SET_CD_1X);
}
#endif
//防止模式设置不进去,因此需要连续设置 set cdrom
// if ((currDSAmode & MODE_CDROM)^(mode & MODE_CDROM)) {
SERVO_set_mode((mode & MODE_CDROM) ? MODE_CDROM : MODE_AUDIO);
// }
currDSAmode = mode;
return(1);
}
/*
* This function simulates real dsa_release function by set the CDDA_play_time
* to a big number, so the end_of_play will not be set until a track change.
*
* Return:
* 1: successful
*/
int dsa_release(unsigned int track_start, unsigned int track_end)
{
CDDA_play_time = adjCDtime(track_end, track_start, -1);
return (1);
}
/*
* 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;
DISP_naicigam();
cd_stop = 1;
SERVO_stop(1);
return 0;
}
/*
* Pause. This is for CDDA.
*/
int dsa_pause(void)
{
if (kickfg) {
SERVO_target_msf = SERVO_cdtime;
SERVO_mode = SERVO_PAUSE;
servo_pause();
TDM_force_stop(1);
}
return(1);
}
/*
* Pause release. This is for CDDA.
*/
int dsa_pauserelease(void)
{
int found;
/* If we play CDDA,there will be some noise while retry to focus if focus
lost,So,I set "pause" monitoring in servoe.c file again,and if focus
lost, don't do unmute.
custom need to keep playing the pause point,Not to next track
maor (05/03/2004)
*/
if ((SERVO_mode == SERVO_PAUSE) && kickfg) {
SERVO_mode = SERVO_PLAY;
servo_pause_release();
TDM_turn_on();
found = SERVO_search_request();
}
/* 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
* depends on track number:
* 0 <= track number <= 63
* track number
* control & address
* start time (min)
* start time (sec)
* start time (frm)
*
* This routine initialize track information as well as lead out time.
*
* Input:
* pTk: Pointer to the track information buffer
* szTk: Size (number of entries) of track information buffer
*
* Return:
* 0: failed
* 1: OK
*/
extern int echo_resume_flag;
int dsa_ltoc(pTk, szTk)
unsigned int * pTk;
int szTk;
{
int track_rd_num; /* # of track info have been read */
unsigned char data, cmd;
int return_value;
int i;
int pt_A0, pt_A1, pt_A2; /* Keep track whether we have received *
* 64h, 65h, 66h (A0, A1, A2) */
int ltoc_done; /* LTOC is done */
int retry_cnt = 0; /* This routine's retry count */
int loopcnt; /* Number of replies from servo. */
int tk1_ctl_adr; /* Track #1 Control/Address */
int pt_A0_PSEC; /* Track #64 data */
unsigned int next_time;
int timeout;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -