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

📄 dalmode.c

📁 此代码为WCE5.0下显示器的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
      if(DALMODEFLAG_OSVIEWRESTRICTED & lpMode->ulFlags)
      {
        bModeSupported = FALSE;
      }
      // reminder here Win16 code (namely only Win9X) requires pointers to be
      // FAR * to properly address segment boundaries in different applications

      if (  (bModeSupported)
          &&(DALRULE2_DYNAMICBANDWIDTHMODEENUMERATION & lpHDE->ulDalRule2))
      {
        // [gphan 01/06/28] assumption here is that the single monitor mode
        // is validated when the list is enumerated from GCO.  DAL only needs
        // to validate clone mode here when both controllers are active on
        // the same driver
        if (   (1 == lpHDE->ulDrivers)
            && (1 < lpHDE->ulControllersCount)
            && (GCO_ACTIVE & lpHDE->aControllers[DAL_PRIMARY_CONTROLLER].ulFlags)
            && (GCO_ACTIVE & lpHDE->aControllers[DAL_SECONDARY_CONTROLLER].ulFlags))
        {
          DEVMODE_INFO sMode[MAX_NUMBER_CONTROLLERS];

          MOVEMEMORY(&sMode[DAL_PRIMARY_CONTROLLER  ], &lpMode->sDevModeInfo, sizeof(DEVMODE_INFO));
          MOVEMEMORY(&sMode[DAL_SECONDARY_CONTROLLER], &lpMode->sDevModeInfo, sizeof(DEVMODE_INFO));

          bModeSupported = bValidateBandwidth(lpHDE,
                                              (LPDEVMODE_INFO)sMode,
                                              (LPULONG)&ulDisplayActiveMask);
        }
      }

      if((bModeSupported) &&
         (DALRULE3_BANDWIDTHMODEENUMERATION & lpHDE->ulDalRule3))
      {
        BOOL bOrigFlag = lpHDE->aDriverData[ulDriverID].bFailNextMode;

        lpHDE->aDriverData[ulDriverID].bFailNextMode = FALSE;

        lpHDE->aDriverData[ulDriverID].bFailNextMode = bOrigFlag;
      }
         
      if (bModeSupported)
      {
    
        MOVEMEMORY((LPDEVMODE_INFO)&lpaMI[ulModesReturned], 
                   (LPDEVMODE_INFO)&lpMode->sDevModeInfo, 
                   sizeof(DEVMODE_INFO));
    
        ulModesReturned += 1;
      }
    }
  }


DALGetModesAvailable_Return:

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetModesAvailable - Exit"));
  return(ulModesReturned);

}



/******************************Public*Routine******************************\
*
* DALGetModesAvailableVMI
*
* Enumerates the list of modes available in a buffer allocated by the OS
* using the VIDEO_MODE_INFORMATION structure
*
* Note:
*
\**************************************************************************/

ULONG DALGetModesAvailableVMI(
HDAL hDAL, 
ULONG ulDriverID,
VIDEO_MODE_INFORMATION FAR *lpaVMI, 
ULONG ulModes)
{
  LPHW_DAL_EXTENSION     lpHDE;
  ULONG                  ulModesReturned;
  ULONG                  ulControllers;
  LONG                   i;
  LPDEVMODE_INFO         lpMode;
  VIDEO_MODE_INFORMATION VMI;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetModesAvailableVMI - 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 DALGetModesAvailableVMI_Return;
  }

  ulControllers = lpHDE->aControllerMap[ulDriverID];

  // 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 - 1; 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!.

/*

    // todo - need to prune the modes based upon the current mapping [GG]

    for (j = 0; j < lpHDE->ulControllersCount; j++)
    {
      // need to ensure for each controller that only the modes which can be
      // set on 

    }
*/
    lpMode = (LPDEVMODE_INFO) &lpHDE->lpaModes[i].sDevModeInfo;

    vFillInVMIStructure(lpHDE,
                        (VIDEO_MODE_INFORMATION FAR *)&VMI,
                        lpMode,
                        (LPULONG)&i);

    // reminder here Win16 code (namely only Win9X) requires pointers to be
    // FAR * to properly address segment boundaries in different applications

    // todo: prune out large desktop modes when one one controller is active.

    MOVEMEMORY((VIDEO_MODE_INFORMATION FAR *)&lpaVMI[ulModesReturned],
               &VMI,
               sizeof(VIDEO_MODE_INFORMATION));

    ulModesReturned += 1;
  }


DALGetModesAvailableVMI_Return:

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetModesAvailableVMI - Exit"));
  return(ulModesReturned);

}

// ------------------------------------------------------------------------------
// This function is used to remember current object map 
// ------------------------------------------------------------------------------
void vSaveObjectMap(LPHW_DAL_EXTENSION lpHDE, LPDAL_SAVED_OBJECT_MAP lpSavedObjectMap)
{
  ULONG n;

  if (!lpSavedObjectMap) return; 
  ZEROMEMORY(lpSavedObjectMap, sizeof(DAL_SAVED_OBJECT_MAP)); 
  if (!lpHDE) return; 

  for (n=0; n<lpHDE->ulControllersCount; n++)
  {
    lpSavedObjectMap->aControllerMap[n] = lpHDE->aControllerMap[n]; 
    lpSavedObjectMap->aDisplays[n] = lpHDE->aControllers[n].ulDisplays; 
  }; 
}; 

