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

📄 dalmode.c

📁 此代码为WCE5.0下显示器的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/****************************************************************************\
*
*  Module Name    dalmode.c
*  Project        ATI Display Abstraction Layer
*  Device         RageProPNP / Rage128 (Win95/98 & WinNT 4.0/5.0)
*
*  Description    source file for Display Abstraction Layer 0.84
*                 contains functions related to getting and setting modes
*
*  Copyright (c) 1998-2002 ATI Technologies Inc. (unpublished)
*
*  All rights reserved.  This notice is intended as a precaution against
*  inadvertent publication and does not imply publication or any waiver
*  of confidentiality.  The year included in the foregoing notice is the
*  year of creation of the work.
*
*  Refer to DAL Developers Guide & Programming Reference Rev 0.84 for usage
*
\****************************************************************************/

#include "dal.h"
#include "daldef.h"
#include "dalddc.h"
#include "atimcode.h"

/******************************Public*Routine******************************\
*
* BOOL DALGetDefaultMode()
*
* Returns the default mode to the caller.  Function queries the registry
* to determine if an OEM specified default mode exists, and if not, the
* mode defaults to 640x480 8bpp, 60hz.
*
*
\**************************************************************************/

BOOL DALGetDefaultMode(
HDAL hDAL, 
ULONG ulDriverID,
LPDEVMODE_INFO lpMI)
{
  LPHW_DAL_EXTENSION lpHDE;
  BOOL               bRet;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetDefaultMode - Entry"));
  DALASSERT((hDAL != NULL), "DAL handle 'hDAL' is NULL!");

  // grab the structure for the DAL out of the DDL's handle to it
  lpHDE = (LPHW_DAL_EXTENSION)hDAL;
  bRet = TRUE;
  
  lpMI->ulModeFlags = 0;
  lpMI->ulPelsWidth = lpHDE->aDriverData[ulDriverID].sDefaultMode.ulPelsWidth;
  lpMI->ulPelsHeight = lpHDE->aDriverData[ulDriverID].sDefaultMode.ulPelsHeight;
  lpMI->ulBitsPerPixel = lpHDE->aDriverData[ulDriverID].sDefaultMode.ulBitsPerPixel;
  lpMI->ulDisplayFrequency = lpHDE->aDriverData[ulDriverID].sDefaultMode.ulDisplayFrequency;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetDefaultMode - Exit"));
  return(bRet);
}



/******************************Public*Routine******************************\
*
* ULONG DALGetNumberModesAvailable
*
* Returns the number of modes available for the adapter, so the caller can
* create a buffer of sufficient size to receive the mode list.
*
* Note:
*
\**************************************************************************/

ULONG DALGetNumberModesAvailable(
HDAL hDAL,
ULONG ulDriverID)
{
  LPHW_DAL_EXTENSION lpHDE;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetNumberModesAvailable - Entry"));
  DALASSERT((hDAL != NULL), "DAL handle 'hDAL' is NULL!");

  // grab the structure for the DAL out of the DDL's handle to it
  lpHDE = (LPHW_DAL_EXTENSION)hDAL;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetNumberModesAvailable - Exit"));
  return(lpHDE->ulModeCount);
}



/******************************Private*Routine*****************************\
*
* BOOL bFindCloneResolution()
*
\**************************************************************************/
BOOL bFindCloneResolution(LPHW_DAL_EXTENSION lpHDE, LPDEVMODE_INFO lpMode, LPULONG lpPanType)
{
  ULONG        i;

  // with current implementation of "pseudo" extended desktop,
  // the bigger dimension is always the extended side...
  if (lpMode->ulPelsHeight > lpMode->ulPelsWidth)
  {
    lpMode->ulPelsHeight >>= 1; // divide by 2
    *lpPanType = PSEUDO_LARGE_DESKTOP_VERTICAL;
  }
  else
  {
    lpMode->ulPelsWidth >>= 1; // divide by 2
    *lpPanType = PSEUDO_LARGE_DESKTOP_HORISONTAL;
  }

  if (bSearchModeTable(lpHDE, lpMode, &i))
  {
    return TRUE;
  }

  return FALSE;
}


/******************************Public*Routine******************************\
*
* DALGetModesAvailable
*
* Enumerates the list of modes available in a buffer allocated by the caller
*
* Note:
*
\**************************************************************************/

