[Spice-commits] Branch 'spice.v11' - 5 commits - hw/qxl-logger.c hw/qxl.c hw/qxl.h

Gerd Hoffmann kraxel at kemper.freedesktop.org
Thu Jun 24 08:13:51 PDT 2010


 hw/qxl-logger.c |   13 ++++++++
 hw/qxl.c        |   81 ++++++++++++++++++++++++++++++++++----------------------
 hw/qxl.h        |    8 ++---
 3 files changed, 66 insertions(+), 36 deletions(-)

New commits:
commit 81ef3303f346cb888ffae14ca860bc5eccd76d81
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Wed Jun 23 15:24:05 2010 +0200

    qxl: drop compat property, add revision property

diff --git a/hw/qxl.c b/hw/qxl.c
index bb16efe..04342e3 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1140,7 +1140,8 @@ static int qxl_init(PCIDevice *dev)
     VGACommonState *vga = &qxl->vga;
     uint8_t* config = qxl->pci.config;
     ram_addr_t ram_size = msb_mask(qxl->vga.vram_size * 2 - 1);
-    uint32_t pci_device_id = QXL_DEVICE_ID;
+    uint32_t pci_device_id;
+    uint32_t pci_device_rev;
 
     if (device_id == 0 && dev->qdev.hotplugged) {
         device_id++;
@@ -1150,8 +1151,20 @@ static int qxl_init(PCIDevice *dev)
     qxl->mode = QXL_MODE_UNDEFINED;
     qxl->generation = 1;
 
-    if (qxl->compat)
-        pci_device_id = 0x100; /* qxl-1 */
+    switch (qxl->revision) {
+    case 1: /* qxl-1 */
+        pci_device_id  = 0x0100;
+        pci_device_rev = 1;
+        break;
+    case 2: /* qxl-2 */
+        pci_device_id  = 0x0100;
+        pci_device_rev = 2;
+        break;
+    default: /* unstable */
+        pci_device_id  = 0x01ff;
+        pci_device_rev = 1;
+        break;
+    }
 
     if (!qxl->id) {
         if (ram_size < 32 * 1024 * 1024)
@@ -1175,10 +1188,10 @@ static int qxl_init(PCIDevice *dev)
         register_displaychangelistener(vga->ds, &display_listener);
 
         if (qxl->pci.romfile == NULL) {
-            if (qxl->compat) {
-                qxl->pci.romfile = qemu_strdup("vgabios-qxl.bin");
-            } else {
+            if (pci_device_id == 0x01ff) {
                 qxl->pci.romfile = qemu_strdup("vgabios-qxldev.bin");
+            } else {
+                qxl->pci.romfile = qemu_strdup("vgabios-qxl.bin");
             }
         }
         pci_config_set_class(config, PCI_CLASS_DISPLAY_VGA);
@@ -1193,7 +1206,7 @@ static int qxl_init(PCIDevice *dev)
 
     pci_config_set_vendor_id(config, REDHAT_PCI_VENDOR_ID);
     pci_config_set_device_id(config, pci_device_id);
-    pci_set_byte(&config[PCI_REVISION_ID], QXL_REVISION);
+    pci_set_byte(&config[PCI_REVISION_ID], pci_device_rev);
     pci_set_byte(&config[PCI_INTERRUPT_PIN], 1);
 
     qxl->rom_size = qxl_rom_size();
@@ -1398,7 +1411,7 @@ static PCIDeviceInfo qxl_info = {
     .qdev.props = (Property[]) {
         DEFINE_PROP_UINT32("ram_size", PCIQXLDevice, vga.vram_size, 64 * 1024 * 1024),
         DEFINE_PROP_UINT32("vram_size", PCIQXLDevice, vram_size, 64 * 1024 * 1024),
-        DEFINE_PROP_UINT32("compat", PCIQXLDevice, compat, 0),
+        DEFINE_PROP_UINT32("revision", PCIQXLDevice, revision, 3),
         DEFINE_PROP_UINT32("debug", PCIQXLDevice, debug, 1),
         DEFINE_PROP_UINT32("cmdlog", PCIQXLDevice, cmdlog, 0),
         DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/qxl.h b/hw/qxl.h
index af60ff4..1216405 100644
--- a/hw/qxl.h
+++ b/hw/qxl.h
@@ -22,9 +22,7 @@ typedef struct PCIQXLDevice {
     enum qxl_mode      mode;
     uint32_t           cmdflags;
     int                generation;
-
-    /* temporary for development */
-    uint32_t           compat;
+    uint32_t           revision;
 
     struct guest_slots {
         QXLMemSlot     slot;
commit 5bf5f7424c0b3053a0af45c8840105a9ed65dfec
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Tue Jun 22 17:45:10 2010 +0200

    qxl: 0.4 compat mode fixups

diff --git a/hw/qxl-logger.c b/hw/qxl-logger.c
index 4f385c0..d4a935a 100644
--- a/hw/qxl-logger.c
+++ b/hw/qxl-logger.c
@@ -94,6 +94,13 @@ static void qxl_log_cmd_draw(PCIQXLDevice *qxl, QXLDrawable *draw)
             qxl_name(qxl_draw_effect, draw->effect));
 }
 
+static void qxl_log_cmd_draw_compat(PCIQXLDevice *qxl, QXLCompatDrawable *draw)
+{
+    fprintf(stderr, ": type %s effect %s",
+            qxl_name(qxl_draw_type, draw->type),
+            qxl_name(qxl_draw_effect, draw->effect));
+}
+
 static void qxl_log_cmd_surface(PCIQXLDevice *qxl, QXLSurfaceCmd *cmd)
 {
     fprintf(stderr, ": %s id %d",
@@ -155,7 +162,11 @@ void qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext)
     data = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id);
     switch (ext->cmd.type) {
     case QXL_CMD_DRAW:
-        qxl_log_cmd_draw(qxl, data);
+        if (!compat) {
+            qxl_log_cmd_draw(qxl, data);
+        } else {
+            qxl_log_cmd_draw_compat(qxl, data);
+        }
         break;
     case QXL_CMD_SURFACE:
         qxl_log_cmd_surface(qxl, data);
diff --git a/hw/qxl.c b/hw/qxl.c
index cd41842..bb16efe 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -668,7 +668,7 @@ static void qxl_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     vga_ioport_write(opaque, addr, val);
 }
 
-static void qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id)
+static void qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta)
 {
     static const int regions[] = {
         QXL_RAM_RANGE_INDEX,
@@ -730,8 +730,8 @@ static void qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id)
     memslot.slot_group_id = MEMSLOT_GROUP_GUEST; /* guest group */
     memslot.virt_start = virt_start + (guest_start - pci_start);
     memslot.virt_end   = virt_start + (guest_end   - pci_start);
-    memslot.addr_delta = memslot.virt_start;
-    memslot.generation = d->rom->slot_generation = 42; // FIXME d->generation++;
+    memslot.addr_delta = memslot.virt_start - delta;
+    memslot.generation = d->rom->slot_generation = 0; // FIXME d->generation++;
     qxl_rom_set_dirty(d);
 
     dprintf(d, 1, "%s: slot %d: host virt 0x%" PRIx64 " - 0x%" PRIx64 "\n",
@@ -741,6 +741,7 @@ static void qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id)
     d->ssd.worker->add_memslot(d->ssd.worker, &memslot);
     d->guest_slots[slot_id].ptr = (void*)memslot.virt_start;
     d->guest_slots[slot_id].size = memslot.virt_end - memslot.virt_start;
+    d->guest_slots[slot_id].delta = delta;
     d->guest_slots[slot_id].active = 1;
 }
 
@@ -778,6 +779,8 @@ void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)
     case MEMSLOT_GROUP_GUEST:
         PANIC_ON(slot > NUM_MEMSLOTS);
         PANIC_ON(!qxl->guest_slots[slot].active);
+        PANIC_ON(offset < qxl->guest_slots[slot].delta);
+        offset -= qxl->guest_slots[slot].delta;
         PANIC_ON(offset > qxl->guest_slots[slot].size)
         return qxl->guest_slots[slot].ptr + offset;
     default:
@@ -836,6 +839,7 @@ static void qxl_set_mode(PCIQXLDevice *d, int modenr)
     pcibus_t start = d->pci.io_regions[QXL_RAM_RANGE_INDEX].addr;
     pcibus_t end   = d->pci.io_regions[QXL_RAM_RANGE_INDEX].size + start;
     QXLMode *mode = d->modes->modes + modenr;
+    uint64_t devmem = d->pci.io_regions[QXL_RAM_RANGE_INDEX].addr;
     QXLMemSlot slot = {
         .mem_start = start,
         .mem_end = end
@@ -843,18 +847,18 @@ static void qxl_set_mode(PCIQXLDevice *d, int modenr)
     QXLSurfaceCreate surface = {
         .width      = mode->x_res,
         .height     = mode->y_res,
-        .stride     = mode->x_res * 4,
+        .stride     = -mode->x_res * 4,
         .format     = SPICE_SURFACE_FMT_32_xRGB,
         .mouse_mode = true,
-        .mem        = 0, /* FIXME */
+        .mem        = devmem,
     };
 
-    dprintf(d, 1, "%s: mode %d  [ %d x %d @ %d bpp ]\n", __FUNCTION__,
-            modenr, mode->x_res, mode->y_res, mode->bits);
+    dprintf(d, 1, "%s: mode %d  [ %d x %d @ %d bpp devmem 0x%lx ]\n", __FUNCTION__,
+            modenr, mode->x_res, mode->y_res, mode->bits, devmem);
     qxl_hard_reset(d, 0);
 
     d->guest_slots[0].slot = slot;
-    qxl_add_memslot(d, 0);
+    qxl_add_memslot(d, 0, devmem);
 
     d->guest_primary.surface = surface;
     qxl_create_guest_primary(d, 0);
@@ -873,12 +877,13 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)
 
     switch (io_port) {
     case QXL_IO_RESET:
+    case QXL_IO_SET_MODE:
     case QXL_IO_MEMSLOT_ADD:
     case QXL_IO_MEMSLOT_DEL:
     case QXL_IO_CREATE_PRIMARY:
         break;
     default:
-        if (d->mode == QXL_MODE_NATIVE)
+        if (d->mode == QXL_MODE_NATIVE || d->mode == QXL_MODE_COMPAT)
             break;
         dprintf(d, 1, "%s: unexpected port 0x%x in vga mode\n", __FUNCTION__, io_port);
         return;
@@ -926,7 +931,7 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)
         PANIC_ON(val >= NUM_MEMSLOTS);
         PANIC_ON(d->guest_slots[val].active);
         d->guest_slots[val].slot = d->ram->mem_slot;
-        qxl_add_memslot(d, val);
+        qxl_add_memslot(d, val, 0);
         break;
     case QXL_IO_MEMSLOT_DEL:
         qxl_del_memslot(d, val);
@@ -1275,7 +1280,7 @@ static int qxl_post_load(void *opaque, int version)
         for (i = 0; i < NUM_MEMSLOTS; i++) {
             if (!d->guest_slots[i].active)
                 continue;
-            qxl_add_memslot(d, i);
+            qxl_add_memslot(d, i, 0);
         }
         qxl_create_guest_primary(d, 1);
 
diff --git a/hw/qxl.h b/hw/qxl.h
index 8619582..af60ff4 100644
--- a/hw/qxl.h
+++ b/hw/qxl.h
@@ -29,7 +29,8 @@ typedef struct PCIQXLDevice {
     struct guest_slots {
         QXLMemSlot     slot;
         void           *ptr;
-        size_t         size;
+        uint64_t       size;
+        uint64_t       delta;
         uint32_t       active;
     } guest_slots[NUM_MEMSLOTS];
 
commit 94451ca94dd962e15fba101fccd3ed08d1ea2788
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Wed Jun 23 13:04:29 2010 +0200

    qxl: render cursur only on primary

diff --git a/hw/qxl.c b/hw/qxl.c
index 7335ce8..cd41842 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -475,7 +475,9 @@ static int interface_get_cursor_command(QXLInstance *sin, struct QXLCommandExt *
         qxl->guest_primary.commands++;
         qxl_track_command(qxl, ext);
         qxl_log_command(qxl, "csr", ext);
-        qxl_render_cursor(qxl, ext);
+        if (qxl->id == 0) {
+            qxl_render_cursor(qxl, ext);
+        }
         return true;
     default:
         return false;
commit 41713c5cfdab33aa5ee5f7685519d4acbcde5882
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Thu Jun 24 17:11:42 2010 +0200

    qxl: allow notify requests in QXL_MODE_UNDEFINED.

diff --git a/hw/qxl.c b/hw/qxl.c
index 9dfb058..7335ce8 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -360,6 +360,7 @@ static int interface_req_cmd_notification(QXLInstance *sin)
     switch (qxl->mode) {
     case QXL_MODE_COMPAT:
     case QXL_MODE_NATIVE:
+    case QXL_MODE_UNDEFINED:
         SPICE_RING_CONS_WAIT(&qxl->ram->cmd_ring, wait);
         qxl_ring_set_dirty(qxl);
         break;
commit 70673d55567e8765cecec437b144fe8d13a9843a
Author: Gerd Hoffmann <kraxel at redhat.com>
Date:   Tue Jun 15 14:46:32 2010 +0200

    qxl: allow flushing the command queue in QXL_MODE_UNDEFINED.

diff --git a/hw/qxl.c b/hw/qxl.c
index f701adb..9dfb058 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -313,7 +313,6 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
     SimpleSpiceUpdate *update;
     QXLCommandRing *ring;
     QXLCommand *cmd;
-    uint32_t flags = 0;
     int notify;
 
     switch (qxl->mode) {
@@ -327,10 +326,10 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
         qxl_log_command(qxl, "vga", ext);
         return true;
     case QXL_MODE_COMPAT:
-        flags = QXL_COMMAND_FLAG_COMPAT;
-        /* fall through */
     case QXL_MODE_NATIVE:
-        dprintf(qxl, 2, "%s: %s\n", __FUNCTION__, flags ? "compat" : "native");
+    case QXL_MODE_UNDEFINED:
+        dprintf(qxl, 2, "%s: %s\n", __FUNCTION__,
+                qxl->cmdflags ? "compat" : "native");
         ring = &qxl->ram->cmd_ring;
         if (SPICE_RING_IS_EMPTY(ring)) {
             return false;
@@ -338,7 +337,7 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
         SPICE_RING_CONS_ITEM(ring, cmd);
         ext->cmd      = *cmd;
         ext->group_id = MEMSLOT_GROUP_GUEST;
-        ext->flags    = flags;
+        ext->flags    = qxl->cmdflags;
         SPICE_RING_POP(ring, notify);
         qxl_ring_set_dirty(qxl);
         if (notify) {
@@ -348,7 +347,6 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
         qxl_track_command(qxl, ext);
         qxl_log_command(qxl, "cmd", ext);
         return true;
-    case QXL_MODE_UNDEFINED:
     default:
         return false;
     }
@@ -381,8 +379,8 @@ static int interface_has_command(QXLInstance *sin)
         return qemu_spice_rect_is_empty(&qxl->ssd.dirty) ? false : true;
     case QXL_MODE_COMPAT:
     case QXL_MODE_NATIVE:
-        return SPICE_RING_IS_EMPTY(&qxl->ram->cmd_ring) ? false : true;
     case QXL_MODE_UNDEFINED:
+        return SPICE_RING_IS_EMPTY(&qxl->ram->cmd_ring) ? false : true;
     default:
         return false;
     }
@@ -454,14 +452,12 @@ static int interface_get_cursor_command(QXLInstance *sin, struct QXLCommandExt *
     PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
     QXLCursorRing *ring;
     QXLCommand *cmd;
-    uint32_t flags = 0;
     int notify;
 
     switch (qxl->mode) {
     case QXL_MODE_COMPAT:
-        flags = QXL_COMMAND_FLAG_COMPAT;
-        /* fall through */
     case QXL_MODE_NATIVE:
+    case QXL_MODE_UNDEFINED:
         ring = &qxl->ram->cursor_ring;
         if (SPICE_RING_IS_EMPTY(ring)) {
             return false;
@@ -469,7 +465,7 @@ static int interface_get_cursor_command(QXLInstance *sin, struct QXLCommandExt *
         SPICE_RING_CONS_ITEM(ring, cmd);
         ext->cmd      = *cmd;
         ext->group_id = MEMSLOT_GROUP_GUEST;
-        ext->flags    = flags;
+        ext->flags    = qxl->cmdflags;
         SPICE_RING_POP(ring, notify);
         qxl_ring_set_dirty(qxl);
         if (notify) {
@@ -813,6 +809,7 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm)
     }
 
     qxl->mode = QXL_MODE_NATIVE;
+    qxl->cmdflags = 0;
     qxl->ssd.worker->create_primary_surface(qxl->ssd.worker, 0, &surface);
 
     /* for local rendering */
@@ -860,6 +857,7 @@ static void qxl_set_mode(PCIQXLDevice *d, int modenr)
     qxl_create_guest_primary(d, 0);
 
     d->mode = QXL_MODE_COMPAT;
+    d->cmdflags = QXL_COMMAND_FLAG_COMPAT;
     d->shadow_rom.mode = cpu_to_le32(modenr);
     d->rom->mode = cpu_to_le32(modenr);
     qxl_rom_set_dirty(d);
diff --git a/hw/qxl.h b/hw/qxl.h
index e1d1bab..8619582 100644
--- a/hw/qxl.h
+++ b/hw/qxl.h
@@ -20,6 +20,7 @@ typedef struct PCIQXLDevice {
     uint32_t           debug;
     uint32_t           cmdlog;
     enum qxl_mode      mode;
+    uint32_t           cmdflags;
     int                generation;
 
     /* temporary for development */


More information about the Spice-commits mailing list