📄 dalgdo.c
字号:
//
// 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 dalgdo.c
* Project ATI Display Abstraction Layer
* Device RageProPNP / Rage128 (Win95/98 & WinNT 4.0/5.0)
*
* Description source file for Display Abstraction Layer 0.92
* contains functions related to graphics display objects
*
* Copyright (c) 1998-2000 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.92 for usage
*
\****************************************************************************/
#include "dal.h"
#include "daldef.h"
#include "dalddc.h"
// Monitor Info may be applied if (DALREGKEY_DISPLAYLIMITSMONITORINFO key is
// not present) or (it's present and its value is non-zero and
// ControllerSetConfig call indicates monitor info should be used.
#define SHOULDOSMONITORINFOBEUSED(x,y) \
( (!(DALRULE2_DISPLAYLIMITSOSMONITORINFO & x->ulDalRule2 )) \
||( (MONITORINFO_DISPLAYCAPS_USEOSMONITORINFO & y->sUserMonitorInfo.ulDisplayCaps) \
&&(DALRULE2_DISPLAYLIMITSOSMONITORINFO & x->ulDalRule2 )))
/******************************Public*Routine******************************\
*
* BOOL bValidateDisplayMapping()
*
* Validates the display mapping to the controllers
*
* Note:Was moved from dalcwdde.c
*
\**************************************************************************/
BOOL bValidateDisplayMapping(
LPHW_DAL_EXTENSION lpHDE,
LPULONG lpDisplayMapping )
{
ULONG i;
ULONG j;
ULONG ulType;
ULONG ulOptions;
ULONG ulDisplayTypes;
ULONG ulCntlMappedObjects;
ULONG ulAdptMappedObjects;
ulOptions = 0;
ulAdptMappedObjects = 0;
for (i = 0; i < MAX_NUMBER_CONTROLLERS; i++)
{
ulDisplayTypes = lpDisplayMapping[i];
ulCntlMappedObjects = 0;
for (j = 0, ulType = 1; j < MAX_NUMBER_DISPLAYS; j++, ulType = ulType << 1)
{
if (ulDisplayTypes & ulType)
{
if ( !bMapObjectValidateDisplayCaps(lpHDE, ulType, ulCntlMappedObjects, ulAdptMappedObjects, i)
|| !bMapObjectValidateDALRule(lpHDE, ulOptions, ulType, ulCntlMappedObjects, ulAdptMappedObjects, i)
|| !bMapObjectValidateGCOCaps(lpHDE, ulType, ulCntlMappedObjects, ulAdptMappedObjects, i))
{
return FALSE;
}
ulCntlMappedObjects |= ulType;
ulAdptMappedObjects |= ulType;
}
}
}
return TRUE;
}
/****************************Private*Routine*******************************\
*
* BOOL bEnableDisplay
*
* Enables a graphics display object (GDO) via the pfnEnable call to the
* object, and stores the appropriate state information in the DAL structures
* for the display object
*
* Also enables all sibling GDOs (i.e. displays of the same or similar type.
*
* Note: this function has side effects which modify the DAL global structure
* including the following fields - pReservedFree
* ulDisplayCount
*
\**************************************************************************/
BOOL bEnableDisplay(LPHW_DAL_EXTENSION lpHDE, PFNGDOENABLE pfnEnable)
{
LPHW_DISPLAY_ENABLEDATA lpHWED;
LPDEVGDO lpDisplay;
LPDEVGDO lpPrevDisplay;
HGDO hGDO;
BOOL bMoreSibling;
ULONG ulSize;
UCHAR aRestrictedModes[MAX_REGISTRY_MODE_LIST];
UCHAR aRegKeyName[MAX_REGISTRY_VALUENAME];
if (lpHDE->ulDisplaysCount >= MAX_NUMBER_DISPLAYS)
{
// no more memory to enable
return FALSE;
}
// ensure the GDO Handle memory is Zero initialized, since this handle may
// have been used to attempt to enable a previous GDO and could contain
// non-zero entries.
ZEROMEMORY(lpHDE->lpReservedFree, sizeof(HW_DISPLAY_ENABLEDATA));
lpHWED = (LPHW_DISPLAY_ENABLEDATA)(lpHDE->lpReservedFree);
// HWED structure may be mismatched between DAL and the GDO. DAL programs the
// ulSize field as an indicator of a structure mismatch, so the GDO can fail the
// enable call, if the libraries were compiled with different versions of dal.h.
lpHWED->ulSize = sizeof(HW_DISPLAY_ENABLEDATA);
hGDO = (HGDO)(lpHDE->sAdditionalMemSeg.aMemSeg[lpHDE->ulDisplaysCount+DAL_GDO_MEMSEG_MIN_INDEX].lpMem);
ZEROMEMORY(hGDO, HW_DISPLAY_EXTENSION_SIZE);
lpDisplay = (LPDEVGDO)&lpHDE->aDisplays[lpHDE->ulDisplaysCount];
if (!(*pfnEnable)(lpHDE->hDDL,
hGDO,
(LPHW_ASIC_ID)&lpHDE->hwAsicID,
lpHWED))
{
// this display failed the pfnEnable call, so fail to enable it.
return(FALSE);
}
// assume there is sibling
bMoreSibling = TRUE;
while (bMoreSibling)
{
// the display was sucessfully enabled, so the structured need be updated
// to indicate this display is present, and account for the resources
// this graphics display object ha reserved or is using.
lpHDE->lpReservedFree += sizeof(HW_DISPLAY_ENABLEDATA);
lpDisplay->hGDO = hGDO;
lpDisplay->lpHWED = lpHWED;
lpDisplay->ulController = (ULONG)GDO_WITHOUT_CONTROLLER;
if (lpDisplay->lpHWED->bEnabledAtBoot)
{
// display is already active on a controller programmed by the BIOS
// at boot time, so the DAL needs store this state to ensure the DAL
// preserves the VGA display configuration during physical display
// detection
lpDisplay->ulFlags |= GDO_ACTIVE;
lpDisplay->ulFlags &= ~ GDO_PM_LOWREFRESHRATE_REQUESTED;
lpDisplay->ulFlags &= ~ GDO_PM_LOWREFRESHRATE_SET;
//Get Display default refresh rate.
lpDisplay->ulDefaultRefreshRate = lpDisplay->lpHWED->ulDefaultRefreshRate;
lpDisplay->ulCurrentRefreshRate = lpDisplay->ulDefaultRefreshRate;
}
if (DALRULE2_DISABLESIZEADJUSTMENT & lpHDE->ulDalRule2)
{
// force off the size adjustment for the GDO
lpDisplay->lpHWED->ulFunctionHooks &= ~GDO_HOOK_VERTICAL_SIZE_ADJUSTMENT;
lpDisplay->lpHWED->ulFunctionHooks &= ~GDO_HOOK_HORIZONTAL_SIZE_ADJUSTMENT;
lpDisplay->lpHWED->pfnGetDisplaySizeAdjustment = NULL;
lpDisplay->lpHWED->pfnSetDisplaySizeAdjustment = NULL;
}
if (DALRULE2_DISABLEPOSITIONADJUSTMENT & lpHDE->ulDalRule2)
{
// force off the size adjustment for the GDO
lpDisplay->lpHWED->ulFunctionHooks &= ~GDO_HOOK_VERTICAL_POSITION_ADJUSTMENT;
lpDisplay->lpHWED->ulFunctionHooks &= ~GDO_HOOK_HORIZONTAL_POSITION_ADJUSTMENT;
lpDisplay->lpHWED->pfnGetDisplayPositionAdjustment = NULL;
lpDisplay->lpHWED->pfnSetDisplayPositionAdjustment = NULL;
}
// ulDisplay identifier is a zero based array index counter.
lpDisplay->ulDisplay = lpHDE->ulDisplaysCount;
lpHDE->ulDisplaysCount += 1;
// query for EDID or Monitor Info structure information if supported
vDisplayQueryModeRestrictions(lpHDE, lpDisplay);
// See if there are per-GDO mode restrictions in the registry
lpDisplay->ulRestrictedModesCount = 0;
if (bGetPerDisplayRegKeyName(lpDisplay->lpHWED->ulDisplayType,
(LPUCHAR) &aRegKeyName[0],
(LPUCHAR) DALREGKEY_RESTRICTEDMODESBCDPOSTFIX) )
{
ulSize = sizeof(aRestrictedModes);
if (DDLGetRegistryParameters(lpHDE->hDDL,
(LPUCHAR) &aRegKeyName[0],
(LPVOID) &aRestrictedModes[0],
(LPULONG) &ulSize))
{
if (ulSize > sizeof(lpDisplay->aRestrictedModes))
ulSize = sizeof(lpDisplay->aRestrictedModes);
lpDisplay->ulRestrictedModesCount = ulSize;
MOVEMEMORY((LPVOID)&lpDisplay->aRestrictedModes[0],
(LPVOID)&aRestrictedModes[0],
ulSize);
}
}
// force the display to query it's sizing and positioning adjustments
lpDisplay->ulFlags |= GDO_QUERYPERMODEADJUSTMENTS;
if (GDO_HOOK2_ENABLESIBLING & lpDisplay->lpHWED->ulFunctionHooks2)
{
if (lpHDE->ulDisplaysCount >= MAX_NUMBER_DISPLAYS)
{
// no more memory to enable
break;
}
lpPrevDisplay = lpDisplay;
// ensure the GDO Handle memory is Zero initialized, since this handle may
// have been used to attempt to enable a previous GDO and could contain
// non-zero entries.
ZEROMEMORY(lpHDE->lpReservedFree, sizeof(HW_DISPLAY_ENABLEDATA));
lpHWED = (LPHW_DISPLAY_ENABLEDATA)(lpHDE->lpReservedFree);
// HWED structure may be mismatched between DAL and the GDO. DAL programs the
// ulSize field as an indicator of a structure mismatch, so the GDO can fail the
// enable call, if the libraries were compiled with different versions of dal.h.
lpHWED->ulSize = sizeof(HW_DISPLAY_ENABLEDATA);
hGDO = (HGDO)(lpHDE->sAdditionalMemSeg.aMemSeg[lpHDE->ulDisplaysCount+DAL_GDO_MEMSEG_MIN_INDEX].lpMem);
ZEROMEMORY(hGDO, HW_DISPLAY_EXTENSION_SIZE);
lpDisplay = (LPDEVGDO)&lpHDE->aDisplays[lpHDE->ulDisplaysCount];
if (!(*lpPrevDisplay->lpHWED->pfnEnableSibling)(lpHDE->hDDL,
hGDO,
lpPrevDisplay->hGDO,
(LPHW_ASIC_ID)&lpHDE->hwAsicID,
lpHWED))
{
// No more sibling.
bMoreSibling = FALSE;
}
}
else
{
bMoreSibling = FALSE;
}
}
return(TRUE);
}
/****************************Private*Routine*******************************\
*
* VOID vDisableDisplay
*
* Disables a previously enabled graphics display object
*
* Note: vDisableDisplay does not return the memory reserved for this GDO to
* the ReservedFree pool, and hence should only be called when the DAL
* itself is being disabled
*
* This function has side effects which modify the DAL global structure
* including the following fields - ulDisplayCount
*
\**************************************************************************/
VOID vDisableDisplay(LPHW_DAL_EXTENSION lpHDE, LPDEVGDO lpDisplay)
{
(*lpDisplay->lpHWED->pfnDisable)(lpDisplay->hGDO);
lpHDE->ulDisplaysCount -= 1;
}
/****************************Private*Routine*******************************\
*
* BOOL bIsAdjustmentValid(
*
* Test to determine if an adjutsment is valid.
*
* Notes:
*
\**************************************************************************/
BOOL bIsAdjustmentValid(
LPHW_DAL_EXTENSION lpHDE,
LPHW_ADJUSTMENT lpAdjustment,
LPLONG lplValue)
{
if (*lplValue > lpAdjustment->lMax)
{
return(FALSE);
}
if (*lplValue < lpAdjustment->lMin)
{
return(FALSE);
}
if (lpAdjustment->lStep != 0)
{
if (*lplValue != ((*lplValue / lpAdjustment->lStep) * lpAdjustment->lStep))
{
return(FALSE);
}
}
return(TRUE);
}
/****************************Private*Routine*******************************\
*
* VOID vGetDisplayAdjustmentsValueName()
*
* Function creates the key name used for display adjustments saved into
* the registry, returni
*
* Notes:
*
\**************************************************************************/
VOID vGetDisplayAdjustmentsValueName(
LPHW_DAL_EXTENSION lpHDE,
LPDEVGDO lpDisplay,
LPUCHAR lpValueName)
{
DALASSERT(lpDisplay->lpHWED->lpDisplayName != NULL,
"vGetDisplayAdjustmentsValueName - display does not have a name!");
strcpy(lpValueName, DALREGKEY_DAL);
strcat(lpValueName, lpDisplay->lpHWED->lpDisplayName);
}
/****************************Private*Routine*******************************\
*
* VOID vGetDisplayPerModeValueName()
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -