[Spice-devel] [spice-protocol PATCH 34/46] qxl_driver: add and use qxlhw_clear_memory

Alon Levy alevy at redhat.com
Tue Apr 10 04:50:30 PDT 2012


---
 src/qxl_driver.c |    9 +--------
 src/qxlhw.c      |    5 +++++
 src/qxlhw.h      |    2 ++
 src/qxlhw_pci.c  |   15 +++++++++++++++
 4 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index c551282..3de060d 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -232,14 +232,7 @@ qxl_switch_mode(int scrnIndex, DisplayModePtr p, int flags)
     }
     
     ErrorF ("primary is %p\n", qxl->primary);
-    if (qxl->mem)
-    {
-       qxl_mem_free_all (qxl->mem);
-       qxl_drop_image_cache (qxl);
-    }
-
-    if (qxl->surf_mem)
-	qxl_mem_free_all (qxl->surf_mem);
+    qxlhw_clear_memory(qxl->hw);
 
     qxl_surface_cache_replace_all (qxl->surface_cache, evacuated);
     
diff --git a/src/qxlhw.c b/src/qxlhw.c
index 5bcb175..6172e6c 100644
--- a/src/qxlhw.c
+++ b/src/qxlhw.c
@@ -28,6 +28,11 @@ void qxlhw_reset(struct qxlhw *base)
         base->reset(base);
 }
 
+void qxlhw_clear_memory(struct qxlhw *base)
+{
+        base->clear_memory(base);
+}
+
 void qxlhw_save_state(struct qxlhw *base, ScrnInfoPtr pScrn)
 {
         base->save_state(base, pScrn);
diff --git a/src/qxlhw.h b/src/qxlhw.h
index eb51f26..4ecbe64 100644
--- a/src/qxlhw.h
+++ b/src/qxlhw.h
@@ -11,6 +11,7 @@ struct qxlhw {
     /* device callbacks */
     void (*device_reset)(struct qxlhw *base);
     void (*reset)(struct qxlhw *base);
+    void (*clear_memory)(struct qxlhw *base);
     void (*save_state)(struct qxlhw *base, ScrnInfoPtr pScrn);
     void (*restore_state)(struct qxlhw *base, ScrnInfoPtr pScrn);
     Bool (*map_memory)(struct qxlhw *base, int scrnIndex);
@@ -50,6 +51,7 @@ void qxlhw_update_area(struct qxlhw *base, int surface_id, struct QXLRect rect);
 void qxlhw_device_reset(struct qxlhw *base);
 void qxlhw_reset(struct qxlhw *base);
 
+void qxlhw_clear_memory(struct qxlhw *base);
 void qxlhw_save_state(struct qxlhw *base, ScrnInfoPtr pScrn);
 void qxlhw_restore_state(struct qxlhw *base, ScrnInfoPtr pScrn);
 
diff --git a/src/qxlhw_pci.c b/src/qxlhw_pci.c
index 9c8387c..6d53d99 100644
--- a/src/qxlhw_pci.c
+++ b/src/qxlhw_pci.c
@@ -525,6 +525,20 @@ static void qxlhw_pci_reset(struct qxlhw *base)
 #endif
 }
 
+static void qxlhw_pci_clear_memory(struct qxlhw *base)
+{
+    struct qxlhw_pci *hw = (struct qxlhw_pci *)base;
+
+    if (hw->mem)
+    {
+       qxl_mem_free_all (hw->mem);
+    }
+
+    if (hw->surf_mem)
+	qxl_mem_free_all (hw->surf_mem);
+
+}
+
 static void qxlhw_pci_save_state(struct qxlhw *base, ScrnInfoPtr pScrn)
 {
 #ifndef XSPICE
@@ -875,6 +889,7 @@ struct qxlhw *create_qxlhw_pci(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
     qxlhw_init(base, qxl);
     base->device_reset = qxlhw_pci_device_reset;
     base->reset = qxlhw_pci_reset;
+    base->clear_memory = qxlhw_pci_clear_memory;
     base->save_state = qxlhw_pci_save_state;
     base->restore_state = qxlhw_pci_restore_state;
     base->map_memory = qxlhw_pci_map_memory;
-- 
1.7.9.3



More information about the Spice-devel mailing list