ULONG DALGetModesAvailable(
HDAL hDAL, 
ULONG ulDriverID,
LPDEVMODE_INFO lpaMI, 
ULONG ulModes)
{
  LPHW_DAL_EXTENSION lpHDE;
  ULONG              ulModesReturned;
  ULONG              ulControllers;
  ULONG              i, j;
  ULONG              ulDisplayActiveMask;
  ULONG              ulNumOfConnectedDisplays;
  LPDAL_MODEINFO     lpMode;
  LPDEVGDO           lpDisplay;
  BOOL               bModeSupported;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetModesAvailable - Entry"));
  DALASSERT((hDAL != NULL), "DAL handle 'hDAL' is NULL!");

  // grab the structure for the DAL out of the DDL's handle to it
  lpHDE = (LPHW_DAL_EXTENSION)hDAL;
  ulModesReturned = 0;

  if (ulModes < lpHDE->ulModeCount)
  {
    // number of DEVMODE_INFO structures passed in by the caller has
    // insufficient size to return all the modes, so the DAL does not return
    // any by returning with no modes enumerated.

    goto DALGetModesAvailable_Return;
  }

  // loop through the displays and find the CRT display to determine if the
  // MonitorInfo for this display has changed.

  for (i = 0; i < lpHDE->ulDisplaysCount; i++)
  {
    lpDisplay = (LPDEVGDO) &lpHDE->aDisplays[i];

    if (lpDisplay->lpHWED->ulDisplayType & HW_DISPLAY_TYPE_CRT)
    {
      break;
    }
  }

  // On 9X the user could at any time change what MonitorInfo is used 
  // for the monitor, if it is Plug and Play or not .... and so on.  To
  // ensure the DAL picks up the latest user changes, on every query of
  // the mode list, DAL goes out and checks to see if the mode list needs
  // be rebuild because the MonitorInfo changed.  If so, all monitor
  // properties are refreshed, and a new mode table is created [GG] 02/12/98

  if (bDisplayMonitorInfoModeRestrictions(lpHDE, lpDisplay))
  {
    // some property of the Operating Systems MonitorInfo structure has
    // changed, so the DAL should re-build the mode list.

    vAddDisplaysToModeTable(lpHDE);
  }

  ulControllers = lpHDE->aControllerMap[ulDriverID];

  // let return the modes that connected display devices support only
  ulDisplayActiveMask      = 0;
  ulNumOfConnectedDisplays = 0;
  for (i = 0; i < lpHDE->ulDisplaysCount; i++)
  {
    lpDisplay = (LPDEVGDO) &lpHDE->aDisplays[i];

    if (GDO_ACTIVE & lpDisplay->ulFlags)
    {
      ulDisplayActiveMask |= VECTORFROMINDEX(i);
    }

    if (GDO_PHYSICALLY_CONNECTED & lpDisplay->ulFlags)
    {
      ulNumOfConnectedDisplays++;
    }
  }

  // the ulDisplayActiveMask can be empty.
  if (0 == ulDisplayActiveMask)
  {
    if (lpHDE->ulConnectedDisplays)
    {
      ulDisplayActiveMask = lpHDE->ulConnectedDisplays;
    }
    else
    {
      ulDisplayActiveMask = VECTORFROMINDEX(ulGetDefaultWhenNoDisplayConnected(lpHDE, 0));
    }
  }

  // loop through the list of modes stored by the DAL and copy them into the
  // buffer allocated by the functions caller

  for (i = lpHDE->ulModeCount; i != 0; i--)
  {
    // since the DAL stores the modes in decreasing size, but WinNT looks for 
    // the default mode as the first mode, the modes should be enumerated in
    // order from smaller to bigger, hence DAL walks the mode structure
    // backwards!.

    lpMode = (LPDAL_MODEINFO) &lpHDE->lpaModes[i - 1];

    if ((lpMode->ulControllers & ulControllers) != 0)
    {
      // at least one of the contollers attached to this driver support the 
      // mode.

      bModeSupported = FALSE;

      for (j = 0; j < lpHDE->ulControllersCount; j++)
      {
        if (  (DALRULE1_DISPLAYSRESTRICTMODES       & lpHDE->ulDalRule1)
            ||(DALRULE2_DISPLAYSRESTRICTMODESLOWEST & lpHDE->ulDalRule2)
            ||(DALRULE3_ENUMDISPLAYSRESTRICTMODES   & lpHDE->ulDalRule3))
        {
          // mode is reported only if one of the active displays for this
          // controller actually supports the mode.  This prevents a 
          // virtual desktop on modes where none of the displays does not
          // support the mode. [GG] 29/11/98

          if (  (DEVMODEFLAG_LARGEDESKTOP & lpMode->sDevModeInfo.ulModeFlags)
              &&(DALRULE2_DISPLAYSRESTRICTMODESLARGEDESKTOP & lpHDE->ulDalRule2))
          {
            if (ulNumOfConnectedDisplays > 1)
            {
              DEVMODE_INFO sMode;
              ULONG        mT;
              ULONG        ulPanType;

              MOVEMEMORY(&sMode, &(lpMode->sDevModeInfo), sizeof(DEVMODE_INFO));

              // with current implementation of "pseudo" extended desktop,
              // the bigger dimension is always the extended side...
              if (bFindCloneResolution(lpHDE, (LPDEVMODE_INFO)&sMode, &ulPanType))
              {
                if (bSearchModeTable(lpHDE, (LPDEVMODE_INFO)&sMode, &mT))
                {
                  if ((lpHDE->lpaModes[mT].ulControllers & ulControllers) != 0)
                  {
                    // at least one of the contollers attached to this driver
                    // support the mode.

                    if (DALRULE2_DISPLAYSRESTRICTMODESLOWEST & lpHDE->ulDalRule2)
                    {
                      if ((ulDisplayActiveMask & lpHDE->lpaModes[mT].aulSupportedDisplays[j])
                                                                       == ulDisplayActiveMask)
                      {
                        bModeSupported = TRUE;
                      }
                    }
                    else
                    {
                      if ((ulDisplayActiveMask & lpHDE->lpaModes[mT].aulSupportedDisplays[j]) != 0)
                      {
                        bModeSupported = TRUE;
                      }
                    }
                  }
                }
              }
            }
          }
          else
          {
            if (DALRULE2_DISPLAYSRESTRICTMODESLOWEST & lpHDE->ulDalRule2)
            {
              if ((ulDisplayActiveMask & lpMode->aulSupportedDisplays[j]) == ulDisplayActiveMask)
              {
                bModeSupported = TRUE;
              }
            }
            else if (DALRULE3_ENUMDISPLAYSRESTRICTMODES & lpHDE->ulDalRule3)
            {
              if(lpMode->aulSupportedDisplays[j] != 0)
                bModeSupported = TRUE;

            }else
            {
              if ((ulDisplayActiveMask & lpMode->aulSupportedDisplays[j]) != 0) 
              {
                // at least one display on this controller supports this mode, so
                // DAL can report the mode as supported.

                bModeSupported = TRUE;
              }
            }
          }
        }
        else
        {
          if (DEVMODEFLAG_LARGEDESKTOP & lpMode->sDevModeInfo.ulModeFlags)
          {
            if (  (DALRULE2_DISPLAYSRESTRICTMODESLARGEDESKTOP & lpHDE->ulDalRule2)
                &&(ulNumOfConnectedDisplays > 1))
            {
              bModeSupported = TRUE;
            }
          }else if (DEVMODEFLAG_VIRTUALDESKTOP & lpMode->sDevModeInfo.ulModeFlags)
          {
            bModeSupported = TRUE;
          }
          else
          {
             if ((DALRULE3_DONOTREPORTCUSTOMREFRESHRATE & lpHDE->ulDalRule3)&&
                 (DEVMODEFLAG_CUSTOMREFRESHRATE & lpMode->sDevModeInfo.ulModeFlags)&&
                 (!(DEVMODEFLAG_CVMODE & lpMode->sDevModeInfo.ulModeFlags))) 
             {
               bModeSupported = FALSE; //not report to OS. For CV mode, we report to OS at this time.
             }
             else
             {
            // we will support the mode, independent of which displays are attached,
            // as long as a controller supports it.

            bModeSupported = TRUE;
             }
          }
        }
      }

⌨️ 快捷键说明

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