⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mode_detect.lst

📁 Realtek 公司的RTD2523A芯片原厂source code,没有被修改过的。
💻 LST
📖 第 1 页 / 共 5 页
字号:
 782   3                  // So usIPV_ACT_LEN should not be too larger than pre-set capture window length
 783   3                  if (Mode_Preset[Wait_Time_Cnt][2] > usIPV_ACT_LEN || (CAP_WIN[Wait_Time_Cnt][4] + 24) < usIPV_
             -ACT_LEN)   continue;
 784   3              }
 785   2              else
 786   2              {
 787   3                  if (Mode_Preset[Wait_Time_Cnt][2] < usIPV_ACT_LEN)   continue;
 788   3              }
 789   2      
 790   2              ((unsigned int *)Data)[0]   = (unsigned long)(RTD_XTAL / 10) * Mode_Preset[Wait_Time_Cnt][0] 
 791   2                                          * Mode_Preset[Wait_Time_Cnt][2] / ((unsigned long)100 * usIPV_ACT_LEN 
             -* usHsync);
 792   2      
 793   2              // Return if we find out a suitable user-mode.
 794   2              if (MAX_DCLK > ((unsigned int *)Data)[0])   return Wait_Time_Cnt;
 795   2          }
 796   1          while (MODE_USER1600x1200 >= ++Wait_Time_Cnt);
 797   1      
 798   1          Wait_Time_Cnt   = MODE_NOSUPPORT;
 799   1      
 800   1      #if (PARTIAL_DISP)
                  // If failed, we try partial-screen display.
                  Wait_Time_Cnt   = Partial_Display();
              #endif
 804   1      
 805   1          return  Wait_Time_Cnt;
 806   1      
 807   1      #else
              
                  return  MODE_NOSIGNAL;
              
              #endif
 812   1      }
 813          
 814          /////////////////////////////////////////////////////////
 815          //------------------ Detect VIDEO Mode ----------------//
 816          /////////////////////////////////////////////////////////
 817          #if (VIDEO_CHIP != VDC_NONE)
              
              void Detect_Video_Mode(void)
              {
                  I2CRead(ADDR_VIDEO, 0x1f, 0x01);
              
                  //------ Check Horizontal Lock & Frequency ------
                  if (0 == (Data[0] & 0x40))
                  {   
                      if ((Data[0] & 0x20) && (0x01 != (ucAV_Mode & 0x0f)))
                      {
                          // Field rate changed to 60Hz
                          ucAV_Mode       = 0x01;
                          ucMode_Found    = MODE_NOSUPPORT;
                          ucMode_Times    = 0;
              
                          Data[0] = 4;
                          Data[1] = ADDR_VIDEO;
                          Data[2] = 0x0e;
                          Data[3] = 0x08;     // Start color search from NTSC-M
                          I2CWrite(Data);
                      }
                      else if ((0 == (Data[0] & 0x20)) && (0x02 != (ucAV_Mode & 0x02)))
                      {
                          // Field rate changed to 50Hz
C51 COMPILER V6.20c  MODE_DETECT                                                           04/15/2004 12:59:19 PAGE 15  

                          ucAV_Mode       = 0x02; 
                          ucMode_Found    = MODE_NOSUPPORT;
                          ucMode_Times    = 0;
                          
                          Data[0] = 4;
                          Data[1] = ADDR_VIDEO;
                          Data[2] = 0x0e;
                          Data[3] = 0x08;     // Start color search from PAL-BDGHI
                          I2CWrite(Data);
                      }
                      else
                      {    
                          //------ Check Lock Color ------
                          if (0x01 == (Data[0] & 0x01))
                          {   
                              // Lock Color
                              if (ucAV_Mode & 0x01)
                              {
                                  if (MODE_VIDEO60HZ == ucMode_Found)
                                  {
                                      ucMode_Times ++;
                                  }
                                  else
                                  {
                                      ucMode_Found    = MODE_VIDEO60HZ;
                                      ucMode_Times    = 0;
                                  }
                              }
                              else
                              {
                                  if (MODE_VIDEO50HZ == ucMode_Found)
                                  {
                                      ucMode_Times ++;
                                  }
                                  else
                                  {
                                      ucMode_Found    = MODE_VIDEO50HZ;
                                      ucMode_Times    = 0;
                                  }
                              }
                          }
                          else
                          {
                              // Non Lock Color
                              if (MODE_NOSUPPORT != ucMode_Found)
                              {
                                  ucMode_Found    = MODE_NOSUPPORT;
                                  ucMode_Times    = 0;
                              }
                              
                              Data[0] = 4;
                              Data[1] = ADDR_VIDEO;
                              Data[2] = 0x0e;
                              
                              if (0x03 == (ucAV_Mode & 0x03))
                              {
                                  // SECAM -> PAL-BDGHI(50Hz)
                                  Data[3] = 0x08;
                                  I2CWrite(Data);                    
                                  ucAV_Mode   = 0x02;
                              }
                              else
C51 COMPILER V6.20c  MODE_DETECT                                                           04/15/2004 12:59:19 PAGE 16  

                              {
                                  if (ucMode_Times & 0x01)    // Every 2-times , change color
                                  {
                                      switch (ucAV_Mode & 0x70)
                                      {
                                      case 0x00:  
                                          Data[3] = 0x18; // NTSC-4.43(50Hz)  // PAL-4.43(60Hz)
                                          I2CWrite(Data);
                                          ucAV_Mode   = (ucAV_Mode & 0x0f) | 0x10;
                                          break;
                                      case 0x10:
                                          Data[3] = 0x28; // PAL-N(50Hz)      // NTSC-4.43(60Hz)
                                          I2CWrite(Data);
                                          ucAV_Mode   = (ucAV_Mode & 0x0f) | 0x20;
                                          break;
                                      case 0x20:
                                          Data[3] = 0x38; // NTSC-N(50Hz)     // PAL-M(60Hz)
                                          I2CWrite(Data);
                                          ucAV_Mode   = (ucAV_Mode & 0x0f) | 0x30;
                                          break;
                                      case 0x30:
                                          if (ucAV_Mode & 0x02)
                                          {
                                              // NTSC-N -> SECAM (50Hz)
                                              Data[3]     = 0x5c;
                                              I2CWrite(Data);
                                              ucAV_Mode   = 0x03;
                                          }
                                          else
                                          {	
                                              // PAL-M -> NTSC_M (60Hz)
                                              Data[3]     = 0x08;
                                              I2CWrite(Data);
                                              ucAV_Mode   = ucAV_Mode & 0x0f | 0x00;
                                          }    
                                      default:
                                          break;
                                      }//end of "switch (ucAV_Mode & 0x70)"
                                  }//end of "if (ucMode_Times & 0x01)"	
                              }//end of "if (0x03 == (ucAV_Mode & 0x03)) else"
                          }//end of "Non Lock color
                      }//end of "Check Lock Color"
                  }//end of "if (0==(Data[0] & 0x40))"
                  else
                  {   
                      // Non Horizontal Lock
                      ucAV_Mode   = 0;
                      
                      if (ucMode_Found != MODE_NOSUPPORT)
                      {
                          ucMode_Found    = MODE_NOSUPPORT;
                          ucMode_Times    = 0;
                      }
                  }
                  
                  //-------------Check result--------------
                  if (MODE_NOSUPPORT != ucMode_Found)
                  {   
                      if (VIDEO_SEARCH_TIMES < ucMode_Times)
                      {
              
                          bLIGHT_PWR  = LIGHT_OFF;        // Turn off BackLight for reset display
C51 COMPILER V6.20c  MODE_DETECT                                                           04/15/2004 12:59:19 PAGE 17  

                          
                          RTDSetByte(HOSTCTRL_02, 0x00);  // Wake RTD up
                          RTDOSDW(OSD_Reset);            // Clear OSD
                          
                          if (SOURCE_YUV == (stGUD1.INPUT_SOURCE & 0x07))
                              ucMode_Curr = (ucAV_Mode & 0x02) ? MODE_YUV50HZ : MODE_YUV60HZ;
                          else
                              ucMode_Curr = ucMode_Found;
                                  
                          ucMode_Times    = 0;
                          bStable         = 0;            // bStable must be cleared when mode changed
              
                          Display_Video_Set();            
                      }
                  }
                  else
                  {
                      ucMode_Times ++;
                      
                      if (ucAV_Mode)
                      {
                          // Force to display although we cannot lock color
                          if (VIDEO_SEARCH_TIMES < ucMode_Times 
                              && (NO_COLOR_TIMES < ucMode_Times || SOURCE_YUV == (stGUD1.INPUT_SOURCE & 0x07)))
                          {
              
                              bLIGHT_PWR  = LIGHT_OFF;        // Turn off BackLight for reset display
              
                              RTDSetByte(HOSTCTRL_02, 0x00);  // Wake RTD up
                              RTDOSDW(OSD_Reset);             // Clear OSD
                              
                              ucAV_Mode       = (ucAV_Mode & 0x02) ? 0x82 : 0x81;
              
                              if (SOURCE_YUV != (stGUD1.INPUT_SOURCE & 0x07))
                                  ucMode_Curr = (ucAV_Mode & 0x02) ? MODE_VIDEO50HZ : MODE_VIDEO60HZ;
                              else
                                  ucMode_Curr = (ucAV_Mode & 0x02) ? MODE_YUV50HZ : MODE_YUV60HZ;
              
                              ucMode_Times    = 0;
                              bStable         = 0;    // bStable must be cleared when mode changed
              
                              Display_Video_Set();
                          }
                      }
                      else
                      {
                          if (NO_MODE_TIMES < ucMode_Times)
                          {
                              bStable         = 1;    // Set bStable to 1 when signal timing is stable.
              
                              ucMode_Times    = NO_MODE_TIMES - 1;
                          }
                      }
                  }
              }
              
              
              /////////////////////////////////////////////////////////
              //------------------- Check VIDEO Mode ----------------//
              /////////////////////////////////////////////////////////
              void Check_Video_Mode(void)
              {   
C51 COMPILER V6.20c  MODE_DETECT                                                           04/15/2004 12:59:19 PAGE 18  

                  I2CRead(ADDR_VIDEO, 0x1f, 0x01);
                  
                  // Check color
                  if (0 == (ucAV_Mode & 0x80))
                  {
                      if (0 == (Data[0] & 0x01))      ucMode_Curr = MODE_NOSIGNAL;    // Color standard changed
                  }
                  else
                  {
                      if (0 == (Data[0] & 0x01))
                      {
                          ucMode_Times    = 0;
                      }
                      else
                      {
                          // When we cannot lock color, we set color standard to PAL-BDGHI if field rate is 50Hz, 
                          // and to NTSC-M if it is 60Hz.
                          // If we find color is locked, we should update ucAV_Mode to indicate we now get color.
                          if (VIDEO_SEARCH_TIMES < ++ucMode_Times)    ucAV_Mode = ucAV_Mode & 0x0f;
                      }
                  }
              

⌨️ 快捷键说明

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