From patchwork Sat Oct 6 18:35:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: BALATON Zoltan X-Patchwork-Id: 189752 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7D8E32C0131 for ; Sun, 7 Oct 2012 05:35:15 +1100 (EST) Received: from localhost ([::1]:38985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKZDV-0000Su-K6 for incoming@patchwork.ozlabs.org; Sat, 06 Oct 2012 14:35:13 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKZDM-0000RF-WD for qemu-devel@nongnu.org; Sat, 06 Oct 2012 14:35:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TKZDL-0006JK-EV for qemu-devel@nongnu.org; Sat, 06 Oct 2012 14:35:04 -0400 Received: from mono.eik.bme.hu ([152.66.115.2]:39132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TKZDL-0006I7-23 for qemu-devel@nongnu.org; Sat, 06 Oct 2012 14:35:03 -0400 Received: from localhost (localhost [127.0.0.1]) by mono.eik.bme.hu (Postfix) with ESMTP id 7A20C19B for ; Sat, 6 Oct 2012 20:35:02 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Received: from mono.eik.bme.hu ([127.0.0.1]) by localhost (mono.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id EKLrkQOY6A-F for ; Sat, 6 Oct 2012 20:35:02 +0200 (CEST) Received: by mono.eik.bme.hu (Postfix, from userid 432) id 4213749F; Sat, 6 Oct 2012 20:35:02 +0200 (CEST) Date: Sat, 6 Oct 2012 20:35:02 +0200 (CEST) From: BALATON Zoltan X-X-Sender: balaton@mono To: qemu-devel@nongnu.org In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (GSO 1167 2008-08-23) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [PATCH 3/4 v3] vmware_vga: Return a value for FB_SIZE before the device is enabled X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org According to the documentation drivers using this device should read FB_SIZE before enabling the device to know what memory to map. This would not work if we return 0 before enabled. The docs also mention reading SVGA_REG_DEPTH but not writing it. (Only SVGA_REG_BITS_PER_PIXEL can be written but we don't really support that either.) Signed-off-by: BALATON Zoltan --- hw/vmware_vga.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) v3: Changes to address comments from Paolo Bonzini (Thanks for the review!) diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index c5a8909..c3ef924 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -32,13 +32,14 @@ #define HW_FILL_ACCEL #define HW_MOUSE_ACCEL -# include "vga_int.h" +#include "vga_int.h" + +/* See http://vmware-svga.sf.net/ for some documentation on VMWare SVGA */ struct vmsvga_state_s { VGACommonState vga; int invalidated; - int depth; int enable; int config; struct { @@ -56,7 +57,6 @@ struct vmsvga_state_s { uint32_t guest; uint32_t svgaid; int syncing; - int fb_size; MemoryRegion fifo_ram; uint8_t *fifo_ptr; @@ -759,10 +759,10 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) return 0x0; case SVGA_REG_VRAM_SIZE: - return s->vga.vram_size; + return s->vga.vram_size; /* No physical VRAM besides the framebuffer */ case SVGA_REG_FB_SIZE: - return s->fb_size; + return s->vga.vram_size; case SVGA_REG_CAPABILITIES: caps = SVGA_CAP_NONE; @@ -851,7 +851,6 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) s->invalidated = 1; s->vga.invalidate(&s->vga); if (s->enable) { - s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height; vga_dirty_log_stop(&s->vga); } else { vga_dirty_log_start(&s->vga); @@ -876,10 +875,9 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) } break; - case SVGA_REG_DEPTH: case SVGA_REG_BITS_PER_PIXEL: if (value != ds_get_bits_per_pixel(s->vga.ds)) { - printf("%s: Bad colour depth: %i bits\n", __func__, value); + printf("%s: Bad bits per pixel: %i bits\n", __func__, value); s->config = 0; } break; @@ -942,6 +940,7 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) #endif break; + case SVGA_REG_DEPTH: case SVGA_REG_MEM_REGS: case SVGA_REG_NUM_DISPLAYS: case SVGA_REG_PITCHLOCK: @@ -1080,7 +1079,7 @@ 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_UNUSED(4), /* was depth */ VMSTATE_INT32(enable, struct vmsvga_state_s), VMSTATE_INT32(config, struct vmsvga_state_s), VMSTATE_INT32(cursor.id, struct vmsvga_state_s), @@ -1095,7 +1094,7 @@ static const VMStateDescription vmstate_vmware_vga_internal = { VMSTATE_UINT32(guest, struct vmsvga_state_s), VMSTATE_UINT32(svgaid, struct vmsvga_state_s), VMSTATE_INT32(syncing, struct vmsvga_state_s), - VMSTATE_INT32(fb_size, struct vmsvga_state_s), + VMSTATE_UNUSED(4), /* was fb_size */ VMSTATE_END_OF_LIST() } };