autoadj.lst

来自「NOVATEK公司的LCD_CONTROLLER源代码 液晶显示器驱动板源代码N」· LST 代码 · 共 1,316 行 · 第 1/5 页

LST
1,316
字号
   2      =1  #define  _ROM_MAP_H_
   3      =1  
   4      =1  extern code unsigned char MCU_DataMap[];
   5      =1  extern code unsigned char DDC_Tab[];
   6      =1  
   7      =1  #endif
  14          #include "SAA7114.H"
   1      =1  #ifndef _SAA7114_H_
   2      =1  #define _SAA7114_H_
   3      =1  
   4      =1  #define SAA7114 0x42
   5      =1  
   6      =1  void SAA7114Init(void);
   7      =1  void WritePageSAA7114(unsigned char addr1,unsigned char addr2);
   8      =1  void CheckColorSystem(void);
   9      =1  void CheckVideo(void);
  10      =1  void SetVideoBrightness(void);
  11      =1  void SetVideoContrast(void);
  12      =1  void SetVideoSaturation(void);
  13      =1  void SetVideoTint(void);
  14      =1  void SetVideoSharpness(void);
  15      =1  void SetAV_System(void);
  16      =1  
  17      =1  #endif 
  15          
  16          void AutoTune(void)
  17          {
  18   1      xdata unsigned short HP_Temp,VP_Temp,addr;
  19   1              if(H_SYNC_Temp == 0xffff)
  20   1                      goto Error1;
  21   1              HP_Temp = HP_Start;
  22   1              VP_Temp = VP_Start;
  23   1              NonFullScreen = 0;
  24   1              flag2 &= ~BIT_0;
  25   1              AutoPosition();
  26   1              if(H_SYNC_Temp == 0xffff)
  27   1                      goto Error1;
  28   1              if((flag2 & BIT_0) != 0x00){
  29   2                      if(NonFullScreen == 0){
  30   3                              goto Error1;
C51 COMPILER V7.20   AUTOADJ                                                               09/14/2004 12:20:56 PAGE 14  

  31   3                      }
  32   2              }
  33   1              AutoClock();
  34   1              if(H_SYNC_Temp == 0xffff)
  35   1                      goto Error1;
  36   1              if((flag2 & BIT_0) != 0x00){
  37   2                      if(NonFullScreen == 0){
  38   3                              goto Error;
  39   3                      }
  40   2                      else{
  41   3                              flag2 &= ~BIT_0;
  42   3                              AutoClockByPhase(1);
  43   3                      }
  44   2              }
  45   1              else{
  46   2                      AutoClockByPhase(0);
  47   2              }
  48   1              if(H_SYNC_Temp == 0xffff)
  49   1                      goto Error1;
  50   1              AutoPhaseFineTune();
  51   1              if(H_SYNC_Temp == 0xffff)
  52   1                      goto Error1;
  53   1              if((flag2 & BIT_0) != 0x00)
  54   1                      goto Error;
  55   1              AutoPosition();
  56   1              if(H_SYNC_Temp == 0xffff)
  57   1                      goto Error1;
  58   1              if(((flag2 & BIT_0) != 0x00)&&(NonFullScreen == 1)){    //fail
  59   2                      if(ModePoint < UserModeSt){
  60   3                              addr = 0x101 + (ModePoint * 8);
  61   3                              VP_Temp = MCU_DataMap[addr];
  62   3                              addr++;
  63   3                              HP_Temp = MCU_DataMap[addr];
  64   3                              HP_Temp <<= 8;
  65   3                              addr++;
  66   3                              HP_Temp += MCU_DataMap[addr];
  67   3                      }
  68   2                      HP_Start = HP_Temp;
  69   2                      VP_Start = VP_Temp;
  70   2                      SetHP();
  71   2                      SetVP();
  72   2                      flag2 &= ~BIT_0;
  73   2              }
  74   1      Error:
  75   1              if((flag2 & BIT_0) != 0x00){    //fail
  76   2                      if(H_SYNC_Temp != 0xffff){
  77   3                              ForceToBackground(0);   //Set fource to background
  78   3                              LoadModeDependentSettings();
  79   3                              SetADC_PLL();
  80   3                              SetADC_Phase();
  81   3                              SetScaler();
  82   3                              WriteIIC_HW(Scaler_Addr,0x95,0x00);
  83   3                              SetDisplayNormal();
  84   3                              if((flag3 & BIT_2) != 0x00){
  85   4                                      printf("AutoTune fail\r\n");
  86   4                              }
  87   3                      }
  88   2              }
  89   1              else{           //ok
  90   2                      SaveModeDependentSettings();
  91   2                      SetMinMax();
  92   2                      if((flag3 & BIT_2) != 0x00){
C51 COMPILER V7.20   AUTOADJ                                                               09/14/2004 12:20:56 PAGE 15  

  93   3                              printf("AutoTune OK\r\n");
  94   3                      }
  95   2              }
  96   1      Error1:
  97   1              RepeatTimer = KeyHoldTime;
  98   1              Repeat = 0xff;
  99   1      }
 100          
 101          void AutoPosition(void)
 102          {
 103   1      unsigned short temph,tempv;
 104   1              if((flag3 & BIT_2) != 0x00){
 105   2                      printf("AutoPosition\r\n");
 106   2              }
 107   1              WriteIIC_HW(Scaler_Addr,0x2E,HP_Min);  // AutoPosition Pixel mask -> H
 108   1              WriteIIC_HW(Scaler_Addr,0x3C,0x00);  // AutoPosition Pixel mask -> V
 109   1              WriteIIC_HW(Scaler_Addr,0x2F,0x30);  // Red Noise Margin
 110   1              WriteIIC_HW(Scaler_Addr,0x30,0x30);  // Green Noise Margin
 111   1              WriteIIC_HW(Scaler_Addr,0x31,0x30);  // Blue Noise Margin
 112   1      
 113   1              CheckModeChange();
 114   1              if((flag2 & BIT_0) != 0)
 115   1                      return;
 116   1              
 117   1              WriteIIC_HW(Scaler_Addr,0x1F,0x00);
 118   1              if(SyncMode == 3){      //DVI
 119   2                      WriteIIC_HW(Scaler_Addr,0x1E,0x19);
 120   2              }
 121   1              else{
 122   2                      WriteIIC_HW(Scaler_Addr,0x1E,0x09);
 123   2              }
 124   1              Timer3 = 10;
 125   1              while(!(ReadIIC_HW(Scaler_Addr,0x1F) & BIT_0) && Timer3 != 0){
 126   2                      CheckModeChange();
 127   2                      if((flag2 & BIT_0) != 0)
 128   2                              return;
 129   2              }
 130   1              if(Timer3 != 0){                                // Auto-Position OK
 131   2                      tempv = ReadWordIIC_HW(Scaler_Addr,0x32) & 0x07ff;
 132   2                      temph = ReadWordIIC_HW(Scaler_Addr,0x36) & 0x07ff;
 133   2                      if((flag3 & BIT_2) != 0x00){
 134   3                              printf("VP_Start = %d\r\n",tempv);
 135   3                              printf("HP_Start = %d\r\n",temph);
 136   3                      }
 137   2                      if((tempv > 0xff) || (temph > (HTotal-H_Act))){
 138   3                              flag2 |= BIT_0;                 // abort
 139   3                              NonFullScreen = 1;
 140   3                              if((flag3 & BIT_2) != 0x00){
 141   4                                      printf("AutoPosition fail\r\n");
 142   4                              }
 143   3                      }
 144   2                      else{
 145   3                              HP_Start = temph;
 146   3                              VP_Start = tempv;
 147   3                      }
 148   2              }
 149   1              else{
 150   2                      flag2 |= BIT_0;                 // abort
 151   2                      if((flag3 & BIT_2) != 0x00){
 152   3                              printf("AutoPosition fail\r\n");
 153   3                      }
 154   2              }
C51 COMPILER V7.20   AUTOADJ                                                               09/14/2004 12:20:56 PAGE 16  

 155   1              SetHP();
 156   1              SetVP();
 157   1      }
 158          
 159          void AutoClock(void)
 160          {
 161   1      unsigned char H_Difference,i,Compare,k;
 162   1      unsigned short PLL_Divider,V_Act;
 163   1      unsigned short H_Ref;
 164   1              if((flag2 & BIT_0) != 0x00)
 165   1                      return;
 166   1              if((flag3 & BIT_2) != 0x00){
 167   2                      printf("AutoClock\r\n");
 168   2              }
 169   1              V_Act = ReadWordIIC_HW(Scaler_Addr,0x34) & 0x07ff;
 170   1              if(VTotal > (V_Act + 190)){
 171   2                      flag2 |= BIT_0;
 172   2                      NonFullScreen = 1;
 173   2                      if((flag3 & BIT_2) != 0x00){
 174   3                              printf("Nono full screen V\r\n");
 175   3                      }
 176   2                      return;
 177   2              }
 178   1              if((flag3 & BIT_6) != 0){
 179   2                      V_Act <<= 1;
 180   2              }
 181   1              PLL_Divider = ReadWordIIC_HW(Scaler_Addr,0x38) & 0x07ff;
 182   1      
 183   1              if((flag3 & BIT_2) != 0x00){
 184   2                      printf("V_Act = %d\r\n",V_Act);
 185   2                      printf("H_Act = %d\r\n",PLL_Divider);
 186   2              }
 187   1              for(i=0; i<14; i++){            //check Vtotal
 188   2                      if(V_Act > V_ActiveTab[i])
 189   2                              H_Ref = V_Act - V_ActiveTab[i];
 190   2                      else
 191   2                              H_Ref = V_ActiveTab[i] - V_Act;
 192   2                      if(H_Ref < 5){                  //check Htotal
 193   3                              H_Ref = H_ActiveTab[i];
 194   3                              if((i == 1)&&(Read24C16(0xd3) != 0))
 195   3                                      H_Ref = 640;
 196   3                              if(PLL_Divider > H_Ref){
 197   4                                      PLL_Divider = PLL_Divider - H_Ref;
 198   4                                      Compare = 0;
 199   4                              }
 200   3                              else{
 201   4                                      PLL_Divider =  H_Ref - PLL_Divider;
 202   4                                      Compare = 1;
 203   4                              }
 204   3                              if(PLL_Divider > (H_Ref >> 3)){                 //check Htotal range
 205   4                                      if((i == 2) && (Compare == 0)){
 206   5                                              i = 11;
 207   5                                              H_Ref = 848;
 208   5                                      }
 209   4      /*                              else{
 210   4                                              flag2 |= BIT_0;
 211   4                                              NonFullScreen = 1;
 212   4                                              if((flag3 & BIT_2) != 0x00){
 213   4                                                      printf("Nono full screen H\r\n");
 214   4                                              }
 215   4                                              return;
 216   4                                      }*/
C51 COMPILER V7.20   AUTOADJ                                                               09/14/2004 12:20:56 PAGE 17  

 217   4                              }
 218   3                              PLL_Divider = 0x106 + (ModePoint * 8);
 219   3                              if(i != Read24C16(PLL_Divider)){                //change resolution
 220   4                                      Write24C16(PLL_Divider,i);
 221   4                                      SetScaler();
 222   4                              }
 223   3                              break;
 224   3                      }
 225   2              }
 226   1              if((i == 14)||(V_Act < 340)){
 227   2                      flag2 |= BIT_0;
 228   2                      NonFullScreen = 1;
 229   2                      if((flag3 & BIT_2) != 0x00){
 230   3                              printf("Nono full screen V\r\n");
 231   3                      }
 232   2                      return;
 233   2              }
 234   1              k = i;
 235   1      // Set refance H_Active
 236   1              WriteWordIIC_HW(Scaler_Addr,0x3A,H_Ref);
 237   1      // read pll divider
 238   1              if(HTotal <= H_Ref){
 239   2                      HTotal = H_Ref + HP_Start;
 240   2                      SetADC_PLL();
 241   2                      if((flag3 & BIT_1) != 0){
 242   3                              flag2 |= BIT_0;
 243   3                              return;
 244   3                      }
 245   2              }
 246   1              for(i=0; i<0x20; i++){

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?