Patchwork [4/4,v4] vmware_vga: Allow simple drivers to work without using the fifo

login
register
mail settings
Submitter BALATON Zoltan
Date Oct. 31, 2012, 1:10 a.m.
Message ID <alpine.GSO.2.00.1210310209340.21558@mono>
Download mbox | patch
Permalink /patch/195679/
State New
Headers show

Comments

BALATON Zoltan - Oct. 31, 2012, 1:10 a.m.
Postpone stopping the dirty log to the point where the command fifo is
configured to allow drivers which don't use the fifo to work too.
(Without this the picture rendered into the vram never got to the
screen and the DIRECT_VRAM option meant to support this case was
removed a year ago.)

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
  hw/vga.c        |    2 +-
  hw/vga_int.h    |    1 +
  hw/vmware_vga.c |   34 +++++++++++++++++++++-------------
  3 files changed, 23 insertions(+), 14 deletions(-)

  v4: rebased to apply to current

Patch

diff --git a/hw/vga.c b/hw/vga.c
index e4220df..a565002 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -1607,7 +1607,7 @@  void vga_invalidate_scanlines(VGACommonState *s, int y1, int y2)
      }
  }

-static void vga_sync_dirty_bitmap(VGACommonState *s)
+void vga_sync_dirty_bitmap(VGACommonState *s)
  {
      memory_region_sync_dirty_bitmap(&s->vram);
  }
diff --git a/hw/vga_int.h b/hw/vga_int.h
index 22f1706..722de6f 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -184,6 +184,7 @@  MemoryRegion *vga_init_io(VGACommonState *s,
                            const MemoryRegionPortio **vbe_ports);
  void vga_common_reset(VGACommonState *s);

+void vga_sync_dirty_bitmap(VGACommonState *s);
  void vga_dirty_log_start(VGACommonState *s);
  void vga_dirty_log_stop(VGACommonState *s);

diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index deb9dda..86586ce 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -317,14 +317,6 @@  static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
      dpy_update(s->vga.ds, x, y, w, h);
  }

-static inline void vmsvga_update_screen(struct vmsvga_state_s *s)
-{
-    memcpy(ds_get_data(s->vga.ds), s->vga.vram_ptr,
-           ds_get_linesize(s->vga.ds) * ds_get_height(s->vga.ds));
-    dpy_update(s->vga.ds, 0, 0,
-               ds_get_width(s->vga.ds), ds_get_height(s->vga.ds));
-}
-
  static inline void vmsvga_update_rect_delayed(struct vmsvga_state_s *s,
                  int x, int y, int w, int h)
  {
@@ -845,11 +837,10 @@  static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
          break;

      case SVGA_REG_ENABLE:
-        s->enable = value;
-        s->config &= !!value;
+        s->enable = !!value;
          s->invalidated = 1;
          s->vga.invalidate(&s->vga);
-        if (s->enable) {
+        if (s->enable && s->config) {
              vga_dirty_log_stop(&s->vga);
          } else {
              vga_dirty_log_start(&s->vga);
@@ -897,6 +888,7 @@  static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
              if (CMD(max) < CMD(min) + 10 * 1024) {
                  break;
              }
+            vga_dirty_log_stop(&s->vga);
          }
          s->config = !!value;
          break;
@@ -979,6 +971,8 @@  static inline void vmsvga_check_size(struct vmsvga_state_s *s)
  static void vmsvga_update_display(void *opaque)
  {
      struct vmsvga_state_s *s = opaque;
+    bool dirty = false;
+
      if (!s->enable) {
          s->vga.update(&s->vga);
          return;
@@ -993,9 +987,23 @@  static void vmsvga_update_display(void *opaque)
       * Is it more efficient to look at vram VGA-dirty bits or wait
       * for the driver to issue SVGA_CMD_UPDATE?
       */
-    if (s->invalidated) {
+    if (memory_region_is_logging(&s->vga.vram)) {
+        vga_sync_dirty_bitmap(&s->vga);
+        dirty = memory_region_get_dirty(&s->vga.vram, 0,
+            ds_get_linesize(s->vga.ds) * ds_get_height(s->vga.ds),
+            DIRTY_MEMORY_VGA);
+    }
+    if (s->invalidated || dirty) {
          s->invalidated = 0;
-        vmsvga_update_screen(s);
+        memcpy(ds_get_data(s->vga.ds), s->vga.vram_ptr,
+               ds_get_linesize(s->vga.ds) * ds_get_height(s->vga.ds));
+        dpy_update(s->vga.ds, 0, 0,
+                   ds_get_width(s->vga.ds), ds_get_height(s->vga.ds));
+    }
+    if (dirty) {
+        memory_region_reset_dirty(&s->vga.vram, 0,
+            ds_get_linesize(s->vga.ds) * ds_get_height(s->vga.ds),
+            DIRTY_MEMORY_VGA);
      }
  }