📄 dsa.c
字号:
#else /* NO SERVO */
#ifndef THREE_CDS
int retry = 2;
int force_quit; /* 1: force abort; 0: receive OK */
#ifdef SERVO_7
/* for the new PHLIPS LOADER 7001, we have to send
* a Clear Toc command before close */
dsa_cleartoc();
#endif /* SERVO_7 */
do {
#ifdef TWO_CDS
rotate_timer = glbTimer;
if (DISC_SW_IS_HIGH) {
TRAY_CLOSE;
do {
receive_dsa();
if (forceDSAabort) {
TRAY_STOP;
return(1);
}
if (rotate_timer + FIFTEEN_SECOND < glbTimer) {
TRAY_STOP;
return(0);
}
} while (DISC_1_CLOSE_IS_HIGH);
TRAY_STOP;
TRAY_OPEN;
closetimer = glbTimer;
do {
receive_dsa();
} while ((closetimer + 1) > glbTimer);
TRAY_STOP;
} else {
TRAY_OPEN;
do {
receive_dsa();
if (forceDSAabort) {
TRAY_STOP;
return(1);
}
if (rotate_timer + FIFTEEN_SECOND < glbTimer) {
TRAY_STOP;
return(0);
}
} while (DISC_2_CLOSE_IS_HIGH);
TRAY_STOP;
TRAY_CLOSE;
closetimer = glbTimer;
do {
receive_dsa();
} while ((closetimer + 2) > glbTimer);
TRAY_STOP;
}
if (power_down)
trans_dsa(DSA_CLOSE, 0);
return(1);
#else
trans_dsa(DSA_CLOSE, 0);
do {
force_quit = !receive_dsa_all(0);
tmp = (dsa_word >> 8) & 0xff;
if ((tmp == SERVO_CLOSED) || force_quit)
return(1); /* Closed*/
else if (tmp == SERVO_ERROR)
return(0); /* Loader open */
else if (tmp == SERVO_MOVING)
continue; /* Intermediate */
else break; /* Unexpected result */
} while (1);
#endif
} while (--retry); /* Retry if we get unexpected result */
#else
/* If not powering down, for 3-CD loaders we just send the command
* and return..for smoother playing.
*/
#ifdef SERVO_6003
TRAY_CLOSE;
#else
trans_dsa(DSA_CLOSE, 0);
#endif
if (power_down) {
#ifdef SERVO_6003
cd_opened = 1;
eject_6003_retry = 2;
TRAY_CLOSE;
#else
do {
receive_dsa_all(0);
tmp = (dsa_word >> 8) & 0xff;
if (tmp == SERVO_CLOSED) return(1); /* Closed*/
else if (tmp == SERVO_MOVING) continue; /* Intermediate */
else break; /* Unexpected result */
} while (1);
#endif
}
#endif /* THREE_CDS */
DEBUGASSIGN(dbgDSAclose, dsa_word);
return(0);
#endif /* NO SERVO */
}
/* This command clears the TOC info stored in memory, and is only allowed
* in stop mode. The command must be sent at disc change in case of
* single tray loader, or top loader applications.
*/
int dsa_cleartoc(void)
{
int retry = 2;
int force_quit; /* 1: force abort; 0: receive OK */
do {
trans_dsa(DSA_CLEARTOC, 0);
force_quit = !receive_dsa_all(0);
if (((dsa_word & 0xff00) == (SERVO_CLEARTOCED << 8)) || force_quit)
return(1);
} while (--retry);
/* Shall never get here! */
DEBUGASSIGN(dbgDSAcleartoc, dsa_word);
return(0);
}
/*
* 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)
{
#ifdef SERVO
return(SERVO_open());
#else /* SERVO */
#ifndef THREE_CDS
int tmp;
int retry = 2; /* Retry twice */
int force_quit; /* 1: force abort; 0: receive OK */
DISP_naicigam();
#ifdef SERVO_7 /* for the new PHLIPS LOADER, we have to send
a stop command before open */
if (!cd_stop)
dsa_stop();
#endif /* SERVO_7 */
do {
#ifdef TWO_CDS
rotate_timer = glbTimer;
if (DISC_SW_IS_HIGH) {
TRAY_OPEN;
do {
receive_dsa();
if (forceDSAabort) {
TRAY_STOP;
return(1);
}
if (rotate_timer + FIFTEEN_SECOND < glbTimer) {
TRAY_STOP;
return(0);
}
} while (DISC_1_OPEN_IS_HIGH);
TRAY_STOP;
return(1);
} else {
TRAY_CLOSE;
do {
receive_dsa();
if (forceDSAabort) {
TRAY_STOP;
return(1);
}
if (rotate_timer + FIFTEEN_SECOND < glbTimer) {
TRAY_STOP;
return(0);
}
} while (DISC_2_OPEN_IS_HIGH);
TRAY_STOP;
return(1);
}
#else
trans_dsa(DSA_OPEN, 0);
do {
force_quit = !receive_dsa_all(0);
tmp = (dsa_word >> 8) & 0xff;
if ((tmp == SERVO_OPENED) || force_quit) {
/* Reset OSD info when we open CD drive */
servo_info = 0;
num_of_track = 0;
servo_min = 0; /* Reset servo_min */
return(1); /* Opened */
} else if (tmp == SERVO_MOVING) continue; /* Intermediate */
else break; /* Unexpected result */
} while (1);
#endif
} while (--retry); /* Retry if we get unexpected result */
#else
/* For 3-CD loaders we just send the command and return..
* for smoother playing.
*/
#ifdef SERVO_6003
TRAY_OPEN;
#else
trans_dsa(DSA_OPEN, 0);
#endif
#endif /* THREE_CDS */
DEBUGASSIGN(dbgDSAopen, dsa_word);
return(0);
#endif /* NO SERVO */
}
/*
* Stops playing the disk and brakes. This command also clears the
* internal 'pause mode indicator'
*/
int dsa_stop(void)
{
int retry = 2;
int force_quit; /* 1: force abort; 0: receive OK */
DISP_naicigam();
#ifdef SONY84412_ERR110
dsa_stop_timer = glbTimer;
CLEAR_FOK;
do {
receive_dsa();
} while ((dsa_stop_timer + 10) > glbTimer);
TRISTATE_FOK;
#endif
#ifdef SERVO
SERVO_stop();
#else /* NO SERVO */
do {
trans_dsa(DSA_STOP, 0);
force_quit = !receive_dsa_all(0);
if (((dsa_word & 0xff00) == (SERVO_STOPPED << 8)) || force_quit)
return(1);
} while (--retry);
/* Shall never get here! */
DEBUGASSIGN(dbgDSAstop, dsa_word);
return(0);
#endif /* NO SERVO */
}
/*
* Pause. This is for CDDA.
*/
int dsa_pause(void)
{
int retry = 2;
int force_quit; /* 1: force abort; 0: receive OK */
#ifdef SERVO
if (kickfg) {
target_min = (SERVO_Qarray_current[3] & 0x0000ff);
target_sec = (SERVO_Qarray_current[4]>>8 & 0x0000ff);
target_frame = (SERVO_Qarray_current[4] & 0x0000ff);
SERVO_mode = SERVO_PAUSE;
}
Do_mute();
return(1);
#else /* NO SERVO */
do {
trans_dsa(DSA_PAUSE, 0);
force_quit = !receive_dsa_all(0);
if (((dsa_word & 0xff00) == (SERVO_FOUND << 8)) || force_quit) {
/*
* end_of_play will be set. We need to clear them.
*
* inA2B will be cleared. It is OK. If dsa_pauserelease
* is called, I'll set it again.
*/
end_of_play = 0; /* In case set by FOUND */
return(1);
}
} while (--retry);
/* Shall never get here! */
DEBUGASSIGN(dbgDSApause, dsa_word);
return(0);
#endif /* NO SERVO */
}
/*
* Pause release. This is for CDDA.
*/
int dsa_pauserelease(void)
{
int retry = 2;
int force_quit; /* 1: force abort; 0: receive OK */
#ifdef SERVO
if ((SERVO_mode == SERVO_PAUSE) && kickfg) {
SERVO_mode = SERVO_PLAY;
SERVO_search();
}
Undo_mute();
return(1);
#else /* NO SERVO */
do {
trans_dsa(DSA_PAUSERELEASE, 0);
force_quit = !receive_dsa_all(0);
if (((dsa_word & 0xff00) == (SERVO_FOUND << 8)) || force_quit) {
/* Redundant, but to be on the safe side */
end_of_play = 0;
return(1);
}
} while (--retry);
/* Shall never get here! */
DEBUGASSIGN(dbgDSApauserelease, dsa_word);
return(0);
#endif /* NO SERVO */
}
/*
* 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
*/
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 i;
int t64r, t65r, t66r; /* Keep track whether we have received *
* 64h, 65h, 66h (A0, A1, A2) */
int ltoc_done; /* LTOC is done */
unsigned char track; /* Current track number */
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 tk64_data; /* Track #64 data */
int ltoc_timeout;
ltoc_timeout = glbTimer;
#ifdef LEDON /*MEIXINDA*/
led_flag = 1;
led_timer = glbTimer;
#endif
#ifdef SERVO
int dly1 = 0;
int num, test;
#endif
CDinited = 0; /* Avoid partially initialized CD info */
#ifdef SERVO_7
#ifndef THREE_CDS
/* send a dsa_close here just in case the tray is opened */
/*
if(cd_opened)
dsa_close(0);
*/
#endif /* not three_CDS */
#endif /* SERVO_7 */
#ifdef SERVO
retry_cnt = 0;
SERVO_ltoc_retry:
CDinfo.type = 255;
if (!SERVO_close()) goto ltoc_err_return;
SERVO_stop();
Job_schedule = job_sledin;
do {
/*
* SERVO_service();
*/
SERVO_schedule(1);
} while (Job_schedule != 0xff);
if ((GFS_ok == 0) || (SERVO_FOK_LOW)) {
CDinfo.type = CD_NODISC;
cd_stop = 1;
err_code = ERR_TRAYEMPTY;
CDinited = 1;
goto ltoc_err_return;
}
if (retry_cnt >= 2) {
err_code = ERR_LTOC;
goto ltoc_err_return; /* Retried twice and still fails */
}
retry_cnt ++;
CDinfo.type = 255;
for (i = 0; i < szTk; i++) pTk[i] = xff000000;
t64r = t65r = t66r = 0;
track_rd_num = num_of_track = 0;
/* process received data until it is done */
loopcnt = ltoc_done = 0;
while (!ltoc_done) {
VCX_service();
loopcnt++;
DEBUGASSIGN(dbgMaxLtocCnt,
(loopcnt > dbgMaxLtocCnt) ? loopcnt : dbgMaxLtocCnt);
if (loopcnt > 2000) {
/*
* Servo is going crazy! This rarely happens; however, I have
* seen this happened!
*/
goto SERVO_ltoc_retry;
}
/* Higher priority command received. Go handle it */
/*victor nov*/ /*add*/
#if 1
if ((loopcnt % 8) == 0)
if(SERVO_check_key_new()) return(0);
#endif
/*
* if (!receive_dsa_all(0)) break;
*/
dly1 = glbTimer;
do {
SERVO_service();
if (SERVO_new_Qcode) break;
if (glbTimer - dly1 > 30) goto SERVO_ltoc_retry;
} while (1);
SERVO_new_Qcode = 0;
for (num=0; num<5; num++) {
test = SERVO_Qarray_new[num];
Qcode[num*2] = (unsigned char) ((test>>8) & 0x00ff);
Qcode[num*2+1] = (unsigned char) (test & 0x00ff);
}
switch ((int) Qcode[SERVO_QTRACK]) {
case 0x00:
switch (Qcode[SERVO_QPOINT]) {
case 0xA0:
CDinfo.firsttrack = (unsigned int) bcd2hex[Qcode[SERVO_QPMIN]];
tk64_data = Qcode[SERVO_QPSEC];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -