📄 dalgco.c
字号:
// DPMS state is applied to that display
vSetDisplayPowerState(lpHDE,
(LPDEVGDO) &lpHDE->aDisplays[j],
ulState);
}
}
}
}
// store the current DPMS state of the system
lpHDE->ulPowerState = ulState;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetDPMS - Exit"));
}
/******************************Public*Routine******************************\
*
* VOID DALSetPowerState(HDAL hDAL, ULONG ulState)
*
* The function to will call GCO and GDO power state functions.
*
*
\**************************************************************************/
VOID DALSetPowerState(HDAL hDAL, ULONG ulState)
{
LPHW_DAL_EXTENSION lpHDE;
ULONG i;
LPDEVGCO lpController;
LPDEVGDO lpDisplay;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetPowerState - Entry"));
DALASSERT((hDAL != NULL), "DAL handle 'hDAL' is NULL!");
lpHDE = (LPHW_DAL_EXTENSION)hDAL;
if (ulState == ACPI_CM_POWERSTATE_D0)
{
for (i = 0; i < lpHDE->ulControllersCount; i++)
{
lpController = (LPDEVGCO)&lpHDE->aControllers[i];
if (lpController->lpHWED->ulFunctionHooks2 & GCO_HOOK2_SETPOWERSTATE)
{
(*lpController->lpHWED->pfnGCOSetPowerState)(lpController->hGCO,
lpController->ulController,
ulState);
}
}
}
for (i = 0; i < lpHDE->ulDisplaysCount; i++)
{
lpDisplay = (LPDEVGDO) &lpHDE->aDisplays[i];
if (lpDisplay->lpHWED->ulFunctionHooks2 & GDO_HOOK2_SETPOWERSTATE)
{
(*lpDisplay->lpHWED->pfnGDOSetPowerState)(lpDisplay->hGDO, ulState);
}
}
if (ulState != ACPI_CM_POWERSTATE_D0)
{
for (i = 0; i < lpHDE->ulControllersCount; i++)
{
lpController = (LPDEVGCO)&lpHDE->aControllers[i];
if (lpController->lpHWED->ulFunctionHooks2 & GCO_HOOK2_SETPOWERSTATE)
{
(*lpController->lpHWED->pfnGCOSetPowerState)(lpController->hGCO,
lpController->ulController,
ulState);
}
}
}
DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetPowerState - Exit"));
}
/******************************Public*Routine******************************\
*
* VOID DALGetDisplaysPhysicallyConnected(HDAL hDAL, ULONG ulDriverID)
*
* Retrieves all display types physically connected to the adapter
* (but not necessarily active).
*
\**************************************************************************/
ULONG
DALGetDisplaysPhysicallyConnected(
HDAL hDAL,
ULONG ulDriverID
)
{
LPHW_DAL_EXTENSION lpHDE;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetDisplaysPhysicallyConnected - 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;
// Assuming this function returns the displays connected to adapter
// based on what DAL saved upon last detection. If a new detection
// is to be done add following line :
// lpHDE->ulConnectedDisplays = ulDetectConnectedDisplays(lpHDE);
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetDisplaysPhysicallyConnected - Exit"));
// returns a vector of connected displays to the adapter
return (lpHDE->ulConnectedDisplays);
} // DALGetDisplaysPhysicallyConnected()
/******************************Public*Routine******************************\
*
* VOID DALGetDisplaysActive(HDAL hDAL, ULONG ulDriverID)
*
* 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
*
\**************************************************************************/
ULONG
DALGetDisplaysActive(
HDAL hDAL,
ULONG ulDriverID
)
{
LPHW_DAL_EXTENSION lpHDE;
//LPDEVGDO lpDisplay;
LPDEVGCO lpController;
ULONG ulControllers;
ULONG ulDisplaysActive;
ULONG i;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetDisplaysActive - 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;
// Initialize the display vector to zero
ulDisplaysActive = 0;
// Check which controllers belong to this driver.
ulControllers = lpHDE->aControllerMap[ulDriverID];
// Go through all the controllers and see whice displays are
// active on the controller belonging to this driver.
for (i = 0; i < lpHDE->ulControllersCount; i++)
{
if (VECTORFROMINDEX(i) & ulControllers)
{
// Get the displays active on this controller
lpController = (LPDEVGCO) &lpHDE->aControllers[i];
ulDisplaysActive |= lpController->ulDisplays;
}
}
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetDisplaysActive - Exit"));
// returns a vector of active displays attached to this driver
return ulDisplaysActive;
} // DALGetDisplaysActive()
/******************************Public*Routine******************************\
*
* ULONG DALGetGammaMode()
*
* function returns the current gamma mode for the driver
*
* Notes:
*
*
\**************************************************************************/
ULONG DALGetGammaMode(
HDAL hDAL,
ULONG ulDriverID)
{
LPHW_DAL_EXTENSION lpHDE;
ULONG ulGammaMode;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetGammaMode - 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_USEGAMEGAMMA)
{
ulGammaMode = GAMMAMODE_FULLSCREENGAMING;
} else
{
ulGammaMode = GAMMAMODE_DESKTOP;
}
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetGammaMode - Exit"));
return(ulGammaMode);
}
/******************************Public*Routine******************************\
*
* VOID DALSetGammaMode()
*
* function sets the state of the gamma correction to be used, and reapplies
* the appropriate gamma into the controller object.
*
* Notes: DALSetGammaMode is intended to switch from desktop gamma to
* 3D gamma in fullscreen gaming modes. This function can be
* further extended to "tweak" gamma for video as well.
*
\**************************************************************************/
VOID DALSetGammaMode(
HDAL hDAL,
ULONG ulDriverID,
ULONG ulGammaMode)
{
LPHW_DAL_EXTENSION lpHDE;
LPDRIVERDATA lpDriverData;
ULONG i;
ULONG ulGamma;
ULONG ulSize;
ULONG ulRed;
ULONG ulGreen;
ULONG ulBlue;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetGammaMode - 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;
lpDriverData = (LPDRIVERDATA) &lpHDE->aDriverData[ulDriverID];
if (ulGammaMode == GAMMAMODE_FULLSCREENGAMING)
{
// game gamma is programmed using linear scaling factors from a
// registry key if it exists, otherwise it uses a hardcoded default.
// initially Poynton's gamma exponential function was used as defined
// in "A Technical Introduction to Digital Video", but the display
// was too washed out. The function used is signal = intensity ^ (1/y)
// where a gamma value of (1 / 0.75) was used for both the green and
// blue ramps, and (1 / 0.70) was used for the red gamma ramp.
lpDriverData->ulFlags |= DRIVERDATA_USEGAMEGAMMA;
ulSize = sizeof(ULONG);
if (!(DDLGetRegistryParameters(lpHDE->hDDL,
(LPUCHAR) DALREGKEY_GAMEGAMMASCALE,
(LPVOID) &ulGamma,
(LPULONG) &ulSize)) &&
(ulSize == (sizeof(ULONG))))
{
// game gamma scale is not in the registry, so use a 130/120/120
// scaling ramp
ulGamma = 0x00827878;
}
// the DAL restores the game gamma correction from it's default
// whenever game gamma is selected. This ensures the same initial
// gaming visual quality, if gamma was adjusted in a previous gaming
// session
ulRed = ((ulGamma & 0x00FF0000) / 0x64);
ulGreen = (((ulGamma & 0x0000FF00) << 8) / 0x64);
ulBlue = (((ulGamma & 0x000000FF) << 16) / 0x64);
for (i = 0; i < 256; i++)
{
// this function really needs a floating point calculation, but a
// fixed point calculation will have to suffice. The calculations
// are perfomed in 16.16 fixed point format.
ulGamma = ((i * ulRed) >> 8);
lpDriverData->aGameGamma16[i].usRed = (USHORT)(ulGamma < 0xFFFF ? ulGamma : 0xFFFF);
ulGamma = ((i * ulGreen) >> 8);
lpDriverData->aGameGamma16[i].usGreen = (USHORT)(ulGamma < 0xFFFF ? ulGamma : 0xFFFF);
ulGamma = ((i * ulBlue) >> 8);
lpDriverData->aGameGamma16[i].usBlue = (USHORT)(ulGamma < 0xFFFF ? ulGamma : 0xFFFF);
}
DALSetGamma16Correction(hDAL, ulDriverID,
(LPDEVCLUT16)lpDriverData->aGameGamma16);
} else if (ulGammaMode == GAMMAMODE_DESKTOP)
{
lpDriverData->ulFlags &= ~DRIVERDATA_USEGAMEGAMMA;
DALSetGamma16Correction(hDAL, ulDriverID,
(LPDEVCLUT16)lpDriverData->aGamma16);
} else
{
DALDEBUG((DALDBG_DETAIL, "DALGetSammaMode - bogus gamma mode!"));
}
DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetGammaMode - Exit"));
}
/******************************Public*Routine******************************\
*
* VOID DALSetGammaCorrection
*
* Programs the gamma correction of the specified controllers.
*
* Note: DAL does nothing if the controller is inactive. If multiple
* controllers are specified in the same call, both need be working
* cooperatively from the same desktop, and hence will require the
* same gamma correction values.
*
* Gamma correction is normally programmed via ATI's property pages,
* but Microsoft has their own API into the driver for Gamma Correction
* via ExtEscape .... hence DAL has to support a call to process Gamma.
*
\**************************************************************************/
VOID DALSetGammaCorrection(
HDAL hDAL,
ULONG ulDriverID,
LPDEVCLUT lpaGamma)
{
LPHW_DAL_EXTENSION lpHDE;
LPDEVGCO lpController;
LPDRIVERDATA lpDriverData;
LPDEVCLUT16 lpaGamma16;
ULONG ulControllers;
ULONG i;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetGammaCorrection - 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;
// save the gamma correction in DAL DRIVERDATA structure.
lpDriverData = (LPDRIVERDATA) &lpHDE->aDriverData[ulDriverID];
if (lpHDE->aDriverData[ulDriverID].ulFlags & DRIVERDATA_USEGAMEGAMMA)
{
// DAL does not save out the game gamma when modified by a gaming
// application because this will change from game to game, and the
// DAL should ensure each gaming session starts from the same
// default gamma
lpaGamma16 = (LPDEVCLUT16)lpDriverData->aGameGamma16;
vConvert8To16Gamma(lpaGamma, lpaGamma16);
} else
{
// Set the Gamma Save flag, so that it would be flushed to the registry
// Gamma will be saved only if adjusted via CWDDE interface
//lpDriverData->ulFlags |= DRIVERDATA_SAVEGAMMA;
lpaGamma16 = (LPDEVCLUT16)lpDriverData->aGamma16;
vConvert8To16Gamma(lpaGamma, lpaGamma16);
}
ulControllers = lpHDE->aControllerMap[ulDriverID];
i = 0;
// loop through the specified controller programming gamma correction
// if the controller is active.
while((ulControllers != 0) && (i < lpHDE->ulControllersCount))
{
if (ulControllers & 1)
{
lpController = (LPDEVGCO)&lpHDE->aControllers[i];
// if this controller was specified, test if it is active, before
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -