VBoxDispDriver.cpp revision c42ed5e39ad15ddf3d0a1add14adcea437f2cb6f
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* $Id$ */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/** @file
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * VBox XPDM Display driver interface functions
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/*
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Copyright (C) 2011-2012 Oracle Corporation
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
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 */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include "VBoxDisp.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include "VBoxDispMini.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include "VBoxDispDDraw.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <iprt/initterm.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Engine version we're running on, set in DrvEnableDriver */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic ULONG g_EngineVersionDDI = DDI_DRIVER_VERSION_NT4;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Callback function supported by our driver, stored in index/address pairs (see winddi.h) */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* NT4 version */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsyncstatic DRVFN g_aDrvFnTableNT4[] =
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Required functions */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvGetModes, (PFN) VBoxDispDrvGetModes },
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_DrvLineTo, (PFN) VBoxDispDrvLineTo },
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync {INDEX_DrvStrokePath, (PFN) VBoxDispDrvStrokePath },
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync {INDEX_DrvFillPath, (PFN) VBoxDispDrvFillPath },
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync {INDEX_DrvPaint, (PFN) VBoxDispDrvPaint },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvTextOut, (PFN) VBoxDispDrvTextOut },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvSaveScreenBits, (PFN) VBoxDispDrvSaveScreenBits },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* BitBlt's*/
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvBitBlt, (PFN) VBoxDispDrvBitBlt },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvStretchBlt, (PFN) VBoxDispDrvStretchBlt, },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvCopyBits, (PFN) VBoxDispDrvCopyBits },
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 /* Misc */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvDisableDriver, (PFN) VBoxDispDrvDisableDriver },
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {INDEX_DrvSetPalette, (PFN) VBoxDispDrvSetPalette },
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {INDEX_DrvEscape, (PFN) VBoxDispDrvEscape },
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#ifdef VBOX_WITH_DDRAW
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {INDEX_DrvGetDirectDrawInfo, (PFN) VBoxDispDrvGetDirectDrawInfo},
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvEnableDirectDraw, (PFN) VBoxDispDrvEnableDirectDraw },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvDisableDirectDraw, (PFN) VBoxDispDrvDisableDirectDraw},
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* g_aDrvFnTableNT4, NT4 specific */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvOffset, (PFN) VBoxDispDrvOffset } /*Obsolete*/
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* WIN2K+ version */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic DRVFN g_aDrvFnTableNT5[] =
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Required functions */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvGetModes, (PFN) VBoxDispDrvGetModes },
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_DrvLineTo, (PFN) VBoxDispDrvLineTo },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvStrokePath, (PFN) VBoxDispDrvStrokePath },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvFillPath, (PFN) VBoxDispDrvFillPath },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvPaint, (PFN) VBoxDispDrvPaint },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvTextOut, (PFN) VBoxDispDrvTextOut },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvSaveScreenBits, (PFN) VBoxDispDrvSaveScreenBits },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* BitBlt's*/
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvBitBlt, (PFN) VBoxDispDrvBitBlt },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvStretchBlt, (PFN) VBoxDispDrvStretchBlt, },
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {INDEX_DrvCopyBits, (PFN) VBoxDispDrvCopyBits },
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 /* Misc */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvDisableDriver, (PFN) VBoxDispDrvDisableDriver },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvSetPalette, (PFN) VBoxDispDrvSetPalette },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvEscape, (PFN) VBoxDispDrvEscape },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_DDRAW
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvGetDirectDrawInfo, (PFN) VBoxDispDrvGetDirectDrawInfo},
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvEnableDirectDraw, (PFN) VBoxDispDrvEnableDirectDraw },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {INDEX_DrvDisableDirectDraw, (PFN) VBoxDispDrvDisableDirectDraw},
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* g_aDrvFnTableNT5, NT5 specific */
ffb50166c9adb4ae583b914d405197035cf890advboxsync {INDEX_DrvNotify, (PFN) VBoxDispDrvNotify },
ffb50166c9adb4ae583b914d405197035cf890advboxsync#ifdef VBOX_WITH_DDRAW
ffb50166c9adb4ae583b914d405197035cf890advboxsync {INDEX_DrvDeriveSurface, (PFN) VBoxDispDrvDeriveSurface }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync};
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_CROGL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsynctypedef struct
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DWORD dwVersion;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DWORD dwDriverVersion;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WCHAR szDriverName[256];
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync} OPENGL_INFO, *POPENGL_INFO;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncRT_C_DECLS_BEGIN
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncULONG __cdecl DbgPrint(PCH pszFormat, ...)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_list args;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_start(args, pszFormat);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTLogBackdoorPrintfV(pszFormat, args);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync va_end(args);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncRT_C_DECLS_END
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVOID _wcsncpy(WCHAR *pwcd, WCHAR *pwcs, ULONG dstsize)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ULONG cnt=0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync while (*pwcs!=*L"")
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (cnt>=dstsize)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *pwcd = *pwcs;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pwcs++;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pwcd++;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync cnt ++;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync if (cnt<dstsize)
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync {
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync memset(pwcd, 0, (dstsize-cnt) * sizeof(WCHAR));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#define VBOXDISPSETCIEC(_ciec, _x, _y, _lum) \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync do { \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _ciec.x = _x; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _ciec.y = _y; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _ciec.Y = _lum; \
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync } while (0)
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#define VBOXDISPMAKELOGFONTW(_font, _w, _h, _weight, _clip, _quality, _pitch, _name) \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync do { \
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync _font.lfHeight = _w; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfWidth = _h; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfEscapement = 0; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfOrientation = 0; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfWeight = _weight; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfItalic = 0; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfUnderline = 0; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfStrikeOut = 0; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfCharSet = ANSI_CHARSET; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfOutPrecision = OUT_DEFAULT_PRECIS; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfClipPrecision = _clip; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfQuality = _quality; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync _font.lfPitchAndFamily = (_pitch) | FF_DONTCARE; \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memset(_font.lfFaceName, 0, sizeof(_font.lfFaceName)); \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(_font.lfFaceName, _name, sizeof(_name)); \
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync } while (0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic int VBoxDispInitDevice(PVBOXDISPDEV pDev, DEVMODEW *pdm, GDIINFO *pGdiInfo, DEVINFO *pDevInfo)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VIDEO_MODE_INFORMATION *pModesTable = NULL, selectedMode;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ULONG cModes, i=0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memset(&selectedMode, 0, sizeof(VIDEO_MODE_INFORMATION));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Get a list of supported modes by both miniport and display driver */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPGetVideoModes(pDev->hDriver, &pModesTable, &cModes);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC_RETRC(rc);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Check if requested mode is available in the list */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if ((g_EngineVersionDDI < DDI_DRIVER_VERSION_NT5)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && (pdm->dmBitsPerPel==0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && (pdm->dmPelsWidth==0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && (pdm->dmPelsHeight==0)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync && (pdm->dmDisplayFrequency==0))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Special case for NT4, just return default(first) mode */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(&selectedMode, &pModesTable[0], sizeof(VIDEO_MODE_INFORMATION));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync for (; i<cModes; ++i)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
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 {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(&selectedMode, &pModesTable[i], sizeof(VIDEO_MODE_INFORMATION));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync EngFreeMem(pModesTable);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (i>=cModes)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("can't support requested mode %dx%d@%dbpp(%dHz)!",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmPelsWidth, pdm->dmPelsHeight, pdm->dmBitsPerPel, pdm->dmDisplayFrequency));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return VERR_NOT_SUPPORTED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOG(("match for requested mode %dx%d@%dbpp(%dHz)",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync selectedMode.VisScreenWidth, selectedMode.VisScreenHeight, selectedMode.BitsPerPlane, selectedMode.Frequency));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Update private device info with mode information */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.ulIndex = selectedMode.ModeIndex;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.ulWidth = selectedMode.VisScreenWidth;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.ulHeight = selectedMode.VisScreenHeight;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.ulBitsPerPel = selectedMode.BitsPerPlane * selectedMode.NumberOfPlanes;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.lScanlineStride = selectedMode.ScreenStride;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.flMaskR = selectedMode.RedMask;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.flMaskG = selectedMode.GreenMask;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.flMaskB = selectedMode.BlueMask;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.ulPaletteShift = (pDev->mode.ulBitsPerPel==8) ? (8-selectedMode.NumberRedBits) : 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Fill GDIINFO structure */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memset(pGdiInfo, 0, sizeof(GDIINFO));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulVersion = (g_EngineVersionDDI<DDI_DRIVER_VERSION_NT5) ? GDI_DRIVER_VERSION:0x5000;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulVersion |= VBOXDISPDRIVERVERSION;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulTechnology = DT_RASDISPLAY;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulHorzSize = selectedMode.XMillimeter;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulVertSize = selectedMode.YMillimeter;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulHorzRes = pDev->mode.ulWidth;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulVertRes = pDev->mode.ulHeight;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->cBitsPixel = pDev->mode.ulBitsPerPel;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->cPlanes = selectedMode.NumberOfPlanes;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulNumColors = (pDev->mode.ulBitsPerPel==8) ? 20 : ((ULONG)(-1));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulLogPixelsX = pdm->dmLogPixels;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulLogPixelsY = pdm->dmLogPixels;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pdm->dmLogPixels!=96)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("requested logical pixel res %d isn't 96", pdm->dmLogPixels));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->flTextCaps = TC_RA_ABLE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulDACRed = selectedMode.NumberRedBits;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulDACGreen = selectedMode.NumberGreenBits;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulDACBlue = selectedMode.NumberBlueBits;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulAspectX = 0x24;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulAspectY = 0x24;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* note: ulAspectXY should be square root of sum of squares of x and y aspects */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulAspectXY = 0x33;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* search for "styled cosmetic lines" on msdn for more info */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->xStyleStep = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->yStyleStep = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->denStyleStep = 3;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulNumPalReg = (pDev->mode.ulBitsPerPel==8) ? (1<<pDev->mode.ulBitsPerPel) : 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* @todo: might want to implement IOCTL_VIDEO_QUERY_COLOR_CAPABILITIES in miniport driver
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * and query host for this info there
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
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.Cyan, 0, 0, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPSETCIEC(pGdiInfo->ciDevice.Magenta, 0, 0, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPSETCIEC(pGdiInfo->ciDevice.Yellow, 0, 0, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ciDevice.RedGamma = 20000;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ciDevice.GreenGamma = 20000;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ciDevice.BlueGamma = 20000;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulPrimaryOrder = PRIMARY_ORDER_CBA;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulHTPatternSize = HT_PATSIZE_4x4_M;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (pDev->mode.ulBitsPerPel)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 8:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulHTOutputFormat = HT_FORMAT_8BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 16:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulHTOutputFormat = HT_FORMAT_16BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 24:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulHTOutputFormat = HT_FORMAT_24BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 32:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulHTOutputFormat = HT_FORMAT_32BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->flHTFlags = HT_FLAG_ADDITIVE_PRIMS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulVRefresh = selectedMode.Frequency;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* 0 means BitBlt's are accelerated by driver */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulBltAlignment = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulPhysicalPixelCharacteristics = PPC_UNDEFINED;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pGdiInfo->ulPhysicalPixelGamma = PPG_DEFAULT;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Fill DEVINFO structure */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memset(pDevInfo, 0, sizeof(DEVINFO));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->flGraphicsCaps = GCAPS_OPAQUERECT;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_DDRAW
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->flGraphicsCaps |= GCAPS_DIRECTDRAW;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPMAKELOGFONTW(pDevInfo->lfDefaultFont,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 16, 7, FW_BOLD, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, VARIABLE_PITCH, L"System");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPMAKELOGFONTW(pDevInfo->lfAnsiVarFont,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 12, 9, FW_NORMAL, CLIP_STROKE_PRECIS, PROOF_QUALITY, VARIABLE_PITCH, L"MS Sans Serif");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOXDISPMAKELOGFONTW(pDevInfo->lfAnsiFixFont,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync 12, 9, FW_NORMAL, CLIP_STROKE_PRECIS, PROOF_QUALITY, FIXED_PITCH, L"Courier");
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->cFonts = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->cxDither = 8;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->cyDither = 8;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->hpalDefault = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->flGraphicsCaps2 = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (pDev->mode.ulBitsPerPel)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 8:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->flGraphicsCaps |= GCAPS_PALMANAGED|GCAPS_COLOR_DITHER;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->iDitherFormat = BMF_8BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 16:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->iDitherFormat = BMF_16BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 24:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->iDitherFormat = BMF_24BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 32:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDevInfo->iDitherFormat = BMF_32BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Display Driver entry point,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Returns DDI version number and callbacks supported by driver.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncBOOL DrvEnableDriver(ULONG iEngineVersion, ULONG cj, PDRVENABLEDATA pded)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*@todo: can't link with hal.lib
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int irc = RTR0Init(0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_FAILURE(irc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGREL(("failed to init IPRT (rc=%#x)", irc));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF(("iEngineVersion=%#08X, cj=%d", iEngineVersion, cj));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync g_EngineVersionDDI = iEngineVersion;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Driver can't work if we can't fill atleast first 3 fields in passed PDRVENABLEDATA */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (cj < (2*sizeof(ULONG)+sizeof(DRVFN*)))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("cj<%d, terminating\n", sizeof(DRVENABLEDATA)));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Report driver DDI version and appropriate callbacks table based on engine DDI */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (iEngineVersion>=DDI_DRIVER_VERSION_NT5)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* WIN2K and above */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pded->iDriverVersion = DDI_DRIVER_VERSION_NT5;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pded->pdrvfn = g_aDrvFnTableNT5;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pded->c = RT_ELEMENTS(g_aDrvFnTableNT5);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* NT4_SP3 and below*/
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pded->iDriverVersion = DDI_DRIVER_VERSION_NT4;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pded->pdrvfn = g_aDrvFnTableNT4;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pded->c = RT_ELEMENTS(g_aDrvFnTableNT4);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return TRUE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Free all resources allocated in DrvEnableDriver */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVOID APIENTRY VBoxDispDrvDisableDriver()
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Intentionally left blank */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync}
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
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.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncULONG APIENTRY VBoxDispDrvGetModes(HANDLE hDriver, ULONG cjSize, DEVMODEW *pdm)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VIDEO_MODE_INFORMATION *pModesTable;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ULONG cModes;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPGetVideoModes(hDriver, &pModesTable, &cModes);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC_RETV(rc, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pdm) /* return size of buffer required to store all supported modes */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync EngFreeMem(pModesTable);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return cModes * sizeof(DEVMODEW);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ULONG mode, cMaxNodes=cjSize/sizeof(DEVMODEW);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync for (mode=0; mode<cModes && mode<cMaxNodes; ++mode, ++pdm)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memset(pdm, 0, sizeof(DEVMODEW));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(pdm->dmDeviceName, VBOXDISP_DEVICE_NAME, sizeof(VBOXDISP_DEVICE_NAME));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmSpecVersion = DM_SPECVERSION;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmDriverVersion = DM_SPECVERSION;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmSize = sizeof(DEVMODEW);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmDriverExtra = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
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->dmDisplayFlags = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pdm->dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFREQUENCY|DM_DISPLAYFLAGS;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync EngFreeMem(pModesTable);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOG(("%d mode(s) reported", mode));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return mode * sizeof(DEVMODEW);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
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.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncDHPDEV APIENTRY
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVBoxDispDrvEnablePDEV(DEVMODEW *pdm, LPWSTR pwszLogAddress, ULONG cPat, HSURF *phsurfPatterns,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ULONG cjCaps, ULONG *pdevcaps,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ULONG cjDevInfo, DEVINFO *pdi,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync HDEV hdev, PWSTR pwszDeviceName, HANDLE hDriver)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PVBOXDISPDEV pDev = NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync GDIINFO gdiInfo;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync DEVINFO devInfo;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Next 3 are only used for printer drivers */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NOREF(pwszLogAddress);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NOREF(cPat);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NOREF(phsurfPatterns);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync NOREF(pwszDeviceName);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev = (PVBOXDISPDEV) EngAllocMem(FL_ZERO_MEMORY, sizeof(VBOXDISPDEV), MEM_ALLOC_TAG);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pDev)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("EngAllocMem failed!\n"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->hDriver = hDriver;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ULONG ulRegistryFlags = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPQueryRegistryFlags(hDriver, &ulRegistryFlags);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->bBitmapCacheDisabled = (ulRegistryFlags & VBOXVIDEO_REGISTRY_FLAGS_DISABLE_BITMAP_CACHE) != 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOG(("Bitmap cache %s", pDev->bBitmapCacheDisabled? "disabled": "enabled"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Initialize device structure and query miniport to fill device and gdi infos */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispInitDevice(pDev, pdm, &gdiInfo, &devInfo);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_FAILURE(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC(rc);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync EngFreeMem(pDev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Initialize mouse pointer caps */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispInitPointerCaps(pDev, &devInfo);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_FAILURE(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC(rc);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Initialize palette */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispInitPalette(pDev, &devInfo);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_FAILURE(rc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC(rc);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync EngFreeMem(pDev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if(g_EngineVersionDDI >= DDI_DRIVER_VERSION_NT5)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync devInfo.flGraphicsCaps2 |= GCAPS2_RESERVED1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Copy gathered info to supplied buffers */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(pdevcaps, &gdiInfo, min(sizeof(GDIINFO), cjCaps));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync memcpy(pdi, &devInfo, min(sizeof(DEVINFO), cjDevInfo));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return (DHPDEV)pDev;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
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{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ((PVBOXDISPDEV)dhpdev)->hDevGDI = hdev;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Called to free resources allocated for device in VBoxDispDrvEnablePDEV */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVOID APIENTRY VBoxDispDrvDisablePDEV(DHPDEV dhpdev)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxDispDestroyPalette((PVBOXDISPDEV) dhpdev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync EngFreeMem(dhpdev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Called to create and associate surface with device */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncHSURF APIENTRY VBoxDispDrvEnableSurface(DHPDEV dhpdev)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PVBOXDISPDEV pDev = (PVBOXDISPDEV)dhpdev;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Switch device to mode requested in VBoxDispDrvEnablePDEV */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPSetCurrentMode(pDev->hDriver, pDev->mode.ulIndex);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC_RETV(rc, NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Map fb and vram */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPMapMemory(pDev, &pDev->memInfo);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC_RETV(rc, NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
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
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Allocate memory for pointer attrs */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispInitPointerAttrs(pDev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC_RETV(rc, NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Init VBVA */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispVBVAInit(pDev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC_RETV(rc, NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Enable VBVA */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->hgsmi.bSupported)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->mode.ulBitsPerPel==16 || pDev->mode.ulBitsPerPel==24 || pDev->mode.ulBitsPerPel==32)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
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 }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Inform host */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->hgsmi.bSupported)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
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 }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_VIDEOHWACCEL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxDispVHWAEnable(pDev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Set device palette if needed */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->mode.ulBitsPerPel == 8)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispSetPalette8BPP(pDev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC_RETV(rc, NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->orgDisp.x = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->orgDisp.y = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Create GDI managed bitmap, which resides in our framebuffer memory */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ULONG iFormat;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync SIZEL size;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (pDev->mode.ulBitsPerPel)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 8:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync iFormat = BMF_8BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 16:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync iFormat = BMF_16BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 24:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync iFormat = BMF_24BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 32:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync iFormat = BMF_32BPP;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync }
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync size.cx = pDev->mode.ulWidth;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync size.cy = pDev->mode.ulHeight;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->surface.hBitmap = EngCreateBitmap(size, pDev->mode.lScanlineStride, iFormat,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->mode.lScanlineStride>0 ? BMF_TOPDOWN:0,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->memInfo.FrameBufferBase);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pDev->surface.hBitmap)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("EngCreateBitmap failed!"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->surface.psoBitmap = EngLockSurface((HSURF)pDev->surface.hBitmap);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Create device-managed surface */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->surface.hSurface = EngCreateDeviceSurface((DHSURF)pDev, size, iFormat);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!pDev->surface.hSurface)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("EngCreateDeviceSurface failed!"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxDispDrvDisableSurface(dhpdev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync FLONG flHooks = HOOK_BITBLT|HOOK_TEXTOUT|HOOK_FILLPATH|HOOK_COPYBITS|HOOK_STROKEPATH|HOOK_LINETO|
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync HOOK_PAINT|HOOK_STRETCHBLT;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Associate created surface with our device */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!EngAssociateSurface(pDev->surface.hSurface, pDev->hDevGDI, flHooks))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("EngAssociateSurface failed!"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxDispDrvDisableSurface(dhpdev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->surface.ulFormat = iFormat;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->flDrawingHooks = flHooks;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOG(("Created surface %p for physical device %p", pDev->surface.hSurface, pDev));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return pDev->surface.hSurface;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncVOID APIENTRY VBoxDispDrvDisableSurface(DHPDEV dhpdev)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PVBOXDISPDEV pDev = (PVBOXDISPDEV)dhpdev;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->surface.hSurface)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync EngDeleteSurface(pDev->surface.hSurface);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->surface.hSurface = NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->surface.psoBitmap)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync Assert(pDev->surface.hBitmap);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync EngUnlockSurface(pDev->surface.psoBitmap);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->surface.psoBitmap = NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->surface.hBitmap)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync EngDeleteSurface((HSURF) pDev->surface.hBitmap);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->surface.hBitmap = NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPUnmapMemory(pDev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC(rc);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncBOOL APIENTRY
ffb50166c9adb4ae583b914d405197035cf890advboxsyncVBoxDispDrvRealizeBrush(BRUSHOBJ *pbo, SURFOBJ *psoTarget, SURFOBJ *psoPattern, SURFOBJ *psoMask,
ffb50166c9adb4ae583b914d405197035cf890advboxsync XLATEOBJ *pxlo, ULONG iHatch)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync BOOL bRc = FALSE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (VBoxDispIsScreenSurface(psoTarget))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PVBOXDISPDEV pDev = (PVBOXDISPDEV)psoTarget->dhpdev;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->vbvaCtx.pVBVA && (pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents & VBVA_F_MODE_ENABLED))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents & VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET)
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync vrdpReset(pDev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents &= ~VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents & VBVA_F_MODE_VRDP)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bRc = vrdpDrvRealizeBrush(pbo, psoTarget, psoPattern, psoMask, pxlo, iHatch);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return bRc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncULONG APIENTRY VBoxDispDrvDitherColor(DHPDEV dhpdev, ULONG iMode, ULONG rgb, ULONG *pul)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync ULONG rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* There is no EngDitherColor on NT4, so take the easy path and tell the graphics
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * engine to create a halftone approximation.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = DCR_HALFTONE;
ffb50166c9adb4ae583b914d405197035cf890advboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Called to reset device to default mode or to mode specified with dhpdev */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncBOOL APIENTRY VBoxDispDrvAssertMode(DHPDEV dhpdev, BOOL bEnable)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PVBOXDISPDEV pDev = (PVBOXDISPDEV) dhpdev;
ffb50166c9adb4ae583b914d405197035cf890advboxsync int rc;
ffb50166c9adb4ae583b914d405197035cf890advboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!bEnable)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF(("!bEnable"));
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#ifdef VBOX_WITH_VIDEOHWACCEL
ffb50166c9adb4ae583b914d405197035cf890advboxsync /* tells we can not process host commands any more and ensures that
ffb50166c9adb4ae583b914d405197035cf890advboxsync * we've completed processing of the host VHWA commands
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync VBoxDispVHWADisable(pDev);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#endif
ffb50166c9adb4ae583b914d405197035cf890advboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync /* disable VBVA */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->hgsmi.bSupported)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxVBVADisable(&pDev->vbvaCtx, &pDev->hgsmi.ctx, -1);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* reset the device to default mode */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPResetDevice(pDev->hDriver);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC_RETV(rc, FALSE);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF(("bEnable"));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* switch device to previous pDev mode */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = VBoxDispMPSetCurrentMode(pDev->hDriver, pDev->mode.ulIndex);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_WARNRC_RETV(rc, NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync /* enable VBVA */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->hgsmi.bSupported)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->mode.ulBitsPerPel==16 || pDev->mode.ulBitsPerPel==24 || pDev->mode.ulBitsPerPel==32)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
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 "));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync /* inform host */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pDev->hgsmi.bSupported)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
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 }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_VIDEOHWACCEL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* tells we can process host commands */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxDispVHWAEnable(pDev);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
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 {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("EngAssociateSurface on bitmap failed"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
ffb50166c9adb4ae583b914d405197035cf890advboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* Associate device managed surface with GDI's handle to our device */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!EngAssociateSurface(pDev->surface.hSurface, pDev->hDevGDI, pDev->flDrawingHooks))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync WARN(("EngAssociateSurface on surface failed"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return FALSE;
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_LEAVE();
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync return TRUE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsyncULONG APIENTRY VBoxDispDrvEscape(SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync{
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync PVBOXDISPDEV pDev = (PVBOXDISPDEV)pso->dhpdev;
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync LOGF_ENTER();
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync switch (iEsc)
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync {
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync#ifdef VBOX_WITH_CROGL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case OPENGL_GETINFO:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pvOut && cjOut >= sizeof(OPENGL_INFO))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync POPENGL_INFO pInfo = (POPENGL_INFO)pvOut;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync pInfo->dwVersion = 2;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pInfo->dwDriverVersion = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pInfo->szDriverName[0] = 'V';
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pInfo->szDriverName[1] = 'B';
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pInfo->szDriverName[2] = 'o';
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pInfo->szDriverName[3] = 'x';
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pInfo->szDriverName[4] = 'O';
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pInfo->szDriverName[5] = 'G';
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pInfo->szDriverName[6] = 'L';
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pInfo->szDriverName[7] = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOG(("OPENGL_GETINFO ok"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return cjOut;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync WARN(("OPENGL_GETINFO invalid parms"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case QUERYESCSUPPORT:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (pvIn && cjIn == sizeof(DWORD))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
0dd3967035b8a02985920baa57f948dc542b9388vboxsync DWORD nEscapeQuery = *(DWORD *)pvIn;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (nEscapeQuery==OPENGL_GETINFO)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync LOG(("QUERYESCSUPPORT OPENGL_GETINFO"));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return 1;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync else
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOG(("QUERYESCSUPPORT unsupported query %d", nEscapeQuery));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return 0;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync else
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync WARN(("QUERYESCSUPPORT invalid parms"));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#endif
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case VBOXESC_ISVRDPACTIVE:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (pDev && pDev->vbvaCtx.pVBVA && pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents&VBVA_F_MODE_VRDP)
0dd3967035b8a02985920baa57f948dc542b9388vboxsync {
0dd3967035b8a02985920baa57f948dc542b9388vboxsync LOGF(("VBOXESC_ISVRDPACTIVE: 1"));
0dd3967035b8a02985920baa57f948dc542b9388vboxsync return 1;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync }
0dd3967035b8a02985920baa57f948dc542b9388vboxsync LOGF(("VBOXESC_ISVRDPACTIVE: 0"));
0dd3967035b8a02985920baa57f948dc542b9388vboxsync return 0;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync }
0dd3967035b8a02985920baa57f948dc542b9388vboxsync case VBOXESC_SETVISIBLEREGION:
0dd3967035b8a02985920baa57f948dc542b9388vboxsync {
0dd3967035b8a02985920baa57f948dc542b9388vboxsync LOGF(("VBOXESC_SETVISIBLEREGION"));
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync LPRGNDATA lpRgnData = (LPRGNDATA)pvIn;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync DWORD cRects;
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync if ( cjIn >= sizeof(RGNDATAHEADER)
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync && pvIn
6475559a7e0e52892efbab4fbdedc879f6866109vboxsync && lpRgnData->rdh.dwSize == sizeof(RGNDATAHEADER)
0dd3967035b8a02985920baa57f948dc542b9388vboxsync && lpRgnData->rdh.iType == RDH_RECTANGLES
0dd3967035b8a02985920baa57f948dc542b9388vboxsync && (cRects = lpRgnData->rdh.nCount) <= _1M
0dd3967035b8a02985920baa57f948dc542b9388vboxsync && cjIn == cRects * (uint64_t)sizeof(RECT) + sizeof(RGNDATAHEADER))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /** @todo this whole conversion thing could maybe be skipped
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync * since RTRECT matches the RECT layout. */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#if 0
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync AssertCompile(sizeof(RTRECT) == sizeof(RECT));
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
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync rc = VBoxDispMPSetVisibleRegion(pDev->hDriver, (PRTRECT)&lpRgnData->Buffer[0], cRects);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync VBOX_WARNRC(rc);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#else
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync DWORD i;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync PRTRECT pRTRect;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync int rc;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync RECT *pRect = (RECT *)&lpRgnData->Buffer;
0dd3967035b8a02985920baa57f948dc542b9388vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pRTRect = (PRTRECT) EngAllocMem(0, cRects*sizeof(RTRECT), MEM_ALLOC_TAG);
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync if (!pRTRect)
0dd3967035b8a02985920baa57f948dc542b9388vboxsync {
0dd3967035b8a02985920baa57f948dc542b9388vboxsync WARN(("failed to allocate %d bytes", cRects*sizeof(RTRECT)));
0dd3967035b8a02985920baa57f948dc542b9388vboxsync break;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync for (i = 0; i < cRects; ++i)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync LOG(("New visible rectangle (%d,%d) (%d,%d)",
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pRect[i].left, pRect[i].bottom, pRect[i].right, pRect[i].top));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pRTRect[i].xLeft = pRect[i].left;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pRTRect[i].yBottom = pRect[i].bottom;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pRTRect[i].xRight = pRect[i].right;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pRTRect[i].yTop = pRect[i].top;
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync }
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync rc = VBoxDispMPSetVisibleRegion(pDev->hDriver, pRTRect, cRects);
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync VBOX_WARNRC(rc);
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync EngFreeMem(pRTRect);
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync#endif
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync if (RT_SUCCESS(rc))
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync {
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync LOGF_LEAVE();
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync return 1;
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync }
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync }
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync else
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync {
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync if (pvIn)
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync {
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync WARN(("check failed rdh.dwSize=%x iType=%d size=%d expected size=%d",
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync lpRgnData->rdh.dwSize, lpRgnData->rdh.iType, cjIn,
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync lpRgnData->rdh.nCount * sizeof(RECT) + sizeof(RGNDATAHEADER)));
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync }
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync }
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync break;
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync }
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync case VBOXESC_ISANYX:
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync {
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync if (pvOut && cjOut == sizeof(DWORD))
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync {
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync DWORD cbReturned;
0c80e8c5ac4249337af378ff41c60033c9fff59fvboxsync DWORD dwrc = EngDeviceIoControl(pDev->hDriver, IOCTL_VIDEO_VBOX_ISANYX, NULL, 0,
f75c6db919d277952ca03b7acf643e5e3ac96cafvboxsync pvOut, sizeof (uint32_t), &cbReturned);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (dwrc == NO_ERROR && cbReturned == sizeof (uint32_t))
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return 1;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync WARN(("EngDeviceIoControl failed, dwrc(%d), cbReturned(%d)", dwrc, cbReturned));
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync return 0;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync else
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync {
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync WARN(("VBOXESC_ISANYX invalid parms"));
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync return 0;
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync break;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync default:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync LOG(("unsupported iEsc %#x", iEsc));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync LOGF_LEAVE();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
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{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PVBOXDISPDEV pDev = (PVBOXDISPDEV)pso->dhpdev;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF(("%x %x %x\n", x, y, flReserved));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->memInfo.FrameBufferBase = ((BYTE*)pDev->memInfo.VideoRamBase) + pDev->layout.offFramebuffer
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync - FB_OFFSET(pDev, x, y);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->orgDisp.x = x;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pDev->orgDisp.y = y;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync LOGF_LEAVE();
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync return TRUE;
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync}
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* Called to notify driver about various events */
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsyncVOID APIENTRY VBoxDispDrvNotify(SURFOBJ *pso, ULONG iType, PVOID pvData)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync PVBOXDISPDEV pDev = (PVBOXDISPDEV)pso->dhpdev;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOGF_ENTER();
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync switch (iType)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DN_DEVICE_ORIGIN:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /*device origin in dualview*/
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync POINTL *pOrg = (POINTL *)pvData;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync if (pOrg)
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
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 {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pDev->orgDev = *pOrg;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync /* Inform host about display change */
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync VBoxHGSMIProcessDisplayInfo(&pDev->hgsmi.ctx, pDev->iDevice, pDev->orgDev.x, pDev->orgDev.y,
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync 0, abs(pDev->mode.lScanlineStride),
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync pDev->mode.ulWidth, pDev->mode.ulHeight,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync (uint16_t)pDev->mode.ulBitsPerPel, VBVA_SCREEN_F_ACTIVE);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
3c6306a66deef467e3c13483dd6529e1e1c6b822vboxsync WARN(("DN_DEVICE_ORIGIN pvData==NULL"));
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync break;
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync case DN_DRAWING_BEGIN:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*first drawing op is about to happen for this device*/
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LOG(("DN_DRAWING_BEGIN (pso=%p, pDev[%d]=%p)", pso, pDev->iDevice, pDev));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync default:
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync {
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync LOG(("unknown iType=%#x", iType));
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync }
ffb50166c9adb4ae583b914d405197035cf890advboxsync }
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync
ffb50166c9adb4ae583b914d405197035cf890advboxsync LOGF_LEAVE();
ffb50166c9adb4ae583b914d405197035cf890advboxsync return;
ffb50166c9adb4ae583b914d405197035cf890advboxsync}
ffb50166c9adb4ae583b914d405197035cf890advboxsync