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

DVD

开发平台:

C/C++

  1. //
  2. // FILE
  3. // kernel.c
  4. //
  5. // DESCRIPTION
  6. // kernel interface
  7. //
  8. #include "config.h"
  9. #include "regmap.h"
  10. #include "global.h"
  11. #include "avd.h"
  12. #include "avdctrl.h"
  13. #include "vpp.h"
  14. #include "tvif.h"
  15. #include "aspect.h"
  16. #include "kernel.h"
  17. #include "kinf.h"
  18. #ifdef PNGPIO_CON_TFT
  19. #include "gpio.h"
  20. #endif
  21. #ifdef SUPPORT_SPI
  22. #include "spi.h"
  23. #endif
  24. #ifdef DVD_SETUP_REENG
  25. #include "setup_VA.h"
  26. #include "setup_def.h"
  27. #endif
  28. #ifndef DVDRELEASE
  29. //#define KERNEL_DBG
  30. #endif
  31. #define kern_puts(s)            ((void)0)
  32. #define kern_printf(s...)       ((void)0)
  33. #define kern_show_function()    ((void)0)
  34. #ifdef  KERNEL_DBG
  35. #include "sio.h"
  36. #include "emuio.h"
  37. #include"spv301.h"
  38. #undef  kern_puts
  39. #undef  kern_printf
  40. #undef  kern_show_function
  41. #define kern_puts               puts_w
  42. #define kern_printf             printf_w
  43. #define kern_show_function()    do {kern_puts(__FUNCTION__); kern_puts("n"); } while (0)
  44. #define MONE_TVSETUP
  45. //#define MONE_SIZECHG
  46. #endif
  47. UINT8   Ksetup_tv_format=0xFF;          // PAL / NTSC / ..
  48. UINT8   Ksetup_tv_aspect=0xFF;          // 0:4:3 1:16:9
  49. UINT8   Ksetup_jpeg_h_aspect=0xFF;          // 0:4:3 1:16:9
  50. UINT8   Ksetup_jpeg_v_aspect=0xFF;          // 0:4:3 1:16:9
  51. //
  52. // FUNCTION
  53. // setup_decode_service
  54. //
  55. void
  56. setup_decode_service(int srv)
  57. {
  58.   switch (srv)
  59.   {
  60.     case SERVICE_ROMV:
  61.       srv_kernel = srv_rom; break;
  62.     case SERVICE_CDDA:
  63.       srv_kernel = srv_cdda; break;
  64. #if defined(SUPPORT_CARD_STORAGE)||defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)
  65.     case SERVICE_CARDFILE:
  66.         {
  67.             extern int srv_cardfile(void);
  68.             srv_kernel = srv_cardfile;
  69.         }
  70.         break;
  71. #endif
  72. #ifdef SUPPORT_STREAM_BUFFER
  73.     case SERVICE_STREAMING:
  74.         {
  75.             extern int srv_stream(void);
  76.             srv_kernel = srv_stream;
  77.         }
  78.         break;
  79. #endif
  80.     case SERVICE_CD:
  81.     default:
  82.       srv_kernel = srv_cd; break;
  83.   }
  84. }
  85. void
  86. setup_clock_gating(int onoff)
  87. {
  88.     kernel_clock_gating = onoff;
  89. }
  90. void
  91. setup_error_concealment(int onoff)
  92. {
  93.     kernel_error_concealment = onoff;
  94. }
  95. void
  96. enable_portable_bonding(UINT8 onoff)
  97. {
  98. kernel_portable_bonding = onoff;
  99. }
  100. void
  101. setup_error_mb_limit(int n)
  102. {
  103.     kernel_error_mb_threshold = n;
  104. }
  105. //
  106. // FUNCTION
  107. // setup_tv_format(tvfmt)
  108. //
  109. // DESCRIPTION
  110. // setup TV format
  111. // see kernel.h for supported formats
  112. // if auto then adjust TV format according to current decoding format.
  113. //
  114. void
  115. setup_tv_format(int tvfmt)
  116. {
  117.     #ifdef SUPPORT_FUNCTION_MENU
  118.     #ifdef SUPPORT_SPI
  119.     if(((pdvd_mode == PDVD_MODE) && (tvfmt != TV_FORMAT_NTSC)) || (pdvd_timer))
  120.       return;
  121.     #endif
  122.     #endif
  123. #ifdef ADD_DVI311_SETUP//@Kevin For outo set 2k40525
  124. static unsigned char format_change_sign=0x84;
  125. format_change_sign=dvi311_tv_mode;
  126. #endif
  127.     // now update system tv-format
  128.     if (tvfmt==TV_FORMAT_AUTO && is_avd_tv_auto())
  129.     {
  130.         unsigned decfmt = get_decode_format();
  131.         if (decfmt==DECODE_FORMAT_525)
  132. {
  133. tvfmt=TV_FORMAT_525_DEFAULT;
  134. #ifdef ADD_DVI311_SETUP
  135. dvi311_tv_mode=0x85;    //kevin@2k40517
  136. #endif
  137. }
  138. #ifdef GBM_FORCE_PAL_OUTPUT_NTSC_WHEN_PALM_PALN_AUTO //gerry,2004-2-10 15:04
  139.         else if (decfmt==DECODE_FORMAT_625)
  140. {
  141. tvfmt=TV_FORMAT_525_DEFAULT;
  142. #ifdef ADD_DVI311_SETUP
  143. dvi311_tv_mode=0x85;    //kevin@2k40517
  144. #endif
  145. }
  146. #else//GBM_FORCE_PAL_OUTPUT_NTSC_WHEN_PALM_PALN_AUTO
  147.         else if (decfmt==DECODE_FORMAT_625)
  148. {
  149. tvfmt=TV_FORMAT_625_DEFAULT;
  150. #ifdef ADD_DVI311_SETUP
  151. dvi311_tv_mode=0x84;    //kevin@2k40517
  152. #endif
  153. }
  154. #endif//GBM_FORCE_PAL_OUTPUT_NTSC_WHEN_PALM_PALN_AUTO
  155.     }
  156.     // force initial selection when tvfmt==AUTO
  157.     if (Ksetup_tv_format==0xFF && tvfmt==TV_FORMAT_AUTO)
  158.     {
  159.         tvfmt=TV_FORMAT_AUTO_DEFAULT;
  160. #ifdef ADD_DVI311_SETUP
  161. dvi311_tv_mode=0x84;    //kevin@2k40517
  162. #endif
  163.     }
  164. #ifdef ADD_DVI311_SETUP
  165. if(format_change_sign!=dvi311_tv_mode)
  166.     {   
  167.         if(dvi311_tv_mode>0x84 && dvi311_mode==Mode_576P)// NTSC and 480P   @kevin 2k40708
  168.             dvi311_mode=Mode_480P;
  169.         if(dvi311_tv_mode==0x84 && dvi311_mode==Mode_480P)// PAL and 576P   @kevin 2k40708
  170.             dvi311_mode=Mode_576P;
  171.         #ifdef DVD_SETUP_REENG//Modifed by chenzhao on 2004-11-24 21:8   
  172.             setup_VA[SETUP_VA_SPV311MODE]=dvi311_mode+MIN_ITEM_SEL;
  173.         #endif
  174. scaler_main();
  175.     }
  176. #endif
  177.     // setup tvfmt.
  178.     if (tvfmt!=TV_FORMAT_AUTO && tvfmt!=Ksetup_tv_format)
  179.     {
  180.         int line625;
  181.         Ksetup_tv_format = tvfmt;
  182. #ifdef MONE_TVSETUP
  183.         kern_printf("t %xn", tvfmt);
  184. #endif
  185.         if (tvfmt==TV_FORMAT_PAL)
  186.         {
  187.             line625 = 1;
  188.             #ifdef PNGPIO_CON_TFT//reset gpio59
  189.             PAL_SET();
  190.             #ifdef EASTWIN
  191.             init_an2526h_pal();
  192.             #endif
  193.             #endif
  194.             tv_setup_pal();
  195.         }
  196. #ifdef  SUPPORT_PALN
  197.         else if (tvfmt==TV_FORMAT_PALN)
  198.         {
  199.             line625 = 1;
  200.             tv_setup_pal_n();
  201.         }
  202. #endif
  203. #ifdef  SUPPORT_PALNc
  204.         else if (tvfmt==TV_FORMAT_PALNC)
  205.         {
  206.             line625 = 1;
  207.             tv_setup_pal_nc();
  208.         }
  209. #endif
  210. #ifdef  SUPPORT_PALM
  211.         else if (tvfmt==TV_FORMAT_PALM)
  212.         {
  213.             line625 = 0;
  214.             tv_setup_pal_m();
  215.         }
  216. #endif
  217. #ifdef  SUPPORT_PAL60
  218.         else if (tvfmt==TV_FORMAT_PAL60)
  219.         {
  220.             line625 = 0;
  221.             #ifdef PNGPIO_CON_TFT //gpio59 is set high
  222.             PAL_SET();
  223.             #ifdef EASTWIN
  224.             init_an2526h_pal();
  225.             #endif
  226.             #endif
  227.             tv_setup_pal60();
  228.         }
  229. #endif
  230. #ifdef  SUPPORT_NTSCJ
  231.         else if (tvfmt==TV_FORMAT_NTSCJ)
  232.         {
  233.             line625 = 0;
  234.             tv_setup_ntscj();
  235.         }
  236. #endif
  237.         else                // default to support NTSC
  238.         {
  239.             line625 = 0;
  240.             #ifdef PNGPIO_CON_TFT //gpio59 is set high
  241.             NTSC_SET();
  242.             #ifdef EASTWIN
  243.             init_an2526h_ntsc();
  244.             #endif
  245.             #endif
  246.             tv_setup_ntsc();
  247.         }
  248.         setVPP_TVformat(line625);
  249.         dis_field_cntr = 0;
  250.         dec_field_cntr = 0;
  251. #ifdef SUPPORT_MP4
  252. frctl_set_display_rate();
  253. frctl_clear_count();
  254. #endif
  255.     }
  256. #ifdef GBM_DEFAULT_NTSC_CAPTION_OFF //gerry,2004-2-13 14:18
  257. tv_l21_enable(0);
  258. #endif//GBM_DEFAULT_NTSC_CAPTION_OFF
  259. }
  260. //
  261. //
  262. //
  263. void
  264. setup_tv_aspect(int aspect)
  265. {
  266.     if (aspect!=Ksetup_tv_aspect)
  267.     {
  268.         Ksetup_tv_aspect = aspect;
  269.         tv_setup_aspect(aspect);
  270.     }
  271. }
  272. //
  273. //
  274. void
  275. setup_display_brightness(int br)
  276. {
  277.     setVPP_YOffset(br);
  278. }
  279. //
  280. // FUNCTION
  281. // setup_display_format
  282. //
  283. void
  284. setup_display_format(int __hsize, int __vsize, int __src_aspect, int __zoom, int __progressive)
  285. {
  286.     set_vpp_src_aspect(__src_aspect);               // set video-source aspect-ratio
  287.     setVPP_PictureSize(__hsize, __vsize);       // set-size
  288.     if (__progressive)                          // progressive?
  289.     {
  290.         setVPP_chroma_vint_frame();             // chroma: full-frame
  291.         setVPP_luma_vint_frame();               // luma: full-frame
  292.     }
  293.     else
  294.     {
  295.         setVPP_chroma_vint_field();             // chroma: previous-line
  296.         setVPP_luma_vint_field();               // luma: current field
  297.     }
  298.     setVPP_Display(__zoom);                     // other display parameters
  299. }
  300. //
  301. //
  302. //
  303. void set_jpeg_aspect_ratio(int h_ratio, int v_ratio)
  304. {
  305. Ksetup_jpeg_h_aspect = h_ratio;
  306. Ksetup_jpeg_v_aspect = v_ratio;
  307. }
  308. void
  309. set_jpeg_pic_size(int __hsize, int __vsize, int __zoom)
  310. {
  311.     kern_printf("set_jpeg_pic_size(%d,%d,%d);n", __hsize, __vsize, __zoom);
  312.     setVPP_ExpansionMode(VPP_EXPANSION_ASPECT);
  313.     setup_display_format(__hsize, __vsize, PIXEL_ASPECT_ALMOST_FULL, __zoom, 1);
  314.     set_jpeg_aspect_ratio(240,240); // max 255;
  315.     setVPP_DoItNow();
  316. }
  317. UINT16  old_hsize;
  318. UINT16  old_vsize;
  319. //
  320. // FUNCTION
  321. // void set_dis_pic_size(h,v)
  322. //
  323. // DESCRIPTION
  324. // generic vpp setup
  325. // setup video according to
  326. //  __hsize,
  327. //  __vsize,
  328. //
  329. // will depends on following characterists
  330. //  preview?
  331. //  vpp_zoom
  332. //  tv_format
  333. //  mode_aspect
  334. //
  335. void
  336. set_dis_pic_size(int __hsize, int __vsize)
  337. {
  338.     int __zoom;
  339.     int __progressive;
  340.     int __src_aspect;
  341.     int __out_aspect;
  342. #ifdef MONE_SIZECHG
  343.     if (old_hsize!=__hsize || old_vsize!=__vsize) {
  344.         printf_nw("change resolution to %dx%dn", __hsize, __vsize);
  345.     }
  346. #endif
  347.     //
  348.     old_hsize = __hsize;
  349.     old_vsize = __vsize;
  350.     //
  351.     // fix parameter for PREVIEW mode
  352.     if (IsAVDPreview()) {
  353.         // PREVIEW
  354.         __hsize         = 720;          // override fixed size
  355.         __vsize         = 480;
  356.         __zoom          = 0;
  357.         __src_aspect    = ASPECT_4_3;
  358.         __out_aspect    = OUTPUT_ASPECT_NORMAL;
  359.     } else {
  360.         // NORMAL
  361.         __zoom          = vpp_zoom;
  362.         __src_aspect    = mode_aspect;
  363.         __out_aspect    = get_output_aspect();
  364.     }
  365.     __progressive = 1;
  366.     // Setup TV format
  367.     setup_tv_format(tv_format);
  368.     // Setup TV output-aspect (wss signal)
  369.     setup_tv_aspect(__out_aspect);
  370.     // Setup VPP expansion mode
  371.     setVPP_ExpansionMode(VPP_EXPANSION_FIXED);
  372.     // Setup VPP parameters (size, aspect and zoom)
  373.     setup_display_format(__hsize,__vsize,__src_aspect,__zoom,__progressive);
  374. }