📄 dsa.c
字号:
abc = 0;
}
#endif
/*
* Service microcontroller, CD ROM (etc)
*/
void CUST_background()
{
/*
* If the NTSC/PAL switch is changed, then change TV mode
* accordingly.
*/
#ifdef TWO_CDS
int k;
int ks = 0;
int kss = 0;
int kss_flag = 0;
#endif
#ifndef BROWSER1
#ifdef DSC
if ((!IS_POWER_DOWN)&&(power_up)) /*detect tv only when powerup*/
#endif
{
PREPARE_DETECTION;
if (currentTVmode == TV_NTSC) {
if (!DETECT_NTSC) {
play_change_tv_mode();
}
} else {
if (DETECT_NTSC) {
play_change_tv_mode();
}
}
}
#endif
#ifdef SERVO_6003
/* Philips 6003 loader open setup */
if (eject_6003_retry == 2) {
while (TRAY_SH_IS_LOW){
power_6003_timer++;
if (power_6003_timer > 1000) {
eject_6003_retry=1;
}
break;
}
while (TRAY_SH_IS_HIGH) {
eject_6003_retry = 1;
break;
}
} else {
while (TRAY_SH_IS_HIGH) {
break;
}
while (TRAY_SH_IS_LOW) {
TRAY_STOP;
if (eject_6003_retry == 1) {
cd_opened ^= 1;
}
power_6003_timer=0;
eject_6003_retry=0;
break;
}
} /* Philips 6003 loader open setup end */
#endif
if (power_up) {
initMicroObject();
init_dsa();
#ifdef SERVO_6003 /* Philips 6003 program */
power_6003_timer=0;
disc_6003_status=1;
TRISTATE_6003_EAUX;
eject_6003_retry = 0;
while (DISC_1_IS_HIGH){
ROTATE_CLOCK_MOVE;
}
while (CD_UP_IS_HIGH){
ROTATE_CLOCK_MOVE;
}
ROTATE_STOP;
cd_opened = 1;
eject_6003_retry = 2;
TRAY_CLOSE;
#endif
#ifndef SERVO
dsa_dac(DAC_SONY16_FS); /* External audio's DAC mode for *
* Phyilip's CD. Don't need if we *
* process CDDA internally. */
#endif SERVO
#ifdef TWO_CDS
if (kss_flag == 0) {
panel_system_status(3);
}
trans_dsa(DSA_LTOC,0);
dsa_stop();
k = glbTimer;
do {
receive_dsa();
} while ((k + QUARTER_SECOND) >= glbTimer);
dsa_stop();
if (kss_flag == 0) {
if (DISC_1_CLOSE_IS_HIGH) {
if (DISC_SW_IS_HIGH) {
if (DISC_2_CLOSE_IS_HIGH) {
TRAY_CLOSE;
k = glbTimer;
do {
kss = get_keycode();
if ((kss == DISC_1_EJECT_KEY) || (kss == DISC_2_EJECT_KEY)) {
put_keycode(kss);
kss_flag = 1;
TRAY_STOP;
break;
}
if ((k + TEN_SECOND) < glbTimer) {
TRAY_STOP;
TRAY_OPEN;
do {
receive_dsa();
} while (DISC_1_CLOSE_IS_HIGH);
TRAY_STOP;
TRAY_CLOSE;
k = glbTimer;
}
receive_dsa();
} while (DISC_2_CLOSE_IS_HIGH);
TRAY_STOP;
}
} else {
if (DISC_2_CLOSE_IS_HIGH) {
TRAY_OPEN;
k = glbTimer;
do {
receive_dsa();
kss = get_keycode();
if ((kss == DISC_1_EJECT_KEY) || (kss == DISC_2_EJECT_KEY)) {
put_keycode(kss);
kss_flag = 1;
TRAY_STOP;
break;
}
if (DISC_1_CLOSE_IS_LOW) {
TRAY_STOP;
break;
}
if ((k + TEN_SECOND) < glbTimer) {
TRAY_STOP;
TRAY_CLOSE;
do {
receive_dsa();
} while (DISC_2_CLOSE_IS_HIGH);
TRAY_STOP;
TRAY_OPEN;
k = glbTimer;
}
} while (DISC_2_CLOSE_IS_HIGH);
TRAY_STOP;
}
}
}
}
if (kss_flag == 0) {
if (DISC_1_CLOSE_IS_HIGH) {
if (DISC_SW_IS_HIGH) {
TRAY_CLOSE;
do {
receive_dsa();
kss = get_keycode();
if ((kss == DISC_1_EJECT_KEY) || (kss == DISC_2_EJECT_KEY)) {
put_keycode(kss);
kss_flag = 1;
TRAY_STOP;
break;
}
} while (DISC_2_CLOSE_IS_HIGH);
} else {
TRAY_OPEN;
k = glbTimer;
do {
receive_dsa();
kss = get_keycode();
if ((kss == DISC_1_EJECT_KEY) || (kss == DISC_2_EJECT_KEY)) {
put_keycode(kss);
kss_flag = 1;
TRAY_STOP;
break;
}
if ((k + TEN_SECOND) < glbTimer) {
TRAY_STOP;
TRAY_CLOSE;
do {
receive_dsa();
} while (DISC_2_CLOSE_IS_HIGH);
TRAY_STOP;
TRAY_OPEN;
k = glbTimer;
}
} while (DISC_1_CLOSE_IS_HIGH);
TRAY_STOP;
TRAY_CLOSE;
k = glbTimer;
do {
receive_dsa();
kss = get_keycode();
if ((kss == DISC_1_EJECT_KEY) || (kss == DISC_2_EJECT_KEY)) {
put_keycode(kss);
kss_flag = 1;
TRAY_STOP;
break;
}
} while ((k + 2) > glbTimer);
TRAY_STOP;
}
}
} else {
OUTOSD(OSD_FUNCTION_STATUS_REGION, MSG_open, MSG_c_open,
DISPLAY_TIME_OUT);
kss = get_keycode();
if (kss == DISC_1_EJECT_KEY) {
panel_system_status(15);
} else {
panel_system_status(16);
}
put_keycode(kss);
}
TRAY_STOP;
if (DISC_SW_IS_LOW)
cd_disc_slot = 2;
else
cd_disc_slot = 1;
#endif
#ifdef TWO_CDS
two_initCD();
#else
initCD(); /* Customize your init CD routine */
#endif
CLEAR_EAUX7;
power_up = 0; /* Reset after initCD() */
/*
* In case CD was in pause state when we powered down, we need to]
* release it first. Otherwise, CD will not play!!
*
dsa_pauserelease(); PVu commented out..already in initCD() */
/* this line is added by Andy_ho, temp commented */
/* power_on = 0; */
} else {
DEBUGINC(1, dbgServiceVcxi);
receive_dsa();
/* test_dsa();*/
DEBUGINC(1, dbgSafeServiceVcxi);
DEBUGASSIGN(glbSec, (glbTimer / ((currentTVmode == TV_PAL) ? 50 : 60)));
if (OSD_scheduled_regions)
{
int i;
unsigned short region_mask;
for (i = 0; i < OSD_MAX_REGIONS; i++)
{
region_mask = ptrLshift[i];
if ( (OSD_scheduled_regions & region_mask) &&
(OSD_schedule_time[i] < glbTimer) )
{
OSD_clear_region(i+1);
OSD_scheduled_regions &= ~region_mask;
}
}
}
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.
* size: Size of a CD sector (in bytes)
*
* Return:
* 0: if failed
* 1: if successful
*/
int getSectors(begin, num, size)
unsigned int begin;
int num, size;
{
unsigned int dsatime, tmp;
unsigned int next_time;
int xfer_done;
int counter;
int timeout;
begCDtime = begin;
endCDtime = num;
tmp = 0;
while (endCDtime >= 10) {
tmp++;
endCDtime -= 10;
}
endCDtime |= (tmp << 4);
endCDtime = adjCDtime(begCDtime, endCDtime, 1);
/* Set DSA_GO time to be 4d frames ealier than user specified */
dsatime = adjCDtime(begCDtime, 0x00000004, -1);
/* Only change DSA mode if the current mode is not CDROM */
TDM_isCDDA = 0; /* Data is scrambled (as opposed to CDDA) */
#ifdef SVCD
if (speed2) dsa_mode(MODE_ATTI_REL | MODE_CDROM | MODE_SPEED_DOUBLE);
else
#endif
dsa_mode(MODE_ATTI_REL | MODE_CDROM | MODE_SPEED_NORMAL);
counter = 0;
do {
xfer_done = 0;
if (!dsa_go(dsatime)) { /* DSA_GO command failed */
if (counter >= 2) {
DEBUGINC(1, dbgGetSector);
return(0);
} else {
counter++;
continue; /* Time not specified, don't go */
}
}
if (counter >= 2) {
DEBUGINC(1, dbgGetSector);
err_code = ERR_GETSECTOR;
return(0);
}
counter++;
system_reset();
system_start();
TDM_isCDDA = 0;
XPORT_play20video(XPORT_OFFSET_GET_SECTOR, size);
TDM_turn_on();
next_time = glbTimer + ONE_SECOND;
timeout = 0;
while (!TDM_found_begCDtime) {
/*
* There may not be any SYNC pattern (CDDA disk), so we'll
* conclude that we are not getting the data if we have
* been sitting here for .5 second
*/
if ((glbTimer > next_time) || (currCDtime > endCDtime)) {
/*
* Check one more time. In case CDI_get is cleared since
* I checked it the last time. If we just turn off TDM,
* then there is some chance that nobody will turn
* TDM on again (because CDI_get is cleared)
*/
if ((power_up) && (retry_go < 2) && (CDinfo.type != CD_CDDA)) {
retry_go++;
dsa_stop();
}
timeout = 1;
break;
}
#ifdef ECHO
MIC_service();
#endif
#ifdef SERVO
SERVO_service();
SERVO_mode_handle();
#endif
}
/* check if the data tranfer is done */
if (!timeout) {
/* Timeout to avoid hanging */
next_time = glbTimer + ONE_SECOND;
do {
#ifdef ECHO
MIC_service();
#endif
;
} while (XPORT_active && (glbTimer < next_time));
xfer_done = 1;
TDM_found_begCDtime = 0;
}
} while (!xfer_done);
/* Victor: Because TDM will set end_of_play when CD_end is reached.
We will need to reset end_of_play here.
It should be safe because when we are getting PSD means we are not
playing any playitem.
*/
end_of_play = 0;
return(1);
}
/*
* Start playing from a given sector. There is no ending location!
* Starting sector is specified in CD time format (i.e. MMSSFF where
* each of MM/SS/FF is a BCD)
*
* This routine will always instruct the CD to go 10d frames earlier.
*
* Inputs:
* begin: Starting CD sector time (in MMFFSS)
* vstream: Video stream type (E0/E1/E2)
* sz: Size of a CD sector (in bytes)
*
* Return:
* 1: successful
* 0: failure
*/
#define PLAY_SECTOR_INIT 0
#define PLAY_SECTOR_DSA_GO 1
#define PLAY_SECTOR_DSA_FIND_INIT 2
#define PLAY_SECTOR_DSA_FIND 3
int play_sector_state = PLAY_SECTOR_INIT;
int playSectors(begin, vstream, size)
unsigned int begin, vstream;
int size;
{
int return_val;
stop_timer = glbTimer;
XPORT_active = 0;
play_sector_state = PLAY_SECTOR_INIT;
do {
return_val = playSectors_step_by_step(begin, vstream, size, 1);
if ((return_val == 2) || (return_val == 3)) {
stop_timer = glbTimer;
return (1);
}
if (return_val == 0) { /* failed */
stop_timer = glbTimer;
return(fuzzyPlaySector(begin, size));
}
if (XPORT_active) { /* when begCDtime == currCDtime */
stop_timer = glbTimer;
return (1);
}
} while (1);
}
/*****************************************************************************
Step by step playSectors.
Returns 0 on failure. Returns 1 if don't know. Returns 2 if completed.
Returns 3 if fuzzy.
*****************************************************************************/
int playSectors_step_by_step(begin, vstream, size, fuzzy_allowed)
unsigned int begin, vstream;
int size, fuzzy_allowed;
{
static int dsatime;
static int go_failed;
static int find_trials;
static unsigned int previous_time;
int status;
if (XPORT_active)
return(1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -