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

📄 detect.lst

📁 MSTARXX.rar
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.18   DETECT                                                                09/29/2009 23:58:04 PAGE 1   


C51 COMPILER V8.18, COMPILATION OF MODULE DETECT
OBJECT MODULE PLACED IN ..\..\1out\detect.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ..\..\pc\detect.c BROWSE INCDIR(..\..\inc) DEBUG OBJECTEXTEND PRINT(..\..\1
                    -out\detect.lst) OBJECT(..\..\1out\detect.obj)

line level    source

   1          
   2          #define _DETECT_C_
   3          
   4          #include <math.h>
   5          #include "types.h"
   6          #include "board.h"
   7          #if VGA_ENABLE
   8          #include "global.h"
   9          #include "ms_reg.h"
  10          #include "ms_rwreg.h"
  11          #include "power.h"
  12          #include "DEBUG.h"
  13          #include "misc.h"
  14          #include "menu.h"
  15          #include "UserPref.h"
  16          #include "msOSD.h"
  17          #include "panel.h"
  18          #include "mStar.h"
  19          #include "DevVD.h"
  20          #include "detect.h"
  21          #include "Menufunc.h"
  22          #include "mstar.h"
  23          
  24          void Menu_InitAction(void)
  25          {
  26   1          if (SyncLossState())
  27   1          {
  28   2              g_ucMenuPageIndex=StandbyMenu;
  29   2          }
  30   1          else if (UnsupportedModeFlag)
  31   1          {
  32   2              g_ucMenuPageIndex=UnsupportedModeMenu;
  33   2          }
  34   1          else if (g_ModeSetting.AutoTimes==0 )
  35   1              g_ucMenuPageIndex=AutoMenu;
  36   1          else
  37   1              g_ucMenuPageIndex=RootMenu;
  38   1      
  39   1              g_ucMenuItemIndex=0;
  40   1              g_ucOsdCounter=0;
  41   1              ExecuteKeyEvent(MIA_RedrawMenu);
  42   1              WatchDogClear();
  43   1              //AutoConfig();
  44   1          if (UnsupportedModeFlag)
  45   1          {
  46   2                  if(!FreeRunModeFlag)
  47   2                      {
  48   3                          if (g_ModeSetting.AutoTimes ==0 )
  49   3                          AutoConfig();
  50   3                      }
  51   2          }
  52   1      }
  53          //*******************************************************************
  54          // Function Name: msMonitorInputTiming
