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

📄 dalgdo.c

📁 此代码为WCE5.0下显示器的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
                // active devices and the dsplay to be detected.
                ulTempDisplays = (ulSavedDisplays | VECTORFROMINDEX(lpDisplay->ulDisplay));

                // Check if TV is invloved in the temporary mode setting to
                // detect a display that has to be activated before detection.
                // If so don't invlolve TV in that mode setting. OEMs don't like
                // to see any flikering let alone the extra flikering that is associated 
                // with doing two mode sets with TV while perfoming the CRT detection.              
                for (j = 0; j < lpHDE->ulDisplaysCount; j++)
                {
                  lpActiveDisplay = (LPDEVGDO) &lpHDE->aDisplays[j];

                  if (ulSavedDisplays & VECTORFROMINDEX(j))
                  {
                    if (lpActiveDisplay->lpHWED->ulDisplayType & HW_DISPLAY_TYPE_TV)
                    {
                      // TV is currently active on this controller so just activate
                      // the device that has to be detected.
                      ulTempDisplays = VECTORFROMINDEX(lpDisplay->ulDisplay);
                    }
                  }
                }

                vControllerSetMode(lpHDE,
                                   (LPDEVMODE_INFO)& lpActiveController->sModeInfo,
                                   lpActiveController,
                                   ulTempDisplays,
                                   sQueryGCO.ulDisplayOffset,
                                   ulPitch);

                // display is now active, so perform the detection.

                if (bIsDisplayDDCPhysicallyConnected(lpHDE, lpDisplay))
                {
                  lpDisplay->ulFlags |= GDO_PHYSICALLY_CONNECTED;
                } else
                {
                  lpDisplay->ulFlags &= ~GDO_PHYSICALLY_CONNECTED;
                }

                // We had set a mode for detection purpose so since we
                // are done with detection reset bandwidth values.
                // Since the controller is already active we MUST first
                // call vControllerResetMode or it will lead to bandwidth 
                // leak problems.
                vControllerResetMode(lpHDE, lpActiveController);

                // Set the mode that was previously set on the controller 
                vControllerSetMode(lpHDE,
                                   (LPDEVMODE_INFO)& lpActiveController->sModeInfo,
                                   lpActiveController,
                                   ulSavedDisplays,
                                   sQueryGCO.ulDisplayOffset,
                                   ulPitch);

                // the display was activated to perform the physical display
                // detection, so restore the display to it's off state

                vSetDisplayOff(lpHDE, lpDisplay);

                break;
              }
            }

            // if DAL can't map the display to a controller and detect if it is
            // connected, DAL just gives up

          }
        }
      }
    } else
    {
      // display can determine if it is physically connected without being
      // activated by DAL into a mode, hence let the display do the work.
      // TV OUT devices have this property.

      if (bIsDisplayDDCPhysicallyConnected(lpHDE, lpDisplay))
      {
        lpDisplay->ulFlags |= GDO_PHYSICALLY_CONNECTED;
      } else
      {
        lpDisplay->ulFlags &= ~GDO_PHYSICALLY_CONNECTED;
      }
    }
  }
  
  if (lpHDE->ulDalRule3 & DALRULE3_DONOTPERFORMDISPLAYDETECTION)
  {
    // Report as Display connected
    lpDisplay->ulFlags |= GDO_PHYSICALLY_CONNECTED;

  } 
  if (lpDisplay->lpHWED->bEnabledAtBoot)
  {
    // we need to clear the active flag here because it may have been set
    // exclusively because the display was enabled at boot time.  If it should
    // be set because of other reasons, DAL will take care of it later.

    lpDisplay->ulFlags &= ~GDO_ACTIVE;
    lpDisplay->lpHWED->bEnabledAtBoot = FALSE;

  }
}

/****************************Public*Routine*******************************\
*
* BOOL bIsPositionAdjustmentAllowed
*
* Return TRUE if can allow timing changes to do size adjustmnets,
* FALSE otherwise.
*
\**************************************************************************/

BOOL bIsPositionAdjustmentAllowed(LPHW_DAL_EXTENSION lpHDE, LPDEVGDO lpDisplay)
{
    BOOL bRet = FALSE;

    if (lpDisplay->ulController < lpHDE->ulControllersCount)
    {
      bRet = TRUE;
    
      if( // This display is not on a controller that has CRT and LCD mapped together 
          // while the controller itself does not support Shadow Register set.
          // So it is safe to apply the position adjustments.
          //
          // ... and the expansion is not set. EPR# 31625 [PS]
          //
          (lpHDE->aControllers[lpDisplay->ulController].ulDisplayTypes & HW_DISPLAY_TYPES_DIGITAL_MASK) && 
          (lpHDE->aControllers[lpDisplay->ulController].ulDisplayTypes & HW_DISPLAY_TYPES_CRT_MASK) && 
          !((lpHDE->aControllers[lpDisplay->ulController].lpHWED->aControllerCaps[lpDisplay->ulController] &
             DAL_CONTROLLER_CAPS_SHADOW_REGISTER_SET) && 
            (lpHDE->aControllers[lpDisplay->ulController].ulFlags & GCO_EXPANSION))
        )  
      {
        bRet = FALSE;
      }    

      if( // One last check: ban CRT adjustments when TV is mapped if there is
          // the DAL rule.
          (DALRULE2_DISABLECRTPOSADJUSTIFTVACTIVE & lpHDE->ulDalRule2) &&
          (lpHDE->aControllers[lpDisplay->ulController].ulDisplayTypes & HW_DISPLAY_TYPE_TV) && 
          (lpDisplay->lpHWED->ulDisplayType & HW_DISPLAY_TYPES_CRT_MASK)
        )
      {
        bRet = FALSE;     
      }
    }

    return bRet;

} // bIsPositionAdjustmentAllowed()


