📄 dalgco.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 dalgco.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 graphics controller objects
*
* 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 <stdlib.h>
#include "dal.h"
#include "daldef.h"
#include "dalddc.h"
#include "vpmv7.h"
#include "atimcode.h"
extern DAL_GDOGCO_ADJUSTMENT aGCO_Adjustment[];
BOOL bFindControllerAdjIdxFromDI(ULONG ulOverlayAdjust, LPULONG lpIndex)
{
ULONG i =0, ulHookAdjust, ulHookIndex;
switch(ulOverlayAdjust)
{
case CWDDEDI_CONTROLLER_OVERLAY_BRIGHTNESS:
{
ulHookAdjust = GCO_HOOK_OVERLAY_GAMMA_ADJUSTMENT;
ulHookIndex =0;
break;
}
case CWDDEDI_CONTROLLER_OVERLAY_GAMMA:
{
ulHookAdjust = GCO_HOOK_OVERLAY_COLOR_GAMMA_ADJUSTMENT;
ulHookIndex =0;
break;
}
case CWDDEDI_CONTROLLER_OVERLAY_CONTRAST:
{
ulHookAdjust = GCO_HOOK_OVERLAY_CONTRAST_ADJUSTMENT;
ulHookIndex =0;
break;
}
case CWDDEDI_CONTROLLER_OVERLAY_SATURATION:
{
ulHookAdjust = GCO_HOOK_OVERLAY_SATURATION_ADJUSTMENT;
ulHookIndex =0;
break;
}
case CWDDEDI_CONTROLLER_OVERLAY_HUE:
{
ulHookAdjust = GCO_HOOK_OVERLAY_HUE_ADJUSTMENT;
ulHookIndex =0;
break;
}
case CWDDEDI_CONTROLLER_OVERLAY_ALPHA:
{
ulHookAdjust = GCO_HOOK2_OVERLAY_ALPHA_ADJUSTMENT;
ulHookIndex =1;
break;
}
default:
{
ulHookAdjust = 0;
return FALSE;
}
}
for (i = 0; i < DAL_MAX_GCO_ADJUSTMENTS; i++)
{
if((aGCO_Adjustment[i].ulHook == ulHookAdjust)&&
(aGCO_Adjustment[i].ulHookIndex == ulHookIndex))
{
*lpIndex = i;
return TRUE;
}
}
return FALSE;
}
/****************************Private*Routine*******************************\
*
* BOOL bEnableController
*
* Enables a graphics controller object (GCO) via the pfnEnable call to the
* object, and stores the appropriate state information in the DAL structures
* for the controller object
*
* Note: this function has side effects which modify the DAL global structure
* including the following fields - pReservedFree
* ulControllerCount
*
\**************************************************************************/
BOOL bEnableController(LPHW_DAL_EXTENSION lpHDE, PFNGCOENABLE pfnEnable)
{
LPHW_CONTROLLER_ENABLEDATA lpHWED;
LPDEVGCO lpController;
HGCO hGCO;
ULONG i;
// ensure the GCO Handle memory is Zero initialized, since this handle may
// have been used to attempt to enable a previous GCO and could contain
// non-zero entries.
ZEROMEMORY(lpHDE->lpReservedFree, sizeof(HW_CONTROLLER_ENABLEDATA));
lpHWED = (LPHW_CONTROLLER_ENABLEDATA)(lpHDE->lpReservedFree);
// HWED structure may be mismatched between DAL and the GCO. DAL programs the
// ulSize field as an indicator of a structure mismatch, so the GCO can fail the
// enable call, if the libraries were compiled with different versions of dal.h.
lpHWED->ulSize = sizeof(HW_CONTROLLER_ENABLEDATA);
hGCO = (HGCO)(lpHDE->sAdditionalMemSeg.aMemSeg[lpHDE->ulControllersCount+DAL_GCO_MEMSEG_MIN_INDEX].lpMem);
ZEROMEMORY(hGCO, sizeof(HW_CONTROLLER_EXTENSION_SIZE));
if (!(*pfnEnable)(lpHDE->hDDL, hGCO, (LPHW_ASIC_ID)&lpHDE->hwAsicID, lpHWED))
{
// this controller failed the pfnEnable call, so fail to enable it.
return(FALSE);
}
// produce an assertion if only one of the Get/Set XYPos functions is hooked.
// Both of them should be hooked or none of them should be hooked.
DALASSERT((((!(GCO_HOOK2_GETDISPLAYXYPOS & lpHWED->ulFunctionHooks2)) ||
( GCO_HOOK2_SETDISPLAYXYPOS & lpHWED->ulFunctionHooks2 ) ) &&
(( GCO_HOOK2_GETDISPLAYXYPOS & lpHWED->ulFunctionHooks2 ) ||
(!(GCO_HOOK2_SETDISPLAYXYPOS & lpHWED->ulFunctionHooks2)) ) ),
"DAL - Can't hook one of the Get/SetXYMode without the other!");
// 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_CONTROLLER_ENABLEDATA);
for (i = 0; i < lpHWED->ulNumberOfControllers; i++)
{
// since the DAL requires that all controllers be supported in
// one graphics controller object, the DAL must independantly build
// what appear to be independant GCO's for the controllers
// in future the controllers could really be independant, but for now
// what the heck so they are not.
lpController = (LPDEVGCO)&lpHDE->aControllers[lpHDE->ulControllersCount];
lpController->hGCO = hGCO;
lpController->lpHWED = lpHWED;
if (lpController->lpHWED->bEnabledAtBoot[i])
{
// controller is already active in a mode 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
lpController->ulFlags |= GCO_ACTIVE;
}
// controller index is 0 based.
lpController->ulController = lpHDE->ulControllersCount;
// Increment the controller index before calling the set controller
// adjustements.
vInitializeControllerAdjustments(lpHDE, lpController);
lpHDE->ulControllersCount += 1;
}
return(TRUE);
}
/****************************Private*Routine*******************************\
*
* VOID vGetAdapterPowerState
*
* The function retreives adapter power state capabilities from GCO and saves
* it the DAL extension structure.
*
* Note:
\**************************************************************************/
VOID vGetAdapterPowerState(LPHW_DAL_EXTENSION lpHDE)
{
LPDEVGCO lpController;
ULONG ulSize;
ULONG ulTemp;
lpController = (LPDEVGCO)&lpHDE->aControllers[0]; // sr - Changed to 1 from 0. Need to verify this.
// By default power play feature is not supported.
lpHDE->bPowerPlaySupported = FALSE;
// If dalrule to disable powerplay feature is set then disable the feature.
// DAL RULES !!!
if (!(lpHDE->ulDalRule2 & DALRULE2_DISABLEPOWERPLAYFEATURE))
{
// This GCO supports power play functionality. It means the optional
// power play call function are supported and could be called to get
// power play related information.
if (lpController->lpHWED->ulFunctionHooks2 & GCO_HOOK2_POWERPLAY)
{
(*lpController->lpHWED->pfnGetPowerState)(lpController->hGCO,
(LPULONG)&lpHDE->ulCurrentPowerState,
(LPULONG)&lpHDE->ulNumberOfPowerStates,
(LPDAL_ADAPTERPOWERSTATES)&lpHDE->sAdapterPowerStates);
if(lpHDE->ulCurrentPowerState && lpHDE->ulNumberOfPowerStates)
{
// Returned Max number of power state and current power state is non-zero.
// Flag power play feature as supported.
lpHDE->bPowerPlaySupported = TRUE;
// Get the options from the registry if it is there else apply the default.
lpHDE->ulPowerStateOptions = 0;
ulSize = sizeof(ULONG);
if (!(DDLGetRegistryParameters(lpHDE->hDDL,
(LPUCHAR) DALREGKEY_POWERPLAYOPTIONS,
(LPVOID) &ulTemp,
(LPULONG) &ulSize)) &&
(ulSize == (sizeof(ULONG))))
{
// Option is not in the registry get the default from the registry.
if (lpHDE->ulDalRule2 & DALRULE2_POWERPLAYOPTIONENABLEDBYDEFAULT)
{
lpHDE->ulPowerStateOptions |= DAL_PWRSTATEOPTION_POWERPLAYFEATUREENABLE;
}
// Save the value in the registry for next time.
ulSize = sizeof(ULONG);
DDLSetRegistryParameters(lpHDE->hDDL,
(LPUCHAR) DALREGKEY_POWERPLAYOPTIONS,
(LPVOID) &lpHDE->ulPowerStateOptions,
ulSize);
}
else
{
// use the saved option.
lpHDE->ulPowerStateOptions = ulTemp;
}
// Initially the requested and current is the same until some one specifically sets
// a different state via the CWDDE interface.
lpHDE->ulRequestedPowerState = lpHDE->ulCurrentPowerState;
}
}
}
}
/****************************Private*Routine*******************************\
*
* VOID vDisableController
*
* Disables a previously enabled graphics controller object
*
* Note: vDisableController does not return the memory reserved for this GCO
* to the ReservedFree pool, and hence should only be called when the
* DAL itself is being disabled.
*
* As a side effect to this function, the following variables in the
* in the lpHDE are modified - ulControllerCount
*
\**************************************************************************/
VOID vDisableController(LPHW_DAL_EXTENSION lpHDE, LPDEVGCO lpController)
{
lpHDE->ulControllersCount -= lpController->lpHWED->ulNumberOfControllers;
(*lpController->lpHWED->pfnDisable)(lpController->hGCO);
}
/******************************Public*Routine******************************\
*
* DEVPOWER_STATE DALGetDPMS(HDAL hDAL)
*
* returns the current display power management state for the adapter
*
\**************************************************************************/
ULONG DALGetDPMS(HDAL hDAL)
{
LPHW_DAL_EXTENSION lpHDE;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetDPMS - Entry"));
DALASSERT((hDAL != NULL), "DAL handle 'hDAL' is NULL!");
lpHDE = (LPHW_DAL_EXTENSION)hDAL;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetDPMS - Exit"));
return(lpHDE->ulPowerState);
}
/******************************Public*Routine******************************\
*
* VOID DALGetGammaCorrection()
*
* Copies the current gamma settings for the controller from the DAL's
* private structure into a caller specified array
*
\**************************************************************************/
VOID DALGetGammaCorrection(HDAL hDAL, ULONG ulDriverID, LPDEVCLUT lpaGamma)
{
LPHW_DAL_EXTENSION lpHDE;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetGammaCorrection - 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)
{
vConvert16To8Gamma((LPDEVCLUT16)lpHDE->aDriverData[ulDriverID].aGameGamma16,
lpaGamma);
} else
{
vConvert16To8Gamma((LPDEVCLUT16)lpHDE->aDriverData[ulDriverID].aGamma16,
lpaGamma);
}
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetGammaCorrection - Exit"));
}
/******************************Public*Routine******************************\
*
* VOID DALGetGamma16Correction()
*
* Copies the current gamma settings for the controller from the DAL's
* private structure into a caller specified array
*
\**************************************************************************/
VOID DALGetGamma16Correction(
HDAL hDAL,
ULONG ulDriverID,
LPDEVCLUT16 lpaGamma16)
{
LPHW_DAL_EXTENSION lpHDE;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALGetGamma16Correction - Entry"));
DALASSERT((hDAL != NULL), "DAL handle 'hDAL' is NULL!");
// grab the structure for the DAL out of the DDL's handle to it
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -