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

📄 dalgco.c

📁 此代码为WCE5.0下显示器的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
  lpHDE = (LPHW_DAL_EXTENSION)hDAL;

  if (lpHDE->aDriverData[ulDriverID].ulFlags & DRIVERDATA_USEGAMEGAMMA)
  {
    MOVEMEMORY((LPVOID)lpaGamma16,
               (LPVOID)lpHDE->aDriverData[ulDriverID].aGameGamma16,
               (sizeof(DEVCLUT16) * 256));
  } else
  {
    MOVEMEMORY((LPVOID)lpaGamma16,
               (LPVOID)lpHDE->aDriverData[ulDriverID].aGamma16,
               (sizeof(DEVCLUT16) * 256));
  }

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetGamma16Correction - Exit"));
}



/******************************Public*Routine******************************\
*
* ULONG DALGetGraphicsControllerInfo()
*
* Returns information on the capabilities of the graphics controller in the
* current mode.
*
*
\**************************************************************************/

ULONG DALGetGraphicsControllerInfo(
HDAL hDAL, 
ULONG ulDriverID)
{
  LPHW_DAL_EXTENSION lpHDE;
  ULONG              ulControllers;
  ULONG              ulCaps;
  BOOL               bFirst;
  ULONG              i;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetGraphicsControllerInfo - 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;
  ulControllers = lpHDE->aControllerMap[ulDriverID];

  ulCaps = 0;
  bFirst = TRUE;

  for (i = 0; i < lpHDE->ulControllersCount; i++)
  {
    if (ulControllers & VECTORFROMINDEX(i))
    {
      // found a controller as specified by the caller
      if (bFirst)
      {
        // DAL wants to return the intersection of all the capabilities of
        // controllers requested by the caller, and hence DAL finds the
        // *first* specified controller and logically 'and' all other caps
        // against the caps of the first controller.

        ulCaps = lpHDE->aControllers[i].lpHWED->aControllerCaps[i];
        bFirst = FALSE;
      } else
      {
        ulCaps &= lpHDE->aControllers[i].lpHWED->aControllerCaps[i];
      }
    }
  }

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetGraphicsControllerInfo - Exit"));
  return(ulCaps);
}



/******************************Public*Routine******************************\
*
* BOOL DALGetDisplayEDID(HDAL    hDAL,
*                        ULONG   ulDriverID,
*                        ULONG   ulDisplayIndex,
*                        LPUCHAR lpucQueryBuffer,
*                        ULONG   ulLength)
*
* Retrieves EDID data from a particular display (given the display index)
* as it is required for NT 5.0 conformance.
*
* PARAMETERS:
*  hDAL             Handle to HW_DAL_EXTENSION structure.
*  ulDriverID       Corresponds to a driver instance relative to this DAL.
*  ulDisplayIndex   Specific index into display vector.
*  lpucQueryBuffer  EDID information will be placed in here.
*  ulLength         Length of EDID data placed in lpucQueryBuffer.
*
*
* Note: DAL does nothing for controllers which are not active
*
\**************************************************************************/

