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

📄 mode_detect.lst

📁 液晶显示器程序代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
                      if(bFrameSync)
                         RTDSetBit(ODD_CTRL_8E,0xef,0x10);
              #endif
 740   2          }
 741   1      
 742   1      }
 743          
 744          
 745          
 746          
 747          unsigned char Seek_DVI_Mode(unsigned char mode)
 748          {
 749   1      #if(TMDS_ENABLE)
 750   1          unsigned char   Wait_Time_Cnt;
 751   1      
 752   1          RTDSetByte(SYNC_POR_4C, 0x03);  // Measure data enable width and height
 753   1      
 754   1          Wait_Time_Cnt  = 60;       
 755   1          do
 756   1          {   
 757   2              Delay_Xms(1);
 758   2              RTDRead(SYNC_POR_4C, 0x07, Y_INC);
 759   2          }
 760   1          while ((Data[0] & 0x02) && (--Wait_Time_Cnt));
 761   1      
 762   1          Data[7] = Data[5];
 763   1          Data[6] = Data[6] & 0x0f;
 764   1          Data[5] = Data[3];
 765   1          Data[4] = Data[4] & 0x87;
 766   1          Data[3] = Data[1];
 767   1          Data[2] = Data[2] & 0x8f;
 768   1      
 769   1          // Measure Failed !!!
 770   1          if ((0 == ((unsigned int *)Data)[1]) || (0x07ff <= ((unsigned int *)Data)[1]) ||
 771   1              (0 == ((unsigned int *)Data)[2]) || (0x07ff <= ((unsigned int *)Data)[2]) ||
 772   1              (0 == Wait_Time_Cnt))
 773   1          {
 774   2              RTDSetByte(SYNC_POR_4C, 0x00);
 775   2      
 776   2              return MODE_NOSUPPORT;
 777   2          }
 778   1      
 779   1          // Save IH_TOTAL in usADC_Clock
 780   1          usADC_Clock     = ((unsigned int *)Data)[1] * 2;
 781   1      
 782   1          // Save input data enable width and height
 783   1          usIPV_ACT_LEN   = ((unsigned int *)Data)[2];
 784   1          usIPH_ACT_WID   = ((unsigned int *)Data)[3] * 2;
 785   1      
 786   1          // We don't support input image less than 350 active lines
 787   1          if (350 > usIPV_ACT_LEN)    return MODE_NOSUPPORT;
 788   1      
 789   1          // We only support 8N active width
 790   1          usIPH_ACT_WID   = (2 < (usIPH_ACT_WID & 0x0007)) ? ((usIPH_ACT_WID + 8) & 0xfff8) : (usIPH_ACT_WID & 0
             -xfff8);
C51 COMPILER V7.06   MODE_DETECT                                                           11/21/2005 13:47:38 PAGE 14  

 791   1      
 792   1          // We only support active width not larger than 1280
 793   1          if (1280 < usIPH_ACT_WID)   usIPH_ACT_WID   = 1280;
 794   1      
 795   1          // Calculate maximum usIPV_ACT_LEN limitation
 796   1          ((unsigned int *)Data)[0]   = (unsigned long)(usVsync - 1) * DISP_LEN / MIN_DV_TOTAL;
 797   1      
 798   1          if (((unsigned int *)Data)[0] < usIPV_ACT_LEN)      usIPV_ACT_LEN   = ((unsigned int *)Data)[0];
 799   1      
 800   1          mode    = MODE_UNDEFINED0;
 801   1        
 802   1          if (MODE_UNDEFINED0 == mode)
 803   1          {
 804   2              // First, we try user-mode to fit the undefined mode for full-screen display.
 805   2              Wait_Time_Cnt   = MODE_USER720x400;
 806   2              do
 807   2              {
 808   3                  if (Mode_Preset[Wait_Time_Cnt][2] < CAP_WIN[Wait_Time_Cnt][4])   // V scale-down
 809   3                  {
 810   4                      // Larger scale-down ratio may need a larger DH_TOTAL. 
 811   4                      // So usIPV_ACT_LEN should not be too larger than pre-set capture window length
 812   4                      if (Mode_Preset[Wait_Time_Cnt][2] > usIPV_ACT_LEN || (CAP_WIN[Wait_Time_Cnt][4] + 24) < us
             -IPV_ACT_LEN)   continue;
 813   4                  }
 814   3                  else
 815   3                  {
 816   4                      if (Mode_Preset[Wait_Time_Cnt][2] < usIPV_ACT_LEN)   continue;
 817   4                  }
 818   3      
 819   3                  ((unsigned int *)Data)[0]   = (unsigned long)2458 * Mode_Preset[Wait_Time_Cnt][0] * Mode_Prese
             -t[Wait_Time_Cnt][2]
 820   3                                              / ((unsigned long)100 * usIPV_ACT_LEN * usHsync);
 821   3                  
 822   3                  // Return if we find out a suitable user-mode.
 823   3                  if (MAX_DCLK > ((unsigned int *)Data)[0])   return Wait_Time_Cnt;
 824   3              }
 825   2              while (MODE_USER1600x1200 >= ++Wait_Time_Cnt);
 826   2      
 827   2                      mode = Partial_Display();
 828   2              // If failed, we try partial-screen display.
 829   2      
 830   2          }
 831   1              
 832   1      
 833   1          return  mode;
 834   1      #else
                  mode    = MODE_UNDEFINED0;
                  return  0;
              #endif
 838   1      }
 839          
 840          /////////////////////////////////////////////////////////
 841          //------------------ Detect VIDEO Mode ----------------//
 842          /////////////////////////////////////////////////////////
 843          void Detect_Video_Mode(void)
 844          {
 845   1      #if(VIDEO_CHIP != VDC_NONE)
                  I2CRead(ADDR_VIDEO, 0x1f, 0x01);
              
                  //------ Check Horizontal Lock & Frequency ------
                  if (0 == (Data[0] & 0x40))
                  {   
C51 COMPILER V7.06   MODE_DETECT                                                           11/21/2005 13:47:38 PAGE 15  

                      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
                          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)
                              {
C51 COMPILER V7.06   MODE_DETECT                                                           11/21/2005 13:47:38 PAGE 16  

                                  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
                              {
                                  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
C51 COMPILER V7.06   MODE_DETECT                                                           11/21/2005 13:47:38 PAGE 17  

                      ucAV_Mode   = 0;
                      
                      if (ucMode_Found != MODE_NOSUPPORT)
                      {
                          ucMode_Found    = MODE_NOSUPPORT;
                          ucMode_Times    = 0;
                      }
                  }
                  
                  //-------------Check result--------------

⌨️ 快捷键说明

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