VBoxDispDriver.cpp revision c42ed5e39ad15ddf3d0a1add14adcea437f2cb6f
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * VBox XPDM Display driver interface functions
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Copyright (C) 2011-2012 Oracle Corporation
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * available from http://www.virtualbox.org. This file is free software;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * General Public License (GPL) as published by the Free Software
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Engine version we're running on, set in DrvEnableDriver */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic ULONG g_EngineVersionDDI = DDI_DRIVER_VERSION_NT4;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Callback function supported by our driver, stored in index/address pairs (see winddi.h) */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* NT4 version */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Required functions */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvEnablePDEV, (PFN) VBoxDispDrvEnablePDEV },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvCompletePDEV, (PFN) VBoxDispDrvCompletePDEV },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvDisablePDEV, (PFN) VBoxDispDrvDisablePDEV },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvEnableSurface, (PFN) VBoxDispDrvEnableSurface },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvDisableSurface, (PFN) VBoxDispDrvDisableSurface },
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync {INDEX_DrvAssertMode, (PFN) VBoxDispDrvAssertMode },
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync /* Drawing commands */
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync {INDEX_DrvStrokePath, (PFN) VBoxDispDrvStrokePath },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvSaveScreenBits, (PFN) VBoxDispDrvSaveScreenBits },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* BitBlt's*/
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvStretchBlt, (PFN) VBoxDispDrvStretchBlt, },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* Brush related */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvRealizeBrush, (PFN) VBoxDispDrvRealizeBrush },
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {INDEX_DrvDitherColor, (PFN) VBoxDispDrvDitherColor },
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Pointer related */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {INDEX_DrvSetPointerShape, (PFN) VBoxDispDrvSetPointerShape },
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {INDEX_DrvMovePointer, (PFN) VBoxDispDrvMovePointer },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvDisableDriver, (PFN) VBoxDispDrvDisableDriver },
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {INDEX_DrvSetPalette, (PFN) VBoxDispDrvSetPalette },
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {INDEX_DrvGetDirectDrawInfo, (PFN) VBoxDispDrvGetDirectDrawInfo},
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvEnableDirectDraw, (PFN) VBoxDispDrvEnableDirectDraw },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvDisableDirectDraw, (PFN) VBoxDispDrvDisableDirectDraw},
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* g_aDrvFnTableNT4, NT4 specific */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvOffset, (PFN) VBoxDispDrvOffset } /*Obsolete*/
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* WIN2K+ version */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Required functions */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvEnablePDEV, (PFN) VBoxDispDrvEnablePDEV },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvCompletePDEV, (PFN) VBoxDispDrvCompletePDEV },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvDisablePDEV, (PFN) VBoxDispDrvDisablePDEV },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvEnableSurface, (PFN) VBoxDispDrvEnableSurface },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvDisableSurface, (PFN) VBoxDispDrvDisableSurface },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvAssertMode, (PFN) VBoxDispDrvAssertMode },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* Drawing commands */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvStrokePath, (PFN) VBoxDispDrvStrokePath },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvSaveScreenBits, (PFN) VBoxDispDrvSaveScreenBits },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* BitBlt's*/
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvStretchBlt, (PFN) VBoxDispDrvStretchBlt, },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* Brush related */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvRealizeBrush, (PFN) VBoxDispDrvRealizeBrush },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvDitherColor, (PFN) VBoxDispDrvDitherColor },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* Pointer related */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvSetPointerShape, (PFN) VBoxDispDrvSetPointerShape },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvMovePointer, (PFN) VBoxDispDrvMovePointer },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvDisableDriver, (PFN) VBoxDispDrvDisableDriver },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvSetPalette, (PFN) VBoxDispDrvSetPalette },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvGetDirectDrawInfo, (PFN) VBoxDispDrvGetDirectDrawInfo},
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvEnableDirectDraw, (PFN) VBoxDispDrvEnableDirectDraw },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvDisableDirectDraw, (PFN) VBoxDispDrvDisableDirectDraw},
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* g_aDrvFnTableNT5, NT5 specific */
ffb50166c9adb4ae583b914d405197035cf890advboxsync {INDEX_DrvDeriveSurface, (PFN) VBoxDispDrvDeriveSurface }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsynctypedef struct
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVOID _wcsncpy(WCHAR *pwcd, WCHAR *pwcs, ULONG dstsize)
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync } while (0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#define VBOXDISPMAKELOGFONTW(_font, _w, _h, _weight, _clip, _quality, _pitch, _name) \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memset(_font.lfFaceName, 0, sizeof(_font.lfFaceName)); \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync } while (0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic int VBoxDispInitDevice(PVBOXDISPDEV pDev, DEVMODEW *pdm, GDIINFO *pGdiInfo, DEVINFO *pDevInfo)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VIDEO_MODE_INFORMATION *pModesTable = NULL, selectedMode;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memset(&selectedMode, 0, sizeof(VIDEO_MODE_INFORMATION));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Get a list of supported modes by both miniport and display driver */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPGetVideoModes(pDev->hDriver, &pModesTable, &cModes);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Check if requested mode is available in the list */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Special case for NT4, just return default(first) mode */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(&selectedMode, &pModesTable[0], sizeof(VIDEO_MODE_INFORMATION));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync for (; i<cModes; ++i)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ((pdm->dmBitsPerPel == (pModesTable[i].BitsPerPlane * pModesTable[i].NumberOfPlanes))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && (pdm->dmPelsWidth == pModesTable[i].VisScreenWidth)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && (pdm->dmPelsHeight == pModesTable[i].VisScreenHeight)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && (pdm->dmDisplayFrequency == pModesTable[i].Frequency))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(&selectedMode, &pModesTable[i], sizeof(VIDEO_MODE_INFORMATION));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("can't support requested mode %dx%d@%dbpp(%dHz)!",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmPelsWidth, pdm->dmPelsHeight, pdm->dmBitsPerPel, pdm->dmDisplayFrequency));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync selectedMode.VisScreenWidth, selectedMode.VisScreenHeight, selectedMode.BitsPerPlane, selectedMode.Frequency));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Update private device info with mode information */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.ulHeight = selectedMode.VisScreenHeight;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.ulBitsPerPel = selectedMode.BitsPerPlane * selectedMode.NumberOfPlanes;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.lScanlineStride = selectedMode.ScreenStride;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.ulPaletteShift = (pDev->mode.ulBitsPerPel==8) ? (8-selectedMode.NumberRedBits) : 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Fill GDIINFO structure */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulVersion = (g_EngineVersionDDI<DDI_DRIVER_VERSION_NT5) ? GDI_DRIVER_VERSION:0x5000;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulNumColors = (pDev->mode.ulBitsPerPel==8) ? 20 : ((ULONG)(-1));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("requested logical pixel res %d isn't 96", pdm->dmLogPixels));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulDACGreen = selectedMode.NumberGreenBits;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* note: ulAspectXY should be square root of sum of squares of x and y aspects */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* search for "styled cosmetic lines" on msdn for more info */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulNumPalReg = (pDev->mode.ulBitsPerPel==8) ? (1<<pDev->mode.ulBitsPerPel) : 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* @todo: might want to implement IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES in miniport driver
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * and query host for this info there
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPSETCIEC(pGdiInfo->ciDevice.Red, 6700, 3300, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPSETCIEC(pGdiInfo->ciDevice.Green, 2100, 7100, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPSETCIEC(pGdiInfo->ciDevice.Blue, 1400, 800, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPSETCIEC(pGdiInfo->ciDevice.AlignmentWhite, 3127, 3290, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPSETCIEC(pGdiInfo->ciDevice.Magenta, 0, 0, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPSETCIEC(pGdiInfo->ciDevice.Yellow, 0, 0, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* 0 means BitBlt's are accelerated by driver */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulPhysicalPixelCharacteristics = PPC_UNDEFINED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Fill DEVINFO structure */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 16, 7, FW_BOLD, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH, L"System");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 12, 9, FW_NORMAL, CLIP_STROKE_PRECIS, PROOF_QUALITY, VARIABLE_PITCH, L"MS Sans Serif");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 12, 9, FW_NORMAL, CLIP_STROKE_PRECIS, PROOF_QUALITY, FIXED_PITCH, L"Courier");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->flGraphicsCaps |= GCAPS_PALMANAGED|GCAPS_COLOR_DITHER;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Display Driver entry point,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Returns DDI version number and callbacks supported by driver.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncBOOL DrvEnableDriver(ULONG iEngineVersion, ULONG cj, PDRVENABLEDATA pded)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*@todo: can't link with hal.lib
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int irc = RTR0Init(0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_FAILURE(irc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGREL(("failed to init IPRT (rc=%#x)", irc));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF(("iEngineVersion=%#08X, cj=%d", iEngineVersion, cj));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Driver can't work if we can't fill atleast first 3 fields in passed PDRVENABLEDATA */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("cj<%d, terminating\n", sizeof(DRVENABLEDATA)));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Report driver DDI version and appropriate callbacks table based on engine DDI */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* WIN2K and above */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* NT4_SP3 and below*/
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Free all resources allocated in DrvEnableDriver */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Intentionally left blank */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Returns video modes supported by our device/driver
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Note: If we fail here we'd be asked to enter 800x600@4bpp mode later in VBoxDispDrvEnablePDEV.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncULONG APIENTRY VBoxDispDrvGetModes(HANDLE hDriver, ULONG cjSize, DEVMODEW *pdm)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPGetVideoModes(hDriver, &pModesTable, &cModes);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pdm) /* return size of buffer required to store all supported modes */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync for (mode=0; mode<cModes && mode<cMaxNodes; ++mode, ++pdm)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(pdm->dmDeviceName, VBOXDISP_DEVICE_NAME, sizeof(VBOXDISP_DEVICE_NAME));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmBitsPerPel = pModesTable[mode].NumberOfPlanes*pModesTable[mode].BitsPerPlane;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmPelsWidth = pModesTable[mode].VisScreenWidth;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmPelsHeight = pModesTable[mode].VisScreenHeight;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmDisplayFrequency = pModesTable[mode].Frequency;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY|DM_DISPLAYFLAGS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* First function which is called after entry point, provides info about device to GDI.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Returns pointer to our driver private info structure which would be passed by GDI to our other callbacks.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVBoxDispDrvEnablePDEV(DEVMODEW *pdm, LPWSTR pwszLogAddress, ULONG cPat, HSURF *phsurfPatterns,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Next 3 are only used for printer drivers */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev = (PVBOXDISPDEV) EngAllocMem(FL_ZERO_MEMORY, sizeof(VBOXDISPDEV), MEM_ALLOC_TAG);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPQueryRegistryFlags(hDriver, &ulRegistryFlags);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->bBitmapCacheDisabled = (ulRegistryFlags & VBOXVIDEO_REGISTRY_FLAGS_DISABLE_BITMAP_CACHE) != 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOG(("Bitmap cache %s", pDev->bBitmapCacheDisabled? "disabled": "enabled"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Initialize device structure and query miniport to fill device and gdi infos */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispInitDevice(pDev, pdm, &gdiInfo, &devInfo);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Initialize mouse pointer caps */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Initialize palette */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Copy gathered info to supplied buffers */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(pdevcaps, &gdiInfo, min(sizeof(GDIINFO), cjCaps));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(pdi, &devInfo, min(sizeof(DEVINFO), cjDevInfo));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Called to provide us GDI handle for our device, which we should use later for GDI calls */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVOID APIENTRY VBoxDispDrvCompletePDEV(DHPDEV dhpdev, HDEV hdev)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Called to free resources allocated for device in VBoxDispDrvEnablePDEV */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Called to create and associate surface with device */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncHSURF APIENTRY VBoxDispDrvEnableSurface(DHPDEV dhpdev)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Switch device to mode requested in VBoxDispDrvEnablePDEV */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPSetCurrentMode(pDev->hDriver, pDev->mode.ulIndex);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Map fb and vram */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Clear mapped memory, to avoid garbage while video mode is switching */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* @todo: VIDEO_MODE_NO_ZERO_MEMORY does nothing in miniport's IOCTL_VIDEO_SET_CURRENT_MODE*/
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memset(pDev->memInfo.FrameBufferBase, 0, pDev->mode.ulHeight * abs(pDev->mode.lScanlineStride));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Allocate memory for pointer attrs */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Init VBVA */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Enable VBVA */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->mode.ulBitsPerPel==16 || pDev->mode.ulBitsPerPel==24 || pDev->mode.ulBitsPerPel==32)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBVABUFFER *pVBVA = (VBVABUFFER *)((uint8_t *)pDev->memInfo.VideoRamBase+pDev->layout.offVBVABuffer);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->hgsmi.bSupported = VBoxVBVAEnable(&pDev->vbvaCtx, &pDev->hgsmi.ctx, pVBVA, -1);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LogRel(("VBoxDisp[%d]: VBVA %senabled\n", pDev->iDevice, pDev->hgsmi.bSupported? "":"not "));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Inform host */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxHGSMIProcessDisplayInfo(&pDev->hgsmi.ctx, pDev->iDevice, pDev->orgDev.x, pDev->orgDev.y,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 0, abs(pDev->mode.lScanlineStride), pDev->mode.ulWidth, pDev->mode.ulHeight,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync (uint16_t)pDev->mode.ulBitsPerPel, VBVA_SCREEN_F_ACTIVE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Set device palette if needed */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Create GDI managed bitmap, which resides in our framebuffer memory */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->surface.hBitmap = EngCreateBitmap(size, pDev->mode.lScanlineStride, iFormat,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->surface.psoBitmap = EngLockSurface((HSURF)pDev->surface.hBitmap);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Create device-managed surface */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->surface.hSurface = EngCreateDeviceSurface((DHSURF)pDev, size, iFormat);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync FLONG flHooks = HOOK_BITBLT|HOOK_TEXTOUT|HOOK_FILLPATH|HOOK_COPYBITS|HOOK_STROKEPATH|HOOK_LINETO|
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Associate created surface with our device */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!EngAssociateSurface(pDev->surface.hSurface, pDev->hDevGDI, flHooks))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOG(("Created surface %p for physical device %p", pDev->surface.hSurface, pDev));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVOID APIENTRY VBoxDispDrvDisableSurface(DHPDEV dhpdev)
ffb50166c9adb4ae583b914d405197035cf890advboxsyncVBoxDispDrvRealizeBrush(BRUSHOBJ *pbo, SURFOBJ *psoTarget, SURFOBJ *psoPattern, SURFOBJ *psoMask,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PVBOXDISPDEV pDev = (PVBOXDISPDEV)psoTarget->dhpdev;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->vbvaCtx.pVBVA && (pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents & VBVA_F_MODE_ENABLED))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents & VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents &= ~VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents & VBVA_F_MODE_VRDP)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bRc = vrdpDrvRealizeBrush(pbo, psoTarget, psoPattern, psoMask, pxlo, iHatch);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncULONG APIENTRY VBoxDispDrvDitherColor(DHPDEV dhpdev, ULONG iMode, ULONG rgb, ULONG *pul)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* There is no EngDitherColor on NT4, so take the easy path and tell the graphics
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * engine to create a halftone approximation.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Called to reset device to default mode or to mode specified with dhpdev */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncBOOL APIENTRY VBoxDispDrvAssertMode(DHPDEV dhpdev, BOOL bEnable)
ffb50166c9adb4ae583b914d405197035cf890advboxsync /* tells we can not process host commands any more and ensures that
ffb50166c9adb4ae583b914d405197035cf890advboxsync * we've completed processing of the host VHWA commands
ffb50166c9adb4ae583b914d405197035cf890advboxsync /* disable VBVA */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxVBVADisable(&pDev->vbvaCtx, &pDev->hgsmi.ctx, -1);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* reset the device to default mode */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* switch device to previous pDev mode */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPSetCurrentMode(pDev->hDriver, pDev->mode.ulIndex);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* enable VBVA */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->mode.ulBitsPerPel==16 || pDev->mode.ulBitsPerPel==24 || pDev->mode.ulBitsPerPel==32)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBVABUFFER *pVBVA = (VBVABUFFER *)((uint8_t *)pDev->memInfo.VideoRamBase+pDev->layout.offVBVABuffer);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pDev->hgsmi.bSupported = VBoxVBVAEnable(&pDev->vbvaCtx, &pDev->hgsmi.ctx, pVBVA, -1);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LogRel(("VBoxDisp[%d]: VBVA %senabled\n", pDev->iDevice, pDev->hgsmi.bSupported? "":"not "));
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync /* inform host */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxHGSMIProcessDisplayInfo(&pDev->hgsmi.ctx, pDev->iDevice, pDev->orgDev.x, pDev->orgDev.y,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 0, abs(pDev->mode.lScanlineStride), pDev->mode.ulWidth, pDev->mode.ulHeight,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync (uint16_t)pDev->mode.ulBitsPerPel, VBVA_SCREEN_F_ACTIVE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* tells we can process host commands */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Associate back GDI bitmap residing in our framebuffer memory with GDI's handle to our device */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!EngAssociateSurface((HSURF)pDev->surface.hBitmap, pDev->hDevGDI, 0))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Associate device managed surface with GDI's handle to our device */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!EngAssociateSurface(pDev->surface.hSurface, pDev->hDevGDI, pDev->flDrawingHooks))
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsyncULONG APIENTRY VBoxDispDrvEscape(SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOG(("QUERYESCSUPPORT unsupported query %d", nEscapeQuery));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (pDev && pDev->vbvaCtx.pVBVA && pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents&VBVA_F_MODE_VRDP)
0dd3967035b8a02985920baa57f948dc542b9388vboxsync && cjIn == cRects * (uint64_t)sizeof(RECT) + sizeof(RGNDATAHEADER))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /** @todo this whole conversion thing could maybe be skipped
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * since RTRECT matches the RECT layout. */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync AssertCompileMembersSameSizeAndOffset(RTRECT, xLeft, RECT, left);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync AssertCompileMembersSameSizeAndOffset(RTRECT, xBottom, RECT, bottom);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync AssertCompileMembersSameSizeAndOffset(RTRECT, xRight, RECT, right);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync AssertCompileMembersSameSizeAndOffset(RTRECT, xTop, RECT, top);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync rc = VBoxDispMPSetVisibleRegion(pDev->hDriver, (PRTRECT)&lpRgnData->Buffer[0], cRects);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pRTRect = (PRTRECT) EngAllocMem(0, cRects*sizeof(RTRECT), MEM_ALLOC_TAG);
0dd3967035b8a02985920baa57f948dc542b9388vboxsync WARN(("failed to allocate %d bytes", cRects*sizeof(RTRECT)));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync for (i = 0; i < cRects; ++i)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pRect[i].left, pRect[i].bottom, pRect[i].right, pRect[i].top));
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync rc = VBoxDispMPSetVisibleRegion(pDev->hDriver, pRTRect, cRects);
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync WARN(("check failed rdh.dwSize=%x iType=%d size=%d expected size=%d",
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync lpRgnData->rdh.nCount * sizeof(RECT) + sizeof(RGNDATAHEADER)));
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync DWORD dwrc = EngDeviceIoControl(pDev->hDriver, IOCTL_VIDEO_VBOX_ISANYX, NULL, 0,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (dwrc == NO_ERROR && cbReturned == sizeof (uint32_t))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync WARN(("EngDeviceIoControl failed, dwrc(%d), cbReturned(%d)", dwrc, cbReturned));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#define FB_OFFSET(_dev, _x, _y) ((_y)*pDev->mode.lScanlineStride) + ((_x)*((pDev->mode.ulBitsPerPel+1)/8))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Obsolete, NT4 specific. Called to set display offset in virtual desktop */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsyncBOOL APIENTRY VBoxDispDrvOffset(SURFOBJ* pso, LONG x, LONG y, FLONG flReserved)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->memInfo.FrameBufferBase = ((BYTE*)pDev->memInfo.VideoRamBase) + pDev->layout.offFramebuffer
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Called to notify driver about various events */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsyncVOID APIENTRY VBoxDispDrvNotify(SURFOBJ *pso, ULONG iType, PVOID pvData)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /*device origin in dualview*/
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync LOG(("DN_DEVICE_ORIGIN (pso=%p, pDev[%d]=%p) old=%d,%d new=%d,%d",
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pso, pDev->iDevice, pDev, pDev->orgDev.x, pDev->orgDev.y, pOrg->x, pOrg->y));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (pDev->orgDev.x!=pOrg->x || pDev->orgDev.y!=pOrg->y)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Inform host about display change */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync VBoxHGSMIProcessDisplayInfo(&pDev->hgsmi.ctx, pDev->iDevice, pDev->orgDev.x, pDev->orgDev.y,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync (uint16_t)pDev->mode.ulBitsPerPel, VBVA_SCREEN_F_ACTIVE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*first drawing op is about to happen for this device*/