// ------------------------------------------------------------------------------
// This function is used to restore previously remembered object map 
// ------------------------------------------------------------------------------
void vRestoreObjectMap(LPHW_DAL_EXTENSION lpHDE, const LPDAL_SAVED_OBJECT_MAP lpSavedObjectMap)
{
  ULONG n; 
  
  if (!lpHDE || !lpSavedObjectMap) return; 
  
  for (n=0; n<lpHDE->ulControllersCount; n++)
  {
    lpHDE->aControllerMap[n] = lpSavedObjectMap->aControllerMap[n]; 
    lpHDE->aControllers[n].ulDisplays = lpSavedObjectMap->aDisplays[n]; 
  }
}

/******************************Public*Routine******************************\
*
* BOOL DALGetMode
*
* Returns the current mode for the specified controller to the caller, in
* the PMI structure, only if the function is sucessful given the map of the
* controllers available.
*
* Note:
*
\**************************************************************************/

BOOL  DALGetMode(
HDAL hDAL, 
LPDEVMODE_INFO lpMI, 
LPRECT lprtView, 
LPRECT lprtPanLock, 
ULONG ulController)
{
  LPHW_DAL_EXTENSION  lpHDE;
  LPDEVGCO            lpController;
  BOOL                bReturn;


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

  bReturn = TRUE;

  if (ulController >= lpHDE->ulControllersCount)
  {
    // controller index exceeds the number of available controllers in
    // the system.

    bReturn = FALSE;

  } else if (!(lpHDE->aControllers[ulController].ulFlags & GCO_ACTIVE))
  {
    // there is no active mode on this controller, so fail the call.

    bReturn = FALSE;

  }

  if (bReturn)
  {                  
    lpController = (LPDEVGCO) &lpHDE->aControllers[ulController];

    // copy the controllers mode into the structure passed in by the caller
    MOVEMEMORY(lpMI, 
               (LPDEVMODE_INFO)&lpController->sModeInfo,
               sizeof(DEVMODE_INFO));

    if (lprtView != NULL)
    {
      // program the view position
      lprtView->top = lpController->rtView.top;
      lprtView->left = lpController->rtView.left;
      lprtView->bottom = lpController->rtView.bottom;
      lprtView->right = lpController->rtView.right;
    }

    // program the pan locking rectangle

    if (lprtPanLock != NULL)
    {
      if (lpController->ulFlags & GCO_PANLOCKED)
      {
        // if the controller has a pan lock rectangle return it to the driver

        lprtPanLock->top = lpController->rtPanLock.top;
        lprtPanLock->left = lpController->rtPanLock.left;
        lprtPanLock->bottom = lpController->rtPanLock.bottom;
        lprtPanLock->right = lpController->rtPanLock.right;
      } else
      {
        // return the surface rectangle itself so the driver code does not
        // differentiate between pan locking or no pan locking
    
        lprtPanLock->top = 0;
        lprtPanLock->left = 0;
        lprtPanLock->bottom = lpController->siDesktop.cy;
        lprtPanLock->right = lpController->siDesktop.cx;

/*      Set the dal view to be bottom-right exclusive same as MS convention

        // adjust the rectangle to be zero-based.

        lprtPanLock->bottom = (lprtPanLock->bottom > 0) ? 
                              (lprtPanLock->bottom - 1) : 0;
        lprtPanLock->right = (lprtPanLock->right > 0) ? 
                             (lprtPanLock->right - 1) : 0;
*/

      }
    }
  }

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



/******************************Public*Routine******************************\
*
* BOOL DALGetModeVMI
*
* Returns the current mode for the OS by filling in the VMI structure.
*
* Note:
*
\**************************************************************************/

BOOL DALGetModeVMI(
HDAL hDAL, 
VIDEO_MODE_INFORMATION FAR * lpVMI,
ULONG ulDriverID)
{
  LPDEVMODE_INFO      lpDMI;
  LPHW_DAL_EXTENSION  lpHDE;
  ULONG               ulModeIndex;

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetModeVMI - 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;
  lpDMI = &(lpHDE->aDriverData[ulDriverID].sMode);
  ulModeIndex = 0;

  if (!bSearchModeTable(lpHDE, lpDMI, (LPULONG)&ulModeIndex))
  {
    // could not find the mode in the table...fail
	DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetModeVMI - Exit"));
    return FALSE;
  }

  // fill in the VMI structure using ModeIndex and data from
  // our DMI structure
  vFillInVMIStructure(lpHDE, lpVMI, lpDMI, (LPULONG)&ulModeIndex);

  DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetModeVMI - Exit"));
  return TRUE;
}



/******************************Public*Routine******************************\
*
* DALResetMode()
*
* Resets the mode on the specified controllers and releases the controllers
* for use in future SetModeCalls.
*
* Note:
*
\**************************************************************************/

VOID DALResetMode(
HDAL hDAL, 
ULONG ulDriverID)
{
  LPHW_DAL_EXTENSION  lpHDE;
  LPDEVGCO            lpController;
  ULONG               ulControllers;
  ULONG               i;
  EVENTINFO           sEventInfo;


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

  if (!(lpHDE->aDriverData[ulDriverID].ulFlags & DRIVERDATA_ENABLED))

⌨️ 快捷键说明

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