📄 rsm_util.h
字号:
first_flag=0;
changlen=k;
}
}
savetemparry[k]=p[k];
}
WriteToI2cA0(128,p,changlen+1);
//printf("len=%d\n",changlen+1);
first_flag=(BYTE)resumeMSF; //in dvd mode resumeMSF only use flag!
WriteToI2cA0(128+sizeof(pDSV->rsm_info[0])+sizeof(resumeTRK),(BYTE *)&first_flag, sizeof(first_flag));
}
else
{
printf("resumeTRK=%d\n",resumeTRK);
WriteToI2cA0(128+sizeof(pDSV->rsm_info[0]),(BYTE *)&resumeTRK, sizeof(resumeTRK));
printf("resumeMSF:%x\n",resumeMSF);
WriteToI2cA0(128+sizeof(pDSV->rsm_info[0])+sizeof(resumeTRK),(BYTE *)&resumeMSF, sizeof(resumeMSF));
printf("fsnav_dir_now:%d\n", pFsJpeg->fsnav_dir_now);
//it only cdrom need record
if(cd_type_loaded==CDROM)
{
WriteToI2cA0(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF),
(BYTE *)&(pFsJpeg->fsnav_dir_now), sizeof(pFsJpeg->fsnav_dir_now));
printf("fsnav_trk_now:%d\n", pFsJpeg->fsnav_trk_now);
WriteToI2cA0(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF) + sizeof(pFsJpeg->fsnav_dir_now),
(BYTE *)&(pFsJpeg->fsnav_trk_now), sizeof(pFsJpeg->fsnav_trk_now));
printf("myTime:%d\n", myTime);
WriteToI2cA0(128 + sizeof(pDSV->rsm_info[0]) + sizeof(resumeTRK) + sizeof(resumeMSF) + sizeof(pFsJpeg->fsnav_dir_now) + sizeof(pFsJpeg->fsnav_trk_now),
(BYTE *)&myTime, sizeof(myTime));
}
}
}
#endif //end #ifdef RECORD_PER_SECOND
#ifndef DISC_ID_IN_FLASH //put them at the beginning
/*========================================================================
record resume play func's save and load realized functions prototypes
=========================================================================*/
/*
* last memory function
*/
#define SETUP_MENU_BASE 0
#define DVD_INFO_BASE 128
#define CDROM_INFO_BASE 180
#define CDDA_INFO_BASE 200
#define VCD_INFO_BASE 220
//Maoyong 2004.04.07 for all resume use
#define DVD_DISC_INFO 244
#define CDDA_DISC_INFO 248
#define VCD_DISC_INFO 252
#endif //#ifndef DISC_ID_IN_FLASH
#ifdef POWER_RESUME
/**********************************************************************************************
Function : To identify whether the current MP3 disc is the one played last time
return 1 : yes
0 : no
Created by caiyh , 17:03 , Nov 5th , 2004
**********************************************************************************************/
UINT8 IsTheSameMP3 ( void )
{
UINT32 fsnav_dir_now = 0 ,
fsnav_trk_now = 0 ,
first_mp3_entry = 0 ,
MSFFlag = 0 ,
msf = 0 ;
BYTE v [ 4 ] ;
fsnav_dir_now = ReadFromI2cA0_32 ( CDROM_INFO_BASE , v , sizeof( pFsJpeg -> fsnav_dir_now ) ) ;
fsnav_trk_now = ReadFromI2cA0_32 ( CDROM_INFO_BASE + sizeof( pFsJpeg -> fsnav_dir_now ) ,
v , sizeof( pFsJpeg -> fsnav_trk_now ) ) ;
MSFFlag = ReadFromI2cA0_32 ( CDROM_INFO_BASE + sizeof( pFsJpeg -> fsnav_dir_now )
+ sizeof( pFsJpeg -> fsnav_trk_now ) , v , sizeof( MSFFlag ) ) ;
/* read the information recorded from i2c ,
annotated by caiyh , 17:03 , Nov 5th , 2004 */
first_mp3_entry = pFsJpeg -> Dir_entry [ fsnav_dir_now ] ;
fsnav_trk_now += first_mp3_entry ;
msf = iso9660_file [ fsnav_trk_now ] . loc ;
if ( msf == MSFFlag )
return 1 ;
else
return 0 ;
/* according to the dir and trk recorded in i2c, to find the msf specified ,
and compare the current msf with the one read from i2c ,
annotated by caiyh , 17:03 , Nov 5th , 2004 */
}
/**************************************************************
Function : read the parameters about MP3 resume
para = 0 : dir
1 : trk
2 : msf
3 : myTime
return : the value of dir trk msf or myTime
Created by caiyh , 09:24 , Nov 22nd , 2004
**************************************************************/
UINT32 ReadSameMP3Para ( UINT8 para )
{
UINT32 result = 0 ;
BYTE v [ 4 ] ;
if ( para <=2 )
result = ReadFromI2cA0_32 ( CDROM_INFO_BASE + para * 2 , v , 2 ) ;
else if ( para == 3 )
result = ReadFromI2cA0_32 ( CDROM_INFO_BASE + 8 , v , 4 ) ;
// read parameter of mp3 resume from i2c , annotated by caiyh , 09:24 , Nov 22nd , 2004
return result ;
}
/*********************************************************
Function : clear msf about MP3 resume
Created by caiyh , 09:34 , Nov 22nd , 2004
*********************************************************/
void ClrSameMP3Flag ( void )
{
UINT32 MSFFlag = 0 ;
WriteToI2cA0 ( CDROM_INFO_BASE + 4 , ( BYTE * ) & MSFFlag , sizeof ( MSFFlag ) ) ;
// clear msf of mp3 resume in i2c , annotated by caiyh , 09:34 , Nov 22nd , 2004
}
#endif // POWER_RESUME
#if defined (POWER_RESUME)|| defined(SAME_DISC_RESUME)|| defined(RECORD_KEY)
void clr_rsm_info(void)
{//terry,2003/8/13 01:21AM
if( is_menu() || is_cdg_disc(0) || (pe_run==0) ||(cd_type_loaded==CDROM) || ((disp_trk_now==0)&&(cd_type_loaded!=CDDVD)) )
{
printf("clr rsm info: %d %d %d %d\n",is_menu(),is_cdg_disc(0),pe_run,disp_trk_now);
resumeMSF = 0;
resumeTRK = 0;
pFsJpeg->fsnav_dir_now=0;
pFsJpeg->fsnav_trk_now=0;
myTime=0;
}
}
static inline void same_disc_RsmInfo2Flash(int clr)
{
BYTE *p;
#if defined(POWER_RESUME) || defined(SAME_DISC_RESUME)
UINT32 MSFFlag = 0 ;
#endif // POWER_RESUME , added by caiyh , 15:55 , Nov 5th , 2004
if(clr){}//freyman just for warning message
if(cd_type_loaded==CDUNKNOWN) return;
resumeMSF = s_msf&0x00ffffff;
resumeTRK = cd_trk_now;
#ifdef POWER_RESUME
if(Is_MP3_STATE()==0) // don't clear the resume info of mp3 , added by caiyh , 10:53 , Nov 2nd , 2004
#endif // POWER_RESUME
clr_rsm_info(); //terry,2003/8/13 01:21AM
//#ifdef RECORD_KEY//zhaoyanhua 03-11-2 18:56 //Mark by maoyong 2004.04.07
//write DISC INFO to I2C
UINT32 info1;
int pos= 0;
if(cd_type_loaded==CDDVD)
pos = DVD_DISC_INFO;
else if (cd_type_loaded==CDDA)
#ifdef ONLY_PRE_DISC_RESUME
pos = DVD_DISC_INFO;
#else
pos = CDDA_DISC_INFO;
#endif
else if (cd_type_loaded!=CDROM)
#ifdef ONLY_PRE_DISC_RESUME
pos = DVD_DISC_INFO;
#else
pos = VCD_DISC_INFO;
#endif
#ifdef POWER_RESUME
else if(Is_MP3_STATE()==0) /* to add the function of mp3 power resume ,
added by caiyh , 11:05 , Nov 2nd , 2004 */
#else
else
#endif // POWER_RESUME
return;
//Res=check_cdtype();
if(cd_type_loaded!=CDDVD)
info1=M2I(gettrkmsf_leadout()); //get from sysmain2.c
else//CDDVD
info1 = same_disc_vob11_pos; //search_file("VTS_01_1.VOB"); //get from atapi_if728.c
WriteToI2cA0(pos,(BYTE *)&info1,sizeof(info1));
//#endif
{
printf("save rsm info\n");
p=(BYTE *)&pDSV->rsm_info[0];
if(cd_type_loaded!=CDDVD)
{
if(cd_type_loaded==CDROM)
{//we only support MP3, not contain JPEG/Game
if(Is_MP3_STATE()==0) resumeMSF = 0;
printf("fsnav_dir_now:%d\n",pFsJpeg->fsnav_dir_now);
printf("fsnav_trk_now:%d\n",pFsJpeg->fsnav_trk_now);
printf("myTime:%d\n", myTime);
WriteToI2cA0(CDROM_INFO_BASE,(BYTE *)&pFsJpeg->fsnav_dir_now, sizeof(pFsJpeg->fsnav_dir_now));
WriteToI2cA0(CDROM_INFO_BASE+sizeof(pFsJpeg->fsnav_dir_now),(BYTE *)&pFsJpeg->fsnav_trk_now, sizeof(pFsJpeg->fsnav_trk_now));
MSFFlag = mp3_file_msf ( pFsJpeg -> fsnav_trk_now ) ;
// get the msf of current trk , added by caiyh , 15:55 , Nov 5th , 2004
WriteToI2cA0 ( CDROM_INFO_BASE + sizeof(pFsJpeg->fsnav_dir_now)
+ sizeof ( pFsJpeg -> fsnav_trk_now ) , ( BYTE * ) & MSFFlag ,
sizeof(MSFFlag));
// write the msf of current trk to i2c , added by caiyh , 15:55 , Nov 5th , 2004
WriteToI2cA0 ( CDROM_INFO_BASE + sizeof ( pFsJpeg -> fsnav_dir_now )
+ sizeof ( pFsJpeg -> fsnav_trk_now ) + sizeof ( MSFFlag ) ,
( BYTE * ) & myTime , sizeof ( myTime ) ) ;
// write the myTime of current trk to i2c , modified by caiyh , 17:57 , Nov 16th , 2004
printf("MSFFlag:%d\n", MSFFlag);
}else
{
int pos;
if(cd_type_loaded==CDDA) pos=CDDA_INFO_BASE;
else pos=VCD_INFO_BASE;
printf("resumeMSF:%x\n",resumeMSF);
WriteToI2cA0(pos,(BYTE *)&resumeTRK, sizeof(resumeTRK));
WriteToI2cA0(pos+sizeof(resumeTRK),(BYTE *)&resumeMSF, sizeof(resumeMSF));
}
}else
{
//resumeMSF = 1;//terry 2003-8-12 14:20
if(play_state!=VCD_STATE_STOP)
RSM_save(0xff,0);
clr_rsm_info();//terry,2003/8/13 01:21AM
printf("resumeMSF:%d\n",resumeMSF);
WriteToI2cA0(DVD_INFO_BASE,p, sizeof(pDSV->rsm_info[0]));
WriteToI2cA0(DVD_INFO_BASE+sizeof(pDSV->rsm_info[0]),(BYTE *)&resumeMSF, sizeof(resumeMSF));
// psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_TTN:%x\n",pDSV->rsm_info[0].dRSM_TTN);
// UART0_puts(debug_buffer);
// psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_PTTN:%x\n",pDSV->rsm_info[0].dRSM_PTTN);
// UART0_puts(debug_buffer);
// psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_AGLN:%x\n",pDSV->rsm_info[0].dRSM_AGLN);
// UART0_puts(debug_buffer);
// psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_ASTN:%x\n",pDSV->rsm_info[0].dRSM_ASTN);
// UART0_puts(debug_buffer);
// psprintf(debug_buffer,"resumeMSF:%x\n",resumeMSF);
// UART0_puts(debug_buffer);
}
}
}
static inline void same_disc_LoadRsmInfo(void)
{
BYTE *p,v[4];
printf("reading...\n");
p=(BYTE *)&pDSV->rsm_info[0];
if(cd_type_loaded==CDDVD)
{
ReadFromI2cA0(DVD_INFO_BASE,p, sizeof(pDSV->rsm_info[0]));
ReadFromI2cA0(DVD_INFO_BASE+sizeof(pDSV->rsm_info[0]),(BYTE *)&resumeMSF, sizeof(resumeMSF));
printf("pDSV->rsm_info[i].dRSM_TTN:%x\n",pDSV->rsm_info[0].dRSM_TTN);
printf("pDSV->rsm_info[i].dRSM_PTTN:%x\n",pDSV->rsm_info[0].dRSM_PTTN);
printf("pDSV->rsm_info[i].dRSM_AGLN:%x\n",pDSV->rsm_info[0].dRSM_AGLN);
printf("pDSV->rsm_info[i].dRSM_ASTN:%x\n",pDSV->rsm_info[0].dRSM_ASTN);
printf("Read resumeMSF:%x size %d %d\n",resumeMSF,sizeof(pDSV->rsm_info[0]),sizeof(resumeMSF));
// psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_TTN:%x\n",pDSV->rsm_info[0].dRSM_TTN);
// UART0_puts(debug_buffer);
// psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_PTTN:%x\n",pDSV->rsm_info[0].dRSM_PTTN);
// UART0_puts(debug_buffer);
// psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_AGLN:%x\n",pDSV->rsm_info[0].dRSM_AGLN);
// UART0_puts(debug_buffer);
// psprintf(debug_buffer,"pDSV->rsm_info[i].dRSM_ASTN:%x\n",pDSV->rsm_info[0].dRSM_ASTN);
// UART0_puts(debug_buffer);
// psprintf(debug_buffer,"Read resumeMSF:%x size %d %d\n",resumeMSF,sizeof(pDSV->rsm_info[0]),sizeof(resumeMSF));
// UART0_puts(debug_buffer);
}else if(cd_type_loaded==CDROM)
{
resume_fsnav_dir = ReadFromI2cA0_32(CDROM_INFO_BASE,v, sizeof(resume_fsnav_dir));
resume_fsnav_trk = ReadFromI2cA0_32(CDROM_INFO_BASE+sizeof(pFsJpeg->fsnav_dir_now),v, sizeof(resume_fsnav_trk));
myTime = ReadFromI2cA0_32(CDROM_INFO_BASE+sizeof(pFsJpeg->fsnav_dir_now) + sizeof(resume_fsnav_trk),v, sizeof(myTime));
printf("resume_fsnav_dir:%d\n",resume_fsnav_dir);
printf("resume_fsnav_trk:%d\n",resume_fsnav_trk);
printf("myTime:%d\n", myTime);
}else
{
int pos;
if(cd_type_loaded==CDDA) pos = CDDA_INFO_BASE;
else pos = VCD_INFO_BASE;
ReadFromI2cA0(pos,&resumeTRK, sizeof(resumeTRK));
printf("resumeTRK:%x\n",resumeTRK);
resumeMSF = ReadFromI2cA0_32(pos+sizeof(resumeTRK),v, sizeof(resumeMSF));
printf("resumeMSF:%x %x %x %x %x\n",resumeMSF,v[0],v[1],v[2],v[3]);
}
}
void save_cmp_disc_info(UINT32 info1)
{
UINT8 v[4];
UINT32 rom_info1;
int pos;
#ifdef DISC_ID_IN_FLASH
int i,j,index_match,first_empty_indx;
#endif
printf("save & compare disc info ,in\n");
printf("info1:%x\n",info1);
if(cd_type_loaded==CDDVD)
pos = DVD_DISC_INFO;
else if (cd_type_loaded==CDDA)
#ifdef ONLY_PRE_DISC_RESUME
pos = DVD_DISC_INFO;
#else
pos = CDDA_DISC_INFO;
#endif
else if (cd_type_loaded!=CDROM)
#ifdef ONLY_PRE_DISC_RESUME
pos = DVD_DISC_INFO;
#else
pos = VCD_DISC_INFO;
#endif
else return;
#ifndef DISC_ID_IN_FLASH
rom_info1 = ReadFromI2cA0_32(pos,v,sizeof(rom_info1));
//rom_info2 = ReadFromI2cA0_32(pos+sizeof(rom_info1),v,sizeof(rom_info2));
//if( (rom_info1==info1)&&(rom_info2==info2) )
if(rom_info1==info1)
{
same_disc_flag=1;
}else
{
resumeMSF=0;
same_disc_flag=0;
//Maoyong changed 2004.04.07. record disc info just in record action not after reading disc.
//#ifndef RECORD_KEY
//NOTE:
//must mask it,else cause record error.
//WriteToI2cA0(pos,(BYTE *)&info1,sizeof(info1));
//#endif
//WriteToI2cA0(pos+sizeof(info1),(BYTE *)&info1,sizeof(info2));
}
#else//#ifndef DISC_ID_IN_FLASH
current_resume = TOTAL_RESUME;
//just to read in the disc_resume_index table store in disc_resume[TOTAL_RESUME]
rom_info1 = ReadFromI2cA0_32(pos,v,sizeof(rom_info1));
memcpy(disc_resume_index,&disc_resume[current_resume].disc_id,sizeof(disc_resume_index));
// reset disc_resume_index for the first time usage
if ((disc_resume_index[0]==disc_resume_index[1]) ||
(disc_resume_index[0]<0) ||
(disc_resume_index[0]>= TOTAL_RESUME))
{
for (i=0; i<TOTAL_RESUME; i++)
disc_resume_index[i] = 0xff;
}
index_match = 0;
first_empty_indx = -1;
current_resume = 0;
// find the current index to the disc resume information
for (i=0; i<TOTAL_RESUME; i++)
{
//empty index, use it to store resume information
if ((disc_resume_index[i]<0) || (disc_resume_index[i]>= TOTAL_RESUME))
{
current_resume = i;
break;
}
//compare disc information with the current disc resume
current_resume = disc_resume_index[i];
rom_info1 = ReadFromI2cA0_32(pos,v,sizeof(rom_info1));
//disc information not matches the current disc resume, continue.
if(rom_info1==0)
{
if (first_empty_indx <0)
first_empty_indx = i;
continue;
}
//disc information mateces current disc resume
if(rom_info1==info1)
{
index_match = 1;
break;
}
}
//if none of the disc resume information matches the disc information,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -