enable.c revision aa20c297a3aedc70fb5008a8558f3cc1d486d95e
/******************************Module*Header*******************************\
*
* *******************
* * GDI SAMPLE CODE *
* *******************
*
* Module Name: enable.c
*
* This module contains the functions that enable and disable the
* driver, the pdev, and the surface.
*
* Copyright (c) 1992-1998 Microsoft Corporation
\**************************************************************************/
#include "driver.h"
// Hook functions to track dirty rectangles and generate RDP orders.
// NT4 functions
DRVFN gadrvfn_nt4[] = {
};
/* Experimental begin */
)
{
return TRUE;
}
BOOL DrvNineGrid (PVOID x1, PVOID x2, PVOID x3, PVOID x4, PVOID x5, PVOID x6, PVOID x7, PVOID x8, PVOID x9)
{
DISPDBG((0, "Experimental %s: %p, %p, %p, %p, %p, %p, %p, %p, %p\n", __FUNCTION__, x1, x2, x3, x4, x5, x6, x7, x8, x9));
return FALSE;
}
{
}
)
{
DISPDBG((0, "Experimental %s: %p, %p, %p, %p, %p, %p\n", __FUNCTION__, pso, iEsc, cjIn, pvIn, cjOut, pvOut));
return 0;
}
{
return TRUE;
}
{
return FALSE;
}
{
return FALSE;
}
{
return FALSE;
}
{
return FALSE;
}
{
return FALSE;
}
)
{
DISPDBG((0, "Experimental %s: %p, %p, %p, %p, %p. %p\n", __FUNCTION__, dhpdev, pHalInfo, pdwNumHeaps, pvmList, pdwNumFourCCCodes, pdwFourCC));
return FALSE;
}
)
{
DISPDBG((0, "Experimental %s: %p, %p, %p, %p\n", __FUNCTION__, dhpdev, pCallBacks, pSurfaceCallBacks, pPaletteCallBacks));
return FALSE;
}
/* Experimental end */
// W2K,XP functions
DRVFN gadrvfn_nt5[] = {
// /* Experimental. */
// { 0x7, (PFN) DrvResetPDEV }, // 0x7
// { 0x5b, (PFN) DrvNineGrid }, // 0x5b
// { 0x2b, (PFN) DrvDestroyFont }, // 0x2b
// { 0x18, (PFN) DrvEscape }, // 0x18
// { 0x4d, (PFN) DrvConnect }, // 0x4d
// { 0x4e, (PFN) DrvDisconnect }, // 0x4e
// { 0x4f, (PFN) DrvReconnect }, // 0x4f
// { 0x50, (PFN) DrvShadowConnect }, // 0x50
// { 0x51, (PFN) DrvShadowDisconnect }, // 0x51
// { 0x3d, (PFN) DrvDDInit }, // 0x3d
// { 0x3b, (PFN) DrvGetDirectDrawInfo }, // 0x3b
// { 0x3c, (PFN) DrvEnableDirectDraw }, // 0x3c
};
// Required hook bits will be set up according to DDI version
#define HOOKS_BMF8BPP gflHooks
#define HOOKS_BMF16BPP gflHooks
#define HOOKS_BMF24BPP gflHooks
#define HOOKS_BMF32BPP gflHooks
HSEMAPHORE ghsemHwBuffer = 0;
/******************************Public*Routine******************************\
* DrvEnableDriver
*
* Enables the driver by retrieving the drivers function table and version.
*
\**************************************************************************/
{
// Engine Version is passed down so future drivers can support previous
// engine versions. A next generation driver can support both the old
// and new engine conventions if told what version of engine it is
// working with. For the first version the driver does nothing with it.
// Set up hook flags to intercept all functions which can generate VRDP orders
// Fill in as much as we can.
if (cj >= sizeof(DRVENABLEDATA))
sizeof(gadrvfn_nt5) / sizeof(DRVFN):
sizeof(gadrvfn_nt4) / sizeof(DRVFN);
// DDI version this driver was targeted for is passed back to engine.
// Future graphic's engine may break calls down to old driver format.
if (!ghsemHwBuffer)
{
}
return(TRUE);
}
/******************************Public*Routine******************************\
* DrvDisableDriver
*
* Tells the driver it is being disabled. Release any resources allocated in
* DrvEnableDriver.
*
\**************************************************************************/
{
DISPDBG((0, "VBoxDisp::DrvDisableDriver called.\n"));
if (ghsemHwBuffer)
{
}
return;
}
/******************************Public*Routine******************************\
* DrvEnablePDEV
*
* DDI function, Enables the Physical Device.
*
* Return Value: device handle to pdev.
*
\**************************************************************************/
{
DISPDBG((0, "VBoxDisp::DrvEnablePDEV called\n"));
// Allocate a physical device structure.
{
DISPDBG((0, "DISP DrvEnablePDEV failed EngAllocMem\n"));
return((DHPDEV) 0);
}
// Save the screen handle in the PDEV.
// Get the current screen mode information. Set up device caps and devinfo.
{
DISPDBG((0,"DISP DrvEnablePDEV failed\n"));
goto error_free;
}
// Initialize the cursor information.
{
// Not a fatal error...
DISPDBG((0, "DrvEnablePDEV failed bInitPointer\n"));
}
// Initialize palette information.
{
DISPDBG((0, "DrvEnablePDEV failed bInitPalette\n"));
goto error_free;
}
// // Start a thread that will process notifications from VMMDev
// if (!bInitNotificationThread(ppdev))
// {
// DISPDBG((0, "DrvEnablePDEV failed bInitNotificationThread\n"));
// goto error_free;
// }
// Copy the devinfo into the engine buffer.
DISPDBG((0, "VBoxDisp::DrvEnablePDEV: sizeof(DEVINFO) = %d, cjDevInfo = %d, alpha = %d\n", sizeof(DEVINFO), cjDevInfo, DevInfo.flGraphicsCaps2 & GCAPS2_ALPHACURSOR));
// @todo seems to be not necessary. these bits are initialized in screen.c DevInfo.flGraphicsCaps |= GCAPS_OPAQUERECT |
// GCAPS_DITHERONREALIZE |
// GCAPS_PALMANAGED |
// GCAPS_ALTERNATEFILL |
// GCAPS_WINDINGFILL |
// GCAPS_MONO_DITHER |
// GCAPS_COLOR_DITHER |
// GCAPS_ASYNCMOVE;
//
// DevInfo.flGraphicsCaps |= GCAPS_DITHERONREALIZE;
// Set the pdevCaps with GdiInfo we have prepared to the list of caps for this
// pdev.
DISPDBG((0, "VBoxDisp::DrvEnablePDEV completed\n"));
// Error case for failure.
return((DHPDEV) 0);
}
/******************************Public*Routine******************************\
* DrvCompletePDEV
*
* Store the HPDEV, the engines handle for this PDEV, in the DHPDEV.
*
\**************************************************************************/
{
DISPDBG((0, "VBoxDisp::DrvCompletePDEV called\n"));
}
/******************************Public*Routine******************************\
* DrvDisablePDEV
*
* Release the resources allocated in DrvEnablePDEV. If a surface has been
* enabled DrvDisableSurface will have already been called.
*
\**************************************************************************/
{
DISPDBG((0, "VBoxDisp::DrvDisablePDEV called\n"));
// vStopNotificationThread ((PPDEV) dhpdev);
/* Free the driver's VBVA resources. */
}
/******************************Public*Routine******************************\
* VOID DrvOffset
*
* DescriptionText
*
\**************************************************************************/
LONG x,
LONG y,
{
// Add back last offset that we subtracted. I could combine the next
// two statements, but I thought this was more clear. It's not
// performance critical anyway.
// Subtract out new offset
return(TRUE);
}
/******************************Public*Routine******************************\
* DrvEnableSurface
*
* Enable the surface for the device. Hook the calls this driver supports.
*
* Return: Handle to the surface if successful, 0 for failure.
*
\**************************************************************************/
{
DISPDBG((0, "DISP DrvEnableSurface called\n"));
// Create engine bitmap around frame buffer.
{
DISPDBG((0, "DISP DrvEnableSurface failed bInitSURF\n"));
return(FALSE);
}
DISPDBG((0, "DISP DrvEnableSurface bInitSURF success\n"));
{
if (!bInit256ColorPalette(ppdev)) {
DISPDBG((0, "DISP DrvEnableSurface failed to init the 8bpp palette\n"));
return(FALSE);
}
}
{
}
{
}
else
{
}
{
DISPDBG((0, "DISP DrvEnableSurface failed EngCreateBitmap\n"));
goto l_Failure;
}
else
{
{
DISPDBG((0, "DISP DrvEnableSurface failed EngAssociateSurface for ScreenBitmap.\n"));
goto l_Failure;
}
else
{
sizl,
{
DISPDBG((0, "DISP DrvEnableSurface failed EngCreateDeviceSurface\n"));
goto l_Failure;
}
else
{
{
DISPDBG((0, "DISP DrvEnableSurface failed EngAssociateSurface for Screen.\n"));
goto l_Failure;
}
else
{
}
}
}
}
return ppdev->hsurfScreen;
return((HSURF)0);
}
/******************************Public*Routine******************************\
* DrvDisableSurface
*
* Free resources allocated by DrvEnableSurface. Release the surface.
*
\**************************************************************************/
{
DISPDBG((0, "VBoxDisp::DrvDisableSurface called\n"));
if (ppdev->psoScreenBitmap)
{
}
if (ppdev->hsurfScreen)
{
}
if (ppdev->hsurfScreenBitmap)
{
}
}
/******************************Public*Routine******************************\
* DrvAssertMode
*
* This asks the device to reset itself to the mode of the pdev passed in.
*
\**************************************************************************/
{
if (bEnable)
{
{
DISPDBG((0, "DISP DrvAssertMode failed bInitSURF\n"));
return (FALSE);
}
{
DISPDBG((0, "DISP DrvAssertMode Screen pointer has changed!!!\n"));
{
DISPDBG((0, "DISP DrvAssertMode failed EngCreateBitmap\n"));
return FALSE;
}
if (ppdev->psoScreenBitmap)
{
}
if (ppdev->hsurfScreenBitmap)
{
}
}
{
DISPDBG((0, "DISP DrvAssertMode failed EngAssociateSurface for ScreenBitmap.\n"));
return FALSE;
}
{
DISPDBG((0, "DISP DrvAssertMode failed EngAssociateSurface for Screen.\n"));
return FALSE;
}
return TRUE;
}
else
{
//
// We must give up the display.
// Call the kernel driver to reset the device to a known state.
//
NULL,
0,
NULL,
0,
&ulReturn))
{
DISPDBG((0, "DISP DrvAssertMode failed IOCTL\n"));
return FALSE;
}
else
{
return TRUE;
}
}
}
/******************************Public*Routine******************************\
* DrvGetModes
*
* Returns the list of available modes for the device.
*
\**************************************************************************/
{
&cbModeSize);
if (cModes == 0)
{
DISPDBG((0, "DrvGetModes failed to get mode information"));
return 0;
}
{
}
else
{
//
// Now copy the information for the supported modes back into the output
// buffer
//
cbOutputSize = 0;
do
{
if (pVideoTemp->Length != 0)
{
if (cOutputModes == 0)
{
break;
}
//
// Zero the entire structure to start off with.
//
//
// Set the name of the device to the name of the DLL.
//
pdm->dmDisplayFlags = 0;
//
// Go to the next DEVMODE entry in the buffer.
//
cOutputModes--;
}
} while (--cModes);
}
return cbOutputSize;
}
{
}
/******************************Public*Routine******************************\
* DrvNotify
*
* Called by GDI to notify us of certain "interesting" events
*
* DN_DEVICE_ORIGIN is used to communicate the X/Y offsets of individual monitors
* when DualView is in effect.
*
\**************************************************************************/
{
DISPDBG((0, "VBoxDisp::DrvNotify called.\n"));
switch(iType)
{
case DN_DEVICE_ORIGIN:
{
}
break;
case DN_DRAWING_BEGIN:
break;
}
}