From patchwork Thu Dec 17 22:08:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 41350 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 61083B6EEF for ; Fri, 18 Dec 2009 09:18:09 +1100 (EST) Received: from localhost ([127.0.0.1]:45554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NLOfe-0005VK-K1 for incoming@patchwork.ozlabs.org; Thu, 17 Dec 2009 17:18:06 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NLOYZ-0001m0-Iw for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:47 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NLOYQ-0001fa-Ox for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:43 -0500 Received: from [199.232.76.173] (port=36358 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NLOYQ-0001fL-II for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53315) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NLOYQ-0003ll-3t for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:38 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBHMAb5m027777 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Dec 2009 17:10:37 -0500 Received: from localhost.localdomain (dhcp-0-222.bne.redhat.com [10.64.0.222]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBHMAUQE005737 for ; Thu, 17 Dec 2009 17:10:36 -0500 From: Dave Airlie To: qemu-devel@nongnu.org Date: Fri, 18 Dec 2009 08:08:09 +1000 Message-Id: <1261087691-8319-5-git-send-email-airlied@gmail.com> In-Reply-To: <1261087691-8319-4-git-send-email-airlied@gmail.com> References: <1261087691-8319-1-git-send-email-airlied@gmail.com> <1261087691-8319-2-git-send-email-airlied@gmail.com> <1261087691-8319-3-git-send-email-airlied@gmail.com> <1261087691-8319-4-git-send-email-airlied@gmail.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 4/6] Fix VMware VGA depth computation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Anthony Liguori VMware VGA requires that the depth presented to the guest is the same as the DisplaySurface that it renders to. This is because it performs a very simple memcpy() to blit from one surface to another. We currently hardcode a 24-bit depth. The surface allocator for SDL may, and usually will, allocate a surface with a different depth causing screen corruption. This changes the code to allocate the DisplaySurface before initializing the device which allows the depth of the DisplaySurface to be used instead of hardcoding something. Signed-off-by: Anthony Liguori --- hw/vmware_vga.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index fcb6808..ae91327 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -915,8 +915,8 @@ static void vmsvga_reset(struct vmsvga_state_s *s) s->width = -1; s->height = -1; s->svgaid = SVGA_ID; - s->depth = 24; - s->bypp = (s->depth + 7) >> 3; + s->depth = ds_get_bits_per_pixel(s->vga.ds); + s->bypp = ds_get_bytes_per_pixel(s->vga.ds); s->cursor.on = 0; s->redraw_fifo_first = 0; s->redraw_fifo_last = 0; @@ -1114,6 +1114,11 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) s->scratch_size = SVGA_SCRATCH_SIZE; s->scratch = qemu_malloc(s->scratch_size * 4); + s->vga.ds = graphic_console_init(vmsvga_update_display, + vmsvga_invalidate_display, + vmsvga_screen_dump, + vmsvga_text_update, s); + vmsvga_reset(s); s->fifo_size = SVGA_FIFO_SIZE; @@ -1124,11 +1129,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) vga_init(&s->vga); vmstate_register(0, &vmstate_vga_common, &s->vga); - s->vga.ds = graphic_console_init(vmsvga_update_display, - vmsvga_invalidate_display, - vmsvga_screen_dump, - vmsvga_text_update, s); - vga_init_vbe(&s->vga); rom_add_vga(VGABIOS_FILENAME); }