Changeset 3153 in vbox for trunk/src/VBox/Additions/WINNT
- Timestamp:
- Jun 19, 2007 9:40:23 AM (17 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h
r2558 r3153 23 23 #include "../Miniport/vboxioctl.h" 24 24 25 #include <VBox/VBoxVideo.h> 26 25 27 /* Forward declaration. */ 26 28 struct _PDEV; 27 29 typedef struct _PDEV PDEV; 28 30 typedef PDEV *PPDEV; 31 32 typedef struct _VBOXDISPLAYINFO 33 { 34 VBOXVIDEOINFOHDR hdrLink; 35 VBOXVIDEOINFOLINK link; 36 VBOXVIDEOINFOHDR hdrScreen; 37 VBOXVIDEOINFOSCREEN screen; 38 VBOXVIDEOINFOHDR hdrHostEvents; 39 VBOXVIDEOINFOHOSTEVENTS hostEvents; 40 VBOXVIDEOINFOHDR hdrEnd; 41 } VBOXDISPLAYINFO; 29 42 30 43 #include "vbvavrdp.h" … … 52 65 POINTL ptlOrg; // Where this display is anchored in 53 66 // the virtual desktop. 67 POINTL ptlDevOrg; // Device origin for DualView (0,0 for primary view). 54 68 ULONG ulMode; // Mode the mini-port driver is in. 55 69 LONG lDeltaScreen; // Distance from one scan to the next. … … 74 88 75 89 VBVAENABLERESULT vbva; 76 HSEMAPHORE hsemHwBuffer;90 uint32_t u32VRDPResetFlag; 77 91 BOOL fHwBufferOverflow; 78 92 VBVARECORD *pRecord; … … 81 95 ULONG cSSB; // Number of active saved screen bits records in the following array. 82 96 SSB aSSB[4]; // LIFO type stack for saved screen areas. 97 98 VBOXDISPLAYINFO *pInfo; 99 ULONG iDevice; 83 100 }; 101 102 /* The global semaphore handle for all driver instances. */ 103 extern HSEMAPHORE ghsemHwBuffer; 104 84 105 85 106 DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *); … … 126 147 BOOL vboxOrderSupported (PPDEV ppdev, unsigned code); 127 148 149 void VBoxProcessDisplayInfo(PPDEV ppdev); 150 void VBoxUpdateDisplayInfo (PPDEV ppdev); 128 151 129 152 void drvLoadEng (void); -
trunk/src/VBox/Additions/WINNT/Graphics/Display/drv.c
r2981 r3153 99 99 PPDEV ppdev = (PPDEV)__psoDest->dhpdev; \ 100 100 \ 101 if ( vboxHwBufferBeginUpdate (ppdev))\101 if (ppdev->pInfo && vboxHwBufferBeginUpdate (ppdev)) \ 102 102 { \ 103 103 vbva##__fn __a; \ 104 104 \ 105 if ( ppdev->vbva.pVbvaMemory->fu32ModeFlags\106 & VB VA_F_MODE_VRDP_RESET)\105 if ( ppdev->pInfo->hostEvents.fu32Events \ 106 & VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET) \ 107 107 { \ 108 108 vrdpReset (ppdev); \ 109 109 \ 110 ppdev-> vbva.pVbvaMemory->fu32ModeFlags &=\111 ~VBVA_F_MODE_VRDP_RESET;\110 ppdev->pInfo->hostEvents.fu32Events &= \ 111 ~VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET; \ 112 112 } \ 113 113 \ -
trunk/src/VBox/Additions/WINNT/Graphics/Display/enable.c
r2558 r3153 167 167 { INDEX_DrvSaveScreenBits, (PFN) DrvSaveScreenBits }, // 40 0x28 168 168 { INDEX_DrvGetModes, (PFN) DrvGetModes }, // 41 0x29 169 { INDEX_DrvNotify, (PFN) DrvNotify }, // 87 0x57 169 170 // /* Experimental. */ 170 171 // { 0x7, (PFN) DrvResetPDEV }, // 0x7 … … 191 192 #define HOOKS_BMF32BPP gflHooks 192 193 194 HSEMAPHORE ghsemHwBuffer = 0; 195 193 196 /******************************Public*Routine******************************\ 194 197 * DrvEnableDriver … … 238 241 DDI_DRIVER_VERSION_NT4; 239 242 243 if (!ghsemHwBuffer) 244 { 245 ghsemHwBuffer = EngCreateSemaphore (); 246 } 247 240 248 return(TRUE); 241 249 } … … 252 260 { 253 261 DISPDBG((0, "VBoxDisp::DrvDisableDriver called.\n")); 262 263 if (ghsemHwBuffer) 264 { 265 EngDeleteSemaphore (ghsemHwBuffer); 266 ghsemHwBuffer = NULL; 267 } 268 254 269 return; 255 270 } … … 822 837 } 823 838 839 /******************************Public*Routine******************************\ 840 * DrvNotify 841 * 842 * Called by GDI to notify us of certain "interesting" events 843 * 844 * DN_DEVICE_ORIGIN is used to communicate the X/Y offsets of individual monitors 845 * when DualView is in effect. 846 * 847 \**************************************************************************/ 848 849 VOID DrvNotify( 850 SURFOBJ *pso, 851 ULONG iType, 852 PVOID pvData) 853 { 854 PDEV* ppdev = (PDEV*) pso->dhpdev; 855 856 DISPDBG((0, "VBoxDisp::DrvNotify called.\n")); 857 858 switch(iType) 859 { 860 case DN_DEVICE_ORIGIN: 861 ppdev->ptlDevOrg = *(PPOINTL)pvData; 862 DISPDBG((3, "DN_DEVICE_ORIGIN: %d, %d (PSO = %p, pInfo = %p)\n", ppdev->ptlDevOrg.x, 863 ppdev->ptlDevOrg.y, pso, ppdev->pInfo)); 864 if (ppdev->pInfo) 865 { 866 ppdev->pInfo->screen.xOrigin = ppdev->ptlDevOrg.x; 867 ppdev->pInfo->screen.yOrigin = ppdev->ptlDevOrg.y; 868 VBoxProcessDisplayInfo(ppdev); 869 } 870 break; 871 case DN_DRAWING_BEGIN: 872 DISPDBG((3, "DN_DRAWING_BEGIN (PSO = %p)\n", pso)); 873 break; 874 } 875 } -
trunk/src/VBox/Additions/WINNT/Graphics/Display/screen.c
r1 r3153 35 35 }; 36 36 37 /* Setup display information after remapping. */ 38 static void vboxSetupDisplayInfo (PPDEV ppdev, VIDEO_MEMORY_INFORMATION *pMemoryInformation) 39 { 40 VBOXDISPLAYINFO *pInfo; 41 uint8_t *pu8; 42 43 DWORD returnedDataLength; 44 QUERYDISPLAYINFORESULT DispInfo; 45 RtlZeroMemory(&DispInfo, sizeof (DispInfo)); 46 if (EngDeviceIoControl(ppdev->hDriver, 47 IOCTL_VIDEO_QUERY_DISPLAY_INFO, 48 NULL, 49 0, 50 &DispInfo, 51 sizeof(DispInfo), 52 &returnedDataLength)) 53 { 54 DISPDBG((1, "DISP bInitSURF failed IOCTL_VIDEO_QUERY_DISPLAY_INFO\n")); 55 ppdev->pInfo = NULL; 56 return; 57 } 58 59 if (returnedDataLength != sizeof (QUERYDISPLAYINFORESULT) 60 || DispInfo.u32DisplayInfoSize >= pMemoryInformation->VideoRamLength) 61 { 62 DISPDBG((1, "DISP bInitSURF failed DispInfo.u32DisplayInfoSize 0x%x >= pMemoryInformation->VideoRamLength 0x%x\n", 63 DispInfo.u32DisplayInfoSize, pMemoryInformation->VideoRamLength)); 64 ppdev->pInfo = NULL; 65 return; 66 } 67 68 ppdev->iDevice = DispInfo.iDevice; 69 70 pu8 = (uint8_t *)pMemoryInformation->VideoRamBase; 71 pu8 += pMemoryInformation->VideoRamLength - DispInfo.u32DisplayInfoSize; 72 73 pInfo = (VBOXDISPLAYINFO *)pu8; 74 pu8 += sizeof (VBOXDISPLAYINFO); 75 76 pInfo->hdrLink.u8Type = VBOX_VIDEO_INFO_TYPE_LINK; 77 pInfo->hdrLink.u8Reserved = 0; 78 pInfo->hdrLink.u16Length = sizeof (VBOXVIDEOINFOLINK); 79 pInfo->link.i32Offset = 0; 80 81 pInfo->hdrScreen.u8Type = VBOX_VIDEO_INFO_TYPE_SCREEN; 82 pInfo->hdrScreen.u8Reserved = 0; 83 pInfo->hdrScreen.u16Length = sizeof (VBOXVIDEOINFOSCREEN); 84 DISPDBG((1, "Setup: %d,%d\n", ppdev->ptlDevOrg.x, ppdev->ptlDevOrg.y)); 85 pInfo->screen.xOrigin = ppdev->ptlDevOrg.x; 86 pInfo->screen.yOrigin = ppdev->ptlDevOrg.y; 87 pInfo->screen.u32LineSize = 0; 88 pInfo->screen.u16Width = 0; 89 pInfo->screen.u16Height = 0; 90 pInfo->screen.bitsPerPixel = 0; 91 pInfo->screen.u8Flags = VBOX_VIDEO_INFO_SCREEN_F_NONE; 92 93 pInfo->hdrHostEvents.u8Type = VBOX_VIDEO_INFO_TYPE_HOST_EVENTS; 94 pInfo->hdrHostEvents.u8Reserved = 0; 95 pInfo->hdrHostEvents.u16Length = sizeof (VBOXVIDEOINFOHOSTEVENTS); 96 pInfo->hostEvents.fu32Events = VBOX_VIDEO_INFO_HOST_EVENTS_F_NONE; 97 98 pInfo->hdrEnd.u8Type = VBOX_VIDEO_INFO_TYPE_END; 99 pInfo->hdrEnd.u8Reserved = 0; 100 pInfo->hdrEnd.u16Length = 0; 101 102 ppdev->pInfo = pInfo; 103 } 104 105 106 static void vboxUpdateDisplayInfo (PPDEV ppdev) 107 { 108 if (ppdev->pInfo) 109 { 110 ppdev->pInfo->screen.u32LineSize = ppdev->lDeltaScreen; 111 ppdev->pInfo->screen.u16Width = (uint16_t)ppdev->cxScreen; 112 ppdev->pInfo->screen.u16Height = (uint16_t)ppdev->cyScreen; 113 ppdev->pInfo->screen.bitsPerPixel = (uint8_t)ppdev->ulBitCount; 114 ppdev->pInfo->screen.u8Flags = VBOX_VIDEO_INFO_SCREEN_F_ACTIVE; 115 116 DISPDBG((1, "Update: %d,%d\n", ppdev->ptlDevOrg.x, ppdev->ptlDevOrg.y)); 117 VBoxProcessDisplayInfo(ppdev); 118 } 119 } 120 121 37 122 /******************************Public*Routine******************************\ 38 123 * bInitSURF … … 155 240 ppdev->pPointerAttributes->Row = 0; 156 241 ppdev->pPointerAttributes->Enable = 0; 242 243 /* Setup the display information. */ 244 vboxSetupDisplayInfo (ppdev, &videoMemoryInformation); 157 245 } 158 246 … … 164 252 || ppdev->ulBitCount == 32) 165 253 { 166 /* Enable VBVA for this video mode. */ 167 vboxVbvaEnable (ppdev); 254 if (ppdev->pInfo) /* Do not use VBVA on old hosts. */ 255 { 256 /* Enable VBVA for this video mode. */ 257 vboxVbvaEnable (ppdev); 258 } 168 259 } 169 260 170 261 DISPDBG((1, "DISP bInitSURF success\n")); 262 263 /* Update the display information. */ 264 vboxUpdateDisplayInfo (ppdev); 171 265 172 266 return(TRUE); -
trunk/src/VBox/Additions/WINNT/Graphics/Display/vbox.c
r2981 r3153 55 55 56 56 DISPDBG((1, "VBoxDisp::vboxVbvaEnable called\n")); 57 58 if (!ghsemHwBuffer) 59 { 60 return FALSE; 61 } 57 62 58 63 if (EngDeviceIoControl(ppdev->hDriver, … … 71 76 && ppdev->vbva.pvFlush) 72 77 { 73 if (!ppdev->hsemHwBuffer) 74 { 75 ppdev->hsemHwBuffer = EngCreateSemaphore (); 76 } 77 78 if (ppdev->hsemHwBuffer) 79 { 80 ppdev->fHwBufferOverflow = FALSE; 81 ppdev->pRecord = NULL; 82 83 /* All have been initialized. */ 84 bRc = TRUE; 85 } 86 else 87 { 88 DISPDBG((1, "VBoxDisp::vboxVbvaEnable failed to create semaphore!!!\n")); 89 } 78 ppdev->fHwBufferOverflow = FALSE; 79 ppdev->pRecord = NULL; 80 81 /* All have been initialized. */ 82 bRc = TRUE; 90 83 } 91 84 } … … 104 97 105 98 RtlZeroMemory (&ppdev->vbva, sizeof (ppdev->vbva)); 106 107 if (ppdev->hsemHwBuffer)108 {109 EngDeleteSemaphore (ppdev->hsemHwBuffer);110 ppdev->hsemHwBuffer = NULL;111 }112 99 113 100 ppdev->fHwBufferOverflow = FALSE; … … 130 117 uint32_t indexRecordNext; 131 118 132 EngAcquireSemaphore ( ppdev->hsemHwBuffer);119 EngAcquireSemaphore (ghsemHwBuffer); 133 120 134 121 VBVA_ASSERT (!ppdev->fHwBufferOverflow); … … 148 135 DISPDBG((1, "VBoxDisp::vboxHwBufferBeginUpdate no space in the queue of records!!! first %d, last %d\n", 149 136 pVbvaMemory->indexRecordFirst, pVbvaMemory->indexRecordFree)); 150 EngReleaseSemaphore ( ppdev->hsemHwBuffer);137 EngReleaseSemaphore (ghsemHwBuffer); 151 138 } 152 139 else … … 190 177 ppdev->pRecord = NULL; 191 178 192 EngReleaseSemaphore ( ppdev->hsemHwBuffer);179 EngReleaseSemaphore (ghsemHwBuffer); 193 180 194 181 return; … … 336 323 } 337 324 325 void VBoxProcessDisplayInfo(PPDEV ppdev) 326 { 327 DWORD returnedDataLength; 328 329 DISPDBG((1, "Process: %d,%d\n", ppdev->ptlDevOrg.x, ppdev->ptlDevOrg.y)); 330 331 EngDeviceIoControl(ppdev->hDriver, 332 IOCTL_VIDEO_INTERPRET_DISPLAY_MEMORY, 333 NULL, 334 0, 335 NULL, 336 0, 337 &returnedDataLength); 338 } -
trunk/src/VBox/Additions/WINNT/Graphics/Display/vbva.c
r2981 r3153 23 23 #include "driver.h" 24 24 25 void vboxReportDirtyRect (PPDEV ppdev, RECTL *pRect )25 void vboxReportDirtyRect (PPDEV ppdev, RECTL *pRectOrig) 26 26 { 27 27 if (ppdev) 28 28 { 29 29 VBVACMDHDR hdr; 30 31 hdr.x = (int16_t)pRect->left; 32 hdr.y = (int16_t)pRect->top; 33 hdr.w = (uint16_t)(pRect->right - pRect->left); 34 hdr.h = (uint16_t)(pRect->bottom - pRect->top); 30 31 RECTL rect = *pRectOrig; 32 33 if (rect.left < 0) rect.left = 0; 34 if (rect.top < 0) rect.top = 0; 35 if (rect.right > (int)ppdev->cxScreen) rect.right = ppdev->cxScreen; 36 if (rect.bottom > (int)ppdev->cyScreen) rect.bottom = ppdev->cyScreen; 37 38 hdr.x = (int16_t)rect.left; 39 hdr.y = (int16_t)rect.top; 40 hdr.w = (uint16_t)(rect.right - rect.left); 41 hdr.h = (uint16_t)(rect.bottom - rect.top); 42 43 hdr.x += (int16_t)ppdev->ptlDevOrg.x; 44 hdr.y += (int16_t)ppdev->ptlDevOrg.y; 35 45 36 46 vboxWrite (ppdev, &hdr, sizeof(hdr)); -
trunk/src/VBox/Additions/WINNT/Graphics/Display/vrdp.c
r2981 r3153 304 304 DISPDBG((1, "%d rects\n", cRects)); 305 305 306 VBVA_ASSERT(cRects > 0); 307 308 for (; cRects != 0; cRects--, prclClipSrc++) 309 { 310 vrdpIntersectRects (prclClipDst, prclClipSrc, &pClipRects->rclDst); 311 312 if (vrdpIsRectEmpty (prclClipDst)) 306 if (cRects > 0) 307 { 308 for (; cRects != 0; cRects--, prclClipSrc++) 313 309 { 314 pClipRects->rects.c--; 310 vrdpIntersectRects (prclClipDst, prclClipSrc, &pClipRects->rclDst); 311 312 if (vrdpIsRectEmpty (prclClipDst)) 313 { 314 pClipRects->rects.c--; 315 } 316 else 317 { 318 prclClipDst++; 319 } 315 320 } 316 else317 {318 prclClipDst++;319 }321 } 322 else 323 { 324 pClipRects->rclDst.left = pClipRects->rclDst.right = 0; 320 325 } 321 326 } … … 757 762 memcpy (order.pattern, pBrush->u.pat.au8Pattern, sizeof (order.pattern)); 758 763 759 vrdpReportOrderGeneric (ppdev, pClipRects, &order, sizeof (order), VBVA_VRDP_PATBLT _BRUSH);764 vrdpReportOrderGeneric (ppdev, pClipRects, &order, sizeof (order), VBVA_VRDP_PATBLTBRUSH); 760 765 } 761 766 … … 1051 1056 int cacheResult; 1052 1057 1058 DISPDBG((1, "VRDP::vrdpBitBlt: MEMBLT.\n")); 1053 1059 if ( (psoSrc->fjBitmap & BMF_DONTCACHE) != 0 1054 1060 || psoSrc->iUniq == 0) … … 1059 1065 else 1060 1066 { 1067 DISPDBG((1, "VRDP::vrdpBitBlt: going to cache.\n")); 1061 1068 cacheResult = vrdpbmpCacheSurface (&ppdev->cache, psoSrc, &hash, &hashDeleted); 1062 1069 } … … 1742 1749 void vrdpReset (PPDEV ppdev) 1743 1750 { 1751 DISPDBG((1, "vrdpReset %p\n", ppdev)); 1752 1744 1753 vrdpbmpReset (&ppdev->cache); 1745 1754 -
trunk/src/VBox/Additions/WINNT/Graphics/Display/vrdpbmp.c
r2981 r3153 138 138 { 139 139 BOOL bRc = FALSE; 140 VRDPBCENTRY *pEntry; 141 142 DISPDBG((1, "insert hash cache %p, tail %p.\n", pCache, pCache->tail)); 140 143 141 144 /* Get the free entry to be used. Try tail, that should be */ 142 VRDPBCENTRY *pEntry = pCache->tail; 145 pEntry = pCache->tail; 146 147 if (pEntry == NULL) 148 { 149 return bRc; 150 } 143 151 144 152 if (pEntry->fUsed) … … 172 180 BOOL bResult = bcComputeHash (pso, &hash); 173 181 182 DISPDBG((1, "vrdpbmpCacheSurface: compute hash %d.\n", bResult)); 174 183 if (!bResult) 175 184 { … … 180 189 bResult = bcFindHash (pCache, &hash); 181 190 191 DISPDBG((1, "vrdpbmpCacheSurface: find hash %d.\n", bResult)); 182 192 *phash = hash; 183 193 … … 191 201 bResult = bcInsertHash (pCache, &hash, phashDeleted); 192 202 203 DISPDBG((1, "vrdpbmpCacheSurface: insert hash %d.\n", bResult)); 193 204 if (bResult) 194 205 { -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r3118 r3153 24 24 25 25 #include <VBox/VBoxGuest.h> 26 #include <VBox/VBoxVideo.h> 26 27 27 28 #include <VBox/VBoxGuestLib.h> … … 195 196 196 197 /* size of the VRAM in bytes */ 197 ULONG totalVramSize = VideoPortReadPortUlong((PULONG)VBE_DISPI_IOPORT_DATA); 198 ULONG vramSize; 199 200 /* Split up VRAM for DualView */ 201 vramSize = totalVramSize / gNumDisplays; 202 dprintf(("VBoxVideo: Total VRAM %u bytes, per display %u bytes\n", totalVramSize, vramSize)); 198 ULONG vramSize = DeviceExtension->ulMaxFrameBufferSize; 203 199 204 200 gNumVideoModes = 0; … … 685 681 } 686 682 683 /* Computes the size of a framebuffer. DualView has a few framebuffers of the computed size. */ 684 static ULONG VBoxVideoComputeMaxFrameBufferSize (ULONG AdapterMemorySize) 685 { 686 /* The VRAM layout: 687 * Last 4096 bytes - Adapter information area. 688 * Slack - what left after dividing the VRAM. 689 * 4096 bytes aligned framebuffers: 690 * last 4096 bytes of each framebuffer is the display information area. 691 */ 692 693 /* Size of a framebuffer. */ 694 ULONG ulSize = (AdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE) / gNumDisplays; 695 696 /* Align down to 4096 bytes. */ 697 ulSize &= ~0xFFF; 698 699 dprintf(("VBoxVideo::VBoxVideoComputeMaxFrameBufferSize: AdapterMemorySize = 0x%08X, gNumDisplays = %d, ulSize = 0x%08X, ulSize * gNumDisplays = 0x%08X, slack = 0x%08X\n", 700 AdapterMemorySize, gNumDisplays, ulSize, ulSize * gNumDisplays, (AdapterMemorySize - 4096) - ulSize * gNumDisplays)); 701 702 if (ulSize > VBOX_VIDEO_DISPLAY_INFORMATION_SIZE) 703 { 704 /* Compute the size of the framebuffer. */ 705 ulSize -= VBOX_VIDEO_DISPLAY_INFORMATION_SIZE; 706 } 707 else 708 { 709 ulSize = 0; 710 } 711 712 return ulSize; 713 } 714 715 static VOID VBoxMapAdapterInfo (PDEVICE_EXTENSION PrimaryExtension, ULONG AdapterMemorySize) 716 { 717 PHYSICAL_ADDRESS FrameBuffer; 718 ULONG inIoSpace = 0; 719 VP_STATUS Status; 720 721 dprintf(("VBoxVideo::VBoxSetupAdapterInfo\n")); 722 723 FrameBuffer.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS + AdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE; 724 725 PVOID VideoRamBase = NULL; 726 ULONG VideoRamLength = VBOX_VIDEO_ADAPTER_INFORMATION_SIZE; 727 728 Status = VideoPortMapMemory(PrimaryExtension, FrameBuffer, 729 &VideoRamLength, &inIoSpace, 730 &VideoRamBase); 731 732 if (Status == NO_ERROR) 733 { 734 PrimaryExtension->AdapterInformation = VideoRamBase; 735 } 736 else 737 { 738 PrimaryExtension->AdapterInformation = NULL; 739 } 740 } 741 742 static VOID VBoxSetupAdapterInfo (PDEVICE_EXTENSION PrimaryExtension) 743 { 744 if (!PrimaryExtension->AdapterInformation) 745 { 746 return; 747 } 748 749 /* That dublicates the code in VBoxSetupDisplays, better would be to have 750 * linked list of device extestions and fill the adapter memory with 751 * information from these extension structures. 752 */ 753 uint8_t *pu8 = (uint8_t *)PrimaryExtension->AdapterInformation; 754 uint32_t u32Offset = 0; 755 756 VBOXVIDEOINFOHDR *pHdr; 757 int iDisplay; 758 759 for (iDisplay = 0; iDisplay < gNumDisplays; ++iDisplay) 760 { 761 pHdr = (VBOXVIDEOINFOHDR *)pu8; 762 pu8 += sizeof (VBOXVIDEOINFOHDR); 763 764 pHdr->u8Type = VBOX_VIDEO_INFO_TYPE_DISPLAY; 765 pHdr->u8Reserved = 0; 766 pHdr->u16Length = sizeof (VBOXVIDEOINFODISPLAY); 767 768 VBOXVIDEOINFODISPLAY *pDisplay = (VBOXVIDEOINFODISPLAY *)pu8; 769 pu8 += sizeof (VBOXVIDEOINFODISPLAY); 770 771 pDisplay->u32Index = iDisplay; 772 pDisplay->u32Offset = u32Offset; 773 pDisplay->u32FramebufferSize = PrimaryExtension->ulMaxFrameBufferSize; 774 pDisplay->u32InformationSize = VBOX_VIDEO_DISPLAY_INFORMATION_SIZE; 775 776 u32Offset += PrimaryExtension->ulMaxFrameBufferSize + VBOX_VIDEO_DISPLAY_INFORMATION_SIZE; 777 } 778 779 pHdr = (VBOXVIDEOINFOHDR *)pu8; 780 pu8 += sizeof (VBOXVIDEOINFOHDR); 781 782 pHdr->u8Type = VBOX_VIDEO_INFO_TYPE_END; 783 pHdr->u8Reserved = 0; 784 pHdr->u16Length = 0; 785 786 /* Inform the host about the display configuration. */ 787 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_CMONITORS); 788 VideoPortWritePortUlong((PULONG)VBE_DISPI_IOPORT_DATA, VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY); 789 } 790 687 791 /** 688 792 * Helper function to register secondary displays (DualView). Note that this will not … … 690 794 * intentionally crippled. 691 795 */ 692 VOID VBox RegisterSecondaryDisplays(PDEVICE_EXTENSION PrimaryExtension, PVIDEO_PORT_CONFIG_INFO pConfigInfo)796 VOID VBoxSetupDisplays(PDEVICE_EXTENSION PrimaryExtension, PVIDEO_PORT_CONFIG_INFO pConfigInfo) 693 797 { 694 798 typedef VP_STATUS (*pCreateSecDisp)(PVOID, PVOID *, ULONG); … … 698 802 VP_STATUS rc; 699 803 PDEVICE_EXTENSION pSecExt; 700 701 dprintf(("VBoxVideo::VBoxRegisterSecondaryDisplays\n")); 702 703 /* Initialize DualView related stuff in device extension (must be done always!) */ 804 ULONG AdapterMemorySize; 805 806 dprintf(("VBoxVideo::VBoxRegisterSecondaryDisplays: PrimaryExtension = %p\n", PrimaryExtension)); 807 808 AdapterMemorySize = VideoPortReadPortUlong((PULONG)VBE_DISPI_IOPORT_DATA); 809 810 /* Initialize DualView related stuff in device extension for 1 monitor (must be done always!). 811 * Assume that the is no dual view and initialize the maximum possible frame buffer size. 812 * Also assume no VBox extension support. 813 */ 704 814 PrimaryExtension->iDevice = 0; 705 815 PrimaryExtension->pvPrimaryExt = PrimaryExtension; 816 817 PrimaryExtension->ulFrameBufferOffset = 0; 818 PrimaryExtension->ulMaxFrameBufferSize = AdapterMemorySize - 819 VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - 820 VBOX_VIDEO_DISPLAY_INFORMATION_SIZE; 821 PrimaryExtension->bDualViewSupported = FALSE; 822 PrimaryExtension->AdapterInformation = NULL; 823 824 /* Verify that the HW support VirtualBox extensions. */ 825 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID); 826 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_VBOX_VIDEO); 827 if (VideoPortReadPortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA) != VBE_DISPI_ID_VBOX_VIDEO) 828 { 829 dprintf(("VBoxVideo::VBoxSetupDisplays: virtual hardware do not support VBox extensions!!!\n")); 830 return; 831 } 832 833 /* Map the adapter information memory. */ 834 VBoxMapAdapterInfo (PrimaryExtension, AdapterMemorySize); 835 836 if (!PrimaryExtension->AdapterInformation) 837 { 838 dprintf(("VBoxVideo::VBoxSetupDisplays: failed to map adapter memory!!!\n")); 839 return; 840 } 706 841 707 842 /* Dynamically query the VideoPort import to be binary compatible across Windows versions */ … … 725 860 dprintf(("VBoxVideo::VBoxRegisterSecondaryDisplays: gNumDisplays = %d\n", gNumDisplays)); 726 861 862 PrimaryExtension->bDualViewSupported = (gNumDisplays != 0); 863 864 /* Now when the number of monitors is known, update the maximum size. */ 865 PrimaryExtension->ulMaxFrameBufferSize = VBoxVideoComputeMaxFrameBufferSize (AdapterMemorySize); 866 727 867 for (iDisplay = 1; iDisplay < gNumDisplays; ++iDisplay) 728 868 { 729 869 rc = pVPCreateSecDisp(PrimaryExtension, (PVOID*)&pSecExt, VIDEO_DUALVIEW_REMOVABLE); 730 dprintf(("VBoxVideo::VBoxRegisterSecondaryDisplays: VideoPortCreateSecondaryDisplay returned %#x \n", rc));870 dprintf(("VBoxVideo::VBoxRegisterSecondaryDisplays: VideoPortCreateSecondaryDisplay returned %#x, pSecExt = %p\n", rc, pSecExt)); 731 871 if (rc != NO_ERROR) /* Failure to create secondary displays is not fatal */ 732 872 break; … … 734 874 pSecExt->iDevice = iDisplay; 735 875 pSecExt->pvPrimaryExt = PrimaryExtension; 876 877 pSecExt->ulFrameBufferOffset = iDisplay * (PrimaryExtension->ulMaxFrameBufferSize + VBOX_VIDEO_DISPLAY_INFORMATION_SIZE); 878 pSecExt->ulMaxFrameBufferSize = PrimaryExtension->ulMaxFrameBufferSize; 879 pSecExt->bDualViewSupported = PrimaryExtension->bDualViewSupported; 880 pSecExt->AdapterInformation = PrimaryExtension->AdapterInformation; 736 881 } 737 882 } 883 884 VBoxSetupAdapterInfo (PrimaryExtension); 738 885 } 739 886 … … 819 966 820 967 /* Attempt to register secondary displays */ 821 VBox RegisterSecondaryDisplays((PDEVICE_EXTENSION)HwDeviceExtension, ConfigInfo);968 VBoxSetupDisplays((PDEVICE_EXTENSION)HwDeviceExtension, ConfigInfo); 822 969 823 970 // pretend success to make the driver work. … … 1213 1360 } 1214 1361 1362 case IOCTL_VIDEO_INTERPRET_DISPLAY_MEMORY: 1363 { 1364 dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_INTERPRET_DISPLAY_MEMORY\n")); 1365 1366 if (pDevExt->bDualViewSupported) 1367 { 1368 /* The display driver must have prepared the monitor information. */ 1369 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_CMONITORS); 1370 VideoPortWritePortUlong((PULONG)VBE_DISPI_IOPORT_DATA, VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE + pDevExt->iDevice); 1371 } 1372 else 1373 { 1374 RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION; 1375 } 1376 Result = pDevExt->bDualViewSupported; 1377 break; 1378 } 1379 1380 case IOCTL_VIDEO_QUERY_DISPLAY_INFO: 1381 { 1382 dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_QUERY_DISPLAY_INFO\n")); 1383 1384 if (RequestPacket->OutputBufferLength < sizeof(QUERYDISPLAYINFORESULT)) 1385 { 1386 dprintf(("VBoxVideo::VBoxVideoStartIO: output buffer too small: %d needed: %d!!!\n", 1387 RequestPacket->OutputBufferLength, sizeof(QUERYDISPLAYINFORESULT))); 1388 RequestPacket->StatusBlock->Status = ERROR_INSUFFICIENT_BUFFER; 1389 return FALSE; 1390 } 1391 1392 QUERYDISPLAYINFORESULT *pDispInfo = (QUERYDISPLAYINFORESULT *)RequestPacket->OutputBuffer; 1393 1394 pDispInfo->iDevice = pDevExt->iDevice; 1395 pDispInfo->u32DisplayInfoSize = VBOX_VIDEO_DISPLAY_INFORMATION_SIZE; 1396 1397 RequestPacket->StatusBlock->Information = sizeof(QUERYDISPLAYINFORESULT); 1398 Result = TRUE; 1399 1400 break; 1401 } 1402 1215 1403 case IOCTL_VIDEO_VBVA_ENABLE: 1216 1404 { … … 1256 1444 1257 1445 default: 1258 dprintf(("VBoxVideo::VBoxVideoStartIO: unsupported %p\n", RequestPacket->IoControlCode)); 1446 dprintf(("VBoxVideo::VBoxVideoStartIO: unsupported %p, fn %d(0x%x)\n", 1447 RequestPacket->IoControlCode, 1448 (RequestPacket->IoControlCode >> 2) & 0xFFF, 1449 (RequestPacket->IoControlCode >> 2) & 0xFFF)); 1259 1450 RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION; 1260 1451 return FALSE; … … 1279 1470 { 1280 1471 dprintf(("VBoxVideo::VBoxVideoResetHW\n")); 1472 1473 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)HwDeviceExtension; 1474 1475 if (pDevExt->iDevice > 0) 1476 { 1477 dprintf(("VBoxVideo::VBoxVideoResetHW: Skipping for non-primary display %d\n", 1478 pDevExt->iDevice)); 1479 return TRUE; 1480 } 1481 1281 1482 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE); 1282 1483 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_DISABLED); 1283 1484 1284 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)HwDeviceExtension;1285 1485 if (pDevExt->pvReqFlush != NULL) 1286 1486 { … … 1335 1535 ModeInfo->VisScreenHeight, ModeInfo->BitsPerPlane)); 1336 1536 1337 if (DeviceExtension->iDevice > 0) { 1537 if (DeviceExtension->iDevice > 0) 1538 { 1338 1539 dprintf(("VBoxVideo::VBoxVideoSetCurrentMode: Skipping for non-primary display %d\n", 1339 1540 DeviceExtension->iDevice)); … … 1369 1570 dprintf(("VBoxVideo::VBoxVideoResetDevice\n")); 1370 1571 1572 if (DeviceExtension->iDevice > 0) 1573 { 1574 /* If the device is the secondary display, however, it is recommended that no action be taken. */ 1575 dprintf(("VBoxVideo::VBoxVideoResetDevice: Skipping for non-primary display %d\n", 1576 DeviceExtension->iDevice)); 1577 return TRUE; 1578 } 1579 1371 1580 #if 0 1372 1581 /* Don't disable the extended video mode. This would only switch the video mode … … 1393 1602 PHYSICAL_ADDRESS FrameBuffer; 1394 1603 ULONG inIoSpace = 0; 1395 ULONG ulOffset;1396 ULONG AdapterMemorySize;1397 1604 VP_STATUS Status; 1398 1605 1399 1606 dprintf(("VBoxVideo::VBoxVideoMapVideoMemory\n")); 1400 1607 1401 AdapterMemorySize = VideoPortReadPortUlong((PULONG)VBE_DISPI_IOPORT_DATA); 1402 1403 FrameBuffer.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS; 1608 FrameBuffer.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS + DeviceExtension->ulFrameBufferOffset; 1609 1404 1610 MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress; 1405 MapInformation->VideoRamLength = AdapterMemorySize; 1406 // VideoModes[DeviceExtension->CurrentMode - 1].VideoMemoryBitmapHeight * 1407 // VideoModes[DeviceExtension->CurrentMode - 1].ScreenStride; 1611 MapInformation->VideoRamLength = DeviceExtension->ulMaxFrameBufferSize + VBOX_VIDEO_DISPLAY_INFORMATION_SIZE; 1408 1612 1409 1613 Status = VideoPortMapMemory(DeviceExtension, FrameBuffer, … … 1413 1617 if (Status == NO_ERROR) 1414 1618 { 1415 /* Calculate VRAM offset for DualView */ 1416 ulOffset = AdapterMemorySize / gNumDisplays * DeviceExtension->iDevice; 1417 1418 MapInformation->FrameBufferBase = (PUCHAR)MapInformation->VideoRamBase + ulOffset; 1619 MapInformation->FrameBufferBase = (PUCHAR)MapInformation->VideoRamBase; 1419 1620 MapInformation->FrameBufferLength = 1420 1621 VideoModes[DeviceExtension->CurrentMode - 1].VisScreenHeight * … … 1541 1742 PULONG pUnused) 1542 1743 { 1543 dprintf(("VBoxVideo::VBoxVideoGetChildDescriptor\n")); 1744 dprintf(("VBoxVideo::VBoxVideoGetChildDescriptor: HwDeviceExtension = %p, ChildEnumInfo = %p\n", 1745 HwDeviceExtension, ChildEnumInfo)); 1544 1746 1545 1747 DEVICE_EXTENSION *pDevExt = (DEVICE_EXTENSION *)HwDeviceExtension; … … 1565 1767 { 1566 1768 DEVICE_EXTENSION *pDevExt = (DEVICE_EXTENSION *)pvFlush; 1567 1568 if (pDevExt && pDevExt->pvReqFlush) 1569 { 1570 VMMDevVideoAccelFlush *req = (VMMDevVideoAccelFlush *)pDevExt->pvReqFlush; 1571 1572 int rc = VbglGRPerform (&req->header); 1573 1574 if (VBOX_FAILURE(rc) || VBOX_FAILURE(req->header.rc)) 1575 { 1576 dprintf(("VBoxVideo::vbvaFlush: rc = %Vrc, VMMDev rc = %Vrc!!!\n", rc, req->header.rc)); 1769 DEVICE_EXTENSION *pPrimaryDevExt = (DEVICE_EXTENSION *)(pDevExt? pDevExt->pvPrimaryExt: NULL); 1770 1771 if (pPrimaryDevExt) 1772 { 1773 VMMDevVideoAccelFlush *req = (VMMDevVideoAccelFlush *)pPrimaryDevExt->pvReqFlush; 1774 1775 if (req) 1776 { 1777 int rc = VbglGRPerform (&req->header); 1778 1779 if (VBOX_FAILURE(rc) || VBOX_FAILURE(req->header.rc)) 1780 { 1781 dprintf(("VBoxVideo::vbvaFlush: rc = %Vrc, VMMDev rc = %Vrc!!!\n", rc, req->header.rc)); 1782 } 1577 1783 } 1578 1784 } … … 1596 1802 dprintf(("VBoxVideo::vboxVbvaEnable: VbglQueryVMMDevMemory rc = %d, pVMMDevMemory = %p\n", rc, pVMMDevMemory)); 1597 1803 1804 if (pDevExt->iDevice > 0) 1805 { 1806 DEVICE_EXTENSION *pPrimaryDevExt = (DEVICE_EXTENSION *)pDevExt->pvPrimaryExt; 1807 1808 dprintf(("VBoxVideo::vboxVbvaEnable: Skipping for non-primary display %d\n", 1809 pDevExt->iDevice)); 1810 1811 if ( ulEnable 1812 && pPrimaryDevExt->ulVbvaEnabled) 1813 { 1814 pVbvaResult->pVbvaMemory = &pVMMDevMemory->vbvaMemory; 1815 pVbvaResult->pfnFlush = vboxVbvaFlush; 1816 pVbvaResult->pvFlush = pDevExt; 1817 } 1818 else 1819 { 1820 VideoPortZeroMemory(&pVbvaResult, sizeof(VBVAENABLERESULT)); 1821 } 1822 1823 return rc; 1824 } 1825 1598 1826 if (VBOX_SUCCESS(rc)) 1599 1827 { … … 1624 1852 if (VBOX_SUCCESS(rc)) 1625 1853 { 1854 ULONG ulEnabled = 0; 1855 1626 1856 /* 1627 1857 * Tell host that VBVA status is changed. … … 1653 1883 pVbvaResult->pfnFlush = vboxVbvaFlush; 1654 1884 pVbvaResult->pvFlush = pDevExt; 1885 ulEnabled = 1; 1655 1886 } 1656 1887 else … … 1684 1915 } 1685 1916 } 1917 1918 VbglGRFree (&req->header); 1686 1919 } 1687 1920 else … … 1689 1922 dprintf(("VBoxVideo::vboxVbvaEnable: VbglGRAlloc rc = %Vrc!!!\n", rc)); 1690 1923 } 1924 1925 pDevExt->ulVbvaEnabled = ulEnabled; 1691 1926 } 1692 1927 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
r2981 r3153 45 45 #define VBE_DISPI_INDEX_CMONITORS 0xa 46 46 #define VBE_DISPI_ID2 0xB0C2 47 /* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_CMONITORS. */ 48 #define VBE_DISPI_ID_VBOX_VIDEO 0xBE00 47 49 #define VBE_DISPI_DISABLED 0x00 48 50 #define VBE_DISPI_ENABLED 0x01 … … 66 68 PVOID pvPrimaryExt; /* Pointer to primary device extension */ 67 69 BOOLEAN bEnabled; /* Device enabled flag */ 70 71 ULONG ulFrameBufferOffset; 72 ULONG ulMaxFrameBufferSize; 73 74 BOOLEAN bDualViewSupported; 75 76 PVOID AdapterInformation; 77 78 ULONG ulVbvaEnabled; 68 79 } DEVICE_EXTENSION, *PDEVICE_EXTENSION; 69 80 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/vboxioctl.h
r2981 r3153 25 25 26 26 #include <VBox/VBoxGuest.h> 27 28 #define IOCTL_VIDEO_INTERPRET_DISPLAY_MEMORY \ 29 CTL_CODE(FILE_DEVICE_VIDEO, 0x420, METHOD_BUFFERED, FILE_ANY_ACCESS) 30 31 #define IOCTL_VIDEO_QUERY_DISPLAY_INFO \ 32 CTL_CODE(FILE_DEVICE_VIDEO, 0x421, METHOD_BUFFERED, FILE_ANY_ACCESS) 27 33 28 34 /** Called by the display driver when it is ready to … … 59 65 60 66 } VBVAENABLERESULT; 67 68 /** 69 * Data returned by IOCTL_VIDEO_QUERY_DISPLAY_INFO. 70 * 71 */ 72 typedef struct _QUERYDISPLAYINFORESULT 73 { 74 /* Device index (0 for primary) */ 75 ULONG iDevice; 76 77 /* Size of the display information area. */ 78 uint32_t u32DisplayInfoSize; 79 } QUERYDISPLAYINFORESULT; 61 80 #pragma pack() 62 81
Note:
See TracChangeset
for help on using the changeset viewer.