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

DVD

开发平台:

C/C++

  1. /**************************************************************************
  2.  *                                                                        *
  3.  *         Copyright (c) 2002 by Sunplus Technology Co., Ltd.             *
  4.  *                                                                        *
  5.  *  This software is copyrighted by and is the property of Sunplus        *
  6.  *  Technology Co., Ltd. All rights are reserved by Sunplus Technology    *
  7.  *  Co., Ltd. This software may only be used in accordance with the       *
  8.  *  corresponding license agreement. Any unauthorized use, duplication,   *
  9.  *  distribution, or disclosure of this software is expressly forbidden.  *
  10.  *                                                                        *
  11.  *  This Copyright notice MUST not be removed or modified without prior   *
  12.  *  written consent of Sunplus Technology Co., Ltd.                       *
  13.  *                                                                        *
  14.  *  Sunplus Technology Co., Ltd. reserves the right to modify this        *
  15.  *  software without notice.                                              *
  16.  *                                                                        *
  17.  *  Sunplus Technology Co., Ltd.                                          *
  18.  *  19, Innovation First Road, Science-Based Industrial Park,             *
  19.  *  Hsin-Chu, Taiwan, R.O.C.                                              *
  20.  **************************************************************************/
  21. /*--------------------------------------------------------------------------
  22. |  File Name   :  srgb.c
  23. |
  24. |  Description :  8202 Serial RGB interface
  25. |
  26. |  Version     :  0.1  
  27. |  Rev Date         Author(s)      Status & Comments
  28. |---------------------------------------------------------------------------------
  29. |  0.1 2005/1/5        wthsin         Creating
  30. |--------------------------------------------------------------------------------*/
  31. #include "config.h"
  32. #include "global.h"
  33. #include "macro.h"
  34. #include "regmap.h"
  35. #include "emuio.h"
  36.  
  37. #ifdef SERIAL_RGB       
  38. #ifndef DVDRELEASE
  39.  #define SERIAL_RGB_DBG       1
  40. #endif
  41. #define D printf("INFO: __%d__(%s:%s)n",__LINE__,__FILE__,__FUNCTION__);
  42. #ifndef SERIAL_RGB_DBG
  43.  #undef printf
  44.  #undef print_block
  45.  #define printf(f, a...) do {} while (0)
  46.  #define print_block(x,y) do {} while (0)
  47. #endif
  48. /**************************************************************************
  49.  *                                                                        *
  50.  *  Function Name: SetSRGB_MODE                                           *
  51.  *                                                                        *
  52.  *  Purposes:                                                             *
  53.  *      set SerialRGB Mode                                                *                                                       
  54.  *  Descriptions:                                                         *
  55.  *      set SerialRGB Mode                                                *
  56.  *  Arguments:                                                            *
  57.  *      ModeType:                                                         *                                       
  58.  *                 PANEL_MODE_280      0                                  *
  59.  *                 PANEL_MODE_480      1                                  *
  60.  *                 PANEL_MODE_528      2                                  *
  61.  *                 PANEL_MODE_960      3                                  *
  62.  *                 PANEL_MODE_1152     4                                  *
  63.  *                 PANEL_MODE_1440     5                                  *
  64.  *  Returns:                                                              *
  65.  *      None                                                              *
  66.  *  See also:                                                             *
  67.  *      None                                                              *
  68.  **************************************************************************/
  69. void setSRGB_MODE(UINT32 ModeType) 
  70. {
  71.     UINT16 rgb_period,sample_seq,order_odd,order_even;
  72.     switch(ModeType)
  73.     {
  74.      case PANEL_MODE_280:
  75.                          rgb_period=4;
  76.                          sample_seq=0x01;
  77.                          order_odd=0;
  78.                          order_even=2;
  79.                          break;   
  80.      case PANEL_MODE_480:
  81.                          rgb_period=2;
  82.                          sample_seq=0x01;
  83.                          order_odd=0;
  84.                          order_even=2;
  85.                          break;  
  86.      case PANEL_MODE_528:
  87.                          rgb_period=7;
  88.                          sample_seq=0x49;
  89.                          order_odd=0;
  90.                          order_even=2;
  91.                          break;  
  92.      case PANEL_MODE_960:
  93.                          rgb_period=2;
  94.                          sample_seq=0x05;
  95.                          order_odd=0;
  96.                          order_even=0;
  97.                          break;  
  98.      case PANEL_MODE_1152:
  99.                          rgb_period=4;
  100.                          sample_seq=0x0f;
  101.                          order_odd=0;
  102.                          order_even=0;
  103.                          break; 
  104.      case PANEL_MODE_1440:
  105.                          rgb_period=14;
  106.                          sample_seq=0x7FF;
  107.                          order_odd=0;
  108.                          order_even=0;
  109.                          break;                                                                                   
  110.     }    
  111. regs0->srgb_mode[1] = ((order_even&0x07)<<7)&((order_odd&0x07)<<4)&(rgb_period&0x0f);
  112. regs0->srgb_mode[2] = sample_seq;
  113. }
  114. /**************************************************************************
  115.  *                                                                        *
  116.  *  Function Name: SRGB_Output_Switch                                     *
  117.  *                                                                        *
  118.  *  Purposes:                                                             *
  119.  *      Enable/Disable SRGB output                                        *
  120.  *  Descriptions:                                                         *
  121.  *      Enable/Disable SRGB output                                        *
  122.  *  Arguments:                                                            *
  123.  *      srgbonoff:                                                        *
  124.  *                 SRGB_OFF            0                                  *
  125.  *                 SRGB_ON             1                                  *
  126.  *      lcd_tcon_mode:                                                    *
  127.  *                 UPS051              0                                  * 
  128.  *                 UPS052              1                                  *
  129.  *  Returns:                                                              *
  130.  *      None                                                              *
  131.  *  See also:                                                             *
  132.  *      None                                                              *
  133.  **************************************************************************/
  134. void SRGB_Output_Switch(UINT32 srgbonoff,UINT32 lcd_tcon_mode)
  135. {
  136.     regs0->srgb_mode[0]= (regs0->srgb_mode[0]&0xFFFC)+(lcd_tcon_mode<<1+srgbonoff); 
  137. }
  138. /**************************************************************************
  139.  *                                                                        *
  140.  *  Function Name: setSRGB_para                                           *
  141.  *                                                                        *
  142.  *  Purposes:                                                             *
  143.  *      setup SRGB parameter                                              *
  144.  *  Descriptions:                                                         *
  145.  *      setup SRGB parameter                                              *
  146.  *  Arguments:                                                            *
  147.  *      F_S(2 bit)/HV_NEG(1 bit)/CP(1 bit)/VBEN(1 bit)                    *
  148.  *      /VBEN(1 bit)/UHEN(1 bit) (See register doc)                       *
  149.  *  Returns:                                                              *
  150.  *      None                                                              *
  151.  *  See also:                                                             *
  152.  *      None                                                              *
  153.  **************************************************************************/
  154. void setSRGB_para(UINT8 F_S,UINT8 HV_NEG,UINT8 CP,UINT8 VBEN,UINT8 VAEN,UINT8 UHEN)
  155. {
  156.     UINT16 value=0;
  157.     value=F_S<<5 +HV_NEG<<4 +CP<<3 +VBEN<<2 +VAEN<<1 +UHEN;
  158.     regs0->srgb_mode[0]= (regs0->srgb_mode[0]&0xFE03)+(value<<2); 
  159. }
  160. /**************************************************************************
  161.  *                                                                        *
  162.  *  Function Name: SRGB_HV                                                *
  163.  *                                                                        *
  164.  *  Purposes:                                                             *
  165.  *      setup SRGB HV parameter                                              *
  166.  *  Descriptions:                                                         *
  167.  *      setup SRGB HV parameter                                              *
  168.  *  Arguments:                                                            *
  169.  *      SRGB_V_MODE = 1 : Active vertical line number = 234               *
  170.  *      SRGB_V_MODE = 0 : Active vertical line number = 220               *
  171.  *      PAL_NTSC = 1 : PAL                                             *
  172.  *      PAL_NTSC = 0 : NTSC                                            *
  173.  *  Returns:                                                              *
  174.  *      None                                                              *
  175.  *  See also:                                                             *
  176.  *      None                                                              *
  177.  **************************************************************************/
  178. void SRGB_HV ( UINT32 PAL_NTSC, UINT8 SRGB_V_MODE)
  179. {
  180. UINT32 Display_Period;
  181. UINT32 Total_V_Period;
  182. UINT32 SRGB_H_EDGE1_PNT;
  183. if (SRGB_V_MODE) Display_Period = 240;
  184. else Display_Period = 220;
  185. if (PAL_NTSC) Total_V_Period = 313;//313
  186. else Total_V_Period = 262;//263
  187. ////////////////////////////////////////
  188. if (PAL_NTSC) SRGB_H_EDGE1_PNT = 311;
  189. else SRGB_H_EDGE1_PNT = 260;
  190. UINT32 SRGB_H_EDGE2_PNT = SRGB_H_EDGE1_PNT+4;
  191. UINT32 SRGB_V_EDGE1_LT;
  192. if (PAL_NTSC) SRGB_V_EDGE1_LT = 27;
  193. else SRGB_V_EDGE1_LT = 15;
  194. UINT32 SRGB_V_EDGE2_LT = SRGB_V_EDGE1_LT + 1;
  195. UINT32 SRGB_V_EDGE1_LB = SRGB_V_EDGE1_LT + Total_V_Period;
  196. UINT32 SRGB_V_EDGE2_LB = SRGB_V_EDGE1_LB + 1;
  197. UINT32 SRGB_V_START_LT = SRGB_V_EDGE2_LT + 3;
  198. UINT32 SRGB_V_END_LT = SRGB_V_START_LT + Display_Period;
  199. UINT32 SRGB_V_START_LB = SRGB_V_EDGE2_LB + 3;
  200. UINT32 SRGB_V_END_LB = SRGB_V_START_LB + Display_Period;
  201. ////////////////////////////////////////
  202. regs0->tv_pccon[0] = SRGB_H_EDGE1_PNT;
  203. regs0->tv_pccon[1] = SRGB_H_EDGE2_PNT;
  204. regs0->tv_pccon[2] = SRGB_V_START_LT;
  205. regs0->tv_pccon[3] = SRGB_V_END_LT;
  206. regs0->tv_pccon[4] = SRGB_V_START_LB;
  207. regs0->tv_pccon[5] = SRGB_V_END_LB;
  208. regs0->tv_pccon[6] = SRGB_V_EDGE1_LT;
  209. regs0->tv_pccon[7] = SRGB_V_EDGE2_LT;
  210. regs0->tv_pccon[8] = SRGB_V_EDGE1_LB;
  211. regs0->tv_pccon[9] = SRGB_V_EDGE2_LB;
  212. }
  213. #endif    //#ifdef SERIAL_RGB