[Spice-devel] [PATCH v3 23/28] Support future Qxl revisions

Sameeh Jubran sameeh at daynix.com
Wed Sep 7 13:10:41 UTC 2016


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 | 34 ++++++++++++++++++++++++++++------
 qxldod/QxlDod.h   |  2 ++
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
index 5aaa9b1..b606435 100755
--- a/qxldod/QxlDod.cpp
+++ b/qxldod/QxlDod.cpp
@@ -109,7 +109,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;
     }
@@ -432,6 +432,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;
         }
@@ -3673,12 +3676,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)
@@ -4551,8 +4553,28 @@ void QxlDevice::SetMonitorConfig(QXLHead * monitor_config)
     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)
 {
+    PAGED_CODE();
     size_t          data_size(sizeof(uint32_t));
     QXLEscape*     pQXLEscape((QXLEscape*) pEscape->pPrivateDriverData);
     NTSTATUS        status(STATUS_SUCCESS);
diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h
index d539126..3c30b6f 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