qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex DAMIAN <alexandru.damian@intel.com>
To: qemu-devel@nongnu.org, blauwirbel@gmail.com, balaton@eik.bme.hu,
	pbonzini@redhat.com, kraxel@redhat.com
Cc: Alexandru DAMIAN <alexandru.damian@intel.com>
Subject: [Qemu-devel] [PATCH] vmware_vga: do not cache depth and bypp
Date: Fri, 29 Mar 2013 18:28:42 +0200	[thread overview]
Message-ID: <1364574522-4093-1-git-send-email-alexandru.damian@intel.com> (raw)

From: Alexandru DAMIAN <alexandru.damian@intel.com>

Do not cache depth and bypp information in the device state.

This resolves a bug where Xorg video-vmare driver refuses
to start up because the depth value read is the one cached from the
device start (default 32 from ui/console.c) and it is not consistent
with the graphical console depth, which may be different from
the default depth.

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 hw/vmware_vga.c |   20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 5b9ce8f..75ef404 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -39,8 +39,6 @@ struct vmsvga_state_s {
     VGACommonState vga;
 
     int invalidated;
-    int depth;
-    int bypp;
     int enable;
     int config;
     struct {
@@ -742,10 +740,10 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
         return SVGA_MAX_HEIGHT;
 
     case SVGA_REG_DEPTH:
-        return s->depth;
+        return surface_bits_per_pixel(surface);
 
     case SVGA_REG_BITS_PER_PIXEL:
-        return (s->depth + 7) & ~7;
+        return (surface_bits_per_pixel(surface) + 7) & ~7;
 
     case SVGA_REG_PSEUDOCOLOR:
         return 0x0;
@@ -760,7 +758,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
         return surface->pf.bmask;
 
     case SVGA_REG_BYTES_PER_LINE:
-        return s->bypp * s->new_width;
+        return surface_bytes_per_pixel(surface) * s->new_width;
 
     case SVGA_REG_FB_START: {
         struct pci_vmsvga_state_s *pci_vmsvga
@@ -825,7 +823,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
         return s->cursor.on;
 
     case SVGA_REG_HOST_BITS_PER_PIXEL:
-        return (s->depth + 7) & ~7;
+        return (surface_bits_per_pixel(surface) + 7) & ~7;
 
     case SVGA_REG_SCRATCH_SIZE:
         return s->scratch_size;
@@ -888,7 +886,7 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
         break;
 
     case SVGA_REG_BITS_PER_PIXEL:
-        if (value != s->depth) {
+        if (value != surface_bits_per_pixel(qemu_console_surface(s->vga.con))) {
             printf("%s: Bad bits per pixel: %i bits\n", __func__, value);
             s->config = 0;
         }
@@ -1113,7 +1111,6 @@ static const VMStateDescription vmstate_vmware_vga_internal = {
     .minimum_version_id_old = 0,
     .post_load = vmsvga_post_load,
     .fields      = (VMStateField[]) {
-        VMSTATE_INT32_EQUAL(depth, struct vmsvga_state_s),
         VMSTATE_INT32(enable, struct vmsvga_state_s),
         VMSTATE_INT32(config, struct vmsvga_state_s),
         VMSTATE_INT32(cursor.id, struct vmsvga_state_s),
@@ -1149,8 +1146,6 @@ static const VMStateDescription vmstate_vmware_vga = {
 static void vmsvga_init(struct vmsvga_state_s *s,
                         MemoryRegion *address_space, MemoryRegion *io)
 {
-    DisplaySurface *surface;
-
     s->scratch_size = SVGA_SCRATCH_SIZE;
     s->scratch = g_malloc(s->scratch_size * 4);
 
@@ -1158,7 +1153,6 @@ static void vmsvga_init(struct vmsvga_state_s *s,
                                       vmsvga_invalidate_display,
                                       vmsvga_screen_dump,
                                       vmsvga_text_update, s);
-    surface = qemu_console_surface(s->vga.con);
 
     s->fifo_size = SVGA_FIFO_SIZE;
     memory_region_init_ram(&s->fifo_ram, "vmsvga.fifo", s->fifo_size);
@@ -1168,10 +1162,6 @@ static void vmsvga_init(struct vmsvga_state_s *s,
     vga_common_init(&s->vga);
     vga_init(&s->vga, address_space, io, true);
     vmstate_register(NULL, 0, &vmstate_vga_common, &s->vga);
-    /* Save some values here in case they are changed later.
-     * This is suspicious and needs more though why it is needed. */
-    s->depth = surface_bits_per_pixel(surface);
-    s->bypp = surface_bytes_per_pixel(surface);
 }
 
 static uint64_t vmsvga_io_read(void *opaque, hwaddr addr, unsigned size)
-- 
1.7.10.4

             reply	other threads:[~2013-03-29 16:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-29 16:28 Alex DAMIAN [this message]
2013-04-03  9:49 ` [Qemu-devel] [PATCH] vmware_vga: do not cache depth and bypp Gerd Hoffmann
2013-04-03 10:13   ` Damian, Alexandru
2013-04-03 10:48     ` Damian, Alexandru
2013-04-03 11:59     ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364574522-4093-1-git-send-email-alexandru.damian@intel.com \
    --to=alexandru.damian@intel.com \
    --cc=balaton@eik.bme.hu \
    --cc=blauwirbel@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).