VirtualBox

Ignore:
Timestamp:
Apr 13, 2007 2:41:04 PM (18 years ago)
Author:
vboxsync
Message:

Added basic DualView support to the NT miniport.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp

    r553 r2080  
    4040static WCHAR VBoxAdapterString[] = L"VirtualBox Video Adapter";
    4141static WCHAR VBoxBiosString[] = L"Version 0xB0C2 or later";
     42
     43/* Number of reported monitors. Defaults to 1 (no DualView) */
     44static int gNumDisplays = 1;
    4245
    4346/*
     
    192195
    193196    /* 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));
    195203
    196204    gNumVideoModes = 0;
     
    677685}
    678686
     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 */
     692VOID 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
    679740VP_STATUS VBoxVideoFindAdapter(IN PVOID HwDeviceExtension,
    680741                               IN PVOID HwContext, IN PWSTR ArgumentString,
     
    756817
    757818      dprintf(("VBoxVideo::VBoxVideoFindAdapter: VbglInit returned 0x%x\n", rc));
     819
     820      /* Attempt to register secondary displays */
     821      VBoxRegisterSecondaryDisplays((PDEVICE_EXTENSION)HwDeviceExtension, ConfigInfo);
    758822
    759823      // pretend success to make the driver work.
     
    11361200        }
    11371201
     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
    11381215        case IOCTL_VIDEO_VBVA_ENABLE:
    11391216        {
     
    12571334    dprintf(("VBoxVideoSetCurrentMode: width: %d, height: %d, bpp: %d\n", ModeInfo->VisScreenWidth,
    12581335             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    }
    12591342
    12601343    /* set the mode characteristics */
     
    13101393    PHYSICAL_ADDRESS FrameBuffer;
    13111394    ULONG inIoSpace = 0;
     1395    ULONG ulOffset;
     1396    ULONG AdapterMemorySize;
    13121397    VP_STATUS Status;
    13131398
    13141399    dprintf(("VBoxVideo::VBoxVideoMapVideoMemory\n"));
     1400
     1401    AdapterMemorySize = VideoPortReadPortUlong((PULONG)VBE_DISPI_IOPORT_DATA);
    13151402
    13161403    FrameBuffer.QuadPart = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
    13171404    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;
    13231408
    13241409    Status = VideoPortMapMemory(DeviceExtension, FrameBuffer,
     
    13281413    if (Status == NO_ERROR)
    13291414    {
    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;
    13321422        StatusBlock->Information = sizeof(VIDEO_MEMORY_INFORMATION);
     1423
    13331424        return TRUE;
    13341425    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette