[Spice-devel] [PATCH qxl-wddm-dod v2 20/25] Support future Qxl revisions

Sameeh Jubran sameeh at daynix.com
Mon Sep 5 08:34:17 UTC 2016


From: Dmitry Fleytman <dmitry at daynix.com>

The driver determines operation mode
(QXL or VGA) by checking device hardware
ids including revision id field.

Without this patch driver operates in VGA
mode for all revisions other than 4.

This patch makes driver operate in QXL
mode revision 4 and newer devices.

Signed-off-by: Sameeh Jubran <sameeh at daynix.com>
Signed-off-by: Dmitry Fleytman <dmitry at daynix.com>
---
 qxldod/QxlDod.cpp | 42 ++++++++++++++++++++++++++++++++----------
 qxldod/QxlDod.h   |  2 ++
 2 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
index cfbfd78..7b90698 100755
--- a/qxldod/QxlDod.cpp
+++ b/qxldod/QxlDod.cpp
@@ -103,7 +103,7 @@ NTSTATUS QxlDod::CheckHardware()
     Status = STATUS_GRAPHICS_DRIVER_MISMATCH;
     if (Header.VendorID == REDHAT_PCI_VENDOR_ID &&
         Header.DeviceID == 0x0100 &&
-        Header.RevisionID == 4)
+        Header.RevisionID >= 4)
     {
         Status = STATUS_SUCCESS;
     }
@@ -427,6 +427,9 @@ NTSTATUS QxlDod::QueryAdapterInfo(_In_ CONST DXGKARG_QUERYADAPTERINFO* pQueryAda
                 pDriverCaps->PointerCaps.Monochrome = 1;
                 pDriverCaps->PointerCaps.Color = 1;
             }
+
+            pDriverCaps->SupportNonVGA = TRUE;
+
             DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s 1\n", __FUNCTION__));
             return STATUS_SUCCESS;
         }
@@ -3668,12 +3671,11 @@ QxlDevice::ExecutePresentDisplayOnly(
     ctx->Mdl              = NULL;
     ctx->DisplaySource    = this;
 
-    // Alternate between synch and asynch execution, for demonstrating 
-    // that a real hardware implementation can do either
-
+    // Source bitmap is in user mode, must be locked under __try/__except
+    // and mapped to kernel space before use.
     {
-        // Map Source into kernel space, as Blt will be executed by system worker thread
-        UINT sizeToMap = ctx->SrcPitch * ctx->SrcHeight;
+        LONG maxHeight = GetMaxSourceMappingHeight(ctx->Moves, ctx->NumMoves, ctx->DirtyRect, ctx->NumDirtyRects);
+        UINT sizeToMap = ctx->SrcPitch * maxHeight;
 
         PMDL mdl = IoAllocateMdl((PVOID)SrcAddr, sizeToMap,  FALSE, FALSE, NULL);
         if(!mdl)
@@ -4545,12 +4547,32 @@ void QxlDevice::SetMonitorConfig(QXLHead * monitor_config)
         m_monitor_config->heads[0].x, m_monitor_config->heads[0].y,
         m_monitor_config->heads[0].width, m_monitor_config->heads[0].height));
     AsyncIo(QXL_IO_MONITORS_CONFIG_ASYNC, 0);
+}
+
+LONG QxlDevice::GetMaxSourceMappingHeight(D3DKMT_MOVE_RECT* Moves, ULONG NumMoves, RECT* DirtyRects, ULONG NumDirtyRects)
+{
+    LONG maxHeight = 0;
+    if (Moves != NULL) {
+        for (UINT i = 0; i < NumMoves; i++) {
+            POINT*   pSourcePoint = &Moves[i].SourcePoint;
+            RECT*    pDestRect = &Moves[i].DestRect;
+            maxHeight = MAX(maxHeight, pDestRect->bottom - pDestRect->top + pSourcePoint->y);
+        }
+    }
+    if (DirtyRects != NULL) {
+        for (UINT i = 0; i < NumDirtyRects; i++) {
+            RECT*    pDirtyRect = &DirtyRects[i];
+            maxHeight = MAX(maxHeight, pDirtyRect->bottom);
+        }
+    }
+    return maxHeight;
 }
-
-NTSTATUS QxlDevice::Escape(_In_ CONST DXGKARG_ESCAPE* pEscape)
-{
+
+NTSTATUS QxlDevice::Escape(_In_ CONST DXGKARG_ESCAPE* pEscape)
+{
+    PAGED_CODE();
     size_t          data_size(sizeof(uint32_t));
-    QXLEscape*     pQXLEscape((QXLEscape*) pEscape->pPrivateDriverData);
+    QXLEscape*     pQXLEscape((QXLEscape*) pEscape->pPrivateDriverData);
     NTSTATUS        status(STATUS_SUCCESS);
 
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h
index 9260389..2e9ffb7 100755
--- a/qxldod/QxlDod.h
+++ b/qxldod/QxlDod.h
@@ -546,6 +546,8 @@ private:
     NTSTATUS SetCustomDisplay(QXLEscapeSetCustomDisplay* custom_display);
     void SetMonitorConfig(QXLHead* monitor_config);
 
+    LONG static GetMaxSourceMappingHeight(D3DKMT_MOVE_RECT* Moves, ULONG NumMoves, RECT* DirtyRects, ULONG NumDirtyRects);
+
 private:
     PUCHAR m_IoBase;
     BOOLEAN m_IoMapped;
-- 
2.7.0.windows.1



More information about the Spice-devel mailing list