/****************************Public*Routine*******************************\
*
* BOOL bIsSizeAdjustmentAllowed
*
* Return TRUE if can allow timing changes to do size adjustmnets,
* FALSE otherwise.
*
\**************************************************************************/

BOOL bIsSizeAdjustmentAllowed(LPHW_DAL_EXTENSION lpHDE, LPDEVGDO lpDisplay)
{
  BOOL bRet = FALSE;

  if (lpDisplay->ulController < lpHDE->ulControllersCount)
  {
    if (!(lpHDE->aControllers[lpDisplay->ulController].ulDisplayTypes & HW_DISPLAY_TYPES_DIGITAL_MASK) && 
        !((lpHDE->aControllers[lpDisplay->ulController].ulDisplayTypes & HW_DISPLAY_TYPE_TV) &&
          (lpDisplay->lpHWED->ulDisplayType & HW_DISPLAY_TYPES_CRT_MASK)))
    {
      bRet = TRUE;
    }
  }

  return bRet;

} // bIsSizeAdjustmentAllowed()

/****************************Private*Routine*******************************\
*
* ULONG ulSetDisplayAdjustments
*
* Programs out the adjustments stored for the display into the display
* itself.
*
\**************************************************************************/

ULONG ulSetDisplayAdjustments(
LPHW_DAL_EXTENSION lpHDE,
LPDEVGDO lpDisplay,
LPLONG lplAdjust)
{
  LPHW_ADJUSTMENT lpAdjustment;
  LPLONG          lplValue;
  ULONG           ulIndex;
  ULONG           ulHook;

  ULONG           ulModifiedAdjustments = 0;//Bitvector,flags the adjustments which are modified  
  
  BOOL            bAdjusted = FALSE;
  ULONG           ulReturn  = DAL_ADJUSTMENT_OK;

  if (lpDisplay->lpHWED->ulFunctionHooks2 & GDO_HOOK2_PREADJUSTMENTCHANGE)
  {
    DALASSERT(lpDisplay->lpHWED->pfnPreAdjustmentChange != NULL, 
            "ulSetDisplayAdjustments - pfnPreAdjustmentChange is NULL!");

    (*lpDisplay->lpHWED->pfnPreAdjustmentChange)(lpDisplay->hGDO); 
  }
  
  lplValue = lplAdjust;

  for (ulIndex = 0, ulHook = 1;
       ulHook < GDO_ENDOF_ADJUSTMENTS;
       ulIndex ++, ulHook = (ulHook << 1), lplValue++)
  {  
    
    lpAdjustment = (LPHW_ADJUSTMENT) &lpDisplay->aAdjustment[ulIndex];

    if ((!(ulHook & GDO_HOOK_VIDEO_STANDARD_ADJUSTMENT)) &&
          (!(ulHook & GDO_HOOK_VIDEO_SIGNAL_STANDARD_ADJUSTMENT)))
    {

      if (*lplValue > lpAdjustment->lMax)
      {
        // adjustment is outside the valid range of adjustments for the
        // display
        *lplValue = lpAdjustment->lMax;
      }
      if (*lplValue < lpAdjustment->lMin)
      {
        // adjustment is outside the valid range of adjustments for the
        // display itself.
        *lplValue = lpAdjustment->lMin;
      }
      // ensure the adjustment is aligned on a step boundary

      if (lpAdjustment->lStep != 0)
      {
        *lplValue = ((*lplValue / lpAdjustment->lStep) *
                      lpAdjustment->lStep);
      }
      else
      {
        *lplValue = 0;
      }
    }

    if (lpDisplay->alAdjustments[ulIndex] != *lplValue)// so existing adjustment != coming adjustment
    {
      ulModifiedAdjustments |= ulHook;//signals the modified adjustments
      lpDisplay->alAdjustments[ulIndex] = *lplValue; //updates the display existent adjustments with the coming adjustments
    }
  }

  for (ulIndex = 0, ulHook = 1;
       ulHook < GDO_ENDOF_ADJUSTMENTS;
       ulIndex ++, ulHook = (ulHook << 1), lplAdjust++)
  { 
    // loop through each possible adjustment for the display, and
    // program out the adjustment state

    if ((lpDisplay->lpHWED->ulFunctionHooks & ulHook) &&
        (( ulModifiedAdjustments & ulHook)  ||  //modified adjustment , don't set otherwise
         (lpDisplay->ulFlags & GDO_SETADJUSTMENTS)))
    {
      // an adjustment is being changed, hence DAL needs flag the
      // adjutsment structure as dirty so it can be written out to the
      // registry.

      bAdjusted           = TRUE;
      lpDisplay->ulFlags |= GDO_SAVEDATA;

      // adjustment was hooked by the display, and the value of the
      // adjustment has changed, program the adjustment out to the display.

      lplValue = (LPLONG) &lpDisplay->alAdjustments[ulIndex];

      // save the value of the new adjustment into the DAL structure before
      // writing it out to the display;  code ensures the adjustment is
      // within the valid boundaries of the display itself.

      *lplValue = *lplAdjust;

      switch(ulHook)
      {
        case GDO_HOOK_BRIGHTNESS_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnSetBrightnessAdjustment)
                       (lpDisplay->hGDO, *lplValue);
          break;

        case GDO_HOOK_CHROMA_FLICKER_REMOVAL_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnSetChromaFlickerAdjustment)
                       (lpDisplay->hGDO, *lplValue);
          break;

        case GDO_HOOK_COLOR_CONTROL_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnSetColorControlAdjustment)
                     (lpDisplay->hGDO, *lplValue);
          break;

        case GDO_HOOK_CONTRAST_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnSetContrastAdjustment)
                     (lpDisplay->hGDO, *lplValue);
          break;
        case GDO_HOOK_VERTICAL_POSITION_ADJUSTMENT:

          // since this adjustment has changed, flag the display as ,
          // having dirty adjustment values which need be written to the
          // the registry via CWDDE flush calls.

          // This is one of the per mode adjustments so flag it as
          // dirty so that it is saved in the registry on a per mode
          // basis. This will be restored when the user sets this 
          // mode again
          lpDisplay->ulFlags |= GDO_SAVEPERMODEADJUSTMENTS;

          if (bIsPositionAdjustmentAllowed(lpHDE, lpDisplay))
          {
            // If CRT and LCD on one controller with centre mode, ban the adjustment
            // This display is not on a controller that has CRT and LCD mapped together 
            // while the controller itself does not support Shadow Register set.
            // So it is safe to apply the position adjustments.
            (*lpDisplay->lpHWED->pfnSetDisplayPositionAdjustment)
                         (lpDisplay->hGDO, *lplValue, *(lplValue+1));
          }

          break;

        case GDO_HOOK_HORIZONTAL_POSITION_ADJUSTMENT:

          // since this adjustment has changed, flag the display as ,
          // having dirty adjustment values which need be written to the
          // the registry via CWDDE flush calls.

          // This is one of the per mode adjustments so flag it as
          // dirty so that it is saved in the registry on a per mode
          // basis. This will be restored when the user sets this 
          // mode again
          lpDisplay->ulFlags |= GDO_SAVEPERMODEADJUSTMENTS;
         
          if (bIsPositionAdjustmentAllowed(lpHDE, lpDisplay))
          {
            // If CRT and LCD on one controller with centre mode, ban the adjustment
            // This display is not on a controller that has CRT and LCD mapped together 
            // while the controller itself does not support Shadow Register set.
            // So it is safe to apply the position adjustments.
             (*lpDisplay->lpHWED->pfnSetDisplayPositionAdjustment)
                        (lpDisplay->hGDO, *(lplValue-1), *lplValue);
          }

          break;

        case GDO_HOOK_VERTICAL_SIZE_ADJUSTMENT:
        case GDO_HOOK_HORIZONTAL_SIZE_ADJUSTMENT:
          {
            // since this adjustment has changed, flag the display as ,
            // having dirty adjustment values which need be written to the
            // the registry via CWDDE flush calls.

            // This is one of the per mode adjustments so flag it as
            // dirty so that it is saved in the registry on a per mode
            // basis. This will be restored when the user sets this 
            // mode again
            lpDisplay->ulFlags |= GDO_SAVEPERMODEADJUSTMENTS;

            if(bIsSizeAdjustmentAllowed(lpHDE, lpDisplay))
            {
             
              if (ulHook == GDO_HOOK_HORIZONTAL_SIZE_ADJUSTMENT)
              {
                (*lpDisplay->lpHWED->pfnSetDisplaySizeAdjustment)
                              (lpDisplay->hGDO, *(lplValue-1), *lplValue);
              } else
              {
                (*lpDisplay->lpHWED->pfnSetDisplaySizeAdjustment)
                            (lpDisplay->hGDO, *lplValue, *(lplValue+1));
              }

⌨️ 快捷键说明

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