[Spice-devel] [spice-protocol PATCH 37/46] qxlhw: qxl_surface: use qxlhw_ref_primary_surface

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


---
 src/qxl.h         |   10 ----------
 src/qxl_surface.c |    5 ++---
 src/qxlhw.c       |    5 +++++
 src/qxlhw.h       |    3 +++
 src/qxlhw_pci.c   |   21 ++++++++++++++++++---
 5 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/src/qxl.h b/src/qxl.h
index 626abc3..25e6322 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -75,16 +75,6 @@ typedef struct surface_cache_t surface_cache_t;
 
 typedef struct _qxl_screen_t qxl_screen_t;
 
-typedef struct
-{
-    uint8_t	generation;
-    uint64_t	start_phys_addr;
-    uint64_t	end_phys_addr;
-    uint64_t	start_virt_addr;
-    uint64_t	end_virt_addr;
-    uint64_t	high_bits;
-} qxl_memslot_t;
-
 typedef struct qxl_surface_t qxl_surface_t;
 
 /*
diff --git a/src/qxl_surface.c b/src/qxl_surface.c
index 0ce9877..d499593 100644
--- a/src/qxl_surface.c
+++ b/src/qxl_surface.c
@@ -297,13 +297,12 @@ qxl_surface_t *
 qxl_surface_cache_create_primary (surface_cache_t	*cache,
 				  struct QXLMode	*mode)
 {
-    qxl_screen_t *qxl = cache->qxl;
-    void *ram = qxlhw_pci_get_ram(qxl->hw);
     struct QXLSurfaceCreate create;
     pixman_format_code_t format;
     uint8_t *dev_addr;
     pixman_image_t *dev_image, *host_image;
     qxl_surface_t *surface;
+    qxl_screen_t *qxl = cache->qxl;
 
     if (mode->bits == 16)
     {
@@ -331,7 +330,7 @@ qxl_surface_cache_create_primary (surface_cache_t	*cache,
 
     qxlhw_create_primary_surface(qxl->hw, &create);
 
-    dev_addr = (uint8_t *)ram + mode->stride * (mode->y_res - 1);
+    dev_addr = qxlhw_ref_primary_surface(qxl->hw) + mode->stride * (mode->y_res - 1);
 
     dev_image = pixman_image_create_bits (format, mode->x_res, mode->y_res,
 					  (uint32_t *)dev_addr, -mode->stride);
diff --git a/src/qxlhw.c b/src/qxlhw.c
index 5ad7c43..7e444e0 100644
--- a/src/qxlhw.c
+++ b/src/qxlhw.c
@@ -79,6 +79,11 @@ void qxlhw_create_primary_surface(struct qxlhw *base, QXLSurfaceCreate *create)
         base->create_primary_surface(base, create);
 }
 
+uint8_t *qxlhw_ref_primary_surface(struct qxlhw *base)
+{
+        return base->ref_primary_surface(base);
+}
+
 int qxlhw_get_n_surfaces(struct qxlhw *base)
 {
         return base->get_n_surfaces(base);
diff --git a/src/qxlhw.h b/src/qxlhw.h
index c8e0bdf..0e9e6c8 100644
--- a/src/qxlhw.h
+++ b/src/qxlhw.h
@@ -27,6 +27,7 @@ struct qxlhw {
                            int stride, pixman_format_code_t pformat);
     void (*surface_free)(struct qxlhw *base, void *mem);
     void (*create_primary_surface)(struct qxlhw *base, QXLSurfaceCreate *create);
+    uint8_t *(*ref_primary_surface)(struct qxlhw *base);
     void (*push_surface_cmd)(struct qxlhw *base, QXLSurfaceCmd* base_cmd);
     void (*update_area)(struct qxlhw *base, int surface_id, struct QXLRect rect);
     void (*push_cursor)(struct qxlhw *base, struct QXLCursorCmd *base_cmd);
@@ -81,6 +82,8 @@ Bool qxlhw_handle_oom(struct qxlhw *base);
  */
 void qxlhw_create_primary_surface(struct qxlhw *base, QXLSurfaceCreate *create);
 
+uint8_t *qxlhw_ref_primary_surface(struct qxlhw *base);
+
 int qxlhw_get_n_surfaces(struct qxlhw *base);
 
 /* note that allocation of these commands is completely in qxlhw_pci.c,
diff --git a/src/qxlhw_pci.c b/src/qxlhw_pci.c
index e216152..69d6888 100644
--- a/src/qxlhw_pci.c
+++ b/src/qxlhw_pci.c
@@ -12,6 +12,16 @@
 #include "spiceqxl_driver.h"
 #endif
 
+typedef struct
+{
+    uint8_t	generation;
+    uint64_t	start_phys_addr;
+    uint64_t	end_phys_addr;
+    uint64_t	start_virt_addr;
+    uint64_t	end_virt_addr;
+    uint64_t	high_bits;
+} qxl_memslot_t;
+
 struct qxlhw_pci {
     struct qxlhw base;
 
@@ -413,9 +423,6 @@ qxlhw_pci_map_memory(struct qxlhw *base, int scrnIndex)
     hw->mem = qxl_mem_create ((void *)((unsigned long)hw->ram + qxl->surface0_size),
 			       hw->rom->num_pages * getpagesize() - qxl->surface0_size);
     hw->surf_mem = qxl_mem_create ((void *)((unsigned long)hw->vram), hw->vram_size);
-    // Set the pointers in qxl_screen_t since they are still used:
-    base->qxl->mem = hw->mem;
-    base->qxl->surf_mem = hw->surf_mem;
 
     return TRUE;
 }
@@ -646,6 +653,13 @@ static void qxlhw_pci_create_primary_surface(struct qxlhw *base, QXLSurfaceCreat
 #endif
 }
 
+static uint8_t *qxlhw_pci_ref_primary_surface(struct qxlhw *base)
+{
+    struct qxlhw_pci *hw = (struct qxlhw_pci *)base;
+
+    return (uint8_t *)hw->ram;
+}
+
 static int qxlhw_pci_get_n_surfaces(struct qxlhw *base)
 {
     struct qxlhw_pci *hw = (struct qxlhw_pci *)base;
@@ -904,6 +918,7 @@ struct qxlhw *create_qxlhw_pci(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
     base->data_alloc = qxlhw_pci_data_alloc;
     base->data_free = qxlhw_pci_data_free;
     base->create_primary_surface = qxlhw_pci_create_primary_surface;
+    base->ref_primary_surface = qxlhw_pci_ref_primary_surface;
     base->get_n_surfaces = qxlhw_pci_get_n_surfaces;
     base->surface_alloc = qxlhw_pci_surface_alloc;
     base->surface_free = qxlhw_pci_surface_free;
-- 
1.7.9.3



More information about the Spice-devel mailing list