From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [RFC 06/14] vga: 15 and 16bpp draw functions are "swapping" only
Date: Tue, 24 Jun 2014 09:11:00 +1000 [thread overview]
Message-ID: <1403565068-15229-7-git-send-email-benh@kernel.crashing.org> (raw)
In-Reply-To: <1403565068-15229-1-git-send-email-benh@kernel.crashing.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 <benh@kernel.crashing.org>
---
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);
}
-
--
1.9.1
next prev parent reply other threads:[~2014-06-23 23:11 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-23 23:10 [Qemu-devel] [RFC 00/14] VGA cleanups and endian control Benjamin Herrenschmidt
2014-06-23 23:10 ` [Qemu-devel] [RFC 01/14] vga: Create direct sufaces for depth 24 too Benjamin Herrenschmidt
2014-07-01 7:09 ` Gerd Hoffmann
2014-07-01 9:31 ` Benjamin Herrenschmidt
2014-06-23 23:10 ` [Qemu-devel] [RFC 02/14] ui: Remove unused QEMU_BIG_ENDIAN_FLAG Benjamin Herrenschmidt
2014-06-23 23:10 ` [Qemu-devel] [RFC 03/14] vga: Start cutting out non-32bpp conversion support Benjamin Herrenschmidt
2014-06-23 23:10 ` [Qemu-devel] [RFC 04/14] vga: Remove remainder of old conversion cruft Benjamin Herrenschmidt
2014-06-23 23:10 ` [Qemu-devel] [RFC 05/14] vga: Remove unused vga_draw_line24() and vga_draw_line32() Benjamin Herrenschmidt
2014-06-23 23:11 ` Benjamin Herrenschmidt [this message]
2014-06-23 23:11 ` [Qemu-devel] [RFC 07/14] vga: Remove rgb_to_pixel indirection Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 08/14] vga: Simplify vga_draw_blank() a bit Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 09/14] cirrus: Remove non-32bpp cursor drawing Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 10/14] vga: Remove some "should be done in BIOS" comments Benjamin Herrenschmidt
2014-06-30 11:31 ` Gerd Hoffmann
2014-06-23 23:11 ` [Qemu-devel] [RFC 11/14] vga: Make fb endian a common state variable Benjamin Herrenschmidt
2014-06-23 23:24 ` Peter Maydell
2014-06-23 23:44 ` Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 12/14] vga: Rename vga_template.h to vga-helpers.h Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 13/14] vga: Add endian control register Benjamin Herrenschmidt
2014-06-23 23:48 ` Benjamin Herrenschmidt
2014-06-30 11:38 ` Gerd Hoffmann
2014-06-30 12:34 ` Benjamin Herrenschmidt
2014-06-23 23:11 ` [Qemu-devel] [RFC 14/14] ppc/spapr/vga: Switch VGA endian on H_SET_MODE Benjamin Herrenschmidt
2014-06-30 11:49 ` Gerd Hoffmann
2014-06-30 12:34 ` Benjamin Herrenschmidt
2014-06-30 11:50 ` [Qemu-devel] [RFC 00/14] VGA cleanups and endian control Gerd Hoffmann
2014-06-30 12:36 ` Benjamin Herrenschmidt
2014-06-30 13:03 ` Gerd Hoffmann
2014-06-30 13:36 ` Benjamin Herrenschmidt
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=1403565068-15229-7-git-send-email-benh@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=kraxel@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).