BOOL
DALGetDisplayEDID(
    HDAL hDAL,
    ULONG ulDriverID,
    ULONG ulDisplayIndex,
    LPUCHAR lpucQueryBuffer,
    ULONG ulLength
    )
{
  LPHW_DAL_EXTENSION lpHDE;
  LPDEVGDO           lpDisplay;
  ULONG              ulDDCManufacturerName; // Save the old value for comparison
  ULONG              ulDDCProductCode;      // Save the old value for comparison
  DDC_INFO           sDDCInfo;  
  BOOL               bFakeEDID;
  BOOL               bReturn = FALSE;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetDisplayEDID - 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;

  // make sure the index is not greater than max displays
  DALASSERT((ulDisplayIndex < lpHDE->ulDisplaysCount), "ulDisplayIndex is invalid");

  // Check the EDID data for the display that corresponds to the index
  // passed.
  lpDisplay = (LPDEVGDO) &lpHDE->aDisplays[ulDisplayIndex];

  if (lpHDE->ulFlags & HDAL_INITIALIZING)
  {
    
    // Since initialization is still not complete,
    // the cached EDID data is still fresh and could be
    // used to report EDID capability.
    if (lpDisplay->ulFlags & (GDO_EDID | GDO_EDID_REPORT_TO_OS_ONLY))
    {
      bReturn = TRUE;
    }
    else
    {
      bFakeEDID = bGetFakeEDID(lpHDE, ulDisplayIndex);

      if(bFakeEDID)
      {
        bReturn = TRUE;
      }
    }
  }
  else
  {
    // Atleast a DALSetmode call has been made since boot.
    // If DALGetDisplayEDID function is called it would be
    // better to get fresh EDID information rather than
    // reporting the cached data as before. Device may
    // have changed since last time EDID was querried.

    // Save the original manufacturer name and product code
    ulDDCManufacturerName = lpDisplay->sDDCInfo.ulDDCManufacturerName; 
    ulDDCProductCode = lpDisplay->sDDCInfo.ulDDCProductCode; 

    if (bGetEdidData(lpHDE, lpDisplay, (LPEDID_BUFFER)&lpDisplay->sEDID))
    {
      // Find the new Manufacturer ID, product ID, Display Name & Monitor Range Limit
      // The function parces some known formats of EDID only. For others it will
      // fail the call to make DAL treat it as non DDC device. EPR 39053, 39045 & 38944
      if(bGetDDCInfo((LPEDID_BUFFER)&lpDisplay->sEDID, (LPDDC_INFO)&sDDCInfo))
      {
        // Display returned a valid EDID structure, so flag the DAL to use the
        // EDID structure when testing if a mode is supported.

        if (lpDisplay->lpHWED->ulDisplayCaps & GDO_CAPS_REPORT_ONLY_EDID)
          lpDisplay->ulFlags |= GDO_EDID_REPORT_TO_OS_ONLY;
        else
          lpDisplay->ulFlags |= GDO_EDID;

        if ((ulDDCManufacturerName != sDDCInfo.ulDDCManufacturerName) ||
            (ulDDCProductCode != sDDCInfo.ulDDCProductCode))
        {
          // Product code or the manufacturer name has changed since last EDID query.
          // Set a flag to request update of the mode table and update lpDisplay->sDDCInfo.
          if (lpDisplay->ulFlags & GDO_EDID)
          {
            // We only need to update the mode table if we can use this EDID info for that
            lpHDE->ulFlags |= HDAL_UPDATEDISPLAYSMODESUPPORTED;
          }
          MOVEMEMORY((LPVOID)&lpDisplay->sDDCInfo, (LPVOID)&sDDCInfo, sizeof(DDC_INFO));
        }

        bReturn = TRUE;

      }
      else
      {
        // EDID Format reported can not be used by DAL.
        lpDisplay->ulFlags &= ~(GDO_EDID | GDO_EDID_REPORT_TO_OS_ONLY);
        lpDisplay->sDDCInfo.ulDDCManufacturerName = 0;
        lpDisplay->sDDCInfo.ulDDCProductCode = 0;

        // This will take care of the case when last time the display had reported EDID data 
        // but this time around it did not.
        if ((ulDDCManufacturerName != lpDisplay->sDDCInfo.ulDDCManufacturerName) ||
            (ulDDCProductCode != lpDisplay->sDDCInfo.ulDDCProductCode))
        {
          // Product code or the manufacturer name has changed since last EDID query.
          // Set a flag to request update of the mode table.
          if (!(lpDisplay->lpHWED->ulDisplayCaps & GDO_CAPS_REPORT_ONLY_EDID))
          {
            // We only need to update the mode table if we could use EDID info for that
            lpHDE->ulFlags |= HDAL_UPDATEDISPLAYSMODESUPPORTED;
          }
        }
      }
      
    } 
    else
    {
      lpDisplay->ulFlags &= ~(GDO_EDID | GDO_EDID_REPORT_TO_OS_ONLY);
      lpDisplay->sDDCInfo.ulDDCManufacturerName = 0;
      lpDisplay->sDDCInfo.ulDDCProductCode = 0;

      // This will take care of the case when last time the display had reported EDID data 
      // but this time around it did not.
      if ((ulDDCManufacturerName != lpDisplay->sDDCInfo.ulDDCManufacturerName) ||
          (ulDDCProductCode != lpDisplay->sDDCInfo.ulDDCProductCode))
      {
        // Product code or the manufacturer name has changed since last EDID query.
        // Set a flag to request update of the mode table.
        if (!(lpDisplay->lpHWED->ulDisplayCaps & GDO_CAPS_REPORT_ONLY_EDID))
        {
          // We only need to update the mode table if we could use EDID info for that
          lpHDE->ulFlags |= HDAL_UPDATEDISPLAYSMODESUPPORTED;
        }
      }

      // This display does not support EDID check if it supports fake EDID.
      bFakeEDID = bGetFakeEDID(lpHDE, ulDisplayIndex);

      if(bFakeEDID)
      {
        bReturn = TRUE;
      }
    }
  }
  
  //Based on Dalrule, not return Edid to OS
  if(DALRULE3_NOEDIDTOOS & lpHDE->ulDalRule3)
  {
    bReturn = FALSE;
  }

  if (bReturn)
  {
    // copy EDID
    MOVEMEMORY(lpucQueryBuffer,
               &lpDisplay->sEDID.aucEdidDataBuffer[0],
               ulLength);
  }

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetDisplayEDID - Exit"));
  return bReturn;
}

