From patchwork Mon Jun 23 23:11:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 363235 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C4C1214008F for ; Tue, 24 Jun 2014 09:14:17 +1000 (EST) Received: from localhost ([::1]:56462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzDRH-0001lK-Cm for incoming@patchwork.ozlabs.org; Mon, 23 Jun 2014 19:14:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzDOv-0006xp-Px for qemu-devel@nongnu.org; Mon, 23 Jun 2014 19:11:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzDOp-0003ML-Bh for qemu-devel@nongnu.org; Mon, 23 Jun 2014 19:11:49 -0400 Received: from gate.crashing.org ([63.228.1.57]:40441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzDOp-0003Lh-1i for qemu-devel@nongnu.org; Mon, 23 Jun 2014 19:11:43 -0400 Received: from pasglop.au.ibm.com (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id s5NNBAeY030798; Mon, 23 Jun 2014 18:11:24 -0500 From: Benjamin Herrenschmidt To: qemu-devel@nongnu.org Date: Tue, 24 Jun 2014 09:11:00 +1000 Message-Id: <1403565068-15229-7-git-send-email-benh@kernel.crashing.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1403565068-15229-1-git-send-email-benh@kernel.crashing.org> References: <1403565068-15229-1-git-send-email-benh@kernel.crashing.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 63.228.1.57 Cc: Gerd Hoffmann Subject: [Qemu-devel] [RFC 06/14] vga: 15 and 16bpp draw functions are "swapping" only 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 We now only use vga_draw_line15() and vga_draw_line16() when byteswapping. Otherwise we have a shared surface. Make this explicit and remove the reliance on lduw_p which uses TARGET_WORDS_ENDIAN. We now only rely on the "byteswap" variable in vga_draw_graphic(). Signed-off-by: Benjamin Herrenschmidt --- hw/display/vga.c | 22 +++++++++++++--------- hw/display/vga_template.h | 23 ++++++++++++++++------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/hw/display/vga.c b/hw/display/vga.c index e98f7da..198e192 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1342,8 +1342,8 @@ enum { VGA_DRAW_LINE4D2, VGA_DRAW_LINE8D2, VGA_DRAW_LINE8, - VGA_DRAW_LINE15, - VGA_DRAW_LINE16, + VGA_DRAW_LINE15_SWAP, + VGA_DRAW_LINE16_SWAP, VGA_DRAW_LINE_NB, }; @@ -1354,8 +1354,8 @@ static vga_draw_line_func * const vga_draw_line_table[VGA_DRAW_LINE_NB] = { vga_draw_line4d2, vga_draw_line8d2, vga_draw_line8, - vga_draw_line15, - vga_draw_line16, + vga_draw_line15_swap, + vga_draw_line16_swap, }; static int vga_get_bpp(VGACommonState *s) @@ -1537,12 +1537,15 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) bits = 8; break; case 15: - v = VGA_DRAW_LINE15; - bits = 16; - break; case 16: - v = VGA_DRAW_LINE16; - bits = 16; + if (byteswap) { + v = depth == 15 ? VGA_DRAW_LINE15_SWAP : VGA_DRAW_LINE16_SWAP; + } else if (!is_buffer_shared(surface)) { + fprintf(stderr, + "vga: Non-shared surface at %dbpp unsupported !\n", depth); + return; + } + bits = depth; break; case 24: case 32: @@ -1552,6 +1555,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) return; } bits = depth; + break; } } if (!is_buffer_shared(surface)) { diff --git a/hw/display/vga_template.h b/hw/display/vga_template.h index e7cd9e0..7a44771 100644 --- a/hw/display/vga_template.h +++ b/hw/display/vga_template.h @@ -281,18 +281,28 @@ static void vga_draw_line8(VGACommonState *s1, uint8_t *d, /* XXX: optimize */ +/* We have lduw_he_p, lduw_be_p, lduw_le_p but we don't have + * lduw_sw_p, as in unconditionally swap :) So let's make it + * up here + */ +#if defined(HOST_WORDS_BIGENDIAN) +#define ld_sw_pixel16 lduw_le_p +#else +#define ld_sw_pixel16 lduw_be_p +#endif + /* * 15 bit color */ -static void vga_draw_line15(VGACommonState *s1, uint8_t *d, - const uint8_t *s, int width) +static void vga_draw_line15_swap(VGACommonState *s1, uint8_t *d, + const uint8_t *s, int width) { int w; uint32_t v, r, g, b; w = width; do { - v = lduw_p((void *)s); + v = ld_sw_pixel16((void *)s); r = (v >> 7) & 0xf8; g = (v >> 2) & 0xf8; b = (v << 3) & 0xf8; @@ -305,15 +315,15 @@ static void vga_draw_line15(VGACommonState *s1, uint8_t *d, /* * 16 bit color */ -static void vga_draw_line16(VGACommonState *s1, uint8_t *d, - const uint8_t *s, int width) +static void vga_draw_line16_swap(VGACommonState *s1, uint8_t *d, + const uint8_t *s, int width) { int w; uint32_t v, r, g, b; w = width; do { - v = lduw_p((void *)s); + v = ld_sw_pixel16((void *)s); r = (v >> 8) & 0xf8; g = (v >> 3) & 0xfc; b = (v << 3) & 0xf8; @@ -322,4 +332,3 @@ static void vga_draw_line16(VGACommonState *s1, uint8_t *d, d += 4; } while (--w != 0); } -