C51 COMPILER V8.18   DETECT                                                                09/29/2009 23:58:04 PAGE 2   

  55          //
  56          // Decscription: Detect input timing
  57          //
  58          // callee: msSyncLossStateDetect(), msValidTimingDetect(), msAutoDVI() in detect.c
  59          //         msSetInputPort(),  in mstar.c
  60          //
  61          // caller: main() in main.c
  62          //*******************************************************************
  63          void msMonitorInputTiming(void)
  64          {
  65   1              if (!PowerOnFlag)
  66   1              return;
  67   1      
  68   1        // detect whether input signal is changing
  69   1              if (!g_bInputTimingChangeFlag)
  70   1          {
  71   2              if (SyncLossState())
  72   2              {
  73   3                      if (!FreeRunModeFlag)
  74   3                              {//printMsg("!FreeRunModeFlag");
  75   4                            Set_InputTimingChangeFlag();
  76   4                              }
  77   3                      else if (msSyncLossStateDetect()) // detect mode while no Sync/suspend/standby/disconnect
  78   3                            {//printMsg("msSyncLossStateDetect");
  79   4                            Set_InputTimingChangeFlag();
  80   4                              }
  81   3              }
  82   2              else // valid timing
  83   2              { // check if input timing is changing
  84   3                if (msValidTimingDetect())
  85   3                  { //printMsg("msValidTimingDetect");
  86   4                    SrcFlags|=SyncLoss;
  87   4                    Set_InputTimingChangeFlag();
  88   4                  }
  89   3              }
  90   2          }
  91   1      
  92   1        //=============================================================================
  93   1        //=============================================================================
  94   1          if (g_bInputTimingChangeFlag) // input timing is unstable
  95   1          {
  96   2              Clr_InputTimingChangeFlag();
  97   2              Clr_DoModeSettingFlag();
  98   2              g_ucTimingChangeDebunce++;
  99   2              if (!SyncLossState())// && !InputTimingStableFlag) // prevent from SOG
 100   2                  {
 101   3                      if (g_ucTimingChangeDebunce<=3)
 102   3                  {
 103   4                      SrcFlags|=SyncLoss;
 104   4                      return;
 105   4                  }
 106   3              }
 107   2            msPrepareForTimingChange();
 108   2              //printMsg("VGA InputTimingChange");
 109   2          }
 110   1          else // input timing is stable
 111   1          {
 112   2              g_ucTimingChangeDebunce=0;
 113   2              g_ucInputTimingStableCounter++; // counter timing stable times
 114   2              if (g_ucInputTimingStableCounter==0)
 115   2                  g_ucInputTimingStableCounter=1;
 116   2              if (!InputTimingStableFlag)
C51 COMPILER V8.18   DETECT                                                                09/29/2009 23:58:04 PAGE 3   

 117   2              {
 118   3                      if ((!SyncLossState() && g_ucInputTimingStableCounter>=ValidTimingStableCount)|| // set timing st
             -able flag
 119   3                     (SyncLossState() && g_ucInputTimingStableCounter>=SyncLossStableCount))
 120   3                  {
 121   4                      Set_InputTimingStableFlag();// set flag to search for input mode
 122   4                      Set_DoModeSettingFlag();
 123   4                  }
 124   3              }
 125   2          }
 126   1      }
 127          
 128          
 129          //*******************************************************************
 130          // Function Name: msModeHandler
 131          //
 132          // Decscription: Programming scaler while input timing is changing
 133          //
 134          // callee: msSyncLossStateDetect(), msValidTimingDetect(), msAutoDVI() in detect.c
 135          //         msSetInputPort(),  in mstar.c
 136          //
 137          // caller: main() in main.c
 138          //*******************************************************************
 139          void msModeHandler(void)
 140          {
 141   1          if (!DoModeSettingFlag) // while timing change & stable
 142   1              return;
 143   1      
 144   1          printMsg("VGA mode set up");
 145   1              Clr_DoModeSettingFlag();
 146   1      
 147   1              if (!SyncLossState()) // no sync
 148   1                      {
 149   2                      if (!msFindMode()) // search mode index
 150   2                      {
 151   3                          printMsg("mode find fail");
 152   3                              Set_InputTimingChangeFlag(); // search mode faile
 153   3                              return;
 154   3                      }
 155   2      
 156   2                      if (!UnsupportedModeFlag) //supported mode
 157   2                      {
 158   3                              printf("\r\ninput timing index = %d", g_ucSrcModeIndex);
 159   3                              ReadModeSetting(); // restore user's settings from NVRAM for each mode
 160   3                              if (msSetupMode()==FALSE) // setup scaler
 161   3                              {
 162   4                                      Set_InputTimingChangeFlag(); // setup mode failed
 163   4                                  msSetBlueScreen( _ENABLE, FR_BLACK); // setup freerun mode
 164   4                                  printMsg("Failed to setup mode");
 165   4                                  return;
 166   4                          }
 167   3                              if (UnsupportedModeFlag)
 168   3                          {
 169   4                              printMsg("Failed: Out of panel spec");
 170   4                          }
 171   3      
 172   3                      }
 173   2                      else
 174   2                          printMsg("unsupported mode");
 175   2                  }
 176   1      
 177   1              if (SyncLossState() || UnsupportedModeFlag)
C51 COMPILER V8.18   DETECT                                                                09/29/2009 23:58:04 PAGE 4   

 178   1          {
 179   2              msSetBlueScreen( _ENABLE, FR_BLUE); // setup freerun mode
 180   2              Power_TurnOffGreenLed(); // turn off green led
 181   2          }
 182   1              else
 183   1              Power_TurnOnGreenLed(); // turn on green led
 184   1      
 185   1               msSetScaler();
 186   1      
 187   1               Power_TurnOnPanel(); // turn on panel
 188   1               Menu_InitAction(); // initial menu osd state
 189   1      }
 190          
 191          void msPrepareForTimingChange(void)
 192          {
 193   1      
 194   1          msSetInterrupt(INTERRUPT_DISABLE);
 195   1          Clr_ForcePowerSavingFlag();
 196   1          g_ucPowerDownCounter=0;
 197   1      
 198   1          if (PowerSavingFlag)
 199   1              Power_PowerOnSystem();
 200   1          else
 201   1              Power_TurnOffPanel();
 202   1      
 203   1          msSetBlueScreen( _ENABLE, FR_BLUE);
 204   1      
 205   1          Osd_Hide();
 206   1      
 207   1          if (InputTimingStableFlag)
 208   1          {
 209   2              msWriteByte(BK0_E2_SWRST0, OP2R_B|ADCR_B);// Reset Graphic port to re-counter input hfreq & vtotal
 210   2              Delay1ms(3);
 211   2              msWriteByte(BK0_E2_SWRST0, 0);
 212   2              Delay1ms(20);
 213   2          }
 214   1      
 215   1        Clr_InputTimingStableFlag();   // reset input timing stable and wait for timing stable
 216   1        g_ucInputTimingStableCounter=0;
 217   1        SrcFlags&=~(bUnsupportMode|bUserMode|bNativeMode);
 218   1      
 219   1      }
 220          //==========================================================
 221          
 222          BOOL msSyncLossStateDetect(void)
 223          {
 224   1          BYTE fStatus;
 225   1          BOOL result=TRUE;
 226   1      
 227   1          fStatus=msGetInputStatus();
 228   1          if (fStatus&SyncLoss)
 229   1            result=FALSE;
 230   1          else
 231   1            SrcFlags=(SrcFlags&0xF0)|fStatus; // clear others flags, except sync informat (polarity & w/o)
 232   1          return result;
 233   1      }
 234          
 235          BOOL msValidTimingDetect(void)
 236          {
 237   1          BYTE fStatus;
 238   1      
 239   1          fStatus=msGetInputStatus();
C51 COMPILER V8.18   DETECT                                                                09/29/2009 23:58:04 PAGE 5   

 240   1      
 241   1          if (fStatus&SyncLoss) // no sync
 242   1          {
 243   2              SrcFlags=(SrcFlags&0xF0)|fStatus; // clear others flags, except sync informat (polarity & w/o)
 244   2              return TRUE;
 245   2          }
 246   1          else
 247   1          {
 248   2              if (SyncPolarity(SrcFlags)!=SyncPolarity(fStatus)) // Sync polarity changed
 249   2              {
 250   3                  SrcFlags=(SrcFlags&0xF0)|fStatus; // clear others flags, except sync informat (polarity & w/o)
 251   3                  return TRUE;
 252   3                  }
 253   2              else
 254   2              {
 255   3                  WORD tempPeriod;
 256   3      
 257   3                  SrcFlags=(SrcFlags&0xF0)|fStatus; // clear others flags, except sync informat (polarity & w/o)
 258   3                  tempPeriod=msReadWord(BK0_EB_HSPRD_H)&0x1FFF;
 259   3                  //printf("HPeriod %d", tempPeriod);
 260   3                  if (g_ucInputTimingStableCounter==0)
 261   3                      SrcHPeriod=tempPeriod;
 262   3                  if (abs(tempPeriod-SrcHPeriod)>HPeriod_Torlance) // HPeriod changed
 263   3                  {
 264   4                      //printf("\r\nHPeriod %d", tempPeriod);
 265   4                      return TRUE;
 266   4                  }
 267   3      
 268   3                  tempPeriod=msReadWord(BK0_ED_VTOTAL_H)&0x7FF;
 269   3                  //printf("VTotal %d", tempPeriod);
 270   3                  if (g_ucInputTimingStableCounter==0)
 271   3                      SrcVTotal=tempPeriod;
 272   3                  if (abs(tempPeriod-SrcVTotal)>VTotal_Torlance) // vtotal changed
 273   3                  {
 274   4                      //printf("\r\nVTotal %d", tempPeriod);
 275   4                      return TRUE;
 276   4                  }
 277   3              }
 278   2          }
 279   1          return FALSE;
 280   1      }
 281          
 282          BOOL msFindMode(void)
 283          {
 284   1          WORD hFreq, vFreq;
 285   1      
 286   1          #define fStatus      hFreq
 287   1          fStatus=msGetInputStatus();
 288   1          if (SyncPolarity(SrcFlags)!=SyncPolarity(fStatus)) // Sync polarity changed
 289   1              return FALSE;
 290   1          SrcFlags&=0x0F;
 291   1          #undef fStaus
 292   1      
 293   1          g_wHorizontalPeriod = msGetHorizontalPeriod();
 294   1          g_wVerticalTotal = msGetVerticalTotal();
 295   1      
 296   1          if (abs(g_wHorizontalPeriod-SrcHPeriod)>HPeriod_Torlance) // HPeriod changed
 297   1              return FALSE;
 298   1      
 299   1          if (abs(g_wVerticalTotal-SrcVTotal)>VTotal_Torlance) // vtotal changed
 300   1              return FALSE;
 301   1      
C51 COMPILER V8.18   DETECT                                                                09/29/2009 23:58:04 PAGE 6   

 302   1      
 303   1          SrcHPeriod=g_wHorizontalPeriod;
 304   1          SrcVTotal=g_wVerticalTotal;
 305   1          hFreq=HFreq(g_wHorizontalPeriod);//((DWORD)MST_CLOCK_MHZ*10+SrcHPeriod/2)/SrcHPeriod; // round 5

⌨️ 快捷键说明

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