[Spice-devel] [PATCH] add registry key "DisableSurfaces"

Alon Levy alevy at redhat.com
Wed Sep 5 05:27:52 PDT 2012


Presence of the key disables off screen surfaces creation; The callback
is still registered, but it always fails.

Registry key is checked on device initialization only, not during
runtime, so you must reset the vm to see any affects.
---
 display/driver.c     | 11 +++++++++++
 display/driver.rc    |  4 ++--
 display/qxldd.h      |  1 +
 include/qxl_driver.h |  2 ++
 miniport/qxl.c       | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 miniport/qxl.inf     |  2 +-
 miniport/qxl.rc      |  6 +++---
 7 files changed, 66 insertions(+), 7 deletions(-)

diff --git a/display/driver.c b/display/driver.c
index ef011ad..156befe 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -843,6 +843,13 @@ static BOOL PrepareHardware(PDev *pdev)
 
     pdev->dev_id = dev_info.dev_id;
 
+    pdev->create_non_primary_surfaces = dev_info.create_non_primary_surfaces;
+    DEBUG_PRINT((pdev, 1, "%s: create_non_primary_surfaces = %d\n", __FUNCTION__,
+                 pdev->create_non_primary_surfaces));
+
+    DEBUG_PRINT((NULL, 1, "%s: 0x%lx exit: 0x%lx %ul\n", __FUNCTION__, pdev,
+                 pdev->fb, pdev->fb_size));
+
     CreateVRamSlot(pdev);
 
     DEBUG_PRINT((NULL, 1, "%s: 0x%lx exit: 0x%lx %ul\n", __FUNCTION__, pdev,
@@ -1409,6 +1416,10 @@ HBITMAP APIENTRY DrvCreateDeviceBitmap(DHPDEV dhpdev, SIZEL size, ULONG format)
 
     pdev = (PDev *)dhpdev;
 
+    if (!pdev->create_non_primary_surfaces) {
+        return FALSE;
+    }
+
     if (!pdev->vram_slot_initialized || pdev->bitmap_format != format || pdev->fb == 0) {
         DEBUG_PRINT((pdev, 3, "%s failed: %p: slot_initialized %d, format(%d,%d), fb %p\n",
                     __FUNCTION__, pdev, pdev->vram_slot_initialized,
diff --git a/display/driver.rc b/display/driver.rc
index 4368925..ad449ba 100644
--- a/display/driver.rc
+++ b/display/driver.rc
@@ -16,12 +16,12 @@
 #define VER_FILEDESCRIPTION_STR     "Red Hat QXL Display Driver"
 #define VER_INTERNALNAME_STR        "qxldd.dll"
 #define VER_ORIGINALFILENAME_STR    VER_INTERNALNAME_STR
-#define VER_FILEVERSION_STR         "1.4.1.1"
+#define VER_FILEVERSION_STR         "1.4.2.3"
 #define VER_PRODUCTNAME_STR         "Spice"
 #define VER_PRODUCTVERSION_STR      VER_FILEVERSION_STR
 
 #undef  VER_PRODUCTVERSION
-#define VER_PRODUCTVERSION           1,4,1,1
+#define VER_PRODUCTVERSION           1.4.2.3
 
 #define VER_COMPANYNAME_STR         "Red Hat Inc."
 #define VER_LEGALCOPYRIGHT_STR      "© Red Hat Inc. All rights reserved."
diff --git a/display/qxldd.h b/display/qxldd.h
index d0166b5..1a1b5d5 100644
--- a/display/qxldd.h
+++ b/display/qxldd.h
@@ -220,6 +220,7 @@ typedef struct PDev {
     SIZEL resolution;
     UINT32 max_bitmap_size;
     ULONG bitmap_format;
+    UINT8 create_non_primary_surfaces;
 
     ULONG fb_size;
     BYTE* fb;
diff --git a/include/qxl_driver.h b/include/qxl_driver.h
index eac6f5f..677ee17 100644
--- a/include/qxl_driver.h
+++ b/include/qxl_driver.h
@@ -119,6 +119,8 @@ typedef struct QXLDriverInfo {
     UINT32 n_surfaces;
 
     UINT64 fb_phys;
+
+    UINT8 create_non_primary_surfaces;
 } QXLDriverInfo;
 
 #endif
diff --git a/miniport/qxl.c b/miniport/qxl.c
index 003669b..bd449c3 100644
--- a/miniport/qxl.c
+++ b/miniport/qxl.c
@@ -95,6 +95,8 @@ typedef struct QXLExtension {
 
     char *log_buf;
     PUCHAR log_port;
+
+    UINT8 create_non_primary_surfaces;
 } QXLExtension;
 
 #define QXL_ALLOC_TAG '_lxq'
@@ -1002,6 +1004,47 @@ static VP_STATUS SetCustomDisplay(QXLExtension *dev_ext, QXLEscapeSetCustomDispl
                            dev_ext->custom_mode);
 }
 
+VP_STATUS QXLRegistryCallback(
+  PVOID HwDeviceExtension,
+  PVOID Context,
+  PWSTR ValueName,
+  PVOID ValueData,
+  ULONG ValueLength
+)
+{
+    QXLExtension *dev_ext = HwDeviceExtension;
+    ULONG *key_ret = (ULONG *)Context;
+
+    DEBUG_PRINT((dev_ext, 60, "%s: length %d, first byte %d\n", __FUNCTION__,
+                ValueLength, (UINT8)ValueData));
+
+    if (key_ret) {
+        *key_ret = *(PULONG)ValueData;
+    }
+    return NO_ERROR;
+}
+
+static UINT8 check_non_primary_surfaces_registry_key(QXLExtension *dev_ext)
+{
+    VP_STATUS ret;
+    ULONG key_ret;
+
+    ret = VideoPortGetRegistryParameters(
+              dev_ext,
+              L"DisableSurfaces",
+              FALSE,
+              QXLRegistryCallback,
+              &key_ret);
+    if (ret == ERROR_INVALID_PARAMETER) {
+        dev_ext->create_non_primary_surfaces = 1;
+        DEBUG_PRINT((dev_ext, 0, "%s: CreateNonPrimarySurfaces key doesn't exist, default to 1\n",
+                    __FUNCTION__));
+    } else {
+        dev_ext->create_non_primary_surfaces = 0;
+    }
+    return dev_ext->create_non_primary_surfaces;
+}
+
 BOOLEAN StartIO(PVOID dev_extension, PVIDEO_REQUEST_PACKET packet)
 {
     QXLExtension *dev_ext = dev_extension;
@@ -1187,9 +1230,11 @@ BOOLEAN StartIO(PVOID dev_extension, PVIDEO_REQUEST_PACKET packet)
 
             driver_info->n_surfaces = dev_ext->rom->n_surfaces;
 
-	    driver_info->fb_phys = dev_ext->vram_physical.QuadPart;
+            driver_info->fb_phys = dev_ext->vram_physical.QuadPart;
 
             driver_info->dev_id = dev_ext->rom->id;
+
+            driver_info->create_non_primary_surfaces = check_non_primary_surfaces_registry_key(dev_ext);
         }
         break;
 
diff --git a/miniport/qxl.inf b/miniport/qxl.inf
index d20778b..9b17575 100644
--- a/miniport/qxl.inf
+++ b/miniport/qxl.inf
@@ -3,7 +3,7 @@
 
 [Version]
 Signature = "$CHICAGO$"
-DriverVer = 03/20/2011,1.4.1.1
+DriverVer = 08/15/2012,1.4.2.3
 Provider = %RHAT%
 CatalogFile = qxl.cat
 Class = Display
diff --git a/miniport/qxl.rc b/miniport/qxl.rc
index 86f04b9..b912a5e 100644
--- a/miniport/qxl.rc
+++ b/miniport/qxl.rc
@@ -16,12 +16,12 @@
 #define VER_FILEDESCRIPTION_STR     "Red Hat QXL Display Driver"
 #define VER_INTERNALNAME_STR        "qxl.sys"
 #define VER_ORIGINALFILENAME_STR    VER_INTERNALNAME_STR
-#define VER_FILEVERSION_STR         "1.4.1.1"
+#define VER_FILEVERSION_STR         "1.4.2.3"
 #define VER_PRODUCTNAME_STR         "Spice"
-#define VER_PRODUCTVERSION_STR      "1.4.1.1"
+#define VER_PRODUCTVERSION_STR      "1.4.2.3"
 
 #undef  VER_PRODUCTVERSION
-#define VER_PRODUCTVERSION           1,4,1,1
+#define VER_PRODUCTVERSION           1.4.2.3
 
 #define VER_COMPANYNAME_STR         "Red Hat Inc."
 #define VER_LEGALCOPYRIGHT_STR      "© Red Hat Inc. All rights reserved."
-- 
1.7.12



More information about the Spice-devel mailing list