?? dalmode.c
字號:
*
* DALShareModeTable allows the first DAL instance in a MAXX configuration to
* pass the mode table to the second instance in a MAXX configuration.
*
* Note: Function may be called numerous times to reinitialize the set of connected
* Displays [GG]
*
\**************************************************************************/
BOOL DALShareModeTable(HDAL hDal, LPVOID lpModeTable, ULONG ulConnectedDisplays)
{
LPHW_DAL_EXTENSION lpHDE;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALShareModeTable - 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;
// mark this DAL instance as sharing the mode table so it no longer builds it's
// own mode list, and relies on it from somewhere else [GG]
lpHDE->ulFlags |= HDAL_SHARINGMODETABLE;
lpHDE->lpaModes = (LPDAL_MODEINFO)lpModeTable;
lpHDE->ulConnectedDisplays = ulConnectedDisplays;
// todo - need some validation of DAL's here to ensure both instances share the
// same set and order of display types [GG] 17/11/99
DALDEBUG((DALDBG_ENTRY_EXIT, "DALShareModeTable - Exit"));
return(TRUE);
}
/******************************Public*Routine******************************\
*
* BOOL DALUnShareModeTable()
*
* DALUnShareModeTable allows the second DAL instance
* in a non-MAXX configuration to rebuild its own mode table.
*
* Note: Function will be called from Control Panel through Escape call
*
\**************************************************************************/
BOOL DALUnShareModeTable(HDAL hDal, LPVOID lpModeTable, ULONG ulConnectedDisplays)
{
LPHW_DAL_EXTENSION lpHDE;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALUnShareModeTable - 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;
// mark this DAL instance as not sharing the mode table
// and builds it's own mode list
lpHDE->ulFlags &= ~HDAL_SHARINGMODETABLE;
lpHDE->lpaModes = (LPDAL_MODEINFO)lpModeTable;
lpHDE->ulConnectedDisplays = ulDetectConnectedDisplays(lpHDE);
// Update connected displays in BIOS Scratch Registers
// Do not update CMOS
vUpdateBIOSDisplayInfo(lpHDE, TRUE, FALSE);
DALDEBUG((DALDBG_ENTRY_EXIT, "DALUnShareModeTable - Exit"));
return(TRUE);
}
/******************************Public*Routine******************************\
*
* ULONG DALSetModeVMI()
*
* DALSetModeVMI will be called only by GDI.
* Keep in mind it is called with desktop values, which may not
* necessarily coincide with the actual mode we wish to set.
* CWDDE will call vControllerSetMode itself to change modes.
\**************************************************************************/
ULONG DALSetModeVMI(
HDAL hDAL,
ULONG ulDriverID,
VIDEO_MODE_INFORMATION FAR *lpVMI,
BOOL bForce)
{
LPHW_DAL_EXTENSION lpHDE;
LPDAL_MODEINFO lpDalMode;
LPDEVMODE_INFO lpMode;
ULONG ulDisplayOffset;
ULONG ulDisplayPitch;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetModeVMI - 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;
// retrieve the DAL_MODEINFO structure using the index passed in
// from the VIDEO_MODE_INFORMATION structure
lpDalMode = (LPDAL_MODEINFO) &lpHDE->lpaModes[lpVMI->ModeIndex];
lpMode = (LPDEVMODE_INFO) &lpDalMode->sDevModeInfo;
// set pitch equal to the horizontal res and the offset to 0
ulDisplayOffset = 0;
ulDisplayPitch = lpMode->ulPelsWidth;
DALDEBUG((DALDBG_ENTRY_EXIT, "DALSetModeVMI - Exit"));
return (DALSetMode(hDAL,
ulDriverID,
lpMode,
ulDisplayOffset,
ulDisplayPitch,
bForce));
}
/****************************Private*Routine*******************************\
*
* BOOL bValidateBandwidth()
*
* Function will ensure that there is enough bandwidth available and that
* horizontal time falls within lim iting constraints.
* It will return TRUE if conditions are met, FALSE if not.
*
* Note: Inherent in this function is validation of both bandwidth and
* horizonatal time.
*
\**************************************************************************/
BOOL bValidateBandwidth(
LPHW_DAL_EXTENSION lpHDE,
LPDEVMODE_INFO lpMode,
LPULONG lpulDisplaysType)
{
LPDEVGCO lpController = NULL;
FIXEDPOINT sAvailBandwidth;
FIXEDPOINT sAvailPeakBandwidth;
FIXEDPOINT sReqBandwidth;
FIXEDPOINT sReqPeakBandwidth;
FIXEDPOINT sBandwidth;
FIXEDPOINT sPeakBandwidth;
PRIO_ELEM aPrioTable[MAX_PRIO_ELEM];
HORIZONTAL_TIME aTotalHTime[MAX_NUMBER_CONTROLLERS];
LPDEVMODE_INFO lpModeTemp;
LPULONG lpulDisplaysTypeTemp;
BOOL bRet = TRUE;
BOOL bPerformBandwidth = TRUE;
BOOL bPerformHTime = TRUE;
ULONG i, ulIndex;
DAL_CRTC_TIMING sTiming;
lpModeTemp = lpMode;
lpulDisplaysTypeTemp = lpulDisplaysType;
ZEROMEMORY(&sTiming, sizeof(DAL_CRTC_TIMING));
for (i = 0; i < lpHDE->ulControllersCount; i++)
{
lpController = (LPDEVGCO) &lpHDE->aControllers[i];
// If any of the controllers DON'T support bandwidth calcualtions,
// don't perform any.
if (!(lpController->lpHWED->ulFunctionHooks & GCO_CALCULATE_MEMORY_BANDWIDTH))
bPerformBandwidth = FALSE;
else
{
if (i == 0)
{
// Total CURRENT bandwidth in the system of ALL controllers
sAvailBandwidth = lpController->lpHWED->sAvailBandwidth;
ZEROMEMORY((LPVOID)&sReqBandwidth, sizeof(FIXEDPOINT));
sAvailPeakBandwidth = lpController->lpHWED->sAvailPeakBandwidth;
ZEROMEMORY((LPVOID)&sReqPeakBandwidth, sizeof(FIXEDPOINT));
}
if (lpController->ulFlags & GCO_ACTIVE)
{
// if this controller is CURRENTLY active, increment the available bandwidth
// with which we have to work. This will hopefully get our available
// bandwidth in a state we were in at boot time
//First find that mode's timing
if(lpController->lpHWED->ulFunctionHooks2 & GCO_HOOK2_CALCULATE_MODE_BANDWIDTH_EX )
{
(*lpController->lpHWED->pfnGCOGetDetailedTiming)(lpController->hGCO,
lpController->ulController,
NULL, //To get current mode timing
&sTiming);
(*lpController->lpHWED->pfnCalculateModeBandwidthEx) (lpController->hGCO,
&lpController->sModeInfo, (LPDAL_CRTC_TIMING)&sTiming, (LPFIXEDPOINT)&sBandwidth);
}
else
{
(*lpController->lpHWED->pfnCalculateModeBandwidth) (lpController->hGCO,
&lpController->sModeInfo,(LPFIXEDPOINT)&sBandwidth);
}
vIncrementBandwidth(&sAvailBandwidth, (LPFIXEDPOINT)&sBandwidth);
// If this controller was allocated for a half frame buffer display, deallocate the bandwidth
// If not, HalfFrameBuffer is zero
if (lpController->lpHWED->ulFunctionHooks & GCO_CALCULATE_HALFFRAMEBUFFER_BANDWIDTH)
vIncrementBandwidth(&sAvailBandwidth, (LPFIXEDPOINT)&lpController->sAllocatedBandwidth.HalfFrameBuffer);
if(lpController->lpHWED->ulFunctionHooks2 & GCO_HOOK2_CALCULATE_PEAK_MEMORY_BANDWIDTH_EX)
{
if(sTiming.usPixelClock ==0) //We did not hook get mode bandwidth.
{
(*lpController->lpHWED->pfnGCOGetDetailedTiming)(lpController->hGCO,
lpController->ulController,
NULL, //To get current mode timing
&sTiming);
}
(*lpController->lpHWED->pfnCalculatePeakModeBandwidthEx)
(lpController->hGCO, &lpController->sModeInfo, &sTiming, (LPFIXEDPOINT)&sPeakBandwidth);
vIncrementBandwidth(&sAvailPeakBandwidth, (LPFIXEDPOINT)&sPeakBandwidth);
}
else if (lpController->lpHWED->ulFunctionHooks & GCO_CALCULATE_PEAK_MEMORY_BANDWIDTH)
{
(*lpController->lpHWED->pfnCalculatePeakModeBandwidth)
(lpController->hGCO, &lpController->sModeInfo, (LPFIXEDPOINT)&sPeakBandwidth);
vIncrementBandwidth(&sAvailPeakBandwidth, (LPFIXEDPOINT)&sPeakBandwidth);
}
}
}
// If any of the controllers DON'T support HTime calcualtions,
// don't perform any.
if (!(lpController->lpHWED->ulFunctionHooks & GCO_CALCULATE_HORIZONTAL_TIME))
bPerformHTime = FALSE;
}
//
// Bandwidth validation
//
if (bPerformBandwidth)
{
LPDAL_CRTC_TIMING lpTiming;
for (i = 0; i < lpHDE->ulControllersCount; i++)
{
lpController = (LPDEVGCO) &lpHDE->aControllers[i];
lpTiming = NULL;
if (*lpulDisplaysTypeTemp != 0)
{
// Get the requested bandwidth for this controller only if the
// displays passed in for this controller are non-zero. This is done
// since we are unaware if we are validating for the current
// configuration or a possible future one
if(lpController->lpHWED->ulFunctionHooks2 & GCO_HOOK2_CALCULATE_MODE_BANDWIDTH_EX)
{
if(bGetModeDetailedTimingEx(lpHDE, *lpulDisplaysTypeTemp, lpModeTemp, (LPDAL_CRTC_TIMING)&sTiming, FALSE))
{
lpTiming =(LPDAL_CRTC_TIMING)&sTiming;
}
(*lpController->lpHWED->pfnCalculateModeBandwidthEx) (lpController->hGCO,
lpModeTemp, (LPDAL_CRTC_TIMING)lpTiming, (LPFIXEDPOINT)&sBandwidth);
}
else
{
(*lpController->lpHWED->pfnCalculateModeBandwidth) (lpController->hGCO,
lpModeTemp, (LPFIXEDPOINT)&sBandwidth);
}
vIncrementBandwidth(&sReqBandwidth, (LPFIXEDPOINT)&sBandwidth);
if ((lpController->lpHWED->ulFunctionHooks & GCO_CALCULATE_HALFFRAMEBUFFER_BANDWIDTH) &&
(*lpulDisplaysTypeTemp & HW_DISPLAY_TYPE_LCD))
{
// If this LCD is half frame buffered, add the beandwidth.
if ((*lpController->lpHWED->pfnCalculateHFBBandwidth) (lpController->hGCO,
lpModeTemp, (LPFIXEDPOINT)&sBandwidth))
{
vIncrementBandwidth(&sReqBandwidth, (LPFIXEDPOINT)&sBandwidth);
}
}
//Check the new hook first.
if(lpController->lpHWED->ulFunctionHooks2 & GCO_HOOK2_CALCULATE_PEAK_MEMORY_BANDWIDTH_EX)
{
// lpTiming = NULL; Use previous .
if(sTiming.usPixelClock == 0)
{
if(bGetModeDetailedTimingEx(lpHDE, *lpulDisplaysTypeTemp, lpModeTemp, (LPDAL_CRTC_TIMING)&sTiming, FALSE))
{
lpTiming = (LPDAL_CRTC_TIMING)&sTiming;
}
}
(*lpController->lpHWED->pfnCalculatePeakModeBandwidthEx)
(lpController->hGCO, lpModeTemp, (LPDAL_CRTC_TIMING)lpTiming, (LPFIXEDPOINT)&sPeakBandwidth);
vIncrementBandwidth(&sReqPeakBandwidth, (LPFIXEDPOINT)&sPeakBandwidth);
}
else if (lpController->lpHWED->ulFunctionHooks & GCO_CALCULATE_PEAK_MEMORY_BANDWIDTH)
{
(*lpController->lpHWED->pfnCalculatePeakModeBandwidth)
(lpController->hGCO, lpModeTemp, (LPFIXEDPOINT)&sPeakBandwidth);
vIncrementBandwidth(&sReqPeakBandwidth, (LPFIXEDPOINT)&sPeakBandwidth);
}
}
lpModeTemp++;
lpulDisplaysTypeTemp++;
}
// Now perform the validation between available and requested
bRet = (bCompareFixed(&sAvailBandwidth, &sReqBandwidth) &&
bCompareFixed(&sAvailPeakBandwidth, &sReqPeakBandwidth));
if (!(lpHDE->bEnableBandwidthTest))
bRet = TRUE;
// Reset the pointers
lpModeTemp = lpMode;
lpulDisplaysTypeTemp = lpulDisplaysType;
}
//
// HTime validation (only perform if bandwidth validation passes)
//
if (bPerformHTime && bRet)
{
ZEROMEMORY((LPVOID)aTotalHTime, (MAX_NUMBER_CONTROLLERS * sizeof(HORIZONTAL_TIME)));
ZEROMEMORY((LPVOID)aPrioTable, (MAX_PRIO_ELEM * sizeof(PRIO_ELEM)));
for (i = 0; i < lpHDE->ulControllersCount; i++)
{
lpController = (LPDEVGCO) &lpHDE->aControllers[i];
if (*lpulDisplaysTypeTemp != 0)
{
// Get Horizontal Total Time
(*lpController->lpHWED->pfnGetTotalHTime)(lpController->hGCO, (LPHORIZONTAL_TIME)&aTotalHTime[i],
lpModeTemp, *lpulDisplaysTypeTemp);
// Get display index for priority table
ulIndex = 7 - (i * 3);
// Fill in the fields for this controller element
aPrioTable[ulIndex].bEnabled = TRUE;
aPrioTable[ulIndex].ulMappedController = i;
(*lpController->lpHWED->pfnCalculateModeHorizontalTime)(lpController->hGCO,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -