From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 10/14] pl100: Drop support for depths other than 32bpp.
Date: Tue, 2 Sep 2014 10:00:23 +0200 [thread overview]
Message-ID: <1409644827-26317-11-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1409644827-26317-1-git-send-email-kraxel@redhat.com>
DisplaySurfaces created by qemu_create_displaysurface (called indirectly
via by qemu_console_resize) are always 32bpp in host byte order. So
this is the only format we have to support when converting the guest
framebuffer for the host user interface (i.e. gtk / vnc / ...).
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/display/pl110.c | 59 +++-----------------
hw/display/pl110_template.h | 133 ++++++++++++++++++++------------------------
2 files changed, 67 insertions(+), 125 deletions(-)
diff --git a/hw/display/pl110.c b/hw/display/pl110.c
index c574cf1..78b146b 100644
--- a/hw/display/pl110.c
+++ b/hw/display/pl110.c
@@ -112,15 +112,6 @@ static const unsigned char *idregs[] = {
pl111_id
};
-#define BITS 8
-#include "pl110_template.h"
-#define BITS 15
-#include "pl110_template.h"
-#define BITS 16
-#include "pl110_template.h"
-#define BITS 24
-#include "pl110_template.h"
-#define BITS 32
#include "pl110_template.h"
static int pl110_enabled(PL110State *s)
@@ -133,7 +124,6 @@ static void pl110_update_display(void *opaque)
PL110State *s = (PL110State *)opaque;
SysBusDevice *sbd;
DisplaySurface *surface = qemu_console_surface(s->con);
- drawfn* fntable;
drawfn fn;
int dest_width;
int src_width;
@@ -147,33 +137,6 @@ static void pl110_update_display(void *opaque)
sbd = SYS_BUS_DEVICE(s);
- switch (surface_bits_per_pixel(surface)) {
- case 0:
- return;
- case 8:
- fntable = pl110_draw_fn_8;
- dest_width = 1;
- break;
- case 15:
- fntable = pl110_draw_fn_15;
- dest_width = 2;
- break;
- case 16:
- fntable = pl110_draw_fn_16;
- dest_width = 2;
- break;
- case 24:
- fntable = pl110_draw_fn_24;
- dest_width = 3;
- break;
- case 32:
- fntable = pl110_draw_fn_32;
- dest_width = 4;
- break;
- default:
- fprintf(stderr, "pl110: Bad color depth\n");
- exit(1);
- }
if (s->cr & PL110_CR_BGR)
bpp_offset = 0;
else
@@ -208,11 +171,11 @@ static void pl110_update_display(void *opaque)
}
if (s->cr & PL110_CR_BEBO)
- fn = fntable[s->bpp + 8 + bpp_offset];
+ fn = pl110_draw_fn[s->bpp + 8 + bpp_offset];
else if (s->cr & PL110_CR_BEPO)
- fn = fntable[s->bpp + 16 + bpp_offset];
+ fn = pl110_draw_fn[s->bpp + 16 + bpp_offset];
else
- fn = fntable[s->bpp + bpp_offset];
+ fn = pl110_draw_fn[s->bpp + bpp_offset];
src_width = s->cols;
switch (s->bpp) {
@@ -236,7 +199,9 @@ static void pl110_update_display(void *opaque)
src_width <<= 2;
break;
}
- dest_width *= s->cols;
+
+ g_assert(surface_bits_per_pixel(surface) == 32);
+ dest_width = 4 * s->cols;
first = 0;
framebuffer_update_display(surface, sysbus_address_space(sbd),
s->upbase, s->cols, s->rows,
@@ -277,19 +242,11 @@ static void pl110_update_palette(PL110State *s, int n)
/* The I bit is ignored. */
raw >>= 6;
switch (surface_bits_per_pixel(surface)) {
- case 8:
- s->palette[n] = rgb_to_pixel8(r, g, b);
- break;
- case 15:
- s->palette[n] = rgb_to_pixel15(r, g, b);
- break;
- case 16:
- s->palette[n] = rgb_to_pixel16(r, g, b);
- break;
- case 24:
case 32:
s->palette[n] = rgb_to_pixel32(r, g, b);
break;
+ default:
+ g_assert_not_reached();
}
n++;
}
diff --git a/hw/display/pl110_template.h b/hw/display/pl110_template.h
index 36ba791..5afc64c 100644
--- a/hw/display/pl110_template.h
+++ b/hw/display/pl110_template.h
@@ -11,22 +11,7 @@
#ifndef ORDER
-#if BITS == 8
-#define COPY_PIXEL(to, from) *(to++) = from
-#elif BITS == 15 || BITS == 16
-#define COPY_PIXEL(to, from) do { *(uint16_t *)to = from; to += 2; } while (0)
-#elif BITS == 24
-#define COPY_PIXEL(to, from) \
- do { \
- *(to++) = from; \
- *(to++) = (from) >> 8; \
- *(to++) = (from) >> 16; \
- } while (0)
-#elif BITS == 32
#define COPY_PIXEL(to, from) do { *(uint32_t *)to = from; to += 4; } while (0)
-#else
-#error unknown bit depth
-#endif
#undef RGB
#define BORDER bgr
@@ -47,61 +32,61 @@
#include "pl110_template.h"
#undef BORDER
-static drawfn glue(pl110_draw_fn_,BITS)[48] =
+static drawfn pl110_draw_fn[48] =
{
- glue(pl110_draw_line1_lblp_bgr,BITS),
- glue(pl110_draw_line2_lblp_bgr,BITS),
- glue(pl110_draw_line4_lblp_bgr,BITS),
- glue(pl110_draw_line8_lblp_bgr,BITS),
- glue(pl110_draw_line16_555_lblp_bgr,BITS),
- glue(pl110_draw_line32_lblp_bgr,BITS),
- glue(pl110_draw_line16_lblp_bgr,BITS),
- glue(pl110_draw_line12_lblp_bgr,BITS),
+ pl110_draw_line1_lblp_bgr,
+ pl110_draw_line2_lblp_bgr,
+ pl110_draw_line4_lblp_bgr,
+ pl110_draw_line8_lblp_bgr,
+ pl110_draw_line16_555_lblp_bgr,
+ pl110_draw_line32_lblp_bgr,
+ pl110_draw_line16_lblp_bgr,
+ pl110_draw_line12_lblp_bgr,
- glue(pl110_draw_line1_bbbp_bgr,BITS),
- glue(pl110_draw_line2_bbbp_bgr,BITS),
- glue(pl110_draw_line4_bbbp_bgr,BITS),
- glue(pl110_draw_line8_bbbp_bgr,BITS),
- glue(pl110_draw_line16_555_bbbp_bgr,BITS),
- glue(pl110_draw_line32_bbbp_bgr,BITS),
- glue(pl110_draw_line16_bbbp_bgr,BITS),
- glue(pl110_draw_line12_bbbp_bgr,BITS),
+ pl110_draw_line1_bbbp_bgr,
+ pl110_draw_line2_bbbp_bgr,
+ pl110_draw_line4_bbbp_bgr,
+ pl110_draw_line8_bbbp_bgr,
+ pl110_draw_line16_555_bbbp_bgr,
+ pl110_draw_line32_bbbp_bgr,
+ pl110_draw_line16_bbbp_bgr,
+ pl110_draw_line12_bbbp_bgr,
- glue(pl110_draw_line1_lbbp_bgr,BITS),
- glue(pl110_draw_line2_lbbp_bgr,BITS),
- glue(pl110_draw_line4_lbbp_bgr,BITS),
- glue(pl110_draw_line8_lbbp_bgr,BITS),
- glue(pl110_draw_line16_555_lbbp_bgr,BITS),
- glue(pl110_draw_line32_lbbp_bgr,BITS),
- glue(pl110_draw_line16_lbbp_bgr,BITS),
- glue(pl110_draw_line12_lbbp_bgr,BITS),
+ pl110_draw_line1_lbbp_bgr,
+ pl110_draw_line2_lbbp_bgr,
+ pl110_draw_line4_lbbp_bgr,
+ pl110_draw_line8_lbbp_bgr,
+ pl110_draw_line16_555_lbbp_bgr,
+ pl110_draw_line32_lbbp_bgr,
+ pl110_draw_line16_lbbp_bgr,
+ pl110_draw_line12_lbbp_bgr,
- glue(pl110_draw_line1_lblp_rgb,BITS),
- glue(pl110_draw_line2_lblp_rgb,BITS),
- glue(pl110_draw_line4_lblp_rgb,BITS),
- glue(pl110_draw_line8_lblp_rgb,BITS),
- glue(pl110_draw_line16_555_lblp_rgb,BITS),
- glue(pl110_draw_line32_lblp_rgb,BITS),
- glue(pl110_draw_line16_lblp_rgb,BITS),
- glue(pl110_draw_line12_lblp_rgb,BITS),
+ pl110_draw_line1_lblp_rgb,
+ pl110_draw_line2_lblp_rgb,
+ pl110_draw_line4_lblp_rgb,
+ pl110_draw_line8_lblp_rgb,
+ pl110_draw_line16_555_lblp_rgb,
+ pl110_draw_line32_lblp_rgb,
+ pl110_draw_line16_lblp_rgb,
+ pl110_draw_line12_lblp_rgb,
- glue(pl110_draw_line1_bbbp_rgb,BITS),
- glue(pl110_draw_line2_bbbp_rgb,BITS),
- glue(pl110_draw_line4_bbbp_rgb,BITS),
- glue(pl110_draw_line8_bbbp_rgb,BITS),
- glue(pl110_draw_line16_555_bbbp_rgb,BITS),
- glue(pl110_draw_line32_bbbp_rgb,BITS),
- glue(pl110_draw_line16_bbbp_rgb,BITS),
- glue(pl110_draw_line12_bbbp_rgb,BITS),
+ pl110_draw_line1_bbbp_rgb,
+ pl110_draw_line2_bbbp_rgb,
+ pl110_draw_line4_bbbp_rgb,
+ pl110_draw_line8_bbbp_rgb,
+ pl110_draw_line16_555_bbbp_rgb,
+ pl110_draw_line32_bbbp_rgb,
+ pl110_draw_line16_bbbp_rgb,
+ pl110_draw_line12_bbbp_rgb,
- glue(pl110_draw_line1_lbbp_rgb,BITS),
- glue(pl110_draw_line2_lbbp_rgb,BITS),
- glue(pl110_draw_line4_lbbp_rgb,BITS),
- glue(pl110_draw_line8_lbbp_rgb,BITS),
- glue(pl110_draw_line16_555_lbbp_rgb,BITS),
- glue(pl110_draw_line32_lbbp_rgb,BITS),
- glue(pl110_draw_line16_lbbp_rgb,BITS),
- glue(pl110_draw_line12_lbbp_rgb,BITS),
+ pl110_draw_line1_lbbp_rgb,
+ pl110_draw_line2_lbbp_rgb,
+ pl110_draw_line4_lbbp_rgb,
+ pl110_draw_line8_lbbp_rgb,
+ pl110_draw_line16_555_lbbp_rgb,
+ pl110_draw_line32_lbbp_rgb,
+ pl110_draw_line16_lbbp_rgb,
+ pl110_draw_line12_lbbp_rgb,
};
#undef BITS
@@ -110,18 +95,18 @@ static drawfn glue(pl110_draw_fn_,BITS)[48] =
#else
#if ORDER == 0
-#define NAME glue(glue(lblp_, BORDER), BITS)
+#define NAME glue(lblp_, BORDER)
#ifdef HOST_WORDS_BIGENDIAN
#define SWAP_WORDS 1
#endif
#elif ORDER == 1
-#define NAME glue(glue(bbbp_, BORDER), BITS)
+#define NAME glue(bbbp_, BORDER)
#ifndef HOST_WORDS_BIGENDIAN
#define SWAP_WORDS 1
#endif
#else
#define SWAP_PIXELS 1
-#define NAME glue(glue(lbbp_, BORDER), BITS)
+#define NAME glue(lbbp_, BORDER)
#ifdef HOST_WORDS_BIGENDIAN
#define SWAP_WORDS 1
#endif
@@ -270,14 +255,14 @@ static void glue(pl110_draw_line16_,NAME)(void *opaque, uint8_t *d, const uint8_
MSB = (data & 0x1f) << 3;
data >>= 5;
#endif
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
LSB = (data & 0x1f) << 3;
data >>= 5;
g = (data & 0x3f) << 2;
data >>= 6;
MSB = (data & 0x1f) << 3;
data >>= 5;
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
#undef MSB
#undef LSB
width -= 2;
@@ -307,7 +292,7 @@ static void glue(pl110_draw_line32_,NAME)(void *opaque, uint8_t *d, const uint8_
g = (data >> 16) & 0xff;
MSB = (data >> 8) & 0xff;
#endif
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
#undef MSB
#undef LSB
width--;
@@ -338,14 +323,14 @@ static void glue(pl110_draw_line16_555_,NAME)(void *opaque, uint8_t *d, const ui
data >>= 5;
MSB = (data & 0x1f) << 3;
data >>= 5;
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
LSB = (data & 0x1f) << 3;
data >>= 5;
g = (data & 0x1f) << 3;
data >>= 5;
MSB = (data & 0x1f) << 3;
data >>= 6;
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
#undef MSB
#undef LSB
width -= 2;
@@ -376,14 +361,14 @@ static void glue(pl110_draw_line12_,NAME)(void *opaque, uint8_t *d, const uint8_
data >>= 4;
MSB = (data & 0xf) << 4;
data >>= 8;
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
LSB = (data & 0xf) << 4;
data >>= 4;
g = (data & 0xf) << 4;
data >>= 4;
MSB = (data & 0xf) << 4;
data >>= 8;
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
#undef MSB
#undef LSB
width -= 2;
--
1.8.3.1
next prev parent reply other threads:[~2014-09-02 8:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 8:00 [Qemu-devel] [PATCH 00/14] console/pl110: pixman conversion continued Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 01/14] console: add qemu_pixelformat_from_pixman Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 02/14] console: add qemu_default_pixman_format Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 03/14] console: reimplement qemu_default_pixelformat Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 04/14] console: stop using PixelFormat Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 05/14] console: add qemu_create_displaysurface_guestmem Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 06/14] console: add dpy_gfx_update_dirty Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 07/14] console: add qemu_pixman_linebuf_copy Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 08/14] console: Remove unused QEMU_BIG_ENDIAN_FLAG Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 09/14] pl110: add framebuffer_update_display_swap_pixman Gerd Hoffmann
2014-09-02 8:00 ` Gerd Hoffmann [this message]
2014-09-02 8:00 ` [Qemu-devel] [PATCH 11/14] pl110: move resize Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 12/14] [wip] pl110: start using pixman Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 13/14] [wip] pl110: switch some conversions to swap+pixman mode Gerd Hoffmann
2014-09-02 8:00 ` [Qemu-devel] [PATCH 14/14] [wip] pl110: start handling paletted images via pixman 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=1409644827-26317-11-git-send-email-kraxel@redhat.com \
--to=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).