setup_tab_reeng.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:180k
源码类别:

DVD

开发平台:

C/C++

  1. //
  2. // FILE
  3. // setup_tab_reeng.c
  4. //
  5. //--------------------------------------
  6. //Modefied by JSLin, 20040817
  7. //For setup menu    reengineering 
  8. //--------------------------------------
  9. #include "user_init.h"
  10. extern int user_input_pwd;
  11. #ifdef NEW_SETUP_OSD    // majinping 2002-05-02 for new setup menu
  12. #error
  13. #include "setup_new.c"
  14. #elif defined(KONKA_DVD)    // 2-7-16 14:44 for new setup menu
  15. #include "setup_konka.c"
  16. #else
  17. /*****************************************************
  18. Creater: Terry
  19. Date   : 2001/5/11 12:49PM
  20. Description: Setup menu using
  21. *****************************************************/
  22. //#define USE_MIC_ECHO_PARAM
  23. #include "global.h"
  24. #include "osd.h"
  25. #include "func.h"
  26. #include "navdata.h"
  27. #include "kernel.h"
  28. #include "vpp.h"
  29. #include "user_if.h"
  30. #include "dsp3_if.h"
  31. #include "cchar.h"
  32. #include "ircmd.h"
  33. #include "auddrv.h" //2004AUDDRV oliver 20041004 for using audio driver purpose
  34. //#include "audif.h"
  35. #include "tvif.h"
  36. #include "memmap.h"
  37. #include "stdlib.h"
  38. #include "kinf.h"
  39. #include "gpio.h"//nono 2004-4-26 20:57
  40. #include "setup.h"
  41. #ifdef SUPPORT_DISPLAY_MENU
  42. #include "ircode.h"
  43. #include "irconfig.h"
  44. #endif//end #ifdef DISPLAY_MENUs
  45. #ifdef TAS3001_AMP //Ti3001_OSD_UI_2  // TAS3001_AMP use setup menu control /jsaon 2-8-30 21:30
  46. #include "ti3001.h"
  47. #endif
  48. #ifdef SUPPORT_APOGEE_AMP//xyy 2004-1-12 17:40
  49. #include "ddx8000.h"
  50. #endif
  51. #ifdef SUPPORT_SPI
  52. #include "spi.h"
  53. #endif
  54. #ifndef DVDRELEASE
  55. //#define SETUP_DBG        1
  56. //#define MONE_SETUP
  57. #endif
  58. #ifndef SETUP_DBG
  59. #undef printf
  60. #undef print_block
  61. #define printf(f, a...) do {} while (0)
  62. #define print_block(x,y) do {} while (0)
  63. #endif
  64. #if defined (YI_XIAN_TONG)||defined (TONIC_DVD)//zhaoyanhua add 03-11-3 22:20
  65. #include "gpio.h"
  66. #endif
  67. extern UINT16 echo_para_tbl[9][2];//2004AUDDRV echo_para[9][2]; for using audio driver purpose
  68. #ifdef VGA_CTRL_FORMAT//wangfeng 2003-12-18 16:12
  69. BYTE    temp_format=0; 
  70. #endif
  71. #ifdef MIC_FUNCTION_KEY 
  72. extern BYTE bFuncStep;//nono 20040107 
  73. #endif//MIC_FUNCTION_KEY 
  74. //wangap add for downmix off volume
  75. #ifndef AC3_BASS_MANAGEMENT
  76.   BYTE    cspk_volume;
  77.   BYTE    fspk_volume;
  78.   BYTE    sspk_volume;
  79. #endif
  80. #ifdef USE_PROLOGIC_II_KEY
  81. BYTE    prologic_val;//clead 2003-8-7
  82. #endif 
  83. #if defined(GBM_DVD)&&!defined(GBM_FULL_FUNCTION)&&!defined(USER_MPEG_LOGO)
  84. #undef SAME_DISC_RESUME
  85. BYTE    same_disc_onoff = 1;
  86. #endif
  87. #ifdef   DYNAMIC_SPECTRUM       //fengjl  3-10-21 20:38 
  88. #undef SAME_DISC_RESUME
  89. BYTE   band_onoff = 0;//inital value must be 0.zhaoyanhua modify 2004-1-12 15:01
  90. #endif
  91. #if 0//def ADD_DVI311_SETUP//Modifed by chenzhao on 2004-12-2 11:55  
  92. #include "spv301.h"
  93. extern void scaler_main(void);
  94. void set_default_value_dvi(void)
  95. {
  96.     dvi311_tv_mode = 0x84; //0x85:NTSC, 0x86:PAL60, 0x84:PAL, 0x7a:AUTO
  97.     dvi311_format = 0xb7; //output format:0xb7:模拟输出, 0xb8:数字输出 
  98.     dvi311_mode =5;// 3; //output mode:0:720P, 1:576P, 2:480P, 3:SXGA, 4:XGA, 5:SVGA, 6:VGA
  99.     Power_off_311=0;   //kevin0710
  100. }
  101. #endif
  102. #if defined(BBK_NEW_SETUP)&&defined(BBK_DV961_DVD)    //fengjl add for bbk's new setup  3-11-12 16:17
  103. extern void osd_init_bbk_setup(void);  
  104. BYTE    one_key_pass_flag = 0;
  105. BYTE    main_setup = 0;
  106. #elif defined(BBK_DSS_555_DVD)||defined(BBK_DV911S)
  107. BYTE    main_setup = 0;
  108. #endif
  109. #ifdef VIDEO_SETUP_NEW_GUI//zhaoyanhua add 2004-1-7 17:18
  110. extern int GetVideoSetValue(int id);
  111. #endif//end VIDEO_SETUP_NEW_GUI
  112. #ifdef AUDIO_2CH_5_1CH//zhaoyanhua add 03-11-1 17:33
  113. extern BYTE ChannelFlag;
  114. #endif
  115. #ifdef  KARAOKE_MENU//wangfeng 
  116. BYTE    KARAOKE_MENU_FLAG=0;
  117. #endif
  118. //#define MONE_SETUP
  119. //=======================
  120. #ifdef NEW_STYLE_SETUP
  121. #define BUTTON_COLOR   7
  122. //zhaoyanhua add 3-7-14 17:49
  123. //a flag decide to operate setupmenu or not.
  124. //if 0,only show setup menu, now at level 0, can not operate.
  125. //if 1,now at level 1, can operate setup menu with UP/DOWN/LEFT/RIGHT/SELECT key.
  126. int   GBM_run_setupmenu_flag = 0;
  127. #endif
  128. //define setup pages(including MAX_SETUP_PAGE+MAX_CUSTM_SETUP_PAGE)
  129. #include "setup_def.h"
  130. const BYTE OSD_LANG_MAP[8] = OSD_LANG_SETUP_MAP; //Jeff 20030217
  131. const BYTE upgrade_file_name[] = UPGRADE_FILE_NAME;//nono 3-6-17 14:03
  132. extern void RsmInfo2Flash(int);
  133. extern void audif_set_SPDIF_BITSTREAM();
  134. extern int check_chipinfo(int);
  135. //extern void ircmd_stop(void);
  136. #ifdef SAME_DISC_RESUME
  137. BYTE    same_disc_onoff;
  138. #endif 
  139. extern UINT8 ap_tv_out_id;//nono 2003-8-1 18:08
  140. #ifdef USER_MPEG_LOGO
  141. BYTE    mpeg_logo_onoff=0;
  142. BYTE    need_show_logo=0;
  143. extern void Change_User_Logo();
  144. #endif
  145. #if defined(NEW_PARENTAL_GUI)||defined(MODIFY_PARENTAL_GUI)//zhaoyanhua add 2003-11-28 10:46
  146. #if defined(NEW_PARENTAL_GUI)
  147. extern void osd_init_parental_gui(void);
  148.     BYTE   new_parental_gui = 0;
  149. #endif
  150. #if defined(MODIFY_PARENTAL_GUI)
  151.     BYTE    parental_gui_flag = 0;
  152. #endif//#if defined(MODIFY_PARENTAL_GUI)
  153. void check_parent_password(void);
  154. void ExitParentalGUI(void);
  155. #endif//#if defined(NEW_PARENTAL_GUI)||defined(MODIFY_PARENTAL_GUI)
  156. //osd related function
  157. extern void osd_init_setup(void);
  158. extern void osd_disable(void);
  159. extern void osd_DrawLine(UINT32 xStart, UINT32 yStart, UINT32 xEnd, UINT32 yEnd, BYTE color, BYTE lineWidth);
  160. extern void osd_draw_rect(UINT32 xStart, UINT32 yStart, UINT32 xLen, UINT32 yLen, BYTE bkColor);
  161. extern void osd_draw_setup_button(BYTE xStart, BYTE yStart, BYTE xLen, BYTE color, BYTE bDown);
  162. extern void setVPP_OffsetX(int X);
  163. extern void setVPP_OffsetY(int Y);
  164. //3D sound(EQ, Surround) related setting
  165. extern BYTE soundGetSurroundType();
  166. //misc functions
  167. extern void set_aud_buf_size(void);
  168. void setup_DrawItem(BYTE level, BYTE yStart, BYTE updowngray);
  169. const char * setup_SetItemString(void);
  170. void run_save_tv_cmd(UINT8 item,UINT8 sel);
  171. UINT16 run_save_unChk_cmd(UINT8 save);
  172. void set_video_aspect(void);
  173. int is_aspect_menu(void);
  174. void run_save_sel_cmd(BYTE page,BYTE index);
  175. void run_save_total_sel(void);
  176. void run_save_total_userSet(void);
  177. void rep_run_the_menu(void);
  178. void show_lock(int s,int mode);
  179. void setup_ShowAC3Config();
  180. void setup_CookScaleItem(UINT8 id, UINT8 dir);
  181. void setup_PrepareScaleItem(BYTE id, BYTE up1down);
  182. void setup_ShowVolCtrlConfig();
  183. void ShowPasswordGUI();
  184. void setup_ShowAC3DynamicRange(void);
  185. void set_AC3DynamicRange(void);
  186. void reset_passwd_cnt(void);
  187. void setup_func_return_main(void);
  188. int IsOSDChinese();
  189. //void SetSharpness(BYTE nVal);
  190. void SetBrightness(BYTE nVal);
  191. void SetContrast(BYTE nVal);
  192. void setup_save_exit(void);
  193. #ifdef IR_KEY_SET_VIDEO_MODE
  194. void SetBrightnessAdjust(BYTE nVal, BYTE nVal2);
  195. void SetContrastAdjust(BYTE nVal, BYTE nVal2);
  196. #endif//IR_KEY_SET_VIDEO_MODE
  197. void SetHUE(BYTE nVal);
  198. void SetSaturation(BYTE nVal);
  199. #ifdef DIP_CFG_ENABLE
  200. void SetDeInterlace(BYTE nVal);
  201. #endif
  202. #ifdef BBK_DVD//zhaoyanhua add 03-10-19 10:43
  203. void AudioSet2chOutput(void);
  204. void AudioSet5_1chOutput(void);
  205. void AudioSetPrologic_IIOutput(void);
  206. #endif//end BBK_DVD
  207. #ifdef SHOW_STANDBY_TIMER        //suqiaoli add 2003-8-2
  208. #define STANDBY_TIMER_ITEM         3
  209. void polling_setup_standby_timer(void);
  210. #endif
  211. extern void search_ap_tv_out_id(void);
  212. extern void update_tv_format_sel(void);
  213. /***********   Item description  **********************
  214.   BYTE    function
  215.   0       mode(MSB 4bits)  ==>show direction picture
  216.   0x0:no effect
  217.   0x1:basic select function
  218.   0x2:can enter number
  219.   0x3:need run function by osd id
  220.   0x4:left/right shift only
  221.   0x5:only show text,can't move to this area
  222.   1       title       ---sw region 1
  223.   2~6     select item ---sw region 2
  224. ******************************************************/
  225. enum
  226. {
  227.     SET_NE=0,
  228.     SET_BS=0x1,
  229.     SET_NM=0x2,
  230.     SET_FUNC=0x3,
  231.     SET_SH=0x4,
  232.     SET_SHOW=0x5,
  233.     SET_SCALE=0x6,
  234.     SET_SPACE=0x7,
  235.     SET_LINK=0x8,   //jump to another page
  236. };
  237. UINT8   setup_page,setup_id,setup_sel_item;
  238. #define page    setup_page
  239. #define id  setup_id
  240. #define sel     setup_sel_item
  241. UINT8   id,sel,page;
  242. #ifdef SETUP_6_DIGIT_PASSWORD//zhaoyanhua add 03-10-14 14:22
  243. UINT32  tmp_passwd;
  244. #else
  245. UINT16  tmp_passwd;
  246. #endif
  247. UINT32  romCheckSum;
  248. #ifdef Ti3001_OSD_UI_2
  249.     INT8  amp_volume_level;
  250.     INT8  amp_fspk_level;
  251.     INT8  amp_fspk_balance_level;
  252.     INT8  amp_sspk_level;
  253.     INT8  amp_sspk_balance_level;
  254.     INT8  amp_cspk_level;
  255.     INT8  amp_subwoofer_level;
  256.     INT8  amp_bass_level;
  257.     INT8  amp_tremble_level;
  258.     INT8  amp_dynamic_level;
  259. #endif
  260. BYTE    index_y=0;          //item index for 1st-level page, 2nd-level page
  261. BYTE    index_y2=0;         //item index for 3rd-level page
  262. BYTE    index_y_start=0;
  263. BYTE    index_y2_start=0;
  264. BYTE    submenuStart=SETUP_MENU_YSTART;
  265. BYTE    setupLevel=0;       //0:main menu, 1:sub-menu, 2:selection-menu(menu of sub-menu)
  266. BYTE    setupItemNum[3] = { //max item num in every sub-menu
  267.     MAX_PAGE_ITEM,          //main menu items count
  268.     MAX_PAGE_ITEM,          //second-level menu items count
  269.     MAX_PAGE_ITEM           //third-level menu
  270. };
  271. //define setup page 
  272. //#include "setup_page.h"
  273. // for DVD_SETUP_REENG, no more setup_page.h
  274. #include "setup_VA.h"
  275. //PS:this command line doesn't be used in macro define
  276. //run_save_sel_cmd(0, 5);
  277. #ifdef Ti3001_OSD_UI_2
  278.     const UINT8 setup_MainP[][2] =
  279.     {
  280.         {STR_OS_SYS_SETUP, 0},
  281.         {STR_OS_LANG_SETUP, 1},
  282.         {STR_OS_AUD_SETUP, 2},
  283.         //{STR_OS_SPK_SETUP, 3},
  284.         {STR_OS_SPK_SETUP, 3},
  285.         {STR_OS_DIGTAL_SETUP, 4},
  286.         {STR_OS_AMP_SETUP1,5},       //S:"功放设定1"
  287.         {STR_OS_AMP_SETUP2,6},       //S:"功放设定2"
  288.         {STR_OS_EXIT_MENU, 7},
  289.     };
  290. #else
  291.     const UINT8 setup_MainP[][2] =
  292.     {
  293.         {STR_OS_SYS_SETUP, 0},
  294.         {STR_OS_LANG_SETUP, 1},
  295.         {STR_OS_AUD_SETUP, 2},
  296.         #ifdef QSI_SETUP_MENU//liweihua 2004-6-15
  297.         {STR_OS_KARAOKE_SETUP,3},
  298.         #else
  299.         #ifndef BBK_SIMPLE_SETUP
  300.          #ifndef SETUP_DONGLI459//20040206
  301.         {STR_OS_VIDEO_SETUP, 3},
  302.         {STR_OS_SPK_SETUP, 4},
  303.         {STR_OS_DIGTAL_SETUP, 5},
  304.        #else
  305.        {STR_OS_SPK_SETUP, 3},
  306.         {STR_OS_DIGTAL_SETUP, 4},
  307.        #endif        
  308.         {STR_OS_SPACE, 0},
  309.         #else//#ifndef BBK_SIMPLE_SETUP
  310.         {STR_OS_VIDEO, 0},
  311.         #endif//#ifndef BBK_SIMPLE_SETUP
  312.         #endif//#ifdef QSI_SETUP_MENU
  313. #if defined(BBK_NEW_SETUP)&&defined(BBK_DV961_DVD) //axel 2004/1/26 04:01 DSS555 need not OENKEYPASSPAGE         
  314.         {STR_OS_ONEKEY_SETUP, 7},
  315.         {STR_OS_EXIT_MENU,8},
  316. #else        
  317.         {STR_OS_EXIT_MENU, 7},
  318. #endif     
  319.         {STR_OS_NO, 0},
  320.     };
  321. #endif
  322. //
  323. // If you change the sequence of the menu items, please check up the following definition
  324. // and
  325. // set_default_value()
  326. // run_set_variable()
  327. // setup_func_down()
  328. // setup_SetAC3Config()
  329. //
  330. UINT8 setup_sel[MAX_SETUP_PAGE + MAX_CUSTM_SETUP_PAGE][MAX_PAGE_ITEM+1];//Item number
  331. #ifdef SUPPORT_FUNCTION_MENU
  332. UINT8 setup_sel_plus[MAX_SETUP_PAGE_PLUS][MAX_PAGE_ITEM_PLUS];
  333. #endif 
  334. //const UINT8 setup_item[MAX_SETUP_PAGE + MAX_CUSTM_SETUP_PAGE][MAX_PAGE_ITEM][MAX_ITEM_SEL]
  335. //exe_setup_function,terry,2004/2/10 03:36PM
  336. #include "setup_item.c"
  337. #include "setup_exe.c"
  338. #include "setup_if.c"
  339. #ifdef SUPPORT_FUNCTION_MENU
  340. #include "setup_plus.c"
  341. #endif
  342. int setup_IsSpkSubwooferOn(void)
  343. {
  344.     int res;
  345.     UINT16 P, I;
  346.     P=setup_getItemPos(STR_OS_SUBWOOFER);
  347.     I=P&0xff;
  348.     P=P>>8;
  349.     
  350.         if(setup_item[P][I][setup_VA[SETUP_VA_SUBWOOFER]]==STR_OS_ON)
  351.          res=1;
  352.         else
  353.          res=0;
  354.     return res;
  355. }
  356. int WillKeyShiftNotDo(void)//nono 2-5-12 20:54
  357. {
  358.     int res=0;
  359.     UINT16 P, I;
  360.     P=setup_getItemPos(STR_OS_DOWNMIX_SETUP);
  361.     I=P&0xff;
  362.     P=P>>8;
  363. #ifndef SETUP_ALL_VALID//nono 2003-9-25 16:54
  364.     if( ((setup_item[P][I][setup_VA[SETUP_VA_DOWNMIX]]==STR_OS_OFF)
  365.         ||(coding_mode_now==AUDIF_CODING_MODE_LPCM) )&&(cd_type_loaded==CDDVD) )
  366.         res=1;
  367.     else if( (setup_item[P][I][setup_VA[SETUP_VA_DOWNMIX]]==STR_OS_OFF)
  368.         &&(coding_mode_now==AUDIF_CODING_MODE_DTSCD) )
  369.         res=1;
  370. #endif
  371.     return res;
  372. }
  373. #ifdef USER_MPEG_LOGO
  374. UINT8 setup_GetMPEGLogoItem(void)
  375. {
  376.     //return (SETUP_MPEG_LOGO);
  377.     return (setup_VA[SETUP_VA_SELECT_LOGO]);
  378. }
  379. void setup_SetMPEGLogo(void)//nono 2-5-16 18:05
  380. {   
  381.     //setup_sel[SysNextPage][MPEG_LOGO_ITEM]=3;
  382.         //SETUP_MPEG_LOGO = MPEG_LOGO_ON;//3
  383.     //exe_setup_function(STR_OS_SELECT_LOGO,STR_OS_DEFAULT_SETUP,0);  // alan, 2003/9/16 05:03PM
  384.         //exe_setup_function(STR_OS_SELECT_LOGO,STR_OS_MPEG_LOGO,0);  //NONO 2004-2-17 17:02
  385.     //setup_sel[7][2]=3;
  386.         //run_save_sel_cmd(SysNextPage, MPEG_LOGO_ITEM);//nono 2004-2-17 17:02
  387.     //JS        //20040818
  388.     setup_VA[SETUP_VA_SELECT_LOGO] = MPEG_LOGO_ON;
  389.     exe_setup_function(STR_OS_SELECT_LOGO, STR_OS_MPEG_LOGO, 0);
  390.     run_save_sel_cmd(setup_VA[SETUP_VA_SELECT_LOGO], SETUP_VA_SELECT_LOGO);
  391.     
  392. }
  393. #endif//USER_MPEG_LOGO
  394. int setup_IsSpkDownmixOff(void)//nono 2-5-16 18:05
  395. {
  396.     UINT16 P, I;
  397.     
  398.     P=setup_getItemPos(STR_OS_DOWNMIX_SETUP);
  399.     I=P&0xff;
  400.     P=P>>8;
  401.     if(setup_item[P][I][setup_VA[SETUP_VA_DOWNMIX]]==STR_OS_OFF)
  402.         return 1;
  403.     else
  404.         return 0;
  405. }
  406. #if 0//no used in DVD_SETUP_REENG
  407. void setup_Showredframe(UINT8 page_val)
  408. {
  409. #ifndef SETUPMENU_16Mb_NO_ICON
  410.         UINT16 line=SETUP_MAX_WIDTH*16-20;
  411.         if(page_val==7) page_val=0;
  412.         osd_DrawLine(line*page_val/6+30,14,line*page_val/6+80,14,SANTIBGCOLOR,1);
  413.         osd_DrawLine(line*page_val/6+30,50,line*page_val/6+80,50,SANTIBGCOLOR,1);
  414.         osd_DrawLine(line*page_val/6+30,14,line*page_val/6+30,50,SANTIBGCOLOR,1);
  415.         osd_DrawLine(line*page_val/6+80,14,line*page_val/6+80,50,SANTIBGCOLOR,1);
  416. #endif
  417. }
  418. #endif
  419. void setup_ShowAC3DynamicRange(void)
  420. {
  421.     return;
  422. #if 0
  423.     BYTE    buf[40];
  424.     BYTE    fontColor;
  425.     if ( (page!=AC3DIGITALPAGE) ||
  426.         (setupLevel!=2) ||
  427.         (index_y!=AC3OUTMODEITEM)
  428.         )
  429.     {
  430.         return;
  431.     }
  432.     if ( (SETUP_AC3DIGITAL_OUTMODE==AC3DYNAMICITEM2) && 1
  433. //      (SETUP_SPK_DOWNMIX==AC3DOWNMIXOFF)
  434.         )
  435.     {
  436.         fontColor = SFONTCOLOR;
  437.     } else {
  438.         fontColor = SGRAYCOLOR;
  439.     }
  440.     id = setup_item[page][AC3DYNAMICITEM1][1];
  441.     psprintf(buf, "%s", _OsdMessegeFont1[osd_font_mode][id]);
  442.     osd_DrawString(SETUP_MENU_XSTART+1, AC3DYNAMICITEM1+SETUP_MENU_YSTART, buf, fontColor, SBGCOLOR);
  443. #endif
  444. }
  445. void set_AC3DynamicRange(void)
  446. {
  447.     if (ac3_dynarange) {
  448.         AUDIF_Set_OutputMode(OUT_CustomModeB_DigitalDialnormK1, ac3_dynarange * 0x2020 - 0x0101);//2004AUDDRV AudioSetOutputMode(0x80, ac3_dynarange * 0x2020 - 0x0101);
  449.     } else {
  450.         AUDIF_Set_OutputMode(OUT_CustomModeB_DigitalDialnormK1, 0);//2004AUDDRV AudioSetOutputMode(0x80, 0);
  451.     }
  452. }
  453. #ifdef AUDIO_2CH_5_1CH
  454. int setup_IsSpkStereo(void)
  455. {
  456.     UINT16 P, I;
  457.     P=setup_getItemPos(STR_OS_DOWNMIX_SETUP);
  458.     I=P&0xff;
  459.     P=P>>8;
  460.     if(setup_item[P][I][setup_VA[SETUP_VA_DOWNMIX]] == STR_OS_STEREO)
  461.         return 1;
  462.     else
  463.         return 0;
  464. }
  465. /*
  466.  * to set 5.1 channel output mode
  467.  *
  468.  */
  469. void AudioSet5_1chOutput(void)
  470. {
  471.     exe_setup_function(STR_OS_DOWNMIX_SETUP,STR_OS_OFF,0);//turn off mix off
  472.     //SETUP_SPK_DOWNMIX = AC3DOWNMIXOFF;  
  473.     UINT16 P, I, S;
  474.     P=setup_getItemPos(STR_OS_DOWNMIX_SETUP);
  475.     I=P&0xff;
  476.     P=P>>8; 
  477.     for(S=MIN_ITEM_SEL; S<MAX_ITEM_SEL; S++) {
  478.         if(setup_item[P][I][S]==STR_OS_OFF)
  479.             {break;}
  480.     }
  481.     setup_VA[SETUP_VA_DOWNMIX]=S;
  482.     setup_sel[P][I]=S;
  483.     //run_save_sel_cmd(setup_VA[SETUP_VA_DOWNMIX], SETUP_VA_DOWNMIX);
  484.     
  485. #ifdef YI_XIAN_TONG//zhaoyanhua add 2003-12-17 9:51
  486.         Gpio5ChOutput();
  487. #endif
  488. }
  489. /*
  490.  * to set PROLOGIC_II channel output mode
  491.  *
  492.  */
  493. #ifdef SUPPORT_PROLOGIC_II  //axel 2004/1/28 10:30
  494. void AudioSetPrologic_IIOutput(void)
  495. {
  496.     //abstract from setup_tab_ui.c  
  497.     //NOTE:
  498.     // can not change the order.
  499.     //zhaoyanhua note 03-11-1 18:58 
  500.     exe_setup_function(STR_OS_PROLOGIC,STR_OS_PL_MUSIC,0);
  501.     //SETUP_PROLOGIC_II= 3;//STR_OS_PL_MUSIC  to update SETUP in time.
  502.     UINT16 P,I,S;
  503.     P=setup_getItemPos(STR_OS_PROLOGIC);
  504.     I=P&0xff;
  505.     P=P>>8;
  506.     for(S=MIN_ITEM_SEL; S<MAX_ITEM_SEL; S++) {
  507.         if(setup_item[P][I][S]==STR_OS_PL_MUSIC)
  508.             {break;}
  509.     }
  510.     setup_VA[SETUP_VA_PROLOGIC]=S;
  511.     setup_sel[P][I]=S;  
  512.     
  513.     //set AUDIO output SIMULATE
  514.     //because BBK need SIMULATE and DIGITAL ouput at the same time
  515.     //so we must mask the following sentences.
  516.     //zhaoyanhua mask 2003-11-29 20:29
  517.     #if 0
  518.     SETUP_SPDIF=2;
  519.     exe_setup_function(STR_OS_AUD_OUT,STR_OS_SIMULATE,0);
  520.     #endif
  521.     //set DOWNMIX OFF 
  522.     //SETUP_SPK_DOWNMIX = AC3DOWNMIXOFF;  
  523.     exe_setup_function(STR_OS_DOWNMIX_SETUP,STR_OS_OFF,0);
  524.     P=setup_getItemPos(STR_OS_DOWNMIX_SETUP);
  525.     I=P&0xff;
  526.     P=P>>8;
  527.     for(S=MIN_ITEM_SEL; S<MAX_ITEM_SEL; S++) {
  528.         if(setup_item[P][I][S]==STR_OS_OFF)
  529.             {break;}
  530.     }
  531.     setup_VA[SETUP_VA_DOWNMIX]=S;
  532.     setup_sel[P][I]=S;      
  533.     
  534. }
  535. #endif //SUPPORT_PROLOGIC_II //axel 2004/1/28 10:30
  536. #endif// AUDIO_2CH_5_1CH
  537. //terry,2004/2/5 12:08PM
  538. void setup_SetTV_format(UINT8 id)
  539. {//terry,2004/2/5 12:02PM
  540. #ifndef NO_TV_FORMAT    
  541.    #ifndef FUSS_TV_DVD//nono 2-8-20 12:55
  542.    UINT32 P, I, S;
  543.    P = setup_getSelPos(id);
  544.    I = (P>>8)&0xff;
  545.    S = P&0xff; 
  546.    P = P>>16;
  547.    setup_VA[SETUP_VA_TV_SYS] = S;
  548.    run_save_sel_cmd(setup_VA[SETUP_VA_TV_SYS], SETUP_VA_TV_SYS);
  549.    
  550.    #endif
  551. #endif    
  552. }
  553. #ifdef FORCE_RETURN_TO_DEFAULT_TV_FORMAT//nono 20030913
  554. void setup_SetTV_default_format(void)
  555. {
  556.      setup_VA[SETUP_VA_TV_SYS] = MIN_ITEM_SEL+DEFAULT_TV_SYS;
  557.     //SETUP_TV_FORMAT = MIN_ITEM_SEL+DEFAULT_TV_SYS;
  558.     //setup_tv_format(DEFAULT_TV_SYS); // Robert 020919
  559.     //exe_setup_function(STR_OS_TV_SYS,STR_OS_NTSC,0);
  560. //modefied by wangfeng,2004-2-9 17:39
  561. #if defined(TV_FORMAT)&& !defined(FORCE_RETURN_TO_DEFAULT_TV_FORMAT)//terry,2004/2/3 01:34PM
  562.     UINT16 P, I;
  563.     P=setup_getItemPos(STR_OS_TV_SYS);
  564.     I=P&0xff;
  565.     P=P>>8;
  566.     exe_setup_function(STR_OS_TV_SYS,setup_item[P][I][setup_VA[SETUP_VA_TV_SYS]],1);            
  567. #else
  568.         //exe_setup_function(STR_OS_TV_SYS,STR_OS_NTSC,1);
  569.         #ifdef FORCE_RETURN_TO_FORMAT_PAL
  570.         tv_format=MODE_PAL;//MODE_NTSC;
  571.         #elif defined(FORCE_RETURN_TO_FORMAT_AUTO)   //fengjl  add 2004-03-09 15:47
  572.         tv_format=MODE_AUTO;
  573.         #else
  574.         tv_format=MODE_NTSC;
  575.         #endif
  576.         update_tv_format_sel();
  577.         setup_tv_format(tv_format);
  578.         #ifdef FORCE_RETURN_TO_FORMAT_PAL
  579.         setup_SetTV_format(STR_OS_PAL);
  580.         #elif defined(FORCE_RETURN_TO_FORMAT_AUTO)
  581.         setup_SetTV_format(STR_OS_AUTO);
  582.         #else
  583.         setup_SetTV_format(STR_OS_NTSC);
  584.         #endif
  585.          //exe_setup_function(STR_OS_TV_SYS,STR_OS_PAL,1);
  586. #endif  
  587. }
  588. #endif//FORCE_RETURN_TO_DEFAULT_TV_FORMAT
  589. #ifdef USE_PROLOGIC_II_KEY//clead 2003-8-7 
  590. void set_prologic_val(BYTE prologic_mode)
  591. {
  592.                 BYTE type=0x23;
  593.                 switch (prologic_mode)
  594.                 {
  595.                     case 0:
  596.                         pl2_init_val|=(1<<20);      // set prologic-II enable
  597.                         pl2_init_val|=(1<<16);      // set init-val to movie mode                       
  598.         //DSP set prologic-II enable
  599.         AUDIF_Set_ProLogicII(0x11);//2004AUDDRV AudioIOControl(PROLOGIC,0x11,0);
  600.                         type=0x23;
  601.                         printf("<MOVIE>, pl2_init_val=0x%06xn",pl2_init_val);
  602.                         break;
  603.                     case 1:     
  604.                         pl2_init_val|=(1<<20);      // set prologic-II enable
  605.                         pl2_init_val&=(~(1<<16));   // set init-val to music mode
  606.         //DSP set prologic-II enable
  607.         AUDIF_Set_ProLogicII(0x11);//2004AUDDRV AudioIOControl(PROLOGIC,0x11,0);
  608.                         type=0x22;
  609.                         printf("<MUSIC>, pl2_init_val=0x%06xn",pl2_init_val);
  610.                         break;
  611.                     case 2:                 
  612.                         //pl2_init_val&=(~(1<<20)); // set prologic-II disable
  613.                         pl2_init_val=0x037300;
  614.         //DSP set prologic-II disable
  615.         AUDIF_Set_ProLogicII(0x10);//2004AUDDRV AudioIOControl(PROLOGIC,0x10,0);
  616.                         printf("<OFF>, pl2_init_val=0x%06xn",pl2_init_val);
  617.                         break;
  618.                 }
  619.     //DSP set prologic-II Decoder Mode Select
  620.     AUDIF_Set_ProLogicII(type);//2004AUDDRV AudioIOControl(PROLOGIC,type,0);
  621.                     //SETUP_PROLOGIC_II=prologic_mode+2;
  622.                     //exe_setup_function(STR_OS_PROLOGIC, setup_item[AUDPAGE][PROLOGIC_II][SETUP_PROLOGIC_II], 1);
  623.                     //clead 2003-10-21 
  624.                     //run_save_sel_cmd(AUDPAGE,PROLOGIC_II);//clead 2003-10-21 
  625.             //added by JS   //for setup reengineering   //20040818          
  626.             UINT32 P, I;
  627.             P = setup_getItemPos(STR_OS_PROLOGIC);
  628.             I = P&0xff;
  629.             P = P>>8;
  630.             setup_VA[SETUP_VA_PROLOGIC] = prologic_mode+2;
  631.             exe_setup_function(STR_OS_PROLOGIC, setup_item[P][I][setup_VA[SETUP_VA_PROLOGIC]], 1);
  632.             run_save_sel_cmd(setup_VA[SETUP_VA_PROLOGIC], SETUP_VA_PROLOGIC);
  633. }
  634. #endif //clead_prologic
  635. void setup_SetPScan(void)
  636. {
  637.     #ifndef FUSS_TV_DVD//nono 2-8-20 12:55
  638.     //SETUP_VIDEO_FORMAT = ap_tv_out_id+2;
  639.     setup_VA[SETUP_VA_VIDEO] = ap_tv_out_id + MIN_ITEM_SEL;
  640.     
  641. #if defined(SCART_TV)||defined(KSD_SCART_TV)||defined(SCART_TV_2)||defined(SCART_TV_4)||defined(SCART_TV_5)//wangfeng 2003-12-2 23:03
  642.         //if(tv_out_id==PC_VGA||tv_out_id==TV_RGB)
  643.         if(tv_out_id==TV_RGB)//nono 2003-8-24 21:08
  644.         SET_SCART_RGB(1);
  645.         else
  646.         SET_SCART_RGB(0);   
  647. #elif defined(SCART_TV_3)
  648.     if(tv_out_id==TV_RGB)
  649.         SET_SCART_RGB(0);
  650.     else
  651.         SET_SCART_RGB(1);
  652. #endif
  653.    
  654. #ifdef SUPPORT_SCART_TV//SPHE8202//nono 4-3-27 21:35
  655.     if(tv_out_id==TV_RGB)
  656.     {
  657.         SET_SCART_GPIO_SFT_CFG_CTRL();
  658.         SET_SCART_TO_RGB();
  659.     }
  660.     else
  661.     {
  662.         SET_SCART_GPIO_SFT_CFG_CTRL();
  663.         SET_SCART_TO_CVBS();
  664.     }
  665. #endif//SPHE8202
  666.    
  667.     //run_save_cmd();
  668.     //run_save_sel_cmd(SYSPAGE,2);
  669.     run_save_sel_cmd(setup_VA[SETUP_VA_VIDEO], SETUP_VA_VIDEO);
  670.     #endif
  671. }
  672. //this function was modified by JS  //for setup reengineering   //20040819
  673. //but, we should not hard code parameters in function
  674. #if 0   //def IR_KEY_SET_VIDEO_MODE
  675. void set_video_val(BYTE video_mode)
  676. {
  677.         UINT8 parm[6][3] = { {8,8,8},//0
  678.                              {7,9,6},//1
  679.                              {9,8,10},//2
  680.                              {8,9,9},//3
  681.                              {11,10,9},//4
  682.                              {7,5,7},//5
  683.                            };
  684.         if(video_mode<6)
  685.         {
  686.               setup_VA[SETUP_VA_BRIGHTNESS]=parm[video_mode][0];
  687.         setup_VA[SETUP_VA_CONTRAST]=parm[video_mode][1];
  688.         setup_VA[SETUP_VA_HUE]=parm[video_mode][0];
  689.         }else
  690.         {
  691.             ReadFromI2c(0xa0, 240,(BYTE *)&setup_VA[SETUP_VA_BRIGHTNESS],1);
  692.             ReadFromI2c(0xa0, 241,(BYTE *)&setup_VA[SETUP_VA_CONTRAST],1);
  693.             ReadFromI2c(0xa0, 242,(BYTE *)&setup_VA[SETUP_VA_HUE],1);
  694.         }
  695.         SetBrightness(setup_VA[SETUP_VA_BRIGHTNESS] - 2);
  696.         SetContrast(setup_VA[SETUP_VA_CONTRAST] - 2);
  697.         SetHUE(setup_VA[SETUP_VA_HUE] - 2);
  698.         //SetSaturation(SETUP_SATURATION - 2);
  699.         run_save_sel_cmd(setup_VA[SETUP_VA_BRIGHTNESS],SETUP_VA_BRIGHTNESS);
  700.      run_save_sel_cmd(setup_VA[SETUP_VA_CONTRAST],SETUP_VA_CONTRAST);
  701.      run_save_sel_cmd(setup_VA[SETUP_VA_HUE],SETUP_VA_HUE);
  702. }
  703. #endif
  704. //
  705. //
  706. #ifdef IR_KEY_SET_VIDEO_MODE
  707. void set_video_val(BYTE video_mode)
  708. {
  709.         UINT8 b,c,h,s;
  710.     //b:SETUP_BRIGHTNESS
  711.     //c:SETUP_CONTRAST
  712.     //h:SETUP_HUE
  713.     UINT8 parm[6][3] = { {8,8,8},//0
  714.                          {7,9,6},//1
  715.                          {9,8,10},//2
  716. #ifndef SET_4_VIDEO_MODE
  717.                          {8,9,9},//3
  718.                          {11,10,9},//4
  719.                          {7,5,7},//5
  720. #endif//SET_4_VIDEO_MODE
  721.                        };
  722. #ifdef SET_4_VIDEO_MODE
  723.     if(video_mode<3)
  724. #else//SET_4_VIDEO_MODE
  725.     if(video_mode<6)
  726. #endif//SET_4_VIDEO_MODE
  727.     {
  728.         b=parm[video_mode][0];
  729.         c=parm[video_mode][1];
  730.         h=parm[video_mode][2];
  731.                 s=2;
  732.                 SetBrightnessAdjust(b - 2,c);
  733.                 SetContrastAdjust(c - 2,b);
  734.     }else
  735.     {
  736.         b=setup_VA[SETUP_VA_BRIGHTNESS];//SETUP_BRIGHTNESS;
  737.         c=setup_VA[SETUP_VA_CONTRAST];//SETUP_CONTRAST;
  738.         h=setup_VA[SETUP_VA_HUE];//SETUP_HUE;
  739.         s=setup_VA[SETUP_VA_SATURATION];//SETUP_SATURATION;
  740.         SetBrightness(b - 2);
  741.         SetContrast(c - 2);
  742.     }
  743.     
  744.         //SetBrightness(SETUP_BRIGHTNESS - 2);
  745.         //SetContrast(SETUP_CONTRAST - 2);
  746.     //SetSaturation(SETUP_SATURATION - 2);
  747.         //SetHUE(SETUP_HUE - 2);
  748.         //SetSaturation(SETUP_SATURATION - 2);
  749.         SetHUE(h - 2);
  750.         SetSaturation(s - 2);
  751.         //if(video_mode_val==6)
  752. }
  753. #endif 
  754. //for setup reengineering   //added by JS   //20040816
  755. void set_default_value(void)
  756. {
  757.     int     i,j, VA;
  758.     #ifdef MONE_SETUP
  759.     printf("nn=============>  set_default_value()     INn");
  760.     #endif
  761.     
  762.     #ifdef ADD_DVI311_SETUP//Modifed by chenzhao on 2004-11-30 19:55   
  763. Power_off_311=1;   
  764.     #endif
  765.     
  766.     for(i=0;i<(MAX_SETUP_PAGE+MAX_CUSTM_SETUP_PAGE);i++){
  767.         for(j=1;j<=MAX_PAGE_ITEM;j++){
  768.             VA=setup_item[i][j][MAX_ITEM_SEL+1]; 
  769.             if(VA<MAX_SETUP_VA){
  770.                 if((setup_item[i][j][1]==STR_OS_RATING)||(setup_item[i][j][1]==STR_OS_PASSWORD)||(setup_item[i][j][1]==STR_OS_REGION_CODE))
  771.                 {/*do nothing here*/} 
  772.                 #ifdef ADD_DVI311_SETUP//Modifed by chenzhao on 2004-11-30 19:55   
  773.                 else if((setup_item[i][j][1]==STR_OS_HDCP))
  774.                 {
  775.                     if(setup_VA[VA]<MIN_ITEM_SEL)
  776.                         setup_VA[VA]=MIN_ITEM_SEL;
  777.                 } 
  778.                 #endif
  779.                 else
  780.                 {
  781.                     setup_VA[VA] = setup_item[i][j][MAX_ITEM_SEL+2]+MIN_ITEM_SEL;
  782.                     if(setup_item[i][j][1]==STR_OS_TV_SYS)
  783.                         exe_setup_function(setup_item[i][j][1], setup_item[i][j][setup_VA[VA]], 1);
  784.                 }
  785.             }
  786.         }
  787.     }
  788.     setup_VA2sel();
  789.     
  790.     init_val_by_record();
  791.     
  792.     #ifdef MONE_SETUP
  793.     dump_setup_val();
  794.     printf("nn=============>  set_default_value()     OUTn");
  795.     #endif
  796. }
  797. //    xyy deleted 2004-3-8 
  798. //the amp default status settint is moved to amp_gui.c
  799. //void set_ampsetup_default(void)
  800. //added by JS   //for setup reengineering   //20040811
  801. void run_set_variable(void)
  802. {
  803.     int     i,j;
  804.     int     P0, P1, P2, P3;
  805.     P0 = setup_pos[0];
  806.     P1 = setup_pos[1];
  807.     P2 = setup_pos[2];
  808.     P3 = setup_pos[3];
  809. #ifdef MONE_SETUP
  810. printf("nn        >>>>>run_set_variable   INn");
  811. #endif
  812. //freyman 2004-3-26 0:00, for when next page used MAX_SETUP_PAGE is defined 7 in setup_def.h
  813. //#if (defined(SAME_DISC_RESUME)&&!defined(GBM_FULL_FUNCTION))||defined(SHOW_STANDBY_TIMER)//for the next sys-page is P.7,wangfeng 2003-12-1 17:49 
  814. //    for(i=0;i<MAX_SETUP_PAGE+1;i++)       
  815. //#else
  816.     
  817.     for(i=0;i<MAX_SETUP_PAGE;i++)
  818. //#endif
  819.         for(j=1;j<=MAX_PAGE_ITEM;j++)
  820.         {
  821.             setup_pos[1] = i;
  822.         setup_pos[2] = j;
  823.         #if defined(BBK_NEW_SETUP)&&defined(BBK_DV961_DVD)
  824.             if(i == ONEKEYPASSPAGE)
  825.             {
  826.                 /*  //marked by JS  //for setup reengineering   //20040819
  827.                 SETUP_SPK_DOWNMIX = DOWNMIXSTEREO;
  828.           //TV format
  829.                 SETUP_TV_FORMAT = 2;//NTSC;
  830.                 exe_setup_function(setup_item[i][0][1],setup_item[i][0][DOWNMIXSTEREO],1);
  831.                 exe_setup_function(setup_item[i][1][1],setup_item[i][1][2],1);    
  832.                 continue;
  833.               */  
  834.               //added by JS //for setup reengineering   //20040819
  835.           if(setup_item[i][j][1]==STR_OS_DOWNMIX_SETUP){
  836.             setup_VA[SETUP_VA_DOWNMIX] = DOWNMIXSTEREO;
  837.             exe_setup_function(STR_OS_DOWNMIX_SETUP,setup_item[i][j][DOWNMIXSTEREO],1);                
  838.           }
  839.           else if(setup_item[i][j][1]== STR_OS_TV_SYS){
  840.             setup_VA[SETUP_VA_TV_SYS] = 2; //set to NTSC    //??????? is this always correct?
  841.             exe_setup_function(STR_OS_TV_SYS, setup_item[i][j][2], 1);
  842.           }     
  843.             }
  844.         #endif
  845.             
  846.             sel=setup_sel[i][j];
  847.          setup_pos[3]=sel;
  848.          
  849.             if (setup_item[i][j][1]!=STR_OS_SSAVER_SETUP)
  850.             {
  851.                 #ifdef SELECT_MEDIA_IN_SETUPMENU    //Maoyong 2004/8/11 run default setting should ignore media selection item
  852.                 if(setup_item[i][j][1] ==STR_OS_MEDIA_TYPE)
  853.                     continue;
  854.                 #endif
  855.             
  856.                 //only setting variable ,not run function...
  857.                 //printf("i:%d  j:%d sel:%d",i,j,sel);
  858.                 if(setup_item[i][j][1]==STR_OS_RATING)
  859.                 {
  860.                     if( (sel<RATE_LOW)||(sel>RATE_HIGH) )
  861.                     {
  862.                         sel = RATE_DEFAULT;
  863.                         setup_sel[i][j]=sel;
  864.                setup_pos[3] = sel;
  865.                     }
  866.                 }
  867. #ifdef GBM_DVD
  868.                 if (setup_item[i][j][1]==STR_OS_TV_SYS)
  869.                 {
  870.                     exe_setup_function(setup_item[i][j][1],setup_item[i][j][sel],1);
  871.                 }
  872.                 else
  873. #endif
  874.                 exe_setup_function(setup_item[i][j][1],setup_item[i][j][sel],0); 
  875.             }
  876.         }
  877.         safe_srn_forceOFF();
  878.         
  879. #ifdef HDCP_CUSTOM
  880.     UINT16 pi;
  881.     pi=setup_getItemPos(STR_OS_HDCP);
  882.     if(pi!=0xffff)
  883.         exe_setup_function(setup_item[pi>>8][pi & 0xff][1],setup_item[pi>>8][pi & 0xff][setup_sel[pi>>8][pi & 0xff]],0);
  884. #endif
  885.     setup_pos[0] = P0;
  886.     setup_pos[1] = P1;
  887.     setup_pos[2] = P2;
  888.     setup_pos[3] = P3;
  889. #ifdef MONE_SETUP
  890. printf("nn        >>>>>run_set_variable   OUTn");
  891. #endif      
  892. }
  893. #ifdef SUPPORT_PASSWD3
  894. extern UINT8 setup_audio_mode;
  895. void chg_audio_default_mode(void)
  896. {
  897.    WriteToI2c(0xa0, 0,(BYTE *)&setup_audio_mode,1);//audio mode
  898. }
  899. #endif
  900. void init_mode_val(void)
  901. {
  902. #ifdef VOLUME_RECODE
  903. {
  904.    int r;
  905.    int i;
  906.    
  907.    #ifdef CNTR_5SPK_VOLUME//wangfeng 2003-11-11 21:27   
  908.    for (i=0; i<7; i++) 
  909.    {    
  910.     #ifdef SW_VOL_63
  911.       if(i==6) audio_volume  = SUB_DEFAULT;
  912.           else audio_volume = DEFAULT_VOL;
  913.         #else
  914.           audio_volume = DEFAULT_VOL;
  915.         #endif    
  916.    
  917.         //audio_volume = VOL_VALUE;       //set to max volume  at the first time  gerry 2-11-6 9:24
  918.         r=WriteToI2c(0xa0, ADDR_I2C_VOLUME+i, (BYTE *)&audio_volume,sizeof(audio_volume));   
  919.    }//for
  920.     
  921.    audio_volume=DEFAULT_VOL;
  922.    volume_Switch=0;
  923.    
  924.    #else//CNTR_5SPK_VOLUME//wangfeng 2003-11-11 21:27   
  925.     audio_volume = DEFAULT_VOL;       //set to max volume when we default gerry 2-11-6 9:26;   
  926.     r=WriteToI2c(0xa0, ADDR_I2C_VOLUME+i, (BYTE *)&audio_volume,sizeof(audio_volume));
  927.    #endif
  928. }
  929. #endif//#ifdef VOLUME_RECODE
  930.     
  931. #ifdef IR_KEY_SET_VIDEO_MODE
  932.    video_mode_val=0;
  933.    WriteToI2c(0xa0, VIDEO_MODE_I2C_ADDRESS,(BYTE *)&video_mode_val,1);
  934. #endif   
  935. #ifdef SUPPORT_PASSWD3
  936.    setup_audio_mode=0;
  937.    chg_audio_default_mode();
  938. #endif
  939.    
  940. }
  941. void read_record_val(void)
  942. {
  943. #ifdef VOLUME_RECODE     //read volume from I2C    gerry  2-11-5 16:47
  944.     int i,r; 
  945.   #ifdef CNTR_5SPK_VOLUME
  946.   for (i=0; i<7; i++) 
  947.   {  
  948.     r=ReadFromI2c(0xa0,ADDR_I2C_VOLUME+i,(BYTE *)&audio_volume,sizeof(audio_volume));    
  949.     //printf("%%%%%%^^^^^^r==<%d>:audio_volume=====>%dn",r,audio_volume);
  950.     
  951.     if(r<=0) audio_volume = DEFAULT_VOL;       //set to max volume when we default gerry 2-11-6 9:26;   
  952.     volume_5SPK[i] = audio_volume;//VOL_VALUE; //set to maximum volume
  953.     if(i==0) idVolume_5SPK[i]    = Volume_Font_ID;
  954.     else     idVolume_5SPK[i]    = VOL_FL_ID+i-1;
  955.   } //for
  956.   
  957.   audio_volume  = volume_5SPK[0] ;
  958.   volume_Switch = 0;     //set to main volume
  959.   #else
  960.   r=ReadFromI2c(0xa0,ADDR_I2C_VOLUME+i,(BYTE *)&audio_volume,sizeof(audio_volume));  
  961.   //printf("%%%%%%^^^^^^r==<%d>:audio_volume=====>%dn",r,audio_volume);
  962.   #endif
  963. #endif //VOLUME_RECODE
  964. #ifdef IR_KEY_SET_VIDEO_MODE
  965.   int r;
  966.   r=ReadFromI2c(0xa0, VIDEO_MODE_I2C_ADDRESS,(BYTE *)&video_mode_val,1);
  967.   //printf("%%%%%%^^^^^^r==<%d>:video_mode_val=====>%dn",r,video_mode_val);
  968.   if(r<=0) video_mode_val=0;  
  969.   set_video_val(video_mode_val);
  970. #endif  
  971. #ifdef SUPPORT_PASSWD3
  972.   ReadFromI2c(0xa0,0,(BYTE *)&setup_audio_mode,1);
  973. #endif
  974.   
  975. }        
  976. void init_val_by_record(void)
  977. {
  978.     //printf("nn  [init_val_by_record]n");
  979.      //echo: shift to 0 ~ 8
  980.         echo_level = setup_VA[SETUP_VA_ECHO] -2;
  981.         //key: shift to -6 ~ 6
  982.     audio_key = setup_VA[SETUP_VA_KEY]  -2 -6;  
  983.         //ac3_dynarange 0 ~ 8
  984.     ac3_dynarange = setup_VA[SETUP_VA_DYNAMCRANGE] -2;
  985.         //mic-volume: shift to 0 ~  8
  986.        #ifdef  MIC_2CHANNEL    // fake code here
  987.        mic_volume = setup_VA[SETUP_VA_MIC_VOL_2] - 2;
  988.     mic_volume = setup_VA[SETUP_VA_MIC_VOL_1] - 2;   
  989.     #else
  990.     mic_volume = setup_VA[SETUP_VA_MIC_VOL] - 2;
  991.     #endif
  992.         
  993. #ifdef DYNAMIC_SPECTRUM       //zhaoyanhua add  2003-12-3 11:42     
  994.        if(setup_VA[SETUP_VA_BAND] == 2)
  995.        {
  996.             band_onoff = 1;
  997.             bEqDisplay = 1; 
  998.        }
  999. #endif
  1000. }
  1001. #ifdef MONE_SETUP
  1002. void dump_setup_val(void)
  1003. {
  1004.   int i, j;
  1005.   printf(">>>read eeprom setup menu,ok!!n");
  1006.   for (i=0; i<MAX_SETUP_PAGE+MAX_CUSTM_SETUP_PAGE; i++) {
  1007.     for (j=0; j<7; j++) {
  1008.         printf("   setup_sel[%d][%d]=%dn", i, j, setup_sel[i][j]);
  1009.     }
  1010.   }
  1011. }
  1012. #else
  1013. #define dump_setup_val();
  1014. #endif
  1015. #ifdef FORCE_REWRITE_WHEN_UPGRADE//terry,2004/1/8 05:28PM
  1016. void load_user_setup(UINT8 force_update)
  1017. #else
  1018. void load_user_setup(void)
  1019. #endif
  1020. {
  1021.     //int       i,j,VA;
  1022.     int         iRts;
  1023.     UINT16      unChksum,unTmp;
  1024.     BYTE        *p;
  1025.     UINT32  romSum=0;
  1026.     #ifdef MONE_SETUP
  1027.         printf("n  <load_user_setup>  INnn");
  1028.         #endif
  1029.     //================================================================= 
  1030.     //get ROM-code-checksum from ROM(20th ~ 23th Byte)
  1031.     {
  1032.         UINT32  *pSum;
  1033.         pSum = (UINT32 *)(ROM_BASE_UNCACHED+0x40);
  1034.         romCheckSum = *pSum &0xffffff;
  1035.     }
  1036.     //read ROM-code-checksum from setup EEPROM(flash)(0-th Byte)
  1037.     p = (BYTE *)(&romSum);
  1038.     iRts = ReadFromI2c(0xa0, 1, p, 3);    
  1039.     WriteToI2c(0xa0, 1, (BYTE *)&romCheckSum,3);//save rom check sum        
  1040.     printf("romCheckSum:%x %xn",romCheckSum,romSum);
  1041. #ifdef FORCE_REWRITE_WHEN_UPGRADE//terry,2004/1/8 05:28PM
  1042.     if(force_update==1)
  1043.     {
  1044.         romSum = 0;     
  1045.          setup_VA[SETUP_VA_RATING]= RATE_DEFAULT;
  1046.         NP_PTL_LVL = 8;//zhaoyanhua  2004-3-9 11:32 after UPGRADE, must set parent level is 8.
  1047.     }
  1048. #endif    
  1049.     if (iRts > 0)//read ROM-code-checksum from setup EEPROM(flash)(0-th Byte) ok
  1050.     { 
  1051.          if (romSum==romCheckSum) 
  1052.         {
  1053.              #ifdef Ti3001_OSD_UI_1
  1054.               load_amplifier_setup();   // jason add 2-10-5 15:59
  1055.              #endif             
  1056. /*  xyy marked 2004-3-8 11:28
  1057.             #if defined(SUPPORT_APOGEE_AMP)&&defined(XINGQIU_DVD_RECEIVER)
  1058.             //xyy 2004-1-13 10:04
  1059.             load_amp_setup();
  1060.              #endif             
  1061. */
  1062.          //read setup setting from setup EEPROM(4-th Byte)
  1063.          p=(BYTE *)setup_VA;
  1064.          iRts=ReadFromI2c(0xa0, sizeof(UINT32), p, sizeof(setup_VA));
  1065. /*
  1066.     printf("===================================================================n");
  1067.          for(i=0; i<64; i++)
  1068.          {
  1069.             printf("setup_VA[%d] = %xn", i, setup_VA[i]);
  1070.          }
  1071.     printf("===================================================================n");
  1072. */
  1073.         setup_VA2sel();
  1074.          
  1075.             //yanlb added 2004/07/07
  1076.             #ifdef  REMB_3DSOUND 
  1077.                 load_3Dsound(sound_sel,user_osd_set);
  1078.             #endif
  1079.         } 
  1080.     else //flash upgrade (romSum!=romCheckSum)
  1081.        {
  1082.             iRts = -1;
  1083.             //if rom0-check-sum is not equal, set to default password, Jeff 20020703
  1084.             #ifdef SUPER_DEFAULT_OSD_LANG
  1085.             UserSet.setup_default_osd_lang = DEFAULT_OSD_LANG;
  1086.             #endif
  1087.             UserSet.parent_passwd = DEFAULT_PASSWORD;
  1088.             WriteToI2c(0xa0, sizeof(UINT32)+sizeof(setup_VA)+2, (BYTE *)&UserSet, sizeof(t_USER_SET));
  1089.         #if defined(SUPPORT_DDX8000)//xyy 2004-5-26
  1090.             //init_ddx_amp_st();
  1091.             //save_amplifier_status_to_e2prom();
  1092.         #endif
  1093.         #if defined(SUPPORT_TUNER_MV114) || defined(SUPPORT_TUNER_ALPS)//xyy 2004-5-26
  1094.                     init_tuner_var();
  1095.         #endif
  1096.             //init mode
  1097.             init_mode_val();
  1098.         } //if (romSum==romCheckSum) {
  1099.     } //if (iRts > 0) {
  1100.     //read audio/video mode
  1101.     read_record_val();
  1102.     
  1103.     if(iRts>0)  // read setup setting from setup EEPROM(4-th Byte) ok
  1104.     {
  1105.         init_val_by_record();       
  1106.         dump_setup_val();        
  1107.         //read setup checksum from setup EEPROM
  1108.         iRts=ReadFromI2c(0xa0, sizeof(UINT32)+sizeof(setup_VA), (BYTE *)&unChksum, 2);
  1109.         if (iRts>0)
  1110.         {
  1111.             printf("read eeprom setup check successn");            
  1112.             //count setup checksum
  1113.             unTmp = run_save_unChk_cmd(0);
  1114.             //check setup checksum and counted checksum
  1115.             if (unTmp!=unChksum) 
  1116.             {                
  1117.                 printf("check sum error, uTmp=%d unCkhsum=%dn",unTmp,unChksum);                
  1118.                 iRts=-2;
  1119.             }
  1120.             else 
  1121.             {
  1122.                 printf("check sum successn");
  1123.             }        
  1124.         }
  1125.         else 
  1126.         {
  1127.             printf("read eeprom setup check errorn");
  1128.         }
  1129.         
  1130.         #ifdef MONE_SETUP
  1131.         printf("chksum=%02xn",unChksum);
  1132.         #endif
  1133.     }
  1134.     //set to default, when
  1135.     // 1. different ROM-code-checksum(setup-EEPROM vs. ROM)
  1136.     // 2.counted setup-checksum != stored in setup EEPROM
  1137.     if (iRts < 0)
  1138.     {
  1139.         #ifdef MONE_SETUP
  1140.         printf("nn read eeprom setup menu,fail!!  set to default now!!n");
  1141.         #endif
  1142.         setup_VA[SETUP_VA_REGION_CODE] = REGION_NUM+2; //nono 20031121
  1143.         UserSet.P_RCD = REGION_NUM;
  1144.         set_default_value();
  1145.         run_save_total_sel();        
  1146.         #ifdef Ti3001_OSD_UI_1    // jason 2-10-5 15:30
  1147.     reset_amplifier_default_setup();
  1148.         #endif
  1149.         #ifdef POWER_RESUME
  1150.         RsmInfo2Flash(1); //clear resume flash memory, Jeff 20020928
  1151.         #endif
  1152.     }
  1153.     //read UserSet for DVD-related
  1154.     //if (iRts>0)
  1155.     iRts=ReadFromI2c(0xa0, sizeof(UINT32)+sizeof(setup_VA)+2, (BYTE *)&UserSet, sizeof(t_USER_SET));
  1156.     if(iRts>0)
  1157.     {
  1158.         printf("read eeprom system menu,ok!!n");
  1159.         printf("nnpassword>>> %dn", UserSet.parent_passwd);
  1160.         UserSet.P_RCD = setup_VA[SETUP_VA_REGION_CODE] - 2;
  1161.     } else 
  1162.     {
  1163.         printf("read eeprom system menu,fail!!n");
  1164.         
  1165.         setup_VA[SETUP_VA_REGION_CODE] = REGION_NUM+2; //Jeff 20021012
  1166.         UserSet.P_RCD = REGION_NUM;
  1167.     }
  1168.     setup_VA[SETUP_VA_REGION_CODE] = UserSet.P_RCD+2;
  1169. /*  //marked by JS  //20040817
  1170.     #ifdef SUPER_DEFAULT_OSD_LANG
  1171.     SETUP_CUSTM_OSDLANG = UserSet.setup_default_osd_lang + 2;
  1172.     #endif
  1173. */
  1174.     run_set_variable();
  1175. //David added 2003-12-17 23:01 temp
  1176. //Syber required: No need switch video output, only YUV default
  1177. #if defined(YUV_DEFAULT_OUTPUT) && defined(DELETE_VIDEO_ITEM)
  1178.         #ifdef S_VIDEO_OUT
  1179.        regs0->emu_cfg[1]|=0x100;
  1180.         #endif //#ifdef S_VIDEO_OUT
  1181.         setup_tv_out(INTERLACE);//set S-video output(composited+component)(0x00:D0-D1-D2-D3=CVBS-V-Y-U)
  1182.         search_ap_tv_out_id();//terry,2003/8/19 03:21PM
  1183. #endif
  1184.     //UserSet.M_LCD = 'z' * 256 + 'h';
  1185.     //china zh ,taiwan tw
  1186.     //china
  1187.     UserSet.CTY_CD=('C'<<8)|('N');
  1188.     UserSet.P_A_CFG=0xffff;// should be config//uinted states:US ,china:CN , taiwan:TW
  1189.     if (setup_VA[SETUP_VA_PASSWORD] == (MIN_ITEM_SEL+1) ) {
  1190.         UserSet.parental_ststus=C_UNLOCK;
  1191.     } else {
  1192.         UserSet.parental_ststus=C_LOCK;
  1193.         setup_VA[SETUP_VA_PASSWORD] = MIN_ITEM_SEL;
  1194.     }
  1195.     #ifdef MONE_SETUP
  1196.     //printf(">>>>>>load setup menu,outn");
  1197.     #endif
  1198.     //check password and grade
  1199.     #ifdef RATING_8
  1200.         if ( (setup_VA[SETUP_VA_RATING]<2) || (setup_VA[SETUP_VA_RATING]>9) ) {
  1201.             setup_VA[SETUP_VA_RATING] = 9;
  1202. //            UserSet.parent_passwd = 0;//NONO mark it.3-11-23 22:17
  1203. //            UserSet.parental_ststus = C_UNLOCK;//NONO mark it.3-11-23 22:17
  1204.             UserSet.parent_passwd = DEFAULT_PASSWORD; //Jeff 20020703
  1205.         }
  1206.     #else
  1207.         if ( (setup_VA[SETUP_VA_RATING]<2) || (setup_VA[SETUP_VA_RATING]>4) ) {
  1208.             setup_VA[SETUP_VA_RATING] = 4;
  1209.            // UserSet.parent_passwd = 0;
  1210.            // UserSet.parental_ststus = C_UNLOCK;
  1211.             UserSet.parent_passwd = DEFAULT_PASSWORD; //Jeff 20020703
  1212.         }
  1213.     #endif
  1214. #ifdef SETUP_6_DIGIT_PASSWORD//zhaoyanhua add 03-10-14 14:10
  1215.     if (UserSet.parent_passwd > 999999) 
  1216. #else //4 digit 
  1217.     if (UserSet.parent_passwd > 9999) 
  1218. #endif   //end   SETUP_6_DIGIT_PASSWORD
  1219.     {    
  1220.         UserSet.parent_passwd = 0;
  1221.         UserSet.parental_ststus = C_UNLOCK;
  1222.     }
  1223.     setupLevel = 0;
  1224.     
  1225.     #if defined(SAME_DISC_RESUME)&&defined(NEXTPAGE_SYS)//freyman 2004-3-26 0:01 alan, 3-9-30 18:59
  1226.     if(setup_sel[SysNextPage][SAME_DISC_RESUME_ITEM]==3)
  1227.     same_disc_onoff=1;
  1228.     else
  1229.     same_disc_onoff=0;//CLEAD 2003-9-29
  1230.     printf("nn====same_disc_onoff:%d====n",same_disc_onoff);
  1231. #endif
  1232.     
  1233. #ifdef BBK_DVD   //fengjl add 3-11-25 22:09  for YUV output when next power on
  1234.     #define   VIDEO_OUTPUT_OFFSET   240
  1235.     int res = ReadFromI2c(0xa0, VIDEO_OUTPUT_OFFSET,(BYTE *)&tv_out_id,sizeof(tv_out_id));
  1236.     if(res < 0)    tv_out_id = INTERLACE;
  1237.     setup_tv_out(tv_out_id);
  1238.     //audio key set default value.zhaoyanhua add 2003-12-4 11:44
  1239.     audio_key = 0;
  1240. #endif
  1241.     
  1242. #ifdef VGA_CTRL_FORMAT//wangfeng 2003-12-18 18:55
  1243.     int res = ReadFromI2c(0xa0, ADDR_I2C_VGA,(BYTE *)&temp_format,sizeof(temp_format));
  1244.     if(res)
  1245.         if(temp_format) 
  1246.         {
  1247.             exe_setup_function(STR_OS_TV_SYS,temp_format,1);//terry,2004/2/3 01:34PM            
  1248.         }
  1249. #endif
  1250.     setup_VA2sel();
  1251.     run_save_total_sel();
  1252.     run_save_total_userSet();
  1253.     //=================================================================
  1254.     #ifdef MONE_SETUP
  1255.     //dump_setup_val();
  1256.         printf("n  <load_user_setup>  OUTnn");
  1257.     #endif
  1258. }
  1259. //=============================================
  1260. //for DVD_SETUP_REENG   //added by JS   //20040728
  1261. #if 0//ndef DVD_SETUP_REENG
  1262. void show_main_title(int id)
  1263. {
  1264.     #ifndef SPE_SETUP   //2004-4-22 06:51张宇P
  1265.     const char *str;
  1266.     int start,len;
  1267.     //count main menu title string length
  1268.     str   = _OsdMessegeFont1[osd_font_mode][id];
  1269.     len = strlen(str);
  1270.     if ( IsOSDChinese() ) {
  1271.         len = len*2;
  1272.     }
  1273.     start = SETUP_MAX_WIDTH/2-len+2;
  1274.     #ifdef  SETUP_COLOR_TYPE1       //wangfeng 2003-08-29 17:16
  1275.     osd_DrawString(3, 2, (char *)str, 7,SBLACKCOLOR/*SWHITECOLOR, SBLACKCOLOR*/);
  1276.     #elif defined( QSI_SETUP_MENU_DESIGN)//liweihua 2004-7-2 18:02
  1277.         if(id == STR_OS_SYS_SETUP)
  1278.         osd_DrawRegionString(2, 13, (char *)str, 12,SBLACKCOLOR,0);
  1279.         else if(id == STR_OS_LANG_SETUP)
  1280.         osd_DrawRegionString(8, 13, (char *)str, 12,SBLACKCOLOR,0);
  1281.         else if(id == STR_OS_AUD_SETUP)
  1282.         osd_DrawRegionString(16, 13, (char *)str, 12,SBLACKCOLOR,0);
  1283.         else if(id == STR_OS_KARAOKE_SETUP)
  1284.         osd_DrawRegionString(22, 13, (char *)str, 12,SBLACKCOLOR,0);
  1285.     #else
  1286.     osd_DrawString(2, 2, (char *)str, 7,SBLACKCOLOR/*SWHITECOLOR, SBLACKCOLOR*/);
  1287.     #endif
  1288.     #endif
  1289. }
  1290. #endif //end of DVD_SETUP_REENG
  1291. //=============================================
  1292. //for DVD_SETUP_REENG   //added by JS   //20040728
  1293. #if 0//ndef DVD_SETUP_REENG
  1294. void draw_3rd_menu()
  1295. {
  1296.     int i;
  1297.     BYTE    fontColor, bgColor;
  1298.     BYTE    upDown;
  1299.     const char   *str;
  1300.     //draw ">" between sub-mean and it's corresponding selection area
  1301.     #ifdef QSI_SETUP_MENU_DESIGN//liweihua 2004-7-4 17:12
  1302.     osd_DrawString(SETUP_SUB_XSTART-1, index_y+SETUP_MENU_YSTART+1, Ch_arrorR, SANTIFONTCOLOR, SBGCOLOR);
  1303.     #else
  1304.     osd_DrawString(SETUP_SUB_XSTART-1, index_y+SETUP_MENU_YSTART+1, Ch_arrorR, SFONTCOLOR, SBGCOLOR);
  1305.     #endif// QSI_SETUP_MENU_DESIGN
  1306.     
  1307. #ifdef VIDEO_SETUP_NEW_GUI//zhaoyanhua add 2004-1-7 17:15
  1308.     if(page == VIDEOPAGE) 
  1309.     {           
  1310.         for(i = 0; i < (setupItemNum[1]); i++ )
  1311.         {
  1312.             
  1313.             if(setup_item[page][i][0] == SET_SCALE)//"EXIT" item, return
  1314.             {   
  1315.                 if(index_y == i)
  1316.                     fontColor = 4;
  1317.                 else
  1318.                     fontColor = SFONTCOLOR;
  1319.                 
  1320.                 setup_VideoItemValue(i, fontColor,SBGCOLOR);
  1321.             }
  1322.         }
  1323.         return;
  1324.     }   
  1325. #endif      
  1326.     //show first selection menu of third-level menu
  1327.     for (i=2; i<MAX_ITEM_SEL; i++)
  1328.     {
  1329.         //get select item
  1330. #ifdef BBK_NEW_SETUP//zhaoyanhua add 2003-11-18 17:15
  1331.         #if !defined(BBK_DSS_555_DVD)&&!defined(BBK_DV911S) //axel 2004/1/26 04:01 DSS555 need not OENKEYPASSPAGE
  1332.         if(one_key_pass_flag)//OENKEYPASSPAGE
  1333.         {
  1334.             sel = GetOneKeyPageSel(index_y);
  1335.         }
  1336.         else
  1337.         #endif
  1338.             sel=setup_sel[page][index_y];
  1339. #else       
  1340.         sel = setup_sel[page][index_y+index_y_start];
  1341. #endif
  1342.         id = setup_item[page][index_y+index_y_start][i];
  1343.         if (id==0)
  1344.         {
  1345.             if (setup_item[page][index_y+index_y_start][0]==SET_SCALE)
  1346.                 setup_PrepareScaleItem(setup_item[page][index_y+index_y_start][1], 0);
  1347.             break;
  1348.         }
  1349.         str = setup_SetItemString();
  1350.         
  1351.         #ifdef  SETUP_COLOR_TYPE1       //wangfeng 2003-08-29 17:16
  1352.         if (sel == i)
  1353.         {
  1354.             fontColor = SDEFAULTCOLOR;//4; //SFONTCOLOR;
  1355.             bgColor =   SBGCOLOR; // SANTIBGCOLOR;
  1356.             upDown = 1;
  1357.         } else {
  1358.             fontColor = 2;//SFONTCOLOR;
  1359.             bgColor = SBGCOLOR;
  1360.             upDown = 0;
  1361.         }
  1362.     #elif defined( QSI_SETUP_MENU_DESIGN)//liweihua 2004-7-4 16:52
  1363.         if (sel == i)
  1364.         {
  1365.             fontColor = SDEFAULTCOLOR;//4; //SFONTCOLOR;
  1366.             bgColor =   SBGCOLOR; // SANTIBGCOLOR;
  1367.             upDown = 1;
  1368.     } 
  1369.     else {
  1370.             fontColor = SFONTCOLOR;
  1371.             bgColor = SBGCOLOR;
  1372.             upDown = 0;
  1373.         }
  1374.     #else
  1375.     if (sel == i)
  1376.     {
  1377.             fontColor = 4; //SFONTCOLOR;
  1378.             bgColor =   SBGCOLOR; // SANTIBGCOLOR;
  1379.             upDown = 1;
  1380.         } else {
  1381.             fontColor = SFONTCOLOR;
  1382.             bgColor = SBGCOLOR;
  1383.             upDown = 0;
  1384.         }
  1385.         #endif
  1386.         //special item(PASSWORD), page-0, item-4
  1387.         if (setup_item[page][index_y+index_y_start][0]==SET_NM)
  1388.         {
  1389.             submenuStart = index_y+SETUP_MENU_YSTART;//zhaoyanhua add 2004-1-16 11:03
  1390.             
  1391.             if (UserSet.parental_ststus==C_LOCK)
  1392.             {
  1393.                  setup_sel[page][index_y+index_y_start] = MIN_ITEM_SEL;
  1394.                 str = _OsdMessegeFont1[osd_font_mode][STR_OS_LOCK];
  1395.             } else {
  1396.                 setup_sel[page][index_y+index_y_start] = MIN_ITEM_SEL + 1;
  1397.                 str = _OsdMessegeFont1[osd_font_mode][STR_OS_UNLOCK];
  1398.             }
  1399.             #ifndef QSI_SETUP_MENU_DESIGN//liweihua 2004-7-4 16:41
  1400.             osd_draw_setup_button(SETUP_SUB_XSTART, (submenuStart)+1, SETUP_MAX_WIDTH-SETUP_SUB_XSTART-2, SANTIBGCOLOR, 1);
  1401.             #endif
  1402.             osd_DrawString(SETUP_SUB_XSTART+1, (submenuStart)+1, str, SANTIFONTCOLOR, SANTIBGCOLOR);
  1403.         } 
  1404.         else 
  1405.         {
  1406. #ifdef RATING_8
  1407.             //when I draw PASSWORD GUI, return main seutp with"ShowSetupPage()",
  1408.             //rating8 show uncorrectly. so I add the following codes
  1409.             //zhaoyanhua 2004-1-16 10:44
  1410.             if ( (page==SYSPAGE) && (index_y == GRADEITEM) )
  1411.             {
  1412.                 submenuStart = SETUP_MENU_YSTART;
  1413.             }
  1414.             else
  1415. #endif
  1416. #ifdef SUPER_DEFAULT_OSD_LANG
  1417.             if(index_y==CUSTMOSDITEM)
  1418.             {
  1419.                 if((8-N_OSD_LANGS)>=4)
  1420.                     submenuStart = index_y + SETUP_MENU_YSTART;
  1421.                 else
  1422.                     submenuStart = SETUP_MENU_YSTART + (8-N_OSD_LANGS) + 1;
  1423.             }else
  1424. #endif
  1425.             submenuStart = index_y+SETUP_MENU_YSTART;
  1426.             #ifndef QSI_SETUP_MENU_DESIGN//liweihua 2004-7-4 16:41
  1427.             osd_draw_setup_button(SETUP_SUB_XSTART, (i-2)+submenuStart+1, SETUP_MAX_WIDTH-SETUP_SUB_XSTART-2, bgColor, upDown);
  1428.             #endif
  1429.             //printf("#### in draw3rdmenu    --- draw string ---n");
  1430.             osd_DrawString(SETUP_SUB_XSTART+1, (i-2)+submenuStart+1, str, fontColor, bgColor);
  1431.         }
  1432.     }
  1433.     setupItemNum[2] = i-2;
  1434. }
  1435. #endif  //end of DVD_SETUP_RENEG
  1436. void setup_func_return_main(void)
  1437. {
  1438.     setupLevel=0;
  1439.     index_y = 0;
  1440.     index_y_start=0;
  1441.     ShowSetupPage(1);
  1442. }
  1443. #if 0//ndef DVD_SETUP_REENG
  1444. void ShowSel(BYTE xStart, BYTE yStart,BYTE xLen,BYTE down)
  1445. {
  1446.     BYTE        fnColor,bgColor;
  1447.     const char *str;
  1448.     str = setup_SetItemString();
  1449.     //#ifdef    SETUP_COLOR_TYPE1       //wangfeng 2003-08-29 17:16
  1450.     #if defined(SETUP_COLOR_TYPE1) || defined( QSI_SETUP_MENU_DESIGN)//liweihua 2004-7-4 16:46
  1451.     if (down)
  1452.         fnColor=SDEFAULTCOLOR;//4;
  1453.     else
  1454.         fnColor=SFONTCOLOR;
  1455.         bgColor = SBGCOLOR;
  1456.     #else    
  1457.     if (down)
  1458.         fnColor=4;
  1459.     else
  1460.         fnColor=SFONTCOLOR;
  1461.         bgColor = SBGCOLOR;
  1462.     #endif
  1463.     #ifndef QSI_SETUP_MENU_DESIGN//liweihua 2004-7-4 16:41
  1464.     osd_draw_setup_button(xStart,yStart,xLen, bgColor, down);
  1465.     #endif
  1466.     osd_DrawString(xStart+1, yStart, str, fnColor, bgColor);
  1467. }
  1468. #endif
  1469. //NOTE: the following .h files only include UI function,such as
  1470. //      LEFT,RIGHT, UP, DOWN,  SELECT, ShowSetupPage.
  1471. #ifdef NEW_STYLE_SETUP//zhaoyanhua add 3-7-25 17:29
  1472. #include "setup_newstyle_ui.c"
  1473. #else
  1474. #include "setup_tab_ui.c"
  1475. #endif //NEW_STYLE_SETUP
  1476. //=============================================
  1477. //for DVD_SETUP_REENG   //added by JS   //20040728
  1478. void init_setup(void)
  1479. {
  1480.     //printf(">>>>> setup_tab.c     init_setupn");
  1481.     full_scrn=SETUP;       //setup menu
  1482.     ShowSetupPage(0);
  1483. }
  1484. //=============================================
  1485. //for DVD_SETUP_REENG   //added by JS   //20040728
  1486. #if 0 //ndef DVD_SETUP_REENG
  1487. void setup_DrawItem(BYTE level, BYTE yStart, BYTE updowngray)
  1488. {
  1489.     const char *str;
  1490.     BYTE    xStart, xWidth;
  1491.     BYTE    xOffset;
  1492.     BYTE    cFont, cBackground;
  1493.     BYTE    idString;
  1494.     #ifdef SUPPORT_FUNCTION_MENU
  1495.     if(full_scrn&SETUP_PLUS)
  1496.     {
  1497.         if (level==1)
  1498.         {
  1499.           xStart = SETUP_MENU_XSTART_PLUS;
  1500.           #ifdef SUPPORT_DISPLAY_MENU
  1501.           if(In_Display_Menu())
  1502.             xWidth = DISPLAY_MENU_LENGTH;
  1503.           else
  1504.           #endif
  1505.           xWidth = SETUP_SUB_XSTART_PLUS-SETUP_MENU_XSTART_PLUS-1;
  1506.           xOffset = 1;
  1507.           idString = id;
  1508.         }
  1509.     }
  1510.     else
  1511.     {
  1512.     #endif //end #ifdef SUPPORT_FUNCTION_MENU
  1513.     if (level==0) {
  1514.         xStart = SETUP_MENU_XSTART;
  1515.         xWidth = SETUP_MAX_WIDTH-2*SETUP_MENU_XSTART;
  1516.         xOffset = 8;
  1517.         idString = setup_MainP[page][0];
  1518.     } else if (level==1)
  1519.     {
  1520.         xStart = SETUP_MENU_XSTART;
  1521.         xWidth = SETUP_SUB_XSTART-SETUP_MENU_XSTART-1;
  1522.         xOffset = 1;
  1523.         idString = id;
  1524.     } else {
  1525.         xStart = SETUP_SUB_XSTART;
  1526.         xWidth = SETUP_MAX_WIDTH-SETUP_SUB_XSTART-2;
  1527.         xOffset = 1;
  1528.         idString = id;
  1529.     }
  1530.     #ifdef SUPPORT_FUNCTION_MENU
  1531.     }
  1532.     #endif //end #ifdef SUPPORT_FUNCTION_MENU
  1533.     
  1534.     #ifdef SUPPORT_DISPLAY_MENU
  1535.     if((In_Display_Menu()) && (index_y == TITLE_TRACK_ITEM) 
  1536.          && (cd_type_loaded != CDDVD)) 
  1537.         idString = id = setup_item_plus[page][index_y][1] = STR_OS_TRACK;
  1538.     else if((In_Display_Menu()) && (index_y == PBC_MENU_ITEM) 
  1539.          && (cd_type_loaded == CDDVD))
  1540.         idString = id = setup_item_plus[page][index_y][1] = STR_OS_MENU;
  1541.     #endif
  1542.             
  1543.             
  1544.     if (updowngray==0) {        //up
  1545.         cFont = SFONTCOLOR;
  1546.         cBackground = SBGCOLOR;
  1547.     } else if (updowngray==1) { //down
  1548.         cFont = SANTIFONTCOLOR;
  1549.         cBackground = SANTIBGCOLOR;
  1550.     } else
  1551.         //if (updowngray==2)
  1552.     { //gray
  1553.         cFont = SGRAYCOLOR;
  1554.         cBackground = SBGCOLOR;
  1555.         updowngray = 0;
  1556.     }
  1557.     #ifndef QSI_SETUP_MENU_DESIGN//liweihua 2004-7-4 16:41
  1558.     osd_draw_setup_button(xStart, yStart, xWidth, cBackground, updowngray);
  1559.     #endif
  1560. /*
  1561.     #ifndef BBK_NEW_SETUP//zhaoyanhua add for BBK_DVD
  1562.     if (idString==STR_OS_RETURN_MAIN_SETUP)  // no main page, so this item changes to exit_setup_menu
  1563.         idString=STR_OS_EXIT_MENU;
  1564.     #endif
  1565. */
  1566.     #ifdef BBK_NEW_SETUP    //fengjl edit 4-1-28 14:23
  1567.     #if defined(BBK_DSS_555_DVD)||defined(BBK_DV911S)
  1568.     if (idString==STR_OS_RETURN_MAIN_SETUP)
  1569.         idString=STR_OS_EXIT_MENU;
  1570.     #endif
  1571.     #else       
  1572.     if (idString==STR_OS_RETURN_MAIN_SETUP)  // no main page, so this item changes to exit_setup_menu
  1573.         idString=STR_OS_EXIT_MENU;
  1574.     #endif
  1575. #ifdef SUPER_DEFAULT_OSD_LANG
  1576.     if((page==CUSTMPAGEINDEX)&&(index_y==CUSTMOSDITEM)&&(setupLevel!=1))
  1577.     {
  1578.         str = lang_names[osd_font_mode][id];
  1579.     }
  1580.     else
  1581. #endif 
  1582.     str = _OsdMessegeFont1[osd_font_mode][idString];
  1583.     #ifdef SUPPORT_DISPLAY_MENU
  1584.     if((In_Display_Menu()) && (index_y == PBC_MENU_ITEM)
  1585.         && (cd_type_loaded == CDDVD))
  1586.     {
  1587.       BYTE buf[7];
  1588.       
  1589.       osd_DrawString(SETUP_MENU_XSTART_PLUS+6, index_y+SETUP_MENU_YSTART_PLUS, str, cFont, cBackground);
  1590.       psprintf(buf,"GOTO");
  1591.       osd_DrawString(SETUP_MENU_XSTART_PLUS+1, index_y+SETUP_MENU_YSTART_PLUS, buf, cFont, cBackground);
  1592.     }
  1593.     else 
  1594.     if(index_y != BATTERY_ITEM)
  1595.     #endif//end #ifdef SUPPORT_DISPLAY_MENU
  1596.     osd_DrawString(xStart+xOffset, yStart, (char *)str, cFont, cBackground);
  1597. #ifdef VIDEO_SETUP_NEW_GUI//zhaoyanhua add 2004-1-7 18:36
  1598.     if(page == VIDEOPAGE)
  1599.     {
  1600.         if(setup_item[page][index_y][0] == SET_SCALE)       
  1601.         {           
  1602.             if(updowngray)
  1603.                 cFont = 4;//HLCOLOR     
  1604.             else
  1605.                 cFont = SFONTCOLOR;
  1606.             setup_VideoItemValue(index_y, cFont,SBGCOLOR);//show value with HL color.       
  1607.         }                               //draw_3rd_menu();                                  
  1608.     }
  1609. #endif  //VIDEO_SETUP_NEW_GUI
  1610.    #ifdef SUPPORT_DISPLAY_MENU
  1611.    if(In_Display_Menu()) 
  1612.    {
  1613.      Set_Update_Item_Flag();
  1614.     
  1615.      if(updowngray == 1)
  1616.        show_display_item_content(index_y,SANTIFONTCOLOR,SANTIBGCOLOR);
  1617.      else
  1618.        show_display_item_content(index_y,SFONTCOLOR,SBGCOLOR);      
  1619.    }
  1620.    #endif
  1621. }
  1622. #endif  // end of DVD_SETUP_REENG
  1623. UINT16 run_save_unChk_cmd(UINT8 save)
  1624. {
  1625.     int     test,i,j;
  1626.     UINT16  unChksum;
  1627.     unChksum=0;
  1628.     setup_VA2sel();
  1629.     for(i=0;i<(MAX_SETUP_PAGE+MAX_CUSTM_SETUP_PAGE);i++) {
  1630.         
  1631.     #if defined(BBK_NEW_SETUP)&&defined(BBK_DV961_DVD)
  1632.             if(i == ONEKEYPASSPAGE)
  1633.                 continue;
  1634.         //not calculate the last item :RETURN_TO_MAIN_PAGE  
  1635.         for(j=1;j<=(MAX_PAGE_ITEM-1);j++)
  1636.     #else
  1637.         for(j=1;j<=MAX_PAGE_ITEM;j++) 
  1638.     #endif  
  1639.         {
  1640.             #ifdef SELECT_MEDIA_IN_SETUPMENU //Maoyong 2004-8-10 17:28 check sum not consider media switch
  1641.             if( setup_item[i][j][1]==STR_OS_MEDIA_TYPE )
  1642.                 continue;
  1643.             #endif
  1644.         
  1645.             //rating and password
  1646.             if((setup_item[i][j][1]==STR_OS_RATING)||(setup_item[i][j][1]==STR_OS_PASSWORD) )//||(setup_item[i][j][1]==STR_OS_REGION_CODE))
  1647.                 continue; //grade item need not load default value
  1648.             #ifdef SUPER_DEFAULT_OSD_LANG
  1649.             if(i==CUSTMPAGEINDEX)
  1650.             {
  1651.                 if(setup_item[i][j][1]==STR_OS_OSD)
  1652.                     continue;
  1653.             }
  1654.             #endif
  1655.             unChksum+=(UINT16)(setup_sel[i][j]);    
  1656.         }
  1657.     }
  1658.     if(save==1)
  1659.         {
  1660.         test=WriteToI2c(0xa0, sizeof(UINT32)+sizeof(setup_VA), (BYTE *)&unChksum, 2);
  1661.             #ifdef MONE_SETUP
  1662.             if(test==1)
  1663.                 printf("SAVE unChksum=%d,sizeof(setup_VA)=%d OKn",unChksum,sizeof(setup_VA));
  1664.             else
  1665.                 printf("SAVE unChksum=%d,sizeof(setup_VA)=%d ERRORn",unChksum,sizeof(setup_VA));
  1666.             #endif
  1667.        }
  1668.        return unChksum;
  1669. }
  1670. //modified by JS    //for setup reengineering   //20040810
  1671. //void run_save_sel_cmd(BYTE page,BYTE index)
  1672. void run_save_sel_cmd(BYTE value, BYTE index)
  1673. {
  1674.     BYTE    *p;
  1675.     #ifdef MONE_SETUP
  1676.     printf("n  SSSSSSSSSSSSS       run_save_sel_cmd value:%d index:%dn", value, index);
  1677.     #endif
  1678. #if defined(BBK_NEW_SETUP)&&defined(BBK_DV961_DVD)    
  1679.     if(page == ONEKEYPASSPAGE)
  1680.         return;
  1681. #endif
  1682.     if(index>=MAX_SETUP_VA)
  1683.         return;
  1684.     //run_save_romChk_cmd();//terry,2003/12/15 05:11PM
  1685.     p=(BYTE *)&setup_VA[index];
  1686.     WriteToI2c(0xa0, sizeof(UINT32)+index, p, 1);
  1687.     run_save_unChk_cmd(1);
  1688. }
  1689. void run_save_total_sel(void)
  1690. {
  1691.     BYTE    *p;
  1692.     //UINT8 setup_VA[64] = {};  
  1693.     int test;
  1694.     #ifdef MONE_SETUP
  1695.     printf(">>>>>   RUN TOTAL SEL CMDn");
  1696.     #endif
  1697.     setup_sel2VA();
  1698. /*  
  1699.     int i;
  1700.     for(i=0; i<MAX_SETUP_VA; i++)
  1701.     {
  1702.         printf("run_save_total_sel>>>   setup_VA[%d] = %xn", i, setup_VA[i]);
  1703.      }
  1704. */
  1705.     //run_save_romChk_cmd();
  1706.     p=(BYTE *)setup_VA;
  1707.     test=WriteToI2c(0xa0, sizeof(UINT32), p, sizeof(setup_VA));
  1708.     run_save_unChk_cmd(1);
  1709. }
  1710. //added by JS   //for setup reengineering   //20040810
  1711. void run_save_userSet_cmd(UINT8 *update)
  1712. {
  1713.     int test;
  1714.     #ifdef MONE_SETUP
  1715.     printf("!!!run_save_userSet_cmdn");
  1716.     #endif
  1717.     test=WriteToI2c(0xa0, sizeof(UINT32)+sizeof(setup_VA)+2, update, sizeof(update));
  1718. }
  1719. #ifdef SETUP_DONT_PAUSE//terry,2004/2/23 03:58PM
  1720. UINT8 user_set_write_cnt=sizeof(t_USER_SET);
  1721. void polling_10ms_save(void)
  1722. {
  1723.    int test;
  1724.    
  1725.    if(user_set_write_cnt<sizeof(t_USER_SET))
  1726.    {
  1727.       test=WriteToI2c(0xa0, sizeof(UINT32)+sizeof(setup_VA)+2+user_set_write_cnt, (BYTE *)&UserSet+user_set_write_cnt,1);
  1728.       user_set_write_cnt++;      
  1729.       //printf("-%d",user_set_write_cnt);
  1730.    }
  1731. }
  1732. #endif
  1733. void run_save_total_userSet(void)
  1734. {
  1735.     int test;
  1736.     
  1737.     #ifdef NEW_SEARCH_OSD
  1738.         // YW:020725
  1739.         //sound_type = SETUP_SPK_DOWNMIX;
  1740.         //sound_type = ITEM_SPK_DOWNMIX[sound_type];
  1741.         
  1742.     //JS    20040820    //for setup reengineering
  1743.     UINT16 P, I;
  1744.     P=setup_getItemPos(STR_OS_DOWNMIX_SETUP);
  1745.     I=P&0xff;
  1746.     P=P>>8;
  1747.     sound_type=setup_item[P][I][setup_VA[SETUP_VA_DOWNMIX]];
  1748.     #endif
  1749.     #ifdef MONE_SETUP
  1750.         printf("!!!run_save_total_userSetn");
  1751.     #endif
  1752. #ifdef SETUP_DONT_PAUSE//4-2-14 13:45
  1753.     user_set_write_cnt=0;
  1754.     printf("sizeof(t_USER_SET):%dn",sizeof(t_USER_SET));
  1755.     //polling_10ms_save();    
  1756. #else    
  1757.         test=WriteToI2c(0xa0, sizeof(UINT32)+sizeof(setup_VA)+2, (BYTE *)&UserSet, sizeof(t_USER_SET));
  1758. #endif    
  1759.     #ifdef MONE_SETUP
  1760. /*
  1761.    {
  1762.         int i, j;
  1763.         for (i=0; i<4; i++) {
  1764.             for (j=0; j<7; j++) {
  1765.                 printf("setup_sel[%d][%d]=%dn", i, j, setup_sel[i][j]);
  1766.             }
  1767.         }
  1768.     }
  1769. */    
  1770.     #endif
  1771. }
  1772. void setup_save_exit(void)
  1773. {
  1774.     if (cd_type_loaded==CDDVD)
  1775.         nav_param_by_user();
  1776. /*  //marked by JS  20040820
  1777.     if (full_scrn&CUSTM) {
  1778.         SETUP_GRADE = SETUP_CUSTM_GRADE;
  1779.     }
  1780. */
  1781.     run_save_total_userSet();
  1782. }
  1783. int setup_IsLock()//nono 20020707
  1784. {
  1785.     if ( UserSet.parental_ststus==C_LOCK)
  1786.         return 1;
  1787.     else
  1788.         return 0;
  1789. }
  1790. #if 0//ndef DVD_SETUP_REENG
  1791. void show_lock(int s,int mode)
  1792. {
  1793.     //s     :  0:lock 1:unlock
  1794.     //mode :  0:normal 1:ANTI
  1795.     int font,bg;
  1796.     const char *str;
  1797.     UserSet.parental_ststus=s;
  1798.     setup_sel[page][index_y] = (MIN_ITEM_SEL+s);
  1799.     if(mode)
  1800.     {
  1801.         font=SANTIFONTCOLOR;
  1802.         bg=SANTIBGCOLOR;
  1803.     }
  1804.     else
  1805.     {
  1806.         #ifdef JIEKE_DVD
  1807.         font = SBLACKCOLOR;
  1808.         #else
  1809.         font = SFONTCOLOR;
  1810.         #endif
  1811.         bg = SBGCOLOR;
  1812.     }
  1813.     str = _OsdMessegeFont1[osd_font_mode][STR_OS_LOCK+s];
  1814. #ifdef TONIC_DVD
  1815.     if(ShowPasswordErr==0)
  1816.     osd_DrawString(SETUP_SUB_XSTART+1, submenuStart+1, (char *)str , font, bg);
  1817.     else
  1818.     osd_DrawString(SETUP_SUB_XSTART+1, submenuStart+1, "ERROR" , font, bg);
  1819. #else//#ifdef TONIC_DVD
  1820.     osd_DrawString(SETUP_SUB_XSTART+1, submenuStart+1, (char *)str , font, bg);
  1821. #endif//#ifdef TONIC_DVD
  1822. }
  1823. #endif
  1824. #if 0//ndef SETUP_DVD_REENG
  1825. const char * setup_SetItemString()
  1826. {
  1827.     const char *str;
  1828.     if(page==LANGPAGE)
  1829.     {
  1830.         if (id==STR_OS_OFF)
  1831.             str = _OsdMessegeFont1[osd_font_mode][id];
  1832.         else
  1833.             str = lang_names[osd_font_mode][id];
  1834.     }
  1835. #ifdef SUPER_DEFAULT_OSD_LANG
  1836.     else if((page==CUSTMPAGEINDEX)&&(index_y==CUSTMOSDITEM))
  1837.         str = lang_names[osd_font_mode][id];
  1838. #endif
  1839.     else
  1840.         str = _OsdMessegeFont1[osd_font_mode][id];
  1841.     return str;
  1842. }
  1843. #endif
  1844. void setup_password(void)
  1845. {
  1846.     setup_setPasswd();
  1847. }
  1848. void show_password(BYTE num)
  1849. {
  1850.     setup_showPasswd(num);
  1851. }
  1852. void reset_passwd_cnt(void)  /*jhuang 2001/5/17 05:13PM*/
  1853. {
  1854.     tmp_passwd = 0;
  1855.     digit_cnt = 0;
  1856. }
  1857. void read_custm_setup_select(void)
  1858. {
  1859.     reset_passwd_cnt(); /*jhuang pending 2001/5/15 08:16PM*/
  1860.     UserSet.parental_ststus=C_UNLOCK;
  1861. /*  //marked by JS  20040820    
  1862.     SETUP_CUSTM_GRADE=SETUP_GRADE;
  1863.     page=CUSTMPAGEINDEX;
  1864. */    
  1865. }
  1866. #ifdef RCD_GPIO_CONTROL
  1867. #define RCD_GPIO (1<<GPIO_N)
  1868. #define is_gpio_high (regs0->gpio_in[GPIO_N/16]&RCD_GPIO)
  1869. void set_region(void)
  1870. {
  1871.     regs0->gpio_master[GPIO_N/16] |= RCD_GPIO;
  1872.     regs0->gpio_oe[GPIO_N/16] &= ~RCD_GPIO;
  1873.     if (is_gpio_high)
  1874.         NP_P_RCD=0;
  1875.     else
  1876.         NP_P_RCD=0x01<<(CUS_RCD-1);
  1877. }
  1878. #else
  1879. void set_region(void)
  1880. {
  1881.     UINT8 i,region;
  1882.     if(UserSet.P_RCD)
  1883.     {
  1884.         NP_P_RCD= 0x01 << (UserSet.P_RCD-1);
  1885.     }else
  1886.     {
  1887.         #ifdef NAV_DBG
  1888.         printf("Region code:%xn",pDSV->VMG_CAT_RM);
  1889.         #endif
  1890.         NP_P_RCD=0;     //terry,2002/5/29 06:58PM
  1891.         for(i=0,region=1;i<8;i++)
  1892.         {
  1893.             if( !(pDSV->VMG_CAT_RM&(region<<i)) )
  1894.             {
  1895.                 NP_P_RCD=0x01 << i;
  1896.                 #ifdef NAV_DBG
  1897.                 printf("Region code:%xn",i);
  1898.                 #endif
  1899.                 break;
  1900.             }
  1901.         }
  1902. #ifdef BBK_DVD//terry,2003/11/18 04:48PM
  1903.         if(pDSV->VMG_CAT_RM==0) NP_P_RCD=0x4;//terry,2003/11/18 04:44PM,for CONAIR,BBK
  1904. #endif      
  1905.     }
  1906. }
  1907. #endif
  1908. void setup_ShowVolCtrlConfig()
  1909. {
  1910.     return;
  1911. #if 0
  1912.     const char *str;
  1913.     BYTE    fontColor;
  1914.     BYTE    i;
  1915.     
  1916.     if ( (page!=AUDPAGE) ||
  1917.         (index_y!=DIGIOUTITEM)
  1918.         )
  1919.     {
  1920.         return;
  1921.     }
  1922.     if (SETUP_SPDIF!=SPDIFBITSTREAM) {
  1923.         fontColor = SFONTCOLOR;
  1924.         
  1925.     } else {
  1926.         if ( (coding_mode_now&(AUDIF_CODING_MODE_DTS|
  1927.             AUDIF_CODING_MODE_DTSCD|
  1928.             //AUDIF_CODING_MODE_PCM|   //DTSCD-BITSTREAM MODE, Jeff 20020719
  1929.             AUDIF_CODING_MODE_AC3)
  1930.             )||(cd_subtype==CD_DTS) )//nono 2-7-25 17:29
  1931.         {
  1932.             fontColor = SFONTCOLOR;
  1933.             //fontColor = SGRAYCOLOR;
  1934.         } else {
  1935.             fontColor = SFONTCOLOR;
  1936.         }
  1937.     }
  1938.     for (i=VOLCTRLSTART; i<=VOLCTRLEND; i++) {
  1939.         if (coding_mode_now==AUDIF_CODING_MODE_LPCM) { //Jeff 20020703
  1940.             if (i==KEYITEM) {
  1941.                 fontColor = SFONTCOLOR;
  1942.                 //fontColor = SGRAYCOLOR;
  1943.             } else {
  1944.                 fontColor = SFONTCOLOR;
  1945.             }
  1946.         } else
  1947.             if ( (SETUP_SPK_DOWNMIX==AC3DOWNMIXOFF) &&
  1948.                 (i==KEYITEM)
  1949.                 )
  1950.             {
  1951.                 if( ( coding_mode_now&(AUDIF_CODING_MODE_DTS| AUDIF_CODING_MODE_DTSCD|AUDIF_CODING_MODE_AC3|AUDIF_CODING_MODE_LPCM) )||(cd_subtype==CD_DTS) )//nono 2-8-5 15:05
  1952.                 {
  1953.                     fontColor = SFONTCOLOR;
  1954.                     //fontColor = SGRAYCOLOR;
  1955.                 } else {
  1956.                     fontColor = SFONTCOLOR;
  1957.                 }
  1958.                 
  1959.             }
  1960.         #ifdef KARAOKE_MENU //wangfeng 2003-10-30 10:19
  1961.             if((page==AUDPAGE)&&(KARAOKE_MENU_FLAG)&&((i<2)||(i>5)))
  1962.             {
  1963.                 fontColor = SBGCOLOR;
  1964.                 
  1965.             }
  1966.             //wangfeng 2003-11-11 14:06
  1967.             else if((page==AUDPAGE)&&(KARAOKE_MENU_FLAG==0)&&((i>=2)&&(i<=5)))
  1968.             {
  1969.                 fontColor = SBGCOLOR;
  1970.                 
  1971.             }
  1972.             #ifdef PROLOGIC_ON_51CH//wangfeng 2003-12-22 16:40                            
  1973.             else if ((page==AUDPAGE)&&(KARAOKE_MENU_FLAG==0)
  1974.                     && !setup_IsSpkDownmixOff()&&(i==1))
  1975.                 {
  1976.                     fontColor = SGRAYCOLOR;
  1977.                 } 
  1978.             #endif
  1979.             else
  1980.         #endif
  1981.             id = setup_item[page][i][1];
  1982. #ifdef TONIC_DVD
  1983.             if(id==STR_OS_RETURN_MAIN_SETUP)
  1984.             id=STR_OS_EXIT_MENU;
  1985. #endif//#ifdef TONIC_DVD
  1986.             str = _OsdMessegeFont1[osd_font_mode][id];
  1987.             osd_DrawString(SETUP_MENU_XSTART+1, i+SETUP_MENU_YSTART+1, str, fontColor, SBGCOLOR);
  1988.     }
  1989. #endif  
  1990. }
  1991. //To do speaker(AC3) config
  1992. void setup_ShowAC3Config()
  1993. {
  1994.     return;
  1995. #if 0
  1996.     BYTE    buf[40];
  1997.     BYTE    fontColor;
  1998.     BYTE    i;
  1999.     if ( (page!=MULTISPKPAGE) ||
  2000.         (setupLevel!=2) ||
  2001.         (index_y!=AC3DOWNMIXITEM)
  2002.         )
  2003.     {
  2004.         return;
  2005.     }
  2006. #if defined(ONLY_DOWNMIXOFF_CAN_SET_CE_RE)//2003-8-13 23:32
  2007.     if (SETUP_SPK_DOWNMIX==AC3DOWNMIXOFF) { //set to 5.1 channel
  2008.         fontColor = SFONTCOLOR;
  2009.      
  2010.     } else 
  2011.     {
  2012.         fontColor = SGRAYCOLOR;
  2013.     }
  2014. #elif !defined(SETUP_ALL_VALID)
  2015.     if ( (SETUP_SPK_DOWNMIX==AC3DOWNMIXOFF) && (SETUP_SPDIF==SPDIFSIMULATE) ) { //set to 5.1 channel
  2016.         fontColor = SFONTCOLOR;
  2017.      
  2018.     } else 
  2019.     {
  2020.         fontColor = SGRAYCOLOR;
  2021.     }
  2022. #elif defined(SET_FCR_SPEAKER)//XYY 2004-10-23 10:47
  2023.     if (SETUP_SPK_DOWNMIX==AC3DOWNMIXOFF) {        //xulf 2004-01-06
  2024.         fontColor = SFONTCOLOR;     
  2025.     } else 
  2026.     {
  2027.         fontColor = SGRAYCOLOR;
  2028.     }
  2029.     
  2030. #else
  2031.         fontColor = SFONTCOLOR;
  2032. #endif
  2033.     for (i=SPKSTART; i<=SPKEND; i++) {
  2034.         id = setup_item[page][i][1];
  2035.         psprintf(buf, "%s", _OsdMessegeFont1[osd_font_mode][id]);
  2036.         osd_DrawString(SETUP_MENU_XSTART+1, i+SETUP_MENU_YSTART+1, buf, fontColor, SBGCOLOR);
  2037.     }
  2038. #endif
  2039. }
  2040. int setup_IsSet2SPDIF_PCM()
  2041. {
  2042.     UINT16 P,I;
  2043. #ifdef DIVIDE_AC3_DTS_SPDIF_OUTPUTS
  2044.     P=setup_getItemPos(STR_OS_AUD_OUT);
  2045.     I=P&0xff;
  2046.     P=P>>8;
  2047.     if (setup_item[P][I][setup_VA[SETUP_VA_AUD_OUT]]==STR_OS_STEREO_PCM)
  2048. #else
  2049.     P=setup_getItemPos(STR_OS_AUD_OUT);
  2050.     I=P&0xff;
  2051.     P=P>>8;
  2052.     if (setup_item[P][I][setup_VA[SETUP_VA_AUD_OUT]]==STR_OS_STEREO_PCM)
  2053. #endif
  2054.         return 1;
  2055.     return 0;
  2056. }
  2057. void setup_SetAC3PCMConfig()//nono 2004-8-3 22:41
  2058. {
  2059. #if !defined(SPHE8202)
  2060.     if( (cd_type_loaded==CDDVD)&&(coding_mode_now == AUDIF_CODING_MODE_AC3)&&(setup_IsSet2SPDIF_PCM()==1) )//nono  4-5-26 21:49
  2061.     {
  2062.         AUDIF_Set_OutputMode(OUT_51DownmixLtRt, 0);//2004AUDDRV AudioSetOutputMode(8, 0); //Set Output mode(7:2 channel)
  2063.     }                            
  2064. #endif
  2065. }
  2066. void setup_SetAC3Config()
  2067. {
  2068.     //BYTE newid, newsel;
  2069.     
  2070.     //set speaker setting
  2071.     /*newsel = SETUP_SPK_DOWNMIX;
  2072.     newid = ITEM_SPK_DOWNMIX[newsel];
  2073.     #ifdef NEW_SEARCH_OSD
  2074.     // YW:020725
  2075.     sound_type = newid;
  2076.     #endif
  2077.     //to run speaker setup downmix mode
  2078.     // run twice to prevent from losing the very 1st cmd, we have to check risc-dsp to see
  2079.     // why the 1st cmd lost by curr handshake, status report okay, ??????, 2003-05-13
  2080.     exe_setup_function( ITEM_SPK_DOWNMIX[1], newid, 0);
  2081.     exe_setup_function( ITEM_SPK_DOWNMIX[1], newid, 0);*/
  2082.     printf("ac3 setup function ..STR_OS_DOLBY_OP_SETUP:%x STR_OS_DUAL_MONO_SETUP:%xn",STR_OS_DOLBY_OP_SETUP,STR_OS_DUAL_MONO_SETUP);
  2083.     //set AC3 digital setting
  2084.     //newsel = SETUP_AC3DIGITAL_OUTMODE;
  2085.     //newid = ITEM_AC3DIGITAL_OUTMODE[newsel];
  2086.         UINT16 P, I;
  2087.     P=setup_getItemPos(STR_OS_DOLBY_OP_SETUP);
  2088.     I=P&0xff;
  2089.     P=P>>8;
  2090.     
  2091.     //printf("ITEM_AC3DIGITAL_OUTMODE[1]:%x out: newsel:%x newid:%xn",ITEM_AC3DIGITAL_OUTMODE[1],newsel,newid);
  2092.      //exe_setup_function( ITEM_AC3DIGITAL_OUTMODE[1], newid, 0);
  2093.      //exe_setup_function( STR_OS_DOLBY_OP_SETUP, newid, 0);
  2094.      exe_setup_function( STR_OS_DOLBY_OP_SETUP, setup_item[P][I][setup_VA[SETUP_VA_DOLBY_OP]], 0);
  2095.      
  2096.     if (setup_VA[SETUP_VA_DOLBY_OP] == MIN_ITEM_SEL) {
  2097.         set_AC3DynamicRange();
  2098.     }
  2099.     //newsel = SETUP_AC3DIGITAL_LnR;
  2100.     //newid = ITEM_AC3DIGITAL_LnR[newsel];
  2101.     //printf("ITEM_AC3DIGITAL_OUTMODE[1]:%x out: newsel:%x newid:%xn",ITEM_AC3DIGITAL_LnR[1],newsel,newid);
  2102.     //exe_setup_function( ITEM_AC3DIGITAL_OUTMODE[1], newid, 0);
  2103.     P=setup_getItemPos(STR_OS_DUAL_MONO_SETUP);
  2104.     I=P&0xff;
  2105.     P=P>>8;
  2106.     
  2107.     exe_setup_function( STR_OS_DUAL_MONO_SETUP, setup_item[P][I][setup_VA[SETUP_VA_DUAL_MONO]], 0); //axelchen 20040105 Panasonic 瑈ē
  2108.     //terry,2004/6/30 04:57PM
  2109.     //set center speaker delay, 1:center speaker
  2110.     AUDIF_Set_SpkDelay(1, setup_VA[SETUP_VA_CSPK_DELAY]-2);//2004AUDDRV AudioSetSpkDelay(1, setup_VA[SETUP_VA_CSPK_DELAY]-2);
  2111.     //set surround speaker delay, 2:surround speaker
  2112.     AUDIF_Set_SpkDelay(2, (setup_VA[SETUP_VA_SSPK_DELAY]-2)*3);//2004AUDDRV AudioSetSpkDelay(2, (setup_VA[SETUP_VA_SSPK_DELAY]-2)*3);
  2113. }
  2114. #ifdef QSI_SETUP_MENU//liweihua add 2004-6-15
  2115. UINT16 safe_wait_time = 1* 60 * 100;
  2116. BYTE select_save_time(BYTE res)
  2117. {
  2118.     BYTE i;
  2119.     UINT16 save_time[]={1* 60 * 100, 5* 60 * 100, 10* 60 * 100, 30* 60 * 100};
  2120.     if(res <= 5)
  2121.     {
  2122.         safe_wait_time = save_time[res-2];
  2123.         res = 1;
  2124.     }
  2125.     else
  2126.         res=0;
  2127.     return res;  
  2128. }
  2129. #endif
  2130. BYTE setup_GetSSaveType()
  2131. {
  2132.     // In stup menu, we use screen saver item as the auto play item 
  2133.     // when AUTO_PLAY, always return 1 ==> screen saver always turn on
  2134. #ifdef AUTO_PLAY    
  2135.     #ifdef JIEKE_DVD//no saver, wangfeng 2003-10-28 11:19
  2136.     return 0;
  2137.     #else   
  2138.     return 1;
  2139.     #endif
  2140. #else
  2141.     BYTE res;
  2142.     res = setup_VA[SETUP_VA_SSAVER];//SETUP_SSAVER;
  2143.     if (res < 2) res=2;
  2144.     #ifdef QSI_SETUP_MENU//liweihua add for SQI 2004-6-15
  2145.     res = select_save_time(res);
  2146.     #else
  2147.     if (res==2) {
  2148.         res = 1;
  2149.     } else {
  2150.         res = 0;
  2151.     }
  2152.     #endif
  2153.     return res;
  2154. #endif
  2155. }
  2156. //=============================================
  2157. //for DVD_SETUP_REENG   //added by JS   //20040728
  2158. #if 0//ndef DVD_SETUP_REENG
  2159. //up1down : 0 -> up, 1-> down
  2160. #define X_60   SETUP_SUB_XSTART*16+60
  2161. #define X_76   SETUP_SUB_XSTART*16+76
  2162. #define X_94   SETUP_SUB_XSTART*16+94
  2163. #define X_96   SETUP_SUB_XSTART*16+96
  2164. #define Y_0    SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT
  2165. #define Y_8    SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT+8
  2166. void setup_DrawScaleItem(BYTE id, BYTE up1down, int val)
  2167. {
  2168.     BYTE uColor, dColor;
  2169.     BYTE fontColor, bgColor;
  2170.     BYTE clrCursorColor;// to clear cursor. zhaoyanhua add 2003-12-16 10:56
  2171.     UINT32  yStart=0, yDelta=0;
  2172.     UINT32  yNew, yNew_8;
  2173.     if (up1down) {
  2174.         uColor = SBLACKCOLOR;
  2175.         dColor = SWHITECOLOR;
  2176.         #ifdef QSI_SETUP_MENU_DESIGN//liweihua 2004-7-4 17:45
  2177.         fontColor = SFONTCOLOR;
  2178.         bgColor = SANTIFONTCOLOR;
  2179.         #else
  2180.         fontColor = SANTIFONTCOLOR;
  2181.         bgColor = SANTIBGCOLOR;
  2182.         #endif
  2183.     #ifdef HL_CURSOR_ONLY//zhaoyanhua add 2003-12-16 10:58
  2184.         clrCursorColor = SBGCOLOR;
  2185.     #else
  2186.         clrCursorColor = SANTIBGCOLOR;
  2187.     #endif
  2188.     
  2189.     
  2190.     } else {
  2191.         uColor = SWHITECOLOR;
  2192.         dColor = SBLACKCOLOR;
  2193.         fontColor = SFONTCOLOR;
  2194.         #ifdef QSI_SETUP_MENU_DESIGN//liweihua 2004-7-4 17:45
  2195.         bgColor = SDEFAULTCOLOR;
  2196.         #else
  2197.         bgColor = SBGCOLOR;
  2198.         #endif
  2199.         clrCursorColor = SBGCOLOR;
  2200.     }
  2201.         if (id==STR_OS_ECHO) {//echo_level(0 ~ 8)
  2202.             //yStart = SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT+26;
  2203.             //yDelta = 5 * SETUP_BUTTON_HEIGHT-30;
  2204.             yStart = SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT+12;
  2205.             yDelta = 5 * SETUP_BUTTON_HEIGHT-16;
  2206.         } else
  2207. #ifdef  Ti3001_OSD_UI_2
  2208.             if ((id==STR_OS_AMP_MAINVOLUME)||(id==STR_OS_AMP_FSPK)||(id==STR_OS_AMP_FSPK_BALANCE)||
  2209.                 (id==STR_OS_AMP_SSPK)||(id==STR_OS_AMP_SSPK_BALANCE)||(id==STR_OS_AMP_CSPK)||(id==STR_OS_AMP_SUBWOOFER))
  2210.             {//level(1 ~ 15)
  2211.                 yStart = SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT+12;
  2212.                 yDelta = 8 * SETUP_BUTTON_HEIGHT-16;             //中间刻度线的长度。2-8-27 9:59  gerry
  2213.             } else
  2214.                 if ((id==STR_OS_AMP_BASS)||(id==STR_OS_AMP_TREMBLE))
  2215.                 {//level(1 ~ 15)
  2216.                     yStart = SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT+12;
  2217.                     yDelta = 7 * SETUP_BUTTON_HEIGHT-16;
  2218.                 } else
  2219.                     if (id==STR_OS_AMP_DYNAMICRANGE)
  2220.                     {//level(1 ~ 15)
  2221.                         yStart = SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT+12;
  2222.                         yDelta = 7 * SETUP_BUTTON_HEIGHT-16;
  2223.                     } else
  2224. #endif
  2225.                         if (id==STR_OS_KEY) {//audio_key(-6 ~ 6)
  2226.                             yStart = SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT+12;
  2227.                             yDelta = 7 * SETUP_BUTTON_HEIGHT-16;
  2228.                             val+=6;
  2229.                         } else
  2230.                             if (id==STR_OS_MIC_VOL||id==STR_OS_MIC_VOL_1||id==STR_OS_MIC_VOL_2) {//mic_volume(0 ~ 8)
  2231.                                 yStart = SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT+12;//wangfeng 2003-09-12 20:30
  2232.                                 yDelta = 5 * SETUP_BUTTON_HEIGHT-16;
  2233.                             } else
  2234.                                 if ( (id==STR_OS_FSPK) || (id==STR_OS_CSPK) || (id==STR_OS_SSPK) ) { //0 ~ 8
  2235.                                     yStart = SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT+12;
  2236.                                     yDelta = 5 * SETUP_BUTTON_HEIGHT-16;
  2237.                                     //val=0;
  2238.                                 } else
  2239.                                     if ( (id==STR_OS_CSPK_DELAY) || (id==STR_OS_SSPK_DELAY) ) { //0 ~ 5
  2240.                                         
  2241.                                     #ifdef  NO_SHOW_ADD_ICON//zhaoyanhua add 2003-12-9 17:18
  2242.                                         yStart = (SETUP_MENU_YSTART+2)*SETUP_BUTTON_HEIGHT+18;
  2243.                                         yDelta = 4 * SETUP_BUTTON_HEIGHT-30-2;
  2244.                                     #else
  2245.                                         yStart = (SETUP_MENU_YSTART+2)*SETUP_BUTTON_HEIGHT+24;
  2246.                                         yDelta = 4 * SETUP_BUTTON_HEIGHT-30;
  2247.                                     #endif
  2248.                                         
  2249.                                     
  2250.                                         //val=0;
  2251.                                     } else
  2252.                                         if (id==STR_OS_DYNAMICRANGE) {
  2253.                                             yStart = SETUP_MENU_YSTART*SETUP_BUTTON_HEIGHT+12;
  2254.                                             yDelta = 5 * SETUP_BUTTON_HEIGHT-16;
  2255.                                         }
  2256.                                         else if (id == STR_OS_BRIGHTNESS ||
  2257.                                                  id == STR_OS_CONTRAST ||
  2258.                                                  id == STR_OS_HUE ||
  2259.                                             #ifdef ADD_DVI311_SETUP
  2260.                                                  id == STR_OS_DVI311_MODE ||
  2261.                                             #endif
  2262.                                                  id == STR_OS_SATURATION)
  2263.                                         {
  2264.                                             yStart = SETUP_MENU_YSTART * SETUP_BUTTON_HEIGHT + 12;
  2265.                                             yDelta = 7 * SETUP_BUTTON_HEIGHT - 16;
  2266.                                         }
  2267. #ifdef DIP_CFG_ENABLE
  2268.                                         else if (id == STR_OS_DEINTLC)
  2269.                                         {
  2270.                                             yStart = (SETUP_MENU_YSTART+1) * SETUP_BUTTON_HEIGHT + 12;
  2271.                                             yDelta = 4 * SETUP_BUTTON_HEIGHT - 16;
  2272.                                         }
  2273. #endif//#ifdef DIP_CFG_ENABLE
  2274.                                         //osd_draw_rect(X_60, yStart+32, 36, yDelta, bgColor);  // alan, 2003/08/06
  2275.                                         //osd_DrawLine(X_76, yStart+28, X_76, yStart+yDelta+32, fontColor, 3);  // alan, 2003/08/06
  2276.                                         #ifdef ADD_DVI311_SETUP
  2277.                                         if(id==STR_OS_DVI311_MODE)
  2278.                                             yNew = yStart+yDelta-16 - (val*SETUP_BUTTON_HEIGHT);
  2279.                                         else
  2280.                                         #endif
  2281.                                         yNew = yStart+yDelta-16 - (val*SETUP_BUTTON_HEIGHT/2);
  2282.                                         #ifdef NO_SHOW_ADD_ICON//zhaoyanhua add 2003-12-9 17:41 
  2283.                                         if ( (id==STR_OS_CSPK_DELAY) || (id==STR_OS_SSPK_DELAY) ) 
  2284.                                         yNew+=32+8;     
  2285.                                         else
  2286.                                         #endif
  2287.                                         yNew+=32;
  2288.                                         yNew_8=yNew+8;
  2289.                                         // alan,3-8-6 14:34
  2290.                                         {
  2291.                                             UINT32 yyStart,yyLen;
  2292.                                                                                         
  2293.                                             if ( (yNew-20)<(yStart+32) ) 
  2294.                                                 yyStart=yStart+32;
  2295.                                             else
  2296.                                                 yyStart=yNew-20;
  2297.                                             
  2298.                                             if ( (yNew-20+8+40)>(yStart+32+yDelta) )
  2299.                                             {
  2300.                                                 UINT32 diff=(yNew-20+8+40)-(yStart+32+yDelta);
  2301.                                                 yyLen=8+40-diff;
  2302.                                             } else
  2303.                                                 yyLen=8+40;
  2304.                                             
  2305.                                             //osd_draw_rect(X_60-4, yNew-20, 32+8, 8+40, bgColor);
  2306.                                             //osd_draw_rect(X_60-4, yyStart, 32+8, yyLen, bgColor);
  2307.                                         #ifdef  NO_SHOW_ADD_ICON//zhaoyanhua add 2003-12-9 17:41    
  2308.                                         if ( (id==STR_OS_CSPK_DELAY) || (id==STR_OS_SSPK_DELAY) ) 
  2309.                                             osd_draw_rect(X_60-4, yyStart-2-8, 32+8, yyLen+10+4,clrCursorColor);
  2310.                                         else
  2311.                                         #endif  
  2312.                                         #ifdef ADD_DVI311_SETUP
  2313.                                             if(id == STR_OS_DVI311_MODE) //clear Cursor Color
  2314.                                             {
  2315.                                                 osd_draw_rect(X_60+30-4, 108-2, 32+8, 48, clrCursorColor);
  2316.                                                 osd_draw_rect(X_60+30-4, 120-2, 32+8, 48, clrCursorColor);
  2317.                                                 osd_draw_rect(X_60+30-4, 152-2, 32+8, 48, clrCursorColor);
  2318.                                                 osd_draw_rect(X_60+30-4, 184-2, 32+8, 48, clrCursorColor);
  2319.                                                 osd_draw_rect(X_60+30-4, 216-2, 32+8, 48, clrCursorColor);
  2320.                                                 osd_draw_rect(X_60+30-4, 248-2, 32+8, 48, clrCursorColor);
  2321.                                                 osd_draw_rect(X_60+30-4, 280-2, 32+8, 36, clrCursorColor);
  2322.                                             }
  2323.                                             else
  2324.                                         #endif