VBoxDispDriver.cpp revision ad5e8a7dd0aea68e53f3ffd6f8a272c8ecbcacec
/* $Id$ */
/** @file
* VBox XPDM Display driver interface functions
*/
/*
* Copyright (C) 2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "VBoxDisp.h"
#include "VBoxDispMini.h"
#include "VBoxDispDDraw.h"
#include <iprt/initterm.h>
/* Engine version we're running on, set in DrvEnableDriver */
/* NT4 version */
static DRVFN g_aDrvFnTableNT4[] =
{
/* Required functions */
/* Drawing commands */
/* BitBlt's*/
/* Brush related */
/* Pointer related */
/* Misc */
#ifdef VBOX_WITH_DDRAW
#endif
/* g_aDrvFnTableNT4, NT4 specific */
};
/* WIN2K+ version */
static DRVFN g_aDrvFnTableNT5[] =
{
/* Required functions */
/* Drawing commands */
/* BitBlt's*/
/* Brush related */
/* Pointer related */
/* Misc */
#ifdef VBOX_WITH_DDRAW
#endif
/* g_aDrvFnTableNT5, NT5 specific */
#ifdef VBOX_WITH_DDRAW
#endif
};
#ifdef VBOX_WITH_CROGL
typedef struct
{
} OPENGL_INFO, *POPENGL_INFO;
#endif
{
return 0;
}
{
while (*pwcs!=*L"")
{
{
break;
}
pwcs++;
pwcd++;
cnt ++;
}
{
}
}
do { \
} while (0)
do { \
_font.lfEscapement = 0; \
_font.lfOrientation = 0; \
_font.lfUnderline = 0; \
_font.lfStrikeOut = 0; \
} while (0)
static int VBoxDispInitDevice(PVBOXDISPDEV pDev, DEVMODEW *pdm, GDIINFO *pGdiInfo, DEVINFO *pDevInfo)
{
int rc;
LOGF_ENTER();
/* Get a list of supported modes by both miniport and display driver */
/* Check if requested mode is available in the list */
&& (pdm->dmBitsPerPel==0)
&& (pdm->dmPelsWidth==0)
&& (pdm->dmPelsHeight==0)
&& (pdm->dmDisplayFrequency==0))
{
/* Special case for NT4, just return default(first) mode */
}
else
{
for (; i<cModes; ++i)
{
{
break;
}
}
}
if (i>=cModes)
{
WARN(("can't support requested mode %dx%d@%dbpp(%dHz)!",
return VERR_NOT_SUPPORTED;
}
LOG(("match for requested mode %dx%d@%dbpp(%dHz)",
selectedMode.VisScreenWidth, selectedMode.VisScreenHeight, selectedMode.BitsPerPlane, selectedMode.Frequency));
/* Update private device info with mode information */
/* Fill GDIINFO structure */
{
}
/* note: ulAspectXY should be square root of sum of squares of x and y aspects */
/* search for "styled cosmetic lines" on msdn for more info */
/* @todo: might want to implement IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES in miniport driver
* and query host for this info there
*/
{
case 8:
{
break;
}
case 16:
{
break;
}
case 24:
{
break;
}
case 32:
{
break;
}
}
/* 0 means BitBlt's are accelerated by driver */
pGdiInfo->ulBltAlignment = 0;
/* Fill DEVINFO structure */
#ifdef VBOX_WITH_DDRAW
#endif
pDevInfo->hpalDefault = 0;
pDevInfo->flGraphicsCaps2 = 0;
{
case 8:
{
break;
}
case 16:
{
break;
}
case 24:
{
break;
}
case 32:
{
break;
}
}
LOGF_LEAVE();
return rc;
}
/* Display Driver entry point,
* Returns DDI version number and callbacks supported by driver.
*/
{
/*@todo: can't link with hal.lib
int irc = RTR0Init(0);
if (RT_FAILURE(irc))
{
LOGREL(("failed to init IPRT (rc=%#x)", irc));
return FALSE;
}
*/
/* Driver can't work if we can't fill atleast first 3 fields in passed PDRVENABLEDATA */
{
return FALSE;
}
/* Report driver DDI version and appropriate callbacks table based on engine DDI */
{
/* WIN2K and above */
}
else
{
/* NT4_SP3 and below*/
}
LOGF_LEAVE();
return TRUE;
}
/* Free all resources allocated in DrvEnableDriver */
{
LOGF_ENTER();
/* Intentionally left blank */
LOGF_LEAVE();
return;
}
* Note: If we fail here we'd be asked to enter 800x600@4bpp mode later in VBoxDispDrvEnablePDEV.
*/
{
int rc;
LOGF_ENTER();
VBOX_WARNRC_RETV(rc, 0);
if (!pdm) /* return size of buffer required to store all supported modes */
{
LOGF_LEAVE();
}
{
pdm->dmDriverExtra = 0;
pdm->dmDisplayFlags = 0;
}
LOGF_LEAVE();
}
/* First function which is called after entry point, provides info about device to GDI.
* Returns pointer to our driver private info structure which would be passed by GDI to our other callbacks.
*/
{
int rc;
/* Next 3 are only used for printer drivers */
LOGF_ENTER();
if (!pDev)
{
WARN(("EngAllocMem failed!\n"));
return NULL;
}
/* Initialize device structure and query miniport to fill device and gdi infos */
if (RT_FAILURE(rc))
{
return NULL;
}
/* Initialize mouse pointer caps */
if (RT_FAILURE(rc))
{
}
/* Initialize palette */
if (RT_FAILURE(rc))
{
return NULL;
}
{
}
/* Copy gathered info to supplied buffers */
LOGF_LEAVE();
}
/* Called to provide us GDI handle for our device, which we should use later for GDI calls */
{
LOGF_ENTER();
LOGF_LEAVE();
}
/* Called to free resources allocated for device in VBoxDispDrvEnablePDEV */
{
LOGF_ENTER();
LOGF_LEAVE();
}
/* Called to create and associate surface with device */
{
int rc;
LOGF_ENTER();
/* Switch device to mode requested in VBoxDispDrvEnablePDEV */
/* Map fb and vram */
/* Clear mapped memory, to avoid garbage while video mode is switching */
/* @todo: VIDEO_MODE_NO_ZERO_MEMORY does nothing in miniport's IOCTL_VIDEO_SET_CURRENT_MODE*/
/* Allocate memory for pointer attrs */
/* Init VBVA */
/* Enable VBVA */
{
{
VBVABUFFER *pVBVA = (VBVABUFFER *)((uint8_t *)pDev->memInfo.VideoRamBase+pDev->layout.offVBVABuffer);
}
}
/* Inform host */
{
}
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif
/* Set device palette if needed */
{
}
/* Create GDI managed bitmap, which resides in our framebuffer memory */
{
case 8:
{
break;
}
case 16:
{
break;
}
case 24:
{
break;
}
case 32:
{
break;
}
}
{
WARN(("EngCreateBitmap failed!"));
return NULL;
}
/* Create device-managed surface */
{
WARN(("EngCreateDeviceSurface failed!"));
return NULL;
}
/* Associate created surface with our device */
{
WARN(("EngAssociateSurface failed!"));
return NULL;
}
LOGF_LEAVE();
}
{
LOGF_ENTER();
{
}
{
}
{
}
int rc;
LOGF_LEAVE();
}
{
LOGF_ENTER();
{
{
{
}
{
}
}
}
LOGF_LEAVE();
return bRc;
}
{
LOGF_ENTER();
/* There is no EngDitherColor on NT4, so take the easy path and tell the graphics
* engine to create a halftone approximation.
*/
rc = DCR_HALFTONE;
LOGF_LEAVE();
return rc;
}
/* Called to reset device to default mode or to mode specified with dhpdev */
{
int rc;
LOGF_ENTER();
if (!bEnable)
{
LOGF(("!bEnable"));
#ifdef VBOX_WITH_VIDEOHWACCEL
/* tells we can not process host commands any more and ensures that
* we've completed processing of the host VHWA commands
*/
#endif
/* disable VBVA */
{
}
/* reset the device to default mode */
}
else
{
LOGF(("bEnable"));
/* switch device to previous pDev mode */
/* enable VBVA */
{
{
VBVABUFFER *pVBVA = (VBVABUFFER *)((uint8_t *)pDev->memInfo.VideoRamBase+pDev->layout.offVBVABuffer);
}
}
/* inform host */
{
}
#ifdef VBOX_WITH_VIDEOHWACCEL
/* tells we can process host commands */
#endif
/* Associate back GDI bitmap residing in our framebuffer memory with GDI's handle to our device */
{
return FALSE;
}
/* Associate device managed surface with GDI's handle to our device */
{
return FALSE;
}
}
LOGF_LEAVE();
return TRUE;
}
ULONG APIENTRY VBoxDispDrvEscape(SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
LOGF_ENTER();
switch (iEsc)
{
#ifdef VBOX_WITH_CROGL
case OPENGL_GETINFO:
{
{
LOG(("OPENGL_GETINFO ok"));
return cjOut;
}
else
{
WARN(("OPENGL_GETINFO invalid parms"));
return 0;
}
}
case QUERYESCSUPPORT:
{
{
if (nEscapeQuery==OPENGL_GETINFO)
{
LOG(("QUERYESCSUPPORT OPENGL_GETINFO"));
return 1;
}
else
{
return 0;
}
}
else
{
WARN(("QUERYESCSUPPORT invalid parms"));
return 0;
}
}
#endif
case VBOXESC_ISVRDPACTIVE:
{
{
LOGF(("VBOXESC_ISVRDPACTIVE: 1"));
return 1;
}
LOGF(("VBOXESC_ISVRDPACTIVE: 0"));
return 0;
}
case VBOXESC_SETVISIBLEREGION:
{
LOGF(("VBOXESC_SETVISIBLEREGION"));
if (cjIn >= sizeof(RGNDATAHEADER)
&& pvIn
{
DWORD i;
int rc;
if (!pRTRect)
{
break;
}
{
LOG(("New visible rectangle (%d,%d) (%d,%d)",
}
if (RT_SUCCESS(rc))
{
LOGF_LEAVE();
return 1;
}
}
else
{
if (pvIn)
{
WARN(("check failed rdh.dwSize=%x iType=%d size=%d expected size=%d",
}
}
break;
}
default:
{
}
}
LOGF_LEAVE();
return 0;
}
#define FB_OFFSET(_dev, _x, _y) ((_y)*pDev->mode.lScanlineStride) + ((_x)*((pDev->mode.ulBitsPerPel+1)/8))
/* Obsolete, NT4 specific. Called to set display offset in virtual desktop */
{
LOGF_LEAVE();
return TRUE;
}
/* Called to notify driver about various events */
{
LOGF_ENTER();
switch (iType)
{
case DN_DEVICE_ORIGIN:
{
/*device origin in dualview*/
if (pOrg)
{
LOG(("DN_DEVICE_ORIGIN (pso=%p, pDev[%d]=%p) old=%d,%d new=%d,%d",
{
/* Inform host about display change */
}
}
else
{
WARN(("DN_DEVICE_ORIGIN pvData==NULL"));
}
break;
}
case DN_DRAWING_BEGIN:
{
/*first drawing op is about to happen for this device*/
break;
}
default:
{
}
}
LOGF_LEAVE();
return;
}