Changeset 34079 in vbox for trunk/src/VBox/Additions/WINNT/Graphics
- Timestamp:
- Nov 15, 2010 5:17:53 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Miniport
- Files:
-
- 14 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Helper.cpp
r33540 r34079 22 22 } 23 23 #else 24 # include "VBoxVideo .h"24 # include "VBoxVideo-win.h" 25 25 #endif 26 26 … … 65 65 #pragma alloc_text(PAGE, vboxQueryWinVersion) 66 66 67 BOOLEANvboxQueryDisplayRequest(uint32_t *xres, uint32_t *yres, uint32_t *bpp, uint32_t *pDisplayId)68 { 69 BOOLEANbRC = FALSE;67 bool vboxQueryDisplayRequest(uint32_t *xres, uint32_t *yres, uint32_t *bpp, uint32_t *pDisplayId) 68 { 69 bool bRC = FALSE; 70 70 71 71 dprintf(("VBoxVideo::vboxQueryDisplayRequest: xres = 0x%p, yres = 0x%p bpp = 0x%p\n", xres, yres, bpp)); … … 111 111 } 112 112 113 BOOLEANvboxLikesVideoMode(uint32_t display, uint32_t width, uint32_t height, uint32_t bpp)114 { 115 BOOLEANbRC = FALSE;113 bool vboxLikesVideoMode(uint32_t display, uint32_t width, uint32_t height, uint32_t bpp) 114 { 115 bool bRC = FALSE; 116 116 117 117 VMMDevVideoModeSupportedRequest2 *req2 = NULL; … … 171 171 } 172 172 173 ULONGvboxGetHeightReduction()174 { 175 ULONGretHeight = 0;173 uint32_t vboxGetHeightReduction() 174 { 175 uint32_t retHeight = 0; 176 176 177 177 dprintf(("VBoxVideo::vboxGetHeightReduction\n")); … … 189 189 if (RT_SUCCESS(rc)) 190 190 { 191 retHeight = (ULONG)req->heightReduction;191 retHeight = req->heightReduction; 192 192 } 193 193 else … … 203 203 } 204 204 205 static BOOLEANvboxQueryPointerPosInternal (uint16_t *pointerXPos, uint16_t *pointerYPos)206 { 207 BOOLEANbRC = FALSE;205 static bool vboxQueryPointerPosInternal (uint16_t *pointerXPos, uint16_t *pointerYPos) 206 { 207 bool bRC = FALSE; 208 208 209 209 /* Activate next line only when really needed; floods the log very quickly! */ … … 255 255 * (between 0 and 0xFFFF). 256 256 * 257 * @returns BOOLEANsuccess indicator257 * @returns bool success indicator 258 258 * @param pointerXPos address of result variable for x pos 259 259 * @param pointerYPos address of result variable for y pos 260 260 */ 261 BOOLEANvboxQueryPointerPos(uint16_t *pointerXPos, uint16_t *pointerYPos)261 bool vboxQueryPointerPos(uint16_t *pointerXPos, uint16_t *pointerYPos) 262 262 { 263 263 if (!pointerXPos || !pointerYPos) … … 272 272 * Returns whether the host wants us to take absolute coordinates. 273 273 * 274 * @returns BOOLEANTRUE if the host wants to send absolute coordinates.274 * @returns bool TRUE if the host wants to send absolute coordinates. 275 275 */ 276 BOOLEANvboxQueryHostWantsAbsolute (void)276 bool vboxQueryHostWantsAbsolute (void) 277 277 { 278 278 return vboxQueryPointerPosInternal (NULL, NULL); … … 320 320 return winVersion; 321 321 } 322 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Helper.h
r33980 r34079 31 31 extern "C" 32 32 { 33 BOOLEANvboxQueryDisplayRequest(uint32_t *xres, uint32_t *yres, uint32_t *bpp, uint32_t *pDisplayId);34 BOOLEANvboxLikesVideoMode(uint32_t display, uint32_t width, uint32_t height, uint32_t bpp);35 ULONGvboxGetHeightReduction();36 BOOLEANvboxQueryPointerPos(uint16_t *pointerXPos, uint16_t *pointerYPos);37 BOOLEANvboxQueryHostWantsAbsolute();33 bool vboxQueryDisplayRequest(uint32_t *xres, uint32_t *yres, uint32_t *bpp, uint32_t *pDisplayId); 34 bool vboxLikesVideoMode(uint32_t display, uint32_t width, uint32_t height, uint32_t bpp); 35 uint32_t vboxGetHeightReduction(); 36 bool vboxQueryPointerPos(uint16_t *pointerXPos, uint16_t *pointerYPos); 37 bool vboxQueryHostWantsAbsolute(); 38 38 winVersion_t vboxQueryWinVersion(); 39 39 40 #include "vboxioctl.h"40 // #include "vboxioctl.h" 41 41 42 int vboxVbvaEnable (ULONG ulEnable, VBVAENABLERESULT *pVbvaResult);42 // int vboxVbvaEnable (ULONG ulEnable, VBVAENABLERESULT *pVbvaResult); 43 43 } 44 44 45 45 46 46 /* debug printf */ 47 #define OSDBGPRINT(a) DbgPrint a 47 /** @todo replace this with normal IPRT guest logging */ 48 #ifdef RT_OS_WINDOWS 49 # define OSDBGPRINT(a) DbgPrint a 50 #else 51 # define OSDBGPRINT(a) do { } while(0) 52 #endif 48 53 49 54 #ifdef LOG_TO_BACKDOOR -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Makefile.kmk
r33676 r34079 91 91 VBoxVideoWddm_DEFS += LOG_ENABLED 92 92 endif 93 VBoxVideoWddm_DEFS += LOG_DISABLED 93 94 #VBoxVideoWddm_DEFS += VBOX_WITH_MULTIMONITOR_FIX 94 95 #VBoxVideoWddm_DEFS += LOG_TO_BACKDOOR -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo-win.h
r33997 r34079 1 1 /** @file 2 * VirtualBox Video miniport driver 2 * VirtualBox Video miniport driver, Windows-specific header 3 3 * 4 4 * Copyright (C) 2006-2007 Oracle Corporation … … 13 13 */ 14 14 15 #ifndef VBOXVIDEO_H 16 #define VBOXVIDEO_H 17 18 #include <VBox/cdefs.h> 19 #include <VBox/types.h> 20 #include <iprt/assert.h> 21 22 //#include <iprt/thread.h> 23 24 #include <VBox/HGSMI/HGSMI.h> 25 #include <VBox/HGSMI/HGSMIChSetup.h> 26 #include <VBox/VBoxVideo.h> 27 #include "VBoxHGSMI.h" 15 #ifndef VBOXVIDEO_WIN_H 16 #define VBOXVIDEO_WIN_H 17 18 #include "VBoxVideo.h" 28 19 29 20 RT_C_DECLS_BEGIN … … 78 69 RT_C_DECLS_END 79 70 80 #define VBE_DISPI_IOPORT_INDEX 0x01CE81 #define VBE_DISPI_IOPORT_DATA 0x01CF82 #define VBE_DISPI_INDEX_ID 0x083 #define VBE_DISPI_INDEX_XRES 0x184 #define VBE_DISPI_INDEX_YRES 0x285 #define VBE_DISPI_INDEX_BPP 0x386 #define VBE_DISPI_INDEX_ENABLE 0x487 #define VBE_DISPI_INDEX_VIRT_WIDTH 0x688 #define VBE_DISPI_INDEX_VIRT_HEIGHT 0x789 #define VBE_DISPI_INDEX_X_OFFSET 0x890 #define VBE_DISPI_INDEX_Y_OFFSET 0x991 #define VBE_DISPI_INDEX_VBOX_VIDEO 0xa92 93 #define VBE_DISPI_ID2 0xB0C294 /* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */95 #define VBE_DISPI_ID_VBOX_VIDEO 0xBE0096 #define VBE_DISPI_ID_HGSMI 0xBE0197 #define VBE_DISPI_ID_ANYX 0xBE0298 #define VBE_DISPI_DISABLED 0x0099 #define VBE_DISPI_ENABLED 0x01100 #define VBE_DISPI_LFB_ENABLED 0x40101 #define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000102 #define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 4103 #define VBE_DISPI_TOTAL_VIDEO_MEMORY_KB (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024)104 #define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES (VBE_DISPI_TOTAL_VIDEO_MEMORY_KB * 1024)105 106 #define VGA_PORT_HGSMI_HOST 0x3b0107 #define VGA_PORT_HGSMI_GUEST 0x3d0108 109 71 /* common API types */ 110 72 #ifdef VBOX_WITH_WDDM … … 186 148 #endif 187 149 188 typedef struct VBOXVIDEO_COMMON189 {190 int cDisplays; /* Number of displays. */191 192 ULONG cbVRAM; /* The VRAM size. */193 194 ULONG cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.195 * It is at offset:196 * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap197 */198 PVOID pvMiniportHeap; /* The pointer to the miniport heap VRAM.199 * This is mapped by miniport separately.200 */201 volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */202 volatile bool bHostCmdProcessing;203 204 PVOID pvAdapterInformation; /* The pointer to the last 4K of VRAM.205 * This is mapped by miniport separately.206 */207 208 /** Host HGSMI capabilities the guest can handle */209 uint32_t fCaps;210 211 BOOLEAN bHGSMI; /* Whether HGSMI is enabled. */212 213 HGSMIAREA areaHostHeap; /* Host heap VRAM area. */214 215 HGSMICHANNELINFO channels;216 217 HGSMIHEAP hgsmiAdapterHeap;218 219 /* The IO Port Number for host commands. */220 RTIOPORT IOPortHost;221 222 /* The IO Port Number for guest commands. */223 RTIOPORT IOPortGuest;224 } VBOXVIDEO_COMMON, *PVBOXVIDEO_COMMON;225 226 150 typedef struct _DEVICE_EXTENSION 227 151 { … … 333 257 } 334 258 259 static inline bool vboxUpdatePointerShapeWrap(PVBOXVIDEO_COMMON pCommon, 260 PVIDEO_POINTER_ATTRIBUTES pointerAttr, 261 uint32_t cbLength) 262 { 263 return vboxUpdatePointerShape(pCommon, 264 pointerAttr->Enable & 0x0000FFFF, 265 (pointerAttr->Enable >> 16) & 0xFF, 266 (pointerAttr->Enable >> 24) & 0xFF, 267 pointerAttr->Width, 268 pointerAttr->Height, 269 pointerAttr->Pixels, 270 cbLength - sizeof(VIDEO_POINTER_ATTRIBUTES)); 271 } 272 335 273 #ifndef VBOX_WITH_WDDM 336 274 #define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden) … … 354 292 } while (0) 355 293 #endif 294 356 295 extern "C" 357 296 { 358 /** Signal an event in a guest-OS-specific way. pvEvent will be re-cast to359 * something OS-specific. */360 void VBoxVideoCmnSignalEvent(PVBOXVIDEO_COMMON pCommon, uint64_t pvEvent);361 362 /** Allocate memory to be used in normal driver operation (dispatch level in363 * Windows) but not necessarily in IRQ context. */364 void *VBoxVideoCmnMemAllocDriver(PVBOXVIDEO_COMMON pCommon, size_t cb);365 366 /** Free memory allocated by @a VBoxVideoCmnMemAllocDriver */367 void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv);368 369 /** Write an 8-bit value to an I/O port. */370 void VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value);371 372 /** Write a 16-bit value to an I/O port. */373 void VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value);374 375 /** Write a 32-bit value to an I/O port. */376 void VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value);377 378 /** Read an 8-bit value from an I/O port. */379 uint8_t VBoxVideoCmnPortReadUchar(RTIOPORT Port);380 381 /** Read a 16-bit value from an I/O port. */382 uint16_t VBoxVideoCmnPortReadUshort(RTIOPORT Port);383 384 /** Read a 32-bit value from an I/O port. */385 uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port);386 387 297 #ifndef VBOX_WITH_WDDM 388 298 … … 409 319 410 320 /* @return STATUS_BUFFER_TOO_SMALL - if buffer is too small, STATUS_SUCCESS - on success */ 411 NTSTATUS vboxWddmGetModesForResolution(PDEVICE_EXTENSION DeviceExtension, PVBOXWDDM_VIDEOMODES_INFO pModeInfos, 412 D3DKMDT_2DREGION *pResolution, VIDEO_MODE_INFORMATION * pModes, uint32_t cModes, uint32_t *pcModes, int32_t *piPreferrableMode); 413 414 D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo); 321 NTSTATUS vboxWddmGetModesForResolution(VIDEO_MODE_INFORMATION *pAllModes, uint32_t cAllModes, int iSearchPreferredMode, 322 const D3DKMDT_2DREGION *pResolution, VIDEO_MODE_INFORMATION * pModes, uint32_t cModes, uint32_t *pcModes, int32_t *piPreferrableMode); 323 324 int vboxWddmVideoModeFind(const VIDEO_MODE_INFORMATION *pModes, int cModes, const VIDEO_MODE_INFORMATION *pM); 325 int vboxWddmVideoResolutionFind(const D3DKMDT_2DREGION *pResolutions, int cResolutions, const D3DKMDT_2DREGION *pRes); 326 bool vboxWddmVideoResolutionsMatch(const D3DKMDT_2DREGION *pResolutions1, const D3DKMDT_2DREGION *pResolutions2, int cResolutions); 327 bool vboxWddmVideoModesMatch(const VIDEO_MODE_INFORMATION *pModes1, const VIDEO_MODE_INFORMATION *pModes2, int cModes); 328 329 D3DDDIFORMAT vboxWddmCalcPixelFormat(const VIDEO_MODE_INFORMATION *pInfo); 330 bool vboxWddmFillMode(VIDEO_MODE_INFORMATION *pInfo, D3DDDIFORMAT enmFormat, ULONG w, ULONG h); 415 331 416 332 DECLINLINE(ULONG) vboxWddmVramCpuVisibleSize(PDEVICE_EXTENSION pDevExt) … … 524 440 #endif 525 441 526 void* vboxHGSMIBufferAlloc(PVBOXVIDEO_COMMON pCommon,527 HGSMISIZE cbData,528 uint8_t u8Ch,529 uint16_t u16Op);530 void vboxHGSMIBufferFree (PVBOXVIDEO_COMMON pCommon, void *pvBuffer);531 int vboxHGSMIBufferSubmit (PVBOXVIDEO_COMMON pCommon, void *pvBuffer);532 533 442 BOOLEAN FASTCALL VBoxVideoSetCurrentModePerform(PDEVICE_EXTENSION DeviceExtension, 534 443 USHORT width, USHORT height, USHORT bpp … … 578 487 PSTATUS_BLOCK StatusBlock); 579 488 580 int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon,581 void **ppv,582 ULONG ulOffset,583 ULONG ulSize);584 585 void VBoxUnmapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv);586 587 typedef bool(*PFNVIDEOIRQSYNC)(void *);588 bool VBoxSyncToVideoIRQ(PVBOXVIDEO_COMMON pCommon, PFNVIDEOIRQSYNC pfnSync,589 void *pvUser);590 591 489 void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension); 592 593 594 /*595 * Host and Guest port IO helpers.596 */597 DECLINLINE(void) VBoxHGSMIHostWrite(PVBOXVIDEO_COMMON pCommon, ULONG data)598 {599 VBoxVideoCmnPortWriteUlong(pCommon->IOPortHost, data);600 }601 602 DECLINLINE(ULONG) VBoxHGSMIHostRead(PVBOXVIDEO_COMMON pCommon)603 {604 return VBoxVideoCmnPortReadUlong(pCommon->IOPortHost);605 }606 607 DECLINLINE(void) VBoxHGSMIGuestWrite(PVBOXVIDEO_COMMON pCommon, ULONG data)608 {609 VBoxVideoCmnPortWriteUlong(pCommon->IOPortGuest, data);610 }611 612 DECLINLINE(ULONG) VBoxHGSMIGuestRead(PVBOXVIDEO_COMMON pCommon)613 {614 return VBoxVideoCmnPortReadUlong(pCommon->IOPortGuest);615 }616 617 618 BOOLEAN VBoxHGSMIIsSupported (void);619 620 typedef int FNHGSMIFILLVIEWINFO (void *pvData, VBVAINFOVIEW *pInfo);621 typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;622 623 int VBoxHGSMISendViewInfo(PVBOXVIDEO_COMMON pCommon, uint32_t u32Count, PFNHGSMIFILLVIEWINFO pfnFill, void *pvData);624 625 VOID VBoxSetupDisplaysHGSMI (PVBOXVIDEO_COMMON pCommon,626 ULONG AdapterMemorySize, uint32_t fCaps);627 BOOLEAN vboxUpdatePointerShape (PVBOXVIDEO_COMMON pCommon,628 PVIDEO_POINTER_ATTRIBUTES pointerAttr,629 uint32_t cbLength);630 631 void VBoxFreeDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon);632 #ifndef VBOX_WITH_WDDM633 DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);634 DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, uint32_t iDisplay, struct _VBVAHOSTCMD ** ppCmd);635 #endif636 637 638 int vboxVBVAChannelDisplayEnable(PVBOXVIDEO_COMMON pCommon,639 int iDisplay, /* negative would mean this is a miniport handler */640 uint8_t u8Channel);641 642 void hgsmiProcessHostCommandQueue(PVBOXVIDEO_COMMON pCommon);643 644 void HGSMIClearIrq (PVBOXVIDEO_COMMON pCommon);645 646 490 } /* extern "C" */ 647 491 648 #endif /* VBOXVIDEO_ H */492 #endif /* VBOXVIDEO_WIN_H */ -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r34018 r34079 15 15 */ 16 16 17 #include "VBoxVideo .h"17 #include "VBoxVideo-win.h" 18 18 #include "Helper.h" 19 19 #ifdef VBOX_WITH_WDDM … … 2667 2667 } 2668 2668 2669 int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv, ULONG ulOffset, ULONGulSize)2669 int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv, uint32_t ulOffset, uint32_t ulSize) 2670 2670 { 2671 2671 PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon); … … 3209 3209 PointerAttributes.Enable = VBOX_MOUSE_POINTER_VISIBLE; 3210 3210 3211 Result = vboxUpdatePointerShape (commonFromDeviceExt(PrimaryExtension), &PointerAttributes, sizeof (PointerAttributes));3211 Result = vboxUpdatePointerShapeWrap(commonFromDeviceExt(PrimaryExtension), &PointerAttributes, sizeof (PointerAttributes)); 3212 3212 3213 3213 if (Result) … … 3457 3457 PointerAttributes.Enable = 0; 3458 3458 3459 Result = vboxUpdatePointerShape (commonFromDeviceExt((PDEVICE_EXTENSION)HwDeviceExtension), &PointerAttributes, sizeof (PointerAttributes));3459 Result = vboxUpdatePointerShapeWrap(commonFromDeviceExt((PDEVICE_EXTENSION)HwDeviceExtension), &PointerAttributes, sizeof (PointerAttributes)); 3460 3460 3461 3461 if (Result) … … 3502 3502 dprintf(("\tBytes attached: %d\n", RequestPacket->InputBufferLength - sizeof(VIDEO_POINTER_ATTRIBUTES))); 3503 3503 #endif 3504 Result = vboxUpdatePointerShape (commonFromDeviceExt((PDEVICE_EXTENSION)HwDeviceExtension), pPointerAttributes, RequestPacket->InputBufferLength);3504 Result = vboxUpdatePointerShapeWrap(commonFromDeviceExt((PDEVICE_EXTENSION)HwDeviceExtension), pPointerAttributes, RequestPacket->InputBufferLength); 3505 3505 if (!Result) 3506 3506 dprintf(("VBoxVideo::VBoxVideoStartIO: Could not set hardware pointer -> fallback\n")); -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
r34018 r34079 27 27 #include "VBoxHGSMI.h" 28 28 29 RT_C_DECLS_BEGIN30 #ifndef VBOX_WITH_WDDM31 #include "dderror.h"32 #include "devioctl.h"33 #include "miniport.h"34 #include "ntddvdeo.h"35 #include "video.h"36 #else37 # ifdef PAGE_SIZE38 # undef PAGE_SIZE39 # endif40 # ifdef PAGE_SHIFT41 # undef PAGE_SHIFT42 # endif43 # define VBOX_WITH_WORKAROUND_MISSING_PACK44 # if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)45 # define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap46 # define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap47 # define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap48 # define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap49 # define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap50 # define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap51 # define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap52 # define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap53 # pragma warning(disable : 4163)54 # ifdef VBOX_WITH_WORKAROUND_MISSING_PACK55 # pragma warning(disable : 4103)56 # endif57 # include <ntddk.h>58 # pragma warning(default : 4163)59 # ifdef VBOX_WITH_WORKAROUND_MISSING_PACK60 # pragma pack()61 # pragma warning(default : 4103)62 # endif63 # undef _InterlockedExchange64 # undef _InterlockedExchangeAdd65 # undef _InterlockedCompareExchange66 # undef _InterlockedAddLargeStatistic67 # undef _interlockedbittestandset68 # undef _interlockedbittestandreset69 # undef _interlockedbittestandset6470 # undef _interlockedbittestandreset6471 # else72 # include <ntddk.h>73 # endif74 #include "dispmprt.h"75 #include "ntddvdeo.h"76 #include "dderror.h"77 #endif78 RT_C_DECLS_END79 80 29 #define VBE_DISPI_IOPORT_INDEX 0x01CE 81 30 #define VBE_DISPI_IOPORT_DATA 0x01CF … … 107 56 #define VGA_PORT_HGSMI_GUEST 0x3d0 108 57 109 /* common API types */110 #ifdef VBOX_WITH_WDDM111 #define VBOX_WITH_GENERIC_MULTIMONITOR112 typedef struct _DEVICE_EXTENSION *PDEVICE_EXTENSION;113 #include <VBox/VBoxVideo.h>114 #include "wddm/VBoxVideoIf.h"115 #include "wddm/VBoxVideoMisc.h"116 #include "wddm/VBoxVideoShgsmi.h"117 #include "wddm/VBoxVideoCm.h"118 #include "wddm/VBoxVideoVdma.h"119 #include "wddm/VBoxVideoWddm.h"120 #include "wddm/VBoxVideoVidPn.h"121 #ifdef VBOXWDDM_WITH_VBVA122 # include "wddm/VBoxVideoVbva.h"123 #endif124 #ifdef VBOX_WITH_VIDEOHWACCEL125 # include "wddm/VBoxVideoVhwa.h"126 #endif127 128 #define VBOXWDDM_POINTER_ATTRIBUTES_SIZE VBOXWDDM_ROUNDBOUND( \129 VBOXWDDM_ROUNDBOUND( sizeof (VIDEO_POINTER_ATTRIBUTES), 4 ) + \130 VBOXWDDM_ROUNDBOUND(VBOXWDDM_C_POINTER_MAX_WIDTH * VBOXWDDM_C_POINTER_MAX_HEIGHT * 4, 4) + \131 VBOXWDDM_ROUNDBOUND((VBOXWDDM_C_POINTER_MAX_WIDTH * VBOXWDDM_C_POINTER_MAX_HEIGHT + 7) >> 3, 4) \132 , 8)133 134 typedef struct VBOXWDDM_POINTER_INFO135 {136 uint32_t xPos;137 uint32_t yPos;138 union139 {140 VIDEO_POINTER_ATTRIBUTES data;141 char buffer[VBOXWDDM_POINTER_ATTRIBUTES_SIZE];142 } Attributes;143 } VBOXWDDM_POINTER_INFO, *PVBOXWDDM_POINTER_INFO;144 145 typedef struct VBOXWDDM_GLOBAL_POINTER_INFO146 {147 uint32_t cVisible;148 } VBOXWDDM_GLOBAL_POINTER_INFO, *PVBOXWDDM_GLOBAL_POINTER_INFO;149 150 #ifdef VBOX_WITH_VIDEOHWACCEL151 typedef struct VBOXWDDM_VHWA152 {153 VBOXVHWA_INFO Settings;154 volatile uint32_t cOverlaysCreated;155 } VBOXWDDM_VHWA;156 #endif157 158 typedef struct VBOXWDDM_SOURCE159 {160 struct VBOXWDDM_ALLOCATION * pPrimaryAllocation;161 #ifdef VBOXWDDM_RENDER_FROM_SHADOW162 struct VBOXWDDM_ALLOCATION * pShadowAllocation;163 VBOXVIDEOOFFSET offVram;164 VBOXWDDM_SURFACE_DESC SurfDesc;165 VBOXVBVAINFO Vbva;166 #endif167 #ifdef VBOX_WITH_VIDEOHWACCEL168 /* @todo: in our case this seems more like a target property,169 * but keep it here for now */170 VBOXWDDM_VHWA Vhwa;171 volatile uint32_t cOverlays;172 LIST_ENTRY OverlayList;173 KSPIN_LOCK OverlayListLock;174 #endif175 POINT VScreenPos;176 VBOXWDDM_POINTER_INFO PointerInfo;177 } VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;178 179 typedef struct VBOXWDDM_TARGET180 {181 uint32_t ScanLineState;182 uint32_t HeightVisible;183 uint32_t HeightTotal;184 } VBOXWDDM_TARGET, *PVBOXWDDM_TARGET;185 186 #endif187 188 58 typedef struct VBOXVIDEO_COMMON 189 59 { 190 60 int cDisplays; /* Number of displays. */ 191 61 192 ULONG cbVRAM;/* The VRAM size. */193 194 ULONG cbMiniportHeap;/* The size of reserved VRAM for miniport driver heap.62 uint32_t cbVRAM; /* The VRAM size. */ 63 64 uint32_t cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap. 195 65 * It is at offset: 196 66 * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap 197 67 */ 198 PVOIDpvMiniportHeap; /* The pointer to the miniport heap VRAM.68 void *pvMiniportHeap; /* The pointer to the miniport heap VRAM. 199 69 * This is mapped by miniport separately. 200 70 */ … … 202 72 volatile bool bHostCmdProcessing; 203 73 204 PVOIDpvAdapterInformation; /* The pointer to the last 4K of VRAM.74 void *pvAdapterInformation; /* The pointer to the last 4K of VRAM. 205 75 * This is mapped by miniport separately. 206 76 */ … … 209 79 uint32_t fCaps; 210 80 211 BOOLEAN bHGSMI;/* Whether HGSMI is enabled. */81 bool bHGSMI; /* Whether HGSMI is enabled. */ 212 82 213 83 HGSMIAREA areaHostHeap; /* Host heap VRAM area. */ … … 224 94 } VBOXVIDEO_COMMON, *PVBOXVIDEO_COMMON; 225 95 226 typedef struct _DEVICE_EXTENSION227 {228 struct _DEVICE_EXTENSION *pNext; /* Next extension in the DualView extension list.229 * The primary extension is the first one.230 */231 #ifndef VBOX_WITH_WDDM232 struct _DEVICE_EXTENSION *pPrimary; /* Pointer to the primary device extension. */233 234 ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */235 236 ULONG CurrentMode; /* Saved information about video modes */237 ULONG CurrentModeWidth;238 ULONG CurrentModeHeight;239 ULONG CurrentModeBPP;240 241 ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */242 ULONG ulFrameBufferSize; /* The size of the current framebuffer. */243 #endif244 union {245 /* Information that is only relevant to the primary device or is the same for all devices. */246 struct {247 248 void *pvReqFlush; /* Pointer to preallocated generic request structure for249 * VMMDevReq_VideoAccelFlush. Allocated when VBVA status250 * is changed. Deallocated on HwReset.251 */252 253 254 ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */255 256 #ifdef VBOX_WITH_WDDM257 VBOXVDMAINFO Vdma;258 # ifdef VBOXVDMA_WITH_VBVA259 VBOXVBVAINFO Vbva;260 # endif261 #endif262 ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */263 264 BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */265 266 267 VBOXVIDEO_COMMON commonInfo;268 #ifndef VBOX_WITH_WDDM269 /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */270 VBOXVIDEOPORTPROCS VideoPortProcs;271 #else272 /* committed VidPn handle */273 D3DKMDT_HVIDPN hCommittedVidPn;274 /* Display Port handle and callbacks */275 DXGKRNL_INTERFACE DxgkInterface;276 #endif277 } primary;278 279 /* Secondary device information. */280 struct {281 BOOLEAN bEnabled; /* Device enabled flag */282 } secondary;283 } u;284 285 HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */286 287 #ifdef VBOX_WITH_WDDM288 PDEVICE_OBJECT pPDO;289 UNICODE_STRING RegKeyName;290 UNICODE_STRING VideoGuid;291 292 uint8_t * pvVisibleVram;293 294 VBOXVIDEOCM_MGR CmMgr;295 /* hgsmi allocation manager */296 VBOXVIDEOCM_ALLOC_MGR AllocMgr;297 VBOXVDMADDI_CMD_QUEUE DdiCmdQueue;298 LIST_ENTRY SwapchainList3D;299 /* mutex for context list operations */300 FAST_MUTEX ContextMutex;301 KSPIN_LOCK SynchLock;302 volatile uint32_t cContexts3D;303 volatile uint32_t cUnlockedVBVADisabled;304 305 VBOXWDDM_GLOBAL_POINTER_INFO PointerInfo;306 307 VBOXSHGSMILIST CtlList;308 VBOXSHGSMILIST DmaCmdList;309 #ifdef VBOX_WITH_VIDEOHWACCEL310 VBOXSHGSMILIST VhwaCmdList;311 #endif312 // BOOL bSetNotifyDxDpc;313 BOOL bNotifyDxDpc;314 315 VBOXWDDM_SOURCE aSources[VBOX_VIDEO_MAX_SCREENS];316 VBOXWDDM_TARGET aTargets[VBOX_VIDEO_MAX_SCREENS];317 #endif318 BOOLEAN fAnyX; /* Unrestricted horizontal resolution flag. */319 } DEVICE_EXTENSION, *PDEVICE_EXTENSION;320 321 static inline PVBOXVIDEO_COMMON commonFromDeviceExt(PDEVICE_EXTENSION pExt)322 {323 #ifndef VBOX_WITH_WDDM324 return &pExt->pPrimary->u.primary.commonInfo;325 #else326 return &pExt->u.primary.commonInfo;327 #endif328 }329 330 static inline PDEVICE_EXTENSION commonToPrimaryExt(PVBOXVIDEO_COMMON pCommon)331 {332 return RT_FROM_MEMBER(pCommon, DEVICE_EXTENSION, u.primary.commonInfo);333 }334 335 #ifndef VBOX_WITH_WDDM336 #define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)337 #define DEV_SET_MOUSE_HIDDEN(dev) \338 do { \339 (dev)->pPrimary->u.primary.fMouseHidden = TRUE; \340 } while (0)341 #define DEV_SET_MOUSE_SHOWN(dev) \342 do { \343 (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \344 } while (0)345 #else346 #define DEV_MOUSE_HIDDEN(dev) ((dev)->u.primary.fMouseHidden)347 #define DEV_SET_MOUSE_HIDDEN(dev) \348 do { \349 (dev)->u.primary.fMouseHidden = TRUE; \350 } while (0)351 #define DEV_SET_MOUSE_SHOWN(dev) \352 do { \353 (dev)->u.primary.fMouseHidden = FALSE; \354 } while (0)355 #endif356 96 extern "C" 357 97 { … … 384 124 /** Read a 32-bit value from an I/O port. */ 385 125 uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port); 386 387 #ifndef VBOX_WITH_WDDM388 389 RT_C_DECLS_BEGIN390 ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2);391 RT_C_DECLS_END392 393 #else394 395 RT_C_DECLS_BEGIN396 NTSTATUS397 DriverEntry(398 IN PDRIVER_OBJECT DriverObject,399 IN PUNICODE_STRING RegistryPath400 );401 RT_C_DECLS_END402 403 PVBOXWDDM_VIDEOMODES_INFO vboxWddmGetVideoModesInfo(PDEVICE_EXTENSION DeviceExtension, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId);404 PVBOXWDDM_VIDEOMODES_INFO vboxWddmGetAllVideoModesInfos(PDEVICE_EXTENSION DeviceExtension);405 406 void vboxVideoInitCustomVideoModes(PDEVICE_EXTENSION pDevExt);407 408 VOID vboxWddmInvalidateVideoModesInfo(PDEVICE_EXTENSION DeviceExtension);409 410 /* @return STATUS_BUFFER_TOO_SMALL - if buffer is too small, STATUS_SUCCESS - on success */411 NTSTATUS vboxWddmGetModesForResolution(VIDEO_MODE_INFORMATION *pAllModes, uint32_t cAllModes, int iSearchPreferredMode,412 const D3DKMDT_2DREGION *pResolution, VIDEO_MODE_INFORMATION * pModes, uint32_t cModes, uint32_t *pcModes, int32_t *piPreferrableMode);413 414 int vboxWddmVideoModeFind(const VIDEO_MODE_INFORMATION *pModes, int cModes, const VIDEO_MODE_INFORMATION *pM);415 int vboxWddmVideoResolutionFind(const D3DKMDT_2DREGION *pResolutions, int cResolutions, const D3DKMDT_2DREGION *pRes);416 bool vboxWddmVideoResolutionsMatch(const D3DKMDT_2DREGION *pResolutions1, const D3DKMDT_2DREGION *pResolutions2, int cResolutions);417 bool vboxWddmVideoModesMatch(const VIDEO_MODE_INFORMATION *pModes1, const VIDEO_MODE_INFORMATION *pModes2, int cModes);418 419 D3DDDIFORMAT vboxWddmCalcPixelFormat(const VIDEO_MODE_INFORMATION *pInfo);420 bool vboxWddmFillMode(VIDEO_MODE_INFORMATION *pInfo, D3DDDIFORMAT enmFormat, ULONG w, ULONG h);421 422 DECLINLINE(ULONG) vboxWddmVramCpuVisibleSize(PDEVICE_EXTENSION pDevExt)423 {424 #ifdef VBOXWDDM_RENDER_FROM_SHADOW425 /* all memory layout info should be initialized */426 Assert(pDevExt->aSources[0].Vbva.offVBVA);427 /* page aligned */428 Assert(!(pDevExt->aSources[0].Vbva.offVBVA & 0xfff));429 430 return (ULONG)(pDevExt->aSources[0].Vbva.offVBVA & ~0xfffULL);431 #else432 /* all memory layout info should be initialized */433 Assert(pDevExt->u.primary.Vdma.CmdHeap.area.offBase);434 /* page aligned */435 Assert(!(pDevExt->u.primary.Vdma.CmdHeap.area.offBase & 0xfff));436 437 return pDevExt->u.primary.Vdma.CmdHeap.area.offBase & ~0xfffUL;438 #endif439 }440 441 DECLINLINE(ULONG) vboxWddmVramCpuVisibleSegmentSize(PDEVICE_EXTENSION pDevExt)442 {443 return vboxWddmVramCpuVisibleSize(pDevExt);444 }445 446 #ifdef VBOXWDDM_RENDER_FROM_SHADOW447 DECLINLINE(ULONG) vboxWddmVramCpuInvisibleSegmentSize(PDEVICE_EXTENSION pDevExt)448 {449 return vboxWddmVramCpuVisibleSegmentSize(pDevExt);450 }451 452 DECLINLINE(bool) vboxWddmCmpSurfDescsBase(VBOXWDDM_SURFACE_DESC *pDesc1, VBOXWDDM_SURFACE_DESC *pDesc2)453 {454 if (pDesc1->width != pDesc2->width)455 return false;456 if (pDesc1->height != pDesc2->height)457 return false;458 if (pDesc1->format != pDesc2->format)459 return false;460 if (pDesc1->bpp != pDesc2->bpp)461 return false;462 if (pDesc1->pitch != pDesc2->pitch)463 return false;464 return true;465 }466 467 DECLINLINE(void) vboxWddmAssignShadow(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)468 {469 if (pSource->pShadowAllocation == pAllocation)470 {471 Assert(pAllocation->bAssigned);472 return;473 }474 475 if (pSource->pShadowAllocation)476 {477 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pShadowAllocation;478 /* clear the visibility info fo the current primary */479 pOldAlloc->bVisible = FALSE;480 pOldAlloc->bAssigned = FALSE;481 Assert(pOldAlloc->SurfDesc.VidPnSourceId == srcId);482 /* release the shadow surface */483 pOldAlloc->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED;484 }485 486 if (pAllocation)487 {488 Assert(!pAllocation->bAssigned);489 Assert(!pAllocation->bVisible);490 pAllocation->bVisible = FALSE;491 /* this check ensures the shadow is not used for other source simultaneously */492 Assert(pAllocation->SurfDesc.VidPnSourceId == D3DDDI_ID_UNINITIALIZED);493 pAllocation->SurfDesc.VidPnSourceId = srcId;494 pAllocation->bAssigned = TRUE;495 if (!vboxWddmCmpSurfDescsBase(&pSource->SurfDesc, &pAllocation->SurfDesc))496 pSource->offVram = VBOXVIDEOOFFSET_VOID; /* force guest->host notification */497 pSource->SurfDesc = pAllocation->SurfDesc;498 }499 500 pSource->pShadowAllocation = pAllocation;501 }502 #endif503 504 DECLINLINE(VOID) vboxWddmAssignPrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)505 {506 if (pSource->pPrimaryAllocation == pAllocation)507 return;508 509 if (pSource->pPrimaryAllocation)510 {511 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pPrimaryAllocation;512 /* clear the visibility info fo the current primary */513 pOldAlloc->bVisible = FALSE;514 pOldAlloc->bAssigned = FALSE;515 Assert(pOldAlloc->SurfDesc.VidPnSourceId == srcId);516 }517 518 if (pAllocation)519 {520 pAllocation->bVisible = FALSE;521 Assert(pAllocation->SurfDesc.VidPnSourceId == srcId);522 pAllocation->SurfDesc.VidPnSourceId = srcId;523 pAllocation->bAssigned = TRUE;524 }525 526 pSource->pPrimaryAllocation = pAllocation;527 }528 529 530 #endif531 126 532 127 void* vboxHGSMIBufferAlloc(PVBOXVIDEO_COMMON pCommon, … … 537 132 int vboxHGSMIBufferSubmit (PVBOXVIDEO_COMMON pCommon, void *pvBuffer); 538 133 539 BOOLEAN FASTCALL VBoxVideoSetCurrentModePerform(PDEVICE_EXTENSION DeviceExtension,540 USHORT width, USHORT height, USHORT bpp541 #ifdef VBOX_WITH_WDDM542 , ULONG offDisplay543 #endif544 );545 546 BOOLEAN FASTCALL VBoxVideoSetCurrentMode(547 PDEVICE_EXTENSION DeviceExtension,548 PVIDEO_MODE RequestedMode,549 PSTATUS_BLOCK StatusBlock);550 551 BOOLEAN FASTCALL VBoxVideoResetDevice(552 PDEVICE_EXTENSION DeviceExtension,553 PSTATUS_BLOCK StatusBlock);554 555 BOOLEAN FASTCALL VBoxVideoMapVideoMemory(556 PDEVICE_EXTENSION DeviceExtension,557 PVIDEO_MEMORY RequestedAddress,558 PVIDEO_MEMORY_INFORMATION MapInformation,559 PSTATUS_BLOCK StatusBlock);560 561 BOOLEAN FASTCALL VBoxVideoUnmapVideoMemory(562 PDEVICE_EXTENSION DeviceExtension,563 PVIDEO_MEMORY VideoMemory,564 PSTATUS_BLOCK StatusBlock);565 566 BOOLEAN FASTCALL VBoxVideoQueryNumAvailModes(567 PDEVICE_EXTENSION DeviceExtension,568 PVIDEO_NUM_MODES Modes,569 PSTATUS_BLOCK StatusBlock);570 571 BOOLEAN FASTCALL VBoxVideoQueryAvailModes(572 PDEVICE_EXTENSION DeviceExtension,573 PVIDEO_MODE_INFORMATION ReturnedModes,574 PSTATUS_BLOCK StatusBlock);575 576 BOOLEAN FASTCALL VBoxVideoQueryCurrentMode(577 PDEVICE_EXTENSION DeviceExtension,578 PVIDEO_MODE_INFORMATION VideoModeInfo,579 PSTATUS_BLOCK StatusBlock);580 581 BOOLEAN FASTCALL VBoxVideoSetColorRegisters(582 PDEVICE_EXTENSION DeviceExtension,583 PVIDEO_CLUT ColorLookUpTable,584 PSTATUS_BLOCK StatusBlock);585 586 134 int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon, 587 135 void **ppv, 588 ULONGulOffset,589 ULONGulSize);136 uint32_t ulOffset, 137 uint32_t ulSize); 590 138 591 139 void VBoxUnmapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv); … … 595 143 void *pvUser); 596 144 597 void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);598 599 600 145 /* 601 146 * Host and Guest port IO helpers. 602 147 */ 603 DECLINLINE(void) VBoxHGSMIHostWrite(PVBOXVIDEO_COMMON pCommon, ULONGdata)148 DECLINLINE(void) VBoxHGSMIHostWrite(PVBOXVIDEO_COMMON pCommon, uint32_t data) 604 149 { 605 150 VBoxVideoCmnPortWriteUlong(pCommon->IOPortHost, data); 606 151 } 607 152 608 DECLINLINE( ULONG) VBoxHGSMIHostRead(PVBOXVIDEO_COMMON pCommon)153 DECLINLINE(uint32_t) VBoxHGSMIHostRead(PVBOXVIDEO_COMMON pCommon) 609 154 { 610 155 return VBoxVideoCmnPortReadUlong(pCommon->IOPortHost); 611 156 } 612 157 613 DECLINLINE(void) VBoxHGSMIGuestWrite(PVBOXVIDEO_COMMON pCommon, ULONGdata)158 DECLINLINE(void) VBoxHGSMIGuestWrite(PVBOXVIDEO_COMMON pCommon, uint32_t data) 614 159 { 615 160 VBoxVideoCmnPortWriteUlong(pCommon->IOPortGuest, data); 616 161 } 617 162 618 DECLINLINE( ULONG) VBoxHGSMIGuestRead(PVBOXVIDEO_COMMON pCommon)163 DECLINLINE(uint32_t) VBoxHGSMIGuestRead(PVBOXVIDEO_COMMON pCommon) 619 164 { 620 165 return VBoxVideoCmnPortReadUlong(pCommon->IOPortGuest); 621 166 } 622 167 623 624 BOOLEAN VBoxHGSMIIsSupported (void); 168 bool VBoxHGSMIIsSupported (void); 625 169 626 170 typedef int FNHGSMIFILLVIEWINFO (void *pvData, VBVAINFOVIEW *pInfo); … … 629 173 int VBoxHGSMISendViewInfo(PVBOXVIDEO_COMMON pCommon, uint32_t u32Count, PFNHGSMIFILLVIEWINFO pfnFill, void *pvData); 630 174 631 VOID VBoxSetupDisplaysHGSMI (PVBOXVIDEO_COMMON pCommon, 632 ULONG AdapterMemorySize, uint32_t fCaps); 633 BOOLEAN vboxUpdatePointerShape (PVBOXVIDEO_COMMON pCommon, 634 PVIDEO_POINTER_ATTRIBUTES pointerAttr, 635 uint32_t cbLength); 175 void VBoxSetupDisplaysHGSMI (PVBOXVIDEO_COMMON pCommon, 176 uint32_t AdapterMemorySize, uint32_t fCaps); 177 178 bool vboxUpdatePointerShape (PVBOXVIDEO_COMMON pCommon, 179 uint32_t fFlags, 180 uint32_t cHotX, 181 uint32_t cHotY, 182 uint32_t cWidth, 183 uint32_t cHeight, 184 uint8_t *pPixels, 185 uint32_t cbLength); 636 186 637 187 void VBoxFreeDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon); -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp
r33997 r34079 16 16 */ 17 17 18 #include <string.h> 18 19 19 20 #include "VBoxVideo.h" … … 27 28 #include <VBox/VBoxVideo.h> 28 29 29 #include <VBoxDisplay.h>30 31 #include "vboxioctl.h"30 // #include <VBoxDisplay.h> 31 32 // #include "vboxioctl.h" 32 33 33 34 void HGSMINotifyHostCmdComplete (PVBOXVIDEO_COMMON pCommon, HGSMIOFFSET offt) … … 93 94 94 95 /* Detect whether HGSMI is supported by the host. */ 95 BOOLEANVBoxHGSMIIsSupported (void)96 { 97 USHORTDispiId;96 bool VBoxHGSMIIsSupported (void) 97 { 98 uint16_t DispiId; 98 99 99 100 VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID); … … 216 217 typedef struct _QUERYCONFCTX 217 218 { 218 uint32_t u32Index;219 ULONG*pulValue;219 uint32_t u32Index; 220 uint32_t *pulValue; 220 221 } QUERYCONFCTX; 221 222 … … 245 246 } 246 247 247 static int vboxQueryConfHGSMI (PVBOXVIDEO_COMMON pCommon, uint32_t u32Index, ULONG*pulValue)248 static int vboxQueryConfHGSMI (PVBOXVIDEO_COMMON pCommon, uint32_t u32Index, uint32_t *pulValue) 248 249 { 249 250 Log(("VBoxVideo::vboxQueryConf: u32Index = %d\n", u32Index)); … … 379 380 * to talk to the host. 380 381 */ 381 VOID VBoxSetupDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon, 382 ULONG AdapterMemorySize, uint32_t fCaps) 383 { 384 VP_STATUS rc = NO_ERROR; 382 void VBoxSetupDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon, 383 uint32_t AdapterMemorySize, uint32_t fCaps) 384 { 385 /** @todo I simply converted this from Windows error codes. That is wrong, 386 * but we currently freely mix and match those (failure == rc > 0) and iprt 387 * ones (failure == rc < 0) anyway. This needs to be fully reviewed and 388 * fixed. */ 389 int rc = VINF_SUCCESS; 385 390 386 391 Log(("VBoxVideo::VBoxSetupDisplays: pCommon = %p\n", pCommon)); … … 402 407 403 408 /* Map the adapter information. It will be needed for HGSMI IO. */ 409 /** @todo all callers of VBoxMapAdapterMemory expect it to use iprt 410 * error codes, but it doesn't. */ 404 411 rc = VBoxMapAdapterMemory (pCommon, &pCommon->pvAdapterInformation, 405 412 AdapterMemorySize - VBVA_ADAPTER_INFORMATION_SIZE, 406 413 VBVA_ADAPTER_INFORMATION_SIZE 407 414 ); 408 if ( rc != NO_ERROR)415 if (RT_FAILURE(rc)) 409 416 { 410 417 Log(("VBoxVideo::VBoxSetupDisplays: VBoxMapAdapterMemory pvAdapterInfoirrmation failed rc = %d\n", 411 418 rc)); 412 419 413 pCommon->bHGSMI = FALSE;420 pCommon->bHGSMI = false; 414 421 } 415 422 else … … 422 429 false /*fOffsetBased*/); 423 430 424 if (RT_FAILURE 431 if (RT_FAILURE(rc)) 425 432 { 426 433 Log(("VBoxVideo::VBoxSetupDisplays: HGSMIHeapSetup failed rc = %d\n", 427 434 rc)); 428 435 429 pCommon->bHGSMI = FALSE;436 pCommon->bHGSMI = false; 430 437 } 431 438 else … … 441 448 { 442 449 /* The miniport heap is used for the host buffers. */ 443 ULONGcbMiniportHeap = 0;450 uint32_t cbMiniportHeap = 0; 444 451 vboxQueryConfHGSMI (pCommon, VBOX_VBVA_CONF32_HOST_HEAP_SIZE, &cbMiniportHeap); 445 452 … … 447 454 { 448 455 /* Do not allow too big heap. No more than 25% of VRAM is allowed. */ 449 ULONGcbMiniportHeapMaxSize = AdapterMemorySize / 4;456 uint32_t cbMiniportHeapMaxSize = AdapterMemorySize / 4; 450 457 451 458 if (cbMiniportHeapMaxSize >= VBVA_ADAPTER_INFORMATION_SIZE) … … 477 484 pCommon->cbMiniportHeap 478 485 ); 479 if ( rc != NO_ERROR)486 if (RT_FAILURE(rc)) 480 487 { 481 488 pCommon->pvMiniportHeap = NULL; 482 489 pCommon->cbMiniportHeap = 0; 483 pCommon->bHGSMI = FALSE;490 pCommon->bHGSMI = false; 484 491 } 485 492 else … … 508 515 { 509 516 /* Query the configured number of displays. */ 510 ULONGcDisplays = 0;517 uint32_t cDisplays = 0; 511 518 vboxQueryConfHGSMI (pCommon, VBOX_VBVA_CONF32_MONITOR_COUNT, &cDisplays); 512 519 … … 527 534 rc = vboxSetupAdapterInfoHGSMI (pCommon); 528 535 529 if (RT_FAILURE 530 { 531 pCommon->bHGSMI = FALSE;536 if (RT_FAILURE(rc)) 537 { 538 pCommon->bHGSMI = false; 532 539 } 533 540 } … … 539 546 } 540 547 541 static bool VBoxUnmapAdpInfoCallback( PVOIDpvCommon)548 static bool VBoxUnmapAdpInfoCallback(void *pvCommon) 542 549 { 543 550 PVBOXVIDEO_COMMON pCommon = (PVBOXVIDEO_COMMON)pvCommon; 544 551 545 552 pCommon->pHostFlags = NULL; 546 return TRUE;553 return true; 547 554 } 548 555 … … 562 569 typedef struct _MOUSEPOINTERSHAPECTX 563 570 { 564 VIDEO_POINTER_ATTRIBUTES *pPointerAttr; 571 uint32_t fFlags; 572 uint32_t cHotX; 573 uint32_t cHotY; 574 uint32_t cWidth; 575 uint32_t cHeight; 565 576 uint32_t cbData; 566 int32_t i32Result; 577 uint8_t *pPixels; 578 int32_t i32Result; 567 579 } MOUSEPOINTERSHAPECTX; 568 580 … … 576 588 577 589 /* We have our custom flags in the field */ 578 p->fu32Flags = pCtx-> pPointerAttr->Enable & 0x0000FFFF;579 580 p->u32HotX = (pCtx->pPointerAttr->Enable >> 16) & 0xFF;581 p->u32HotY = (pCtx->pPointerAttr->Enable >> 24) & 0xFF;582 p->u32Width = pCtx-> pPointerAttr->Width;583 p->u32Height = pCtx-> pPointerAttr->Height;590 p->fu32Flags = pCtx->fFlags; 591 592 p->u32HotX = pCtx->cHotX; 593 p->u32HotY = pCtx->cHotY; 594 p->u32Width = pCtx->cWidth; 595 p->u32Height = pCtx->cHeight; 584 596 585 597 if (p->fu32Flags & VBOX_MOUSE_POINTER_SHAPE) … … 591 603 592 604 /* Copy the actual pointer data. */ 593 memcpy (p->au8Data, pCtx->pP ointerAttr->Pixels, pCtx->cbData);605 memcpy (p->au8Data, pCtx->pPixels, pCtx->cbData); 594 606 } 595 607 … … 607 619 } 608 620 609 BOOLEAN vboxUpdatePointerShape (PVBOXVIDEO_COMMON pCommon, 610 PVIDEO_POINTER_ATTRIBUTES pointerAttr, 611 uint32_t cbLength) 621 bool vboxUpdatePointerShape (PVBOXVIDEO_COMMON pCommon, 622 uint32_t fFlags, 623 uint32_t cHotX, 624 uint32_t cHotY, 625 uint32_t cWidth, 626 uint32_t cHeight, 627 uint8_t *pPixels, 628 uint32_t cbLength) 612 629 { 613 630 uint32_t cbData = 0; 614 631 615 if ( pointerAttr->Enable& VBOX_MOUSE_POINTER_SHAPE)632 if (fFlags & VBOX_MOUSE_POINTER_SHAPE) 616 633 { 617 634 /* Size of the pointer data: sizeof (AND mask) + sizeof (XOR_MASK) */ 618 cbData = (((( pointerAttr->Width + 7) / 8) * pointerAttr->Height + 3) & ~3)619 + pointerAttr->Width * 4 * pointerAttr->Height;635 cbData = ((((cWidth + 7) / 8) * cHeight + 3) & ~3) 636 + cWidth * 4 * cHeight; 620 637 } 621 638 622 639 #ifndef DEBUG_misha 623 640 Log(("vboxUpdatePointerShape: cbData %d, %dx%d\n", 624 cbData, pointerAttr->Width, pointerAttr->Height));641 cbData, cWidth, cHeight)); 625 642 #endif 626 643 627 if (cbData > cbLength - sizeof(VIDEO_POINTER_ATTRIBUTES))644 if (cbData > cbLength) 628 645 { 629 646 Log(("vboxUpdatePointerShape: calculated pointer data size is too big (%d bytes, limit %d)\n", 630 cbData, cbLength - sizeof(VIDEO_POINTER_ATTRIBUTES)));631 return FALSE;647 cbData, cbLength)); 648 return false; 632 649 } 633 650 634 651 MOUSEPOINTERSHAPECTX ctx; 635 652 636 ctx.pPointerAttr = pointerAttr; 637 ctx.cbData = cbData; 653 ctx.fFlags = fFlags; 654 ctx.cHotX = cHotX; 655 ctx.cHotY = cHotY; 656 ctx.cWidth = cWidth; 657 ctx.cHeight = cHeight; 658 ctx.pPixels = pPixels; 659 ctx.cbData = cbData; 638 660 ctx.i32Result = VERR_NOT_SUPPORTED; 639 661 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoCm.cpp
r33540 r34079 10 10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 11 11 */ 12 #include "../VBoxVideo .h"12 #include "../VBoxVideo-win.h" 13 13 #include "../Helper.h" 14 14 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoMisc.cpp
r33531 r34079 11 11 */ 12 12 13 #include "../VBoxVideo .h"13 #include "../VBoxVideo-win.h" 14 14 #include "../Helper.h" 15 15 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoShgsmi.cpp
r33216 r34079 11 11 */ 12 12 13 #include "../VBoxVideo .h"13 #include "../VBoxVideo-win.h" 14 14 #include "../Helper.h" 15 15 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVbva.cpp
r33711 r34079 16 16 */ 17 17 18 #include "../VBoxVideo .h"18 #include "../VBoxVideo-win.h" 19 19 #include "../Helper.h" 20 20 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.cpp
r33711 r34079 11 11 */ 12 12 13 #include "../VBoxVideo .h"13 #include "../VBoxVideo-win.h" 14 14 #include "../Helper.h" 15 15 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.cpp
r33714 r34079 10 10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 11 11 */ 12 #include "../VBoxVideo .h"12 #include "../VBoxVideo-win.h" 13 13 #include "../Helper.h" 14 14 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp
r34018 r34079 10 10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 11 11 */ 12 #include "../VBoxVideo .h"12 #include "../VBoxVideo-win.h" 13 13 #include "../Helper.h" 14 14 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r34018 r34079 11 11 */ 12 12 13 #include "../VBoxVideo .h"13 #include "../VBoxVideo-win.h" 14 14 #include "../Helper.h" 15 15 … … 3181 3181 PointerAttributes.Enable = pSetPointerPosition->Flags.Visible ? VBOX_MOUSE_POINTER_VISIBLE : 0; 3182 3182 3183 BOOLEAN bResult = vboxUpdatePointerShape (commonFromDeviceExt(pDevExt), &PointerAttributes, sizeof (PointerAttributes));3183 BOOLEAN bResult = vboxUpdatePointerShapeWrap(commonFromDeviceExt(pDevExt), &PointerAttributes, sizeof (PointerAttributes)); 3184 3184 Assert(bResult); 3185 3185 } … … 3211 3211 if (vboxVddmPointerShapeToAttributes(pSetPointerShape, pPointerInfo)) 3212 3212 { 3213 if (vboxUpdatePointerShape (commonFromDeviceExt(pDevExt), &pPointerInfo->Attributes.data, VBOXWDDM_POINTER_ATTRIBUTES_SIZE))3213 if (vboxUpdatePointerShapeWrap (commonFromDeviceExt(pDevExt), &pPointerInfo->Attributes.data, VBOXWDDM_POINTER_ATTRIBUTES_SIZE)) 3214 3214 Status = STATUS_SUCCESS; 3215 3215 else
Note:
See TracChangeset
for help on using the changeset viewer.