[Spice-devel] [spice-protocol PATCH 07/46] qxlhw: add qxlhw_update_area

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


---
 src/qxl.h         |    1 -
 src/qxl_driver.c  |   29 ++++++-----------------------
 src/qxl_surface.c |   16 +++++++---------
 src/qxlhw.c       |    5 +++++
 src/qxlhw.h       |    5 +++++
 src/qxlhw_pci.c   |   23 +++++++++++++++++++++++
 6 files changed, 46 insertions(+), 33 deletions(-)

diff --git a/src/qxl.h b/src/qxl.h
index 929a5de..96144d6 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -373,7 +373,6 @@ int		   qxl_garbage_collect (qxl_screen_t *qxl);
 /*
  * I/O port commands
  */
-void qxl_update_area(qxl_screen_t *qxl);
 void qxl_memslot_add(qxl_screen_t *qxl, uint8_t id);
 void qxl_create_primary(qxl_screen_t *qxl);
 void qxl_notify_oom(qxl_screen_t *qxl);
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index f56a43e..a39d8c7 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -145,20 +145,6 @@ static void qxl_wait_for_io_command(qxl_screen_t *qxl)
 }
 #endif
 
-void qxl_update_area(qxl_screen_t *qxl)
-{
-#ifndef XSPICE
-    if (qxl->pci->revision >= 3) {
-        ioport_write(qxl, QXL_IO_UPDATE_AREA_ASYNC, 0);
-        qxl_wait_for_io_command(qxl);
-    } else {
-        ioport_write(qxl, QXL_IO_UPDATE_AREA, 0);
-    }
-#else
-    ioport_write(qxl, QXL_IO_UPDATE_AREA, 0);
-#endif
-}
-
 void qxl_create_primary(qxl_screen_t *qxl)
 {
 #ifndef XSPICE
@@ -284,6 +270,7 @@ qxl_allocnf (qxl_screen_t *qxl, unsigned long size)
 {
     void *result;
     int n_attempts = 0;
+    struct QXLRect rect;
 #if 0
     static int nth_oom = 1;
 #endif
@@ -292,18 +279,14 @@ qxl_allocnf (qxl_screen_t *qxl, unsigned long size)
     
     while (!(result = qxl_alloc (qxl->mem, size)))
     {
-	struct QXLRam *ram_header = qxlhw_pci_get_ram_header(qxl->hw);
-    
 	/* Rather than go out of memory, we simply tell the
 	 * device to dump everything
 	 */
-	ram_header->update_area.top = 0;
-	ram_header->update_area.bottom = qxl->virtual_y;
-	ram_header->update_area.left = 0;
-	ram_header->update_area.right = qxl->virtual_x;
-	ram_header->update_surface = 0;		/* Only primary for now */
-	
-        qxl_update_area(qxl);
+	rect.top = 0;
+	rect.bottom = qxl->virtual_y;
+	rect.left = 0;
+	rect.right = qxl->virtual_x;
+        qxlhw_update_area(qxl->hw, 0 /* Only primary for now */, rect);
 	
 #if 0
  	ErrorF ("eliminated memory (%d)\n", nth_oom++);
diff --git a/src/qxl_surface.c b/src/qxl_surface.c
index 6343337..2ae7124 100644
--- a/src/qxl_surface.c
+++ b/src/qxl_surface.c
@@ -821,16 +821,14 @@ qxl_surface_flush (qxl_surface_t *surface)
 static void
 download_box (qxl_surface_t *surface, int x1, int y1, int x2, int y2)
 {
-    struct QXLRam *ram_header = qxlhw_pci_get_ram_header (surface->cache->qxl->hw);
-    
-    ram_header->update_area.top = y1;
-    ram_header->update_area.bottom = y2;
-    ram_header->update_area.left = x1;
-    ram_header->update_area.right = x2;
-    
-    ram_header->update_surface = surface->id;
+    QXLRect update_area;
+
+    update_area.top = y1;
+    update_area.bottom = y2;
+    update_area.left = x1;
+    update_area.right = x2;
 
-    qxl_update_area(surface->cache->qxl);
+    qxlhw_update_area(surface->cache->qxl->hw, surface->id, update_area);
 
     pixman_image_composite (PIXMAN_OP_SRC,
      			    surface->dev_image,
diff --git a/src/qxlhw.c b/src/qxlhw.c
index a335ee7..d9617e7 100644
--- a/src/qxlhw.c
+++ b/src/qxlhw.c
@@ -37,3 +37,8 @@ void qxlhw_unmap_memory(struct qxlhw *base, int scrnIndex)
 {
         base->unmap_memory(base, scrnIndex);
 }
+
+void qxlhw_update_area(struct qxlhw *base, int surface_id, struct QXLRect rect)
+{
+        base->update_area(base, surface_id, rect);
+}
diff --git a/src/qxlhw.h b/src/qxlhw.h
index c943cc8..28a1e70 100644
--- a/src/qxlhw.h
+++ b/src/qxlhw.h
@@ -13,6 +13,9 @@ struct qxlhw {
     void (*reset)(struct qxlhw *base);
     Bool (*map_memory)(struct qxlhw *base, int scrnIndex);
     void (*unmap_memory)(struct qxlhw *base, int scrnIndex);
+
+    /* memory handling callbacks */
+    void (*update_area)(struct qxlhw *base, int surface_id, struct QXLRect rect);
 };
 
 void qxlhw_init(struct qxlhw *base, qxl_screen_t *qxl);
@@ -21,6 +24,8 @@ void qxlhw_init(struct qxlhw *base, qxl_screen_t *qxl);
  * to use. currently just PCI. */
 struct qxlhw *qxlhw_create(qxl_screen_t *qxl, ScrnInfoPtr pScrn);
 
+void qxlhw_update_area(struct qxlhw *base, int surface_id, struct QXLRect rect);
+
 /* reset vs device_reset - device_reset is just the io / drm call,
  * reset does -- what? (definition, not contents) */
 void qxlhw_device_reset(struct qxlhw *base);
diff --git a/src/qxlhw_pci.c b/src/qxlhw_pci.c
index d671498..f25b792 100644
--- a/src/qxlhw_pci.c
+++ b/src/qxlhw_pci.c
@@ -367,6 +367,28 @@ static void qxlhw_pci_reset(struct qxlhw *base)
     base->qxl->vram_mem_slot = hw->vram_mem_slot;
 }
 
+static void qxlhw_pci_update_area(struct qxlhw *base, int surface_id, struct QXLRect rect)
+{
+    struct qxlhw_pci *hw = (struct qxlhw_pci *)base;
+    struct QXLRam *ram_header = qxlhw_pci_get_ram_header (base);
+#ifndef XSPICE
+    qxl_screen_t *qxl = base->qxl;
+#endif
+
+    ram_header->update_area = rect;
+    ram_header->update_surface = surface_id;
+#ifndef XSPICE
+    if (qxl->pci->revision >= 3) {
+        qxlhw_pci_ioport_write(hw, QXL_IO_UPDATE_AREA_ASYNC, 0);
+        qxlhw_pci_wait_for_io_command(hw);
+    } else {
+        qxlhw_pci_ioport_write(hw, QXL_IO_UPDATE_AREA, 0);
+    }
+#else
+    qxlhw_pci_ioport_write(hw, QXL_IO_UPDATE_AREA, 0);
+#endif
+}
+
 /* public entry point */
 struct qxlhw *create_qxlhw_pci(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
 {
@@ -378,6 +400,7 @@ struct qxlhw *create_qxlhw_pci(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
     base->reset = qxlhw_pci_reset;
     base->map_memory = qxlhw_pci_map_memory;
     base->unmap_memory = qxlhw_pci_unmap_memory;
+    base->update_area = qxlhw_pci_update_area;
     return base;
 }
 
-- 
1.7.9.3



More information about the Spice-devel mailing list