[Spice-devel] [spice-protocol PATCH 39/46] qxlhw: move and use qxlhw_screen_init

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


---
 src/qxl_driver.c  |    9 ++------
 src/qxl_surface.c |    2 +-
 src/qxlhw.c       |   10 +++++++++
 src/qxlhw.h       |    6 ++++++
 src/qxlhw_pci.c   |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 80 insertions(+), 8 deletions(-)

diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index 3de060d..972aa4a 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -611,7 +611,6 @@ qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 {
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
     qxl_screen_t *qxl = pScrn->driverPrivate;
-    struct QXLRom *rom;
     VisualPtr visual;
 
     CHECK_POINT();
@@ -624,12 +623,8 @@ qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 #ifdef XSPICE
     spiceqxl_screen_init(scrnIndex, pScrn, qxl);
 #endif
-    rom = qxlhw_pci_get_rom(qxl->hw);
-    assert(rom);
-    
-    printf ("ram_header at %d\n", rom->ram_header_offset);
-    printf ("surf0 size: %d\n", rom->surface0_area_size);
-    
+    qxlhw_screen_init(qxl->hw);
+
     qxlhw_save_state(qxl->hw, pScrn);
     qxl_blank_screen(pScreen, SCREEN_SAVER_ON);
     
diff --git a/src/qxl_surface.c b/src/qxl_surface.c
index d499593..9e9c364 100644
--- a/src/qxl_surface.c
+++ b/src/qxl_surface.c
@@ -545,7 +545,7 @@ retry:
     cmd.u.surface_create.height = height;
     cmd.u.surface_create.stride = -stride;
 
-    cmd.u.surface_create.data = pointer_to_u64(surface->address);
+    cmd.u.surface_create.data = pointer_to_u64(address);
 
     push_surface_cmd (cache, &cmd);
 
diff --git a/src/qxlhw.c b/src/qxlhw.c
index 7e444e0..a5c17c6 100644
--- a/src/qxlhw.c
+++ b/src/qxlhw.c
@@ -53,6 +53,16 @@ void qxlhw_unmap_memory(struct qxlhw *base, int scrnIndex)
         base->unmap_memory(base, scrnIndex);
 }
 
