Changeset 2080 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
- Timestamp:
- Apr 13, 2007 2:41:04 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r553 r2080 40 40 static WCHAR VBoxAdapterString[] = L"VirtualBox Video Adapter"; 41 41 static WCHAR VBoxBiosString[] = L"Version 0xB0C2 or later"; 42 43 /* Number of reported monitors. Defaults to 1 (no DualView) */ 44 static int gNumDisplays = 1; 42 45 43 46 /* … … 192 195 193 196 /* size of the VRAM in bytes */ 194 ULONG vramSize = VideoPortReadPortUlong((PULONG)VBE_DISPI_IOPORT_DATA); 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)); 195 203 196 204 gNumVideoModes = 0; … … 677 685 } 678 686 687 /** 688 * Helper function to register secondary displays (DualView). Note that this will not 689 * be available on pre-XP versions, and some editions on XP will fail because they are 690 * intentionally crippled. 691 */ 692 VOID VBoxRegisterSecondaryDisplays(PDEVICE_EXTENSION PrimaryExtension, PVIDEO_PORT_CONFIG_INFO pConfigInfo) 693 { 694 typedef VP_STATUS (*pCreateSecDisp)(PVOID, PVOID *, ULONG); 695 pCreateSecDisp pVPCreateSecDisp; 696 PVOID pFunc; 697 int iDisplay; 698 VP_STATUS rc; 699 PDEVICE_EXTENSION pSecExt; 700 701 dprintf(("VBoxVideo::VBoxRegisterSecondaryDisplays\n")); 702 703 /* Initialize DualView related stuff in device extension (must be done always!) */ 704 PrimaryExtension->iDevice = 0; 705 PrimaryExtension->pvPrimaryExt = PrimaryExtension; 706 707 /* Dynamically query the VideoPort import to be binary compatible across Windows versions */ 708 if (vboxQueryWinVersion() <= WINNT4) 709 { 710 pFunc = NULL; 711 } 712 else 713 { 714 /* This bluescreens on NT4, hence the above version check */ 715 pFunc = (pConfigInfo->VideoPortGetProcAddress)(PrimaryExtension, 716 (PUCHAR)"VideoPortCreateSecondaryDisplay"); 717 } 718 719 if (pFunc != NULL) { 720 pVPCreateSecDisp = (pCreateSecDisp)pFunc; 721 722 /* Query the configured number of displays */ 723 VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_CMONITORS); 724 gNumDisplays = VideoPortReadPortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA); 725 dprintf(("VBoxVideo::VBoxRegisterSecondaryDisplays: gNumDisplays = %d\n", gNumDisplays)); 726 727 for (iDisplay = 1; iDisplay < gNumDisplays; ++iDisplay) 728 { 729 rc = pVPCreateSecDisp(PrimaryExtension, (PVOID*)&pSecExt, VIDEO_DUALVIEW_REMOVABLE); 730 dprintf(("VBoxVideo::VBoxRegisterSecondaryDisplays: VideoPortCreateSecondaryDisplay returned %#x\n", rc)); 731 if (rc != NO_ERROR) /* Failure to create secondary displays is not fatal */ 732 break; 733 734 pSecExt->iDevice = iDisplay; 735 pSecExt->pvPrimaryExt = PrimaryExtension; 736 } 737 } 738 } 739 679 740 VP_STATUS VBoxVideoFindAdapter(IN PVOID HwDeviceExtension, 680 741 IN PVOID HwContext, IN PWSTR ArgumentString, … … 756 817 757 818 dprintf(("VBoxVideo::VBoxVideoFindAdapter: VbglInit returned 0x%x\n", rc)); 819 820 /* Attempt to register secondary displays */ 821 VBoxRegisterSecondaryDisplays((PDEVICE_EXTENSION)HwDeviceExtension, ConfigInfo); 758 822 759 823 // pretend success to make the driver work. … … 1136 1200 } 1137 1201 1202 /* Attach/detach DualView devices */ 1203 case IOCTL_VIDEO_SWITCH_DUALVIEW: 1204 { 1205 ULONG ulAttach; 1206 1207 ulAttach = *((PULONG)RequestPacket->InputBuffer); 1208 dprintf(("VBoxVideo::VBoxVideoStartIO: IOCTL_VIDEO_SWITCH_DUALVIEW (%ld)\n", ulAttach)); 1209 1210 pDevExt->bEnabled = (BOOLEAN)ulAttach; 1211 Result = TRUE; 1212 break; 1213 } 1214 1138 1215 case IOCTL_VIDEO_VBVA_ENABLE: 1139 1216 { … … 1257 1334 dprintf(("VBoxVideoSetCurrentMode: width: %d, height: %d, bpp: %d\n", ModeInfo->VisScreenWidth, 1258 1335 ModeInfo->VisScreenHeight, ModeInfo->BitsPerPlane)); 1336 1337 if (DeviceExtension->iDevice > 0) { 1338 dprintf(("VBoxVideo::VBoxVideoSetCurrentMode: Skipping for non-primary display %d\n", 1339 DeviceExtension->iDevice)); 1340 return TRUE; 1341 } 1259 1342 1260 1343 /* set the mode characteristics */ … … 1310 1393 PHYSICAL_ADDRESS FrameBuffer; 1311 1394 ULONG inIoSpace = 0; 1395 ULONG ulOffset; 1396 ULONG AdapterMemorySize; 1312 1397 VP_STATUS Status; 1313 1398 1314 1399 dprintf(("VBoxVideo::VBoxVideoMapVideoMemory\n")); 1400 1401 AdapterMemorySize = VideoPortReadPortUlong((PULONG)VBE_DISPI_IOPORT_DATA); 1315 1402 1316 1403 FrameBuffer.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS; 1317 1404 MapInformation->VideoRamBase = RequestedAddress->RequestedVirtualAddress; 1318 MapInformation->VideoRamLength = ( 1319 VideoModes[DeviceExtension->CurrentMode - 1].VideoMemoryBitmapWidth * 1320 VideoModes[DeviceExtension->CurrentMode - 1].VideoMemoryBitmapHeight * 1321 VideoModes[DeviceExtension->CurrentMode - 1].BitsPerPlane 1322 ) >> 3; 1405 MapInformation->VideoRamLength = AdapterMemorySize; 1406 // VideoModes[DeviceExtension->CurrentMode - 1].VideoMemoryBitmapHeight * 1407 // VideoModes[DeviceExtension->CurrentMode - 1].ScreenStride; 1323 1408 1324 1409 Status = VideoPortMapMemory(DeviceExtension, FrameBuffer, … … 1328 1413 if (Status == NO_ERROR) 1329 1414 { 1330 MapInformation->FrameBufferBase = MapInformation->VideoRamBase; 1331 MapInformation->FrameBufferLength = MapInformation->VideoRamLength; 1415 /* Calculate VRAM offset for DualView */ 1416 ulOffset = AdapterMemorySize / gNumDisplays * DeviceExtension->iDevice; 1417 1418 MapInformation->FrameBufferBase = (PUCHAR)MapInformation->VideoRamBase + ulOffset; 1419 MapInformation->FrameBufferLength = 1420 VideoModes[DeviceExtension->CurrentMode - 1].VisScreenHeight * 1421 VideoModes[DeviceExtension->CurrentMode - 1].ScreenStride; 1332 1422 StatusBlock->Information = sizeof(VIDEO_MEMORY_INFORMATION); 1423 1333 1424 return TRUE; 1334 1425 }
Note:
See TracChangeset
for help on using the changeset viewer.