/******************************Public*Routine******************************\
*
* VOID DALSetDisplayDPMS(HDAL  hDAL,
*                        ULONG ulDriverID,
*                        ULONG ulState,
*                        ULONG ulDisplayIndex)
*
* Programs the display power management state to a single display --
* this was developed to meet NT 5.0 requirements.
*
* PARAMETERS:
*  hDAL             Handle to HW_DAL_EXTENSION structure.
*  ulDriverID       Corresponds to a driver instance relative to this DAL.
*  ulState          The power state to be set:
*                       typedef enum _VIDEO_POWER_STATE {
*                           VideoPowerUnspecified = 0,
*                           VideoPowerOn = 1,
*                           VideoPowerStandBy,
*                           VideoPowerSuspend,
*                           VideoPowerOff,
*                           VideoPowerHibernate,
*                           VideoPowerMaximum
*                       } VIDEO_POWER_STATE, *PVIDEO_POWER_STATE;
*  ulDisplayIndex   Specific index into display vector.
*
* Note: DAL does nothing for controllers which are not active
*
\**************************************************************************/

VOID
DALSetDisplayDPMS(
    HDAL hDAL,
    ULONG ulDriverID,
    ULONG ulState,
    ULONG ulDisplayIndex
    )
{
  LPHW_DAL_EXTENSION lpHDE;
  ULONG              i;
  ULONG            ulControllersOwned;
  LPDEVGCO           lpController;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetDisplayDPMS - 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;

  ulControllersOwned = lpHDE->aControllerMap[ulDriverID];

  // loop through every controller until matching DisplayIndex
  // is found (Note: the DisplayIndex is unique to each controller...
  // will not be found in two or more controllers).
  for (i = 0; i < lpHDE->ulControllersCount; i++)
  {
    if (ulControllersOwned & VECTORFROMINDEX(i))
    {

      lpController = (LPDEVGCO)&lpHDE->aControllers[i];
      if (lpController->ulFlags & GCO_ACTIVE)
      {
        // only program the DPMS state if the controller is active, the DPMS
        // state should be POWERSTATE_OFF if the controller is not active

        if (VECTORFROMINDEX(ulDisplayIndex) & lpController->ulDisplays)
        {
          // found a display on the controller, so the
          // DPMS state is applied to that display

          vSetDisplayPowerState(lpHDE,
                                (LPDEVGDO) &lpHDE->aDisplays[ulDisplayIndex],
                                ulState);
          break;
        }
      }
    }
  }

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetDisplayDPMS - Exit"));
}


/******************************Public*Routine******************************\
*
* VOID DALSetDPMS(HDAL hDAL, ULONG ulState)
*
* programs the display power management state to the entire display
* subsystem in an atomic operation
*
* Note: DAL does nothing for controllers which are not active
*
\**************************************************************************/

VOID DALSetDPMS(HDAL hDAL, ULONG ulState)
{
  LPHW_DAL_EXTENSION lpHDE;
  ULONG              i, j;
  LPDEVGCO           lpController;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetDPMS - 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;

  for (i = 0; i < lpHDE->ulControllersCount; i++)
  {
    lpController = (LPDEVGCO)&lpHDE->aControllers[i];
    if (lpController->ulFlags & GCO_ACTIVE)
    {
      // only program the DPMS state if the controller is active, the DPMS
      // state should be POWERSTATE_OFF if the controller is not active

      for (j = 0; j < lpHDE->ulDisplaysCount; j++)
      {
        // loop through the displays to idetify which are connected
        // to the identified controller

        if (VECTORFROMINDEX(j) & lpController->ulDisplays)
        {
          // found a display on the controller, so the

⌨️ 快捷键说明

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