+void qxlhw_screen_init(struct qxlhw *base)
+{
+        base->screen_init(base);
+}
+
+Bool qxlhw_check_device(struct qxlhw *base, ScrnInfoPtr pScrn)
+{
+        return base->check_device(base, pScrn);
+}
+
 void *qxlhw_data_alloc(struct qxlhw *base, unsigned long size)
 {
         return base->data_alloc(base, size);
diff --git a/src/qxlhw.h b/src/qxlhw.h
index 0e9e6c8..f59649d 100644
--- a/src/qxlhw.h
+++ b/src/qxlhw.h
@@ -16,6 +16,8 @@ struct qxlhw {
     void (*restore_state)(struct qxlhw *base, ScrnInfoPtr pScrn);
     Bool (*map_memory)(struct qxlhw *base, int scrnIndex);
     void (*unmap_memory)(struct qxlhw *base, int scrnIndex);
+    void (*screen_init)(struct qxlhw *base);
+    Bool (*check_device)(struct qxlhw *base, ScrnInfoPtr pScrn);
 
     /* capabilities check / accessors */
     int (*get_n_surfaces)(struct qxlhw *base);
@@ -62,6 +64,10 @@ void qxlhw_restore_state(struct qxlhw *base, ScrnInfoPtr pScrn);
 Bool qxlhw_map_memory(struct qxlhw *base, int scrnIndex);
 void qxlhw_unmap_memory(struct qxlhw *base, int scrnIndex);
 
+void qxlhw_screen_init(struct qxlhw *base);
+
+Bool qxlhw_check_device(struct qxlhw *base, ScrnInfoPtr pScrn);
+
 /* memory translation, relocations. */
 void *qxlhw_data_alloc(struct qxlhw *base, unsigned long size);
 void qxlhw_data_free(struct qxlhw *base, void *p);
diff --git a/src/qxlhw_pci.c b/src/qxlhw_pci.c
index 5ba2fd8..8613e1c 100644
--- a/src/qxlhw_pci.c
+++ b/src/qxlhw_pci.c
@@ -12,6 +12,11 @@
 #include "spiceqxl_driver.h"
 #endif
 
+#if 0
+#define CHECK_POINT() ErrorF ("%s: %d  (%s)\n", __FILE__, __LINE__, __FUNCTION__);
+#endif
+#define CHECK_POINT()
+
 typedef struct
 {
     uint8_t	generation;
@@ -563,6 +568,60 @@ static void qxlhw_pci_restore_state(struct qxlhw *base, ScrnInfoPtr pScrn)
 #endif
 }
 
+static void qxlhw_pci_screen_init(struct qxlhw *base)
+{
+    struct qxlhw_pci *hw = (struct qxlhw_pci *)base;
+    
+    printf ("ram_header at %d\n", hw->rom->ram_header_offset);
+    printf ("surf0 size: %d\n", hw->rom->surface0_area_size);
+}
+
+static Bool
+qxlhw_pci_check_device(struct qxlhw *base, ScrnInfoPtr pScrn)
+{
+    struct qxlhw_pci *hw = (struct qxlhw_pci *)base;
+    int scrnIndex = pScrn->scrnIndex;
+#ifndef XSPICE
+    struct QXLRom *rom = hw->rom;
+    struct QXLRam *ram_header = (void *)((unsigned long)hw->ram + rom->ram_header_offset);
+
+    CHECK_POINT();
+    
+    if (rom->magic != 0x4f525851) { /* "QXRO" little-endian */
+	xf86DrvMsg(scrnIndex, X_ERROR, "Bad ROM signature %x\n", rom->magic);
+	return FALSE;
+    }
+    
+    xf86DrvMsg(scrnIndex, X_INFO, "Device version %d.%d\n",
+	       rom->id, rom->update_id);
+    
+    xf86DrvMsg(scrnIndex, X_INFO, "Compression level %d, log level %d\n",
+	       rom->compression_level,
+	       rom->log_level);
+    
+    xf86DrvMsg(scrnIndex, X_INFO, "%d io pages at 0x%lx\n",
+	       rom->num_pages, (unsigned long)hw->ram);
+    
+    xf86DrvMsg(scrnIndex, X_INFO, "RAM header offset: 0x%x\n", rom->ram_header_offset);
+
+    if (ram_header->magic != 0x41525851) { /* "QXRA" little-endian */
+	xf86DrvMsg(scrnIndex, X_ERROR, "Bad RAM signature %x at %p\n",
+		   ram_header->magic,
+		   &ram_header->magic);
+	return FALSE;
+    }
+
+    xf86DrvMsg(scrnIndex, X_INFO, "Correct RAM signature %x\n",
+	       ram_header->magic);
+#endif /* !XSPICE */
+
+    pScrn->videoRam = (hw->rom->num_pages * 4096) / 1024;
+    xf86DrvMsg(scrnIndex, X_INFO, "%d KB of video RAM\n", pScrn->videoRam);
+    xf86DrvMsg(scrnIndex, X_INFO, "%d surfaces\n", hw->rom->n_surfaces);
+
+    return TRUE;
+}
+
 static void *qxlhw_pci_data_alloc(struct qxlhw *base, unsigned long size)
 {
     struct qxlhw_pci *hw = (struct qxlhw_pci *)base;
@@ -910,6 +969,8 @@ struct qxlhw *create_qxlhw_pci(qxl_screen_t *qxl, ScrnInfoPtr pScrn)
     base->restore_state = qxlhw_pci_restore_state;
     base->map_memory = qxlhw_pci_map_memory;
     base->unmap_memory = qxlhw_pci_unmap_memory;
+    base->screen_init = qxlhw_pci_screen_init;
+    base->check_device = qxlhw_pci_check_device;
     base->data_alloc = qxlhw_pci_data_alloc;
     base->data_free = qxlhw_pci_data_free;
     base->create_primary_surface = qxlhw_pci_create_primary_surface;
-- 
1.7.9.3



More information about the Spice-devel mailing list