📄 rsm_util.h
字号:
/*
* Terry,2003/8/7 12:23AM
* reduce function
* Maoyong,2004.02.20 15:41PM
To divide POWER_RESUME, RECORD_KEY, SAME_DISC_RESUME for no confusion
POWER_RESUME: when power down, record the current playing pos.
RECORD_KEY: when push RECORD, record the current playing pos
SAME_DISC_RESUME: when TRAY OUT, record the current playing pos
Maoyong, 2004.03.05 13:22
To move record resume relative functions from "sysmain2.c" to this file
Maoyong 2004.03.18 for combinaton usage
Maoyong 2004.04.07 fix bug: When shut down power supply, the next same type disc not recorded will do resume play,
which is wrong.
*/
#ifndef DVDRELEASE
#define SAVE_CDROM_DEBUG 1
#endif
//#define SUPPORT_WHEN_PLAY_MENU_NOT_SAVE_DISC //chik
//add by xlluo 070522
#ifdef SUPPORT_RESUMECTRL_IN_SETUPMENU
#define bIsResumeEn() (setup_VA[SETUP_VA_POWERRESUME_SW]==3) //2 is end
#endif
#if defined(DISC_ID_IN_FLASH)||defined(SETUP_IN_FLASH)//zxb 061019
//#define RESUME_INFO_DBG
//extern int FlashEraseSector(UINT32 unSectorNum);//for warning
//#include "io_uart0.h"
//#include "UartComm.h"
//static char debug_buffer[64]; //for debugging purpose
#include "flash.h"
extern int Resume_Info_Read(UINT32 iStartAddr, BYTE *pBuf, UINT32 iLen);
extern int Resume_Info_Write(UINT32 iStartAddr, BYTE *pBuf, UINT32 iLen);
UINT32 rsm_flash_start_addr;
UINT32 rsm_flash_sec_type;
UINT32 rsm_flash_sec_size;
UINT32 rsm_free_section_idx_array_size;
UINT32 rsm_free_section_size;
UINT32 rsm_flash_erasing_keyword;
/* swpong 2006 0419
* move the following definition to total_rsm.h for rw_nvmem.h
*/
#include "total_rsm.h"
//ted.chang 2006 1117, must be multiple of 4
#define SIZE_PER_ID 64 // Number of bytes storage reserved for disc resume
/*
lijd 2005-6-6 15:23
When make DVD 5 DISC RESUME function for HK OP, yltseng find that there is conflict
between DIVX DRM with DVD 5 DISC RESUME. So,yltseng modify it, and I check it in
vss.
*/
#define SETUP_MENU_BASE 0
/* swpong 2006 0414 */
/*
#define TVG_MEM_BASE 98
#define DVD_INFO_BASE 110//128 6e
#define CDROM_INFO_BASE 162//180
#define CDDA_INFO_BASE 182//200
#define VCD_INFO_BASE 187//220
#ifdef SUPPORT_RECEIVER //hongfeng 2005-08-25
#ifndef SUPPORT_TEN_DISC_RESUME
#define DVD_DISC_INFO 192//244 c0
#define CDDA_DISC_INFO 196//248
#define VCD_DISC_INFO 200//252
#endif
#else
#define DVD_DISC_INFO 192//244
#define CDDA_DISC_INFO 196//248
#define VCD_DISC_INFO 200//252
#endif
*/
//swpong 2006 0414 #define DRM_INFO 208
#define DRM_INFO DRM_REG_CODE_I2C_ADD_ST
typedef struct {
BYTE disc_id[4];
BYTE disc_info[(SIZE_PER_ID+3)&(~3)]; //ted.chang 2006 1117, make multiple of 4
}DISC_RESUME_INFO;
//index table of the disc resume. It will store the latest TOTAL_RESUME disc
BYTE disc_resume_index[TOTAL_RESUME];
//store the information to flash for resume together with
//array[TOTAL_RESUME+1] stores the disc resume index table.
//array[TOTAL_RESUME+2] and array[TOTAL_RESUME+3] stores the setup information
#ifndef RW_NVMEM
#ifdef SETUP_IN_FLASH
DISC_RESUME_INFO disc_resume[TOTAL_RESUME+4];
#else
DISC_RESUME_INFO disc_resume[TOTAL_RESUME+1];
#endif
#endif //RW_NVMEM
//current index
int current_resume = 0;
#endif
#ifdef CHECK_RECORD_DISK_PARENT_LVL //Maoyong 2004.03.04
extern UINT32 setup_CheckPasswd(void);
extern int user_input_pwd;
extern void ShowPasswordGUI(void);
#ifdef NEW_PARENTAL_GUI//zhaoyanhua add 2003-11-28 19:50
extern void ExitParentalGUI(void);
#endif
#endif
#ifdef RECORD_KEY//zhaoyanhua add 03-11-6 15:27
extern void osd_DrawRegionString(BYTE xStart, BYTE yStart, const BYTE *str, BYTE fontColor, BYTE bkColor, BYTE r);
extern void osd_init_record(void);
extern void osd_init(void);
#define FAST2NORM 0x01<<0
#define PAUSE2NORM 0x01<<1
#define SLOW2NORM 0x01<<2
#define REALPLAY 1
//#define TRANSFER 0//nono 2004-2-17 18:05
extern void chg2normal_play(UINT8 md,UINT8 realplay);
extern void run_pause_setting(void);
#endif
#ifdef DYNAMIC_SPECTRUM //zhaoyanhua add 03-11-6 15:26
extern void Show3dspectrum(void);
#endif
#ifdef SAME_DISC_RESUME
extern BYTE same_disc_onoff;
#endif
#if defined (POWER_RESUME)|| defined(SAME_DISC_RESUME)|| defined(RECORD_KEY)||defined(SETUP_IN_FLASH)
//zxb 070412 maybe the flag is needed when resume and setup_in_flash .
UINT32 rsm_disc_type;
#endif
/*
#ifndef DVDRELEASE
//#define RSM_DBG 1
#endif
#ifndef RSM_DBG
#undef printf
#undef print_block
#define printf(f, a...) do {} while (0)
#define print_block(x,y) do {} while (0)
#endif*/
#ifdef SUPPORT_TEN_DISC_RESUME //linrc add for 10 disc resume play 2005-5-12 10:08
BYTE Rsume_Disc_Index; //use this function I2C size must up 1024 BYTE(24C08)
#define RESUME_DISC_NUMBER 3
#define TEN_DISC_INFO_ADDR 339
#define TEN_DISC_RESUME_DEBUG
const UINT16 Info_I2C_ADDR[RESUME_DISC_NUMBER] = {340,344,348,};
const UINT16 MSF_I2C_ADDR[RESUME_DISC_NUMBER] = {353,406,459,};
#endif
#if 0//def SUPPORT_TEN_DISC_RESUME //linrc add for 10 disc resume play 2005-5-12 10:08
BYTE Rsume_Disc_Index; //use this function I2C size must up 1024 BYTE(24C08)
#define RESUME_DISC_NUMBER 10
#define TEN_DISC_INFO_ADDR 257
//#define TEN_DISC_RESUME_DEBUG
const UINT16 Info_I2C_ADDR[10] = {258,262,266,270,274,278,282,286,290,294,};
const UINT16 MSF_I2C_ADDR[10] = {299,351,403,455,507,559,611,663,715,767,};
#endif
#ifdef FLASH_HISTORY
#include "rsm_upd.h"
#endif
#ifdef RW_NVMEM
#include "rw_nvmem.h"
#endif
int is_cdg_disc(int show __UNUSED)
{
#ifdef SUPPORT_CDG
if( (cd_type_loaded==CDDA) && (cd_subtype==CD_DA) && bReadSubChannel && CDG_IsCDGNow())
{
if(show) invalid_key();
return 1;
}else
#endif
return 0;
}
/*
Maoyong changed for resume function define, compile will not give error message
*/
#if !defined(SAME_DISC_RESUME) && !defined(POWER_RESUME) && !defined(RECORD_KEY)
void save_cmp_disc_info(UINT32 info1){ if(info1){} }//terry,2004/4/8 05:36PM
#endif
/*========================================================================
basic I2C read and write function for public use in this file
=========================================================================*/
/*
* i2c device addr : a0
*/
void ReadFromI2cA0(UINT16 iAddr,BYTE *bBuffer,UINT16 len)
{
#if !defined(DISC_ID_IN_FLASH) && !defined(SETUP_IN_FLASH)//zxb 061019
memset(bBuffer,0,len);
if(ReadFromI2c(0xa0, iAddr,bBuffer, len) >=0 )
{//sucess
printf("read flash data:\n");
//print_block(bBuffer,len);
}else
{
printf("read flash error\n");
}
#else//#ifndef DISC_ID_IN_FLASH
int result, j=0;
//int result,i,k;
//int j=0;
//BYTE *p;
//i = sizeof(disc_resume);
#ifdef SETUP_IN_FLASH
#ifndef RW_NVMEM
UINT32 i;
BYTE *p;
int k;
i = sizeof(disc_resume);
#endif
if( iAddr >= DRM_INFO )
{
#ifdef RW_NVMEM
/* swpong 2006 0320 */
result = ReadFromNVMEM(TYPE_DRM, iAddr - DRM_INFO, bBuffer, len);
#else //RW_NVMEM
#ifdef FLASH_HISTORY
result = Resume_Info_Read_Update((BYTE*)disc_resume, i); //swpong 2006 0404
#else
//result = Resume_Info_Read(rsm_flash_start_addr, (BYTE*)disc_resume,i);
result = Resume_Info_Read(rsm_flash_start_addr, (BYTE*)disc_resume,i); // 2005/12/23 yltseng
#endif
p=(BYTE*)&disc_resume[TOTAL_RESUME+3].disc_info;
for (k=0; k<len;k++)
{
j = iAddr - DRM_INFO + k;
*bBuffer++ = *(p+j);
}
#endif //RW_NVMEM
}
else
#endif
#if defined(SAME_DISC_RESUME) || defined(POWER_RESUME) || defined(RECORD_KEY)////zxb 061019
if (iAddr >= DVD_INFO_BASE)
{
if ((iAddr >= DVD_INFO_BASE) && (iAddr <DVD_DISC_INFO))
{
if ((iAddr >= DVD_INFO_BASE) && (iAddr <CDROM_INFO_BASE))
j = iAddr - DVD_INFO_BASE;
else if ((iAddr >= CDROM_INFO_BASE) && (iAddr <CDDA_INFO_BASE))
j = iAddr - CDROM_INFO_BASE;
else if ((iAddr >= CDDA_INFO_BASE) && (iAddr <VCD_INFO_BASE))
j = iAddr - CDDA_INFO_BASE;
else if ((iAddr >= VCD_INFO_BASE) && (iAddr <DVD_DISC_INFO))
j = iAddr - VCD_INFO_BASE;
#ifdef RW_NVMEM
/* swpong 2006 0320 */
result = ReadFromNVMEM(TYPE_RESUME, iAddr - DVD_INFO_BASE, bBuffer, len);
#else //RW_NVMEM
#ifdef FLASH_HISTORY
result = Resume_Info_Read_Update((BYTE*)disc_resume, i); //swpong 2006 0404
#else
result = Resume_Info_Read(rsm_flash_start_addr,(BYTE*)disc_resume,i);
#endif
p= (BYTE*)&disc_resume[current_resume].disc_info;
p+= j;
for (k=0; k<len;k++) *bBuffer++ = *p++;
//memcpy(bBuffer,&disc_resume[current_resume].disc_info+j,len);
#endif //RW_NVMEM
}
else
{
#ifdef RW_NVMEM
/* swpong 2006/03/22 */
result = ReadFromNVMEM(TYPE_DISC_ID, 0, bBuffer, ID_LEN);
#else //RW_NVMEM
#ifdef FLASH_HISTORY
result = Resume_Info_Read_Update((BYTE*)disc_resume, i); //swpong 2006 0404
#else
result = Resume_Info_Read(rsm_flash_start_addr,(BYTE*)disc_resume,i);
#endif
p= (BYTE*)&disc_resume[current_resume].disc_id;
for (k=0; k<len;k++) *bBuffer++ = *p++;
// memcpy(bBuffer,&disc_resume[current_resume].disc_id,len);
#endif //RW_NVMEM
}
}
else
#endif
#if defined( SETUP_IN_FLASH ) && defined( SUPPORT_TVG )
if( iAddr >= TVG_MEM_BASE )
{
#ifdef FLASH_HISTORY
result = Resume_Info_Read_Update((BYTE*)disc_resume, i); //swpong 2006 0404
#else
result = Resume_Info_Read( rsm_flash_start_addr, disc_resume,i );
#endif
p = ((UINT8*)&disc_resume[TOTAL_RESUME+3].disc_info) + 48;
for (k=0; k<len;k++)
{
j = iAddr - TVG_MEM_BASE + k;
*bBuffer++ = *(p+j);
}
}
else
#endif
{
#ifdef SETUP_IN_FLASH
#ifdef RW_NVMEM
result = ReadFromNVMEM(TYPE_SETUP, iAddr, bBuffer, len);
#else //RW_NVMEM
#ifdef FLASH_HISTORY
result = Resume_Info_Read_Update((BYTE*)disc_resume, i); //swpong 2006 0404
#else
result = Resume_Info_Read(rsm_flash_start_addr, (BYTE*)disc_resume,i);
#endif
for (k=0; k<len;k++)
{
j=iAddr+k;
p=(BYTE*)&disc_resume[TOTAL_RESUME+1].disc_info;
if (j>=(SETUP_MENU_BASE+SIZE_PER_ID))
//Wrap around for the next 64 (SIZE_PER_ID) bytes for setup
{
j-= SIZE_PER_ID;
p=(BYTE*)&disc_resume[TOTAL_RESUME+2].disc_info;
}
*bBuffer++ = *(p+j);
}
#endif //RW_NVMEM
#else
result = ReadFromI2c(0xa0, iAddr,bBuffer, len);
#endif
}
if(result >=0 )
{//sucess
printf("read flash data:\n");
//print_block(bBuffer,len);
}else
{
printf("read flash error\n");
}
#endif//#ifndef DISC_ID_IN_FLASH
}
/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -