From: "Blue Swirl" <blauwirbel@gmail.com>
To: "Andreas Färber" <andreas.faerber@web.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Sparc32 network problems
Date: Sat, 9 Jun 2007 11:05:21 +0300 [thread overview]
Message-ID: <f43fc5580706090105r7cae2eebtd88de21cce1ba430@mail.gmail.com> (raw)
In-Reply-To: <f43fc5580706090005o633a454bo7360dd35da792ff7@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 612 bytes --]
On 6/9/07, Blue Swirl <blauwirbel@gmail.com> wrote:
> On 6/8/07, Andreas Färber <andreas.faerber@web.de> wrote:
> > It is not okay. It works on ppc but on Intel applied to 0.9.0 s->ds-
> > >bgr does not evaluate to true so OpenBIOS and Tux are blue again...
> > (tested i386 and sparc guests; my console output indicates
> > rgb_to_pixel32 is called for tcx)
>
> Maybe the bgr detection logic in sdl.c is flawed. Is this patch any better?
Except that on OSX the correct place to fix this would be in cocoa.m, right?
Is there some better way to detect BGR than using the host endianness
like in this version?
[-- Attachment #2: big_endian_display4.diff --]
[-- Type: text/x-diff, Size: 10726 bytes --]
Index: qemu/hw/pixel_ops.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ qemu/hw/pixel_ops.h 2007-06-08 17:09:59.000000000 +0000
@@ -0,0 +1,41 @@
+static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g,
+ unsigned int b)
+{
+ return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6);
+}
+
+static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g,
+ unsigned int b)
+{
+ return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
+}
+
+static inline unsigned int rgb_to_pixel15bgr(unsigned int r, unsigned int g,
+ unsigned int b)
+{
+ return ((b >> 3) << 10) | ((g >> 3) << 5) | (r >> 3);
+}
+
+static inline unsigned int rgb_to_pixel16(unsigned int r, unsigned int g,
+ unsigned int b)
+{
+ return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
+}
+
+static inline unsigned int rgb_to_pixel16bgr(unsigned int r, unsigned int g,
+ unsigned int b)
+{
+ return ((b >> 3) << 11) | ((g >> 2) << 5) | (r >> 3);
+}
+
+static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g,
+ unsigned int b)
+{
+ return (r << 16) | (g << 8) | b;
+}
+
+static inline unsigned int rgb_to_pixel32bgr(unsigned int r, unsigned int g,
+ unsigned int b)
+{
+ return (b << 16) | (g << 8) | r;
+}
Index: qemu/hw/tcx.c
===================================================================
--- qemu.orig/hw/tcx.c 2007-06-08 16:40:44.000000000 +0000
+++ qemu/hw/tcx.c 2007-06-08 17:09:59.000000000 +0000
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "vl.h"
+#include "pixel_ops.h"
#define MAXX 1024
#define MAXY 768
@@ -47,27 +48,6 @@
static void tcx_invalidate_display(void *opaque);
static void tcx24_invalidate_display(void *opaque);
-/* XXX: unify with vga draw line functions */
-static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b)
-{
- return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6);
-}
-
-static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, unsigned b)
-{
- return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
-}
-
-static inline unsigned int rgb_to_pixel16(unsigned int r, unsigned int g, unsigned b)
-{
- return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
-}
-
-static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsigned b)
-{
- return (r << 16) | (g << 8) | b;
-}
-
static void update_palette_entries(TCXState *s, int start, int end)
{
int i;
@@ -78,13 +58,22 @@
s->palette[i] = rgb_to_pixel8(s->r[i], s->g[i], s->b[i]);
break;
case 15:
- s->palette[i] = rgb_to_pixel15(s->r[i], s->g[i], s->b[i]);
+ if (s->ds->bgr)
+ s->palette[i] = rgb_to_pixel15bgr(s->r[i], s->g[i], s->b[i]);
+ else
+ s->palette[i] = rgb_to_pixel15(s->r[i], s->g[i], s->b[i]);
break;
case 16:
- s->palette[i] = rgb_to_pixel16(s->r[i], s->g[i], s->b[i]);
+ if (s->ds->bgr)
+ s->palette[i] = rgb_to_pixel16bgr(s->r[i], s->g[i], s->b[i]);
+ else
+ s->palette[i] = rgb_to_pixel16(s->r[i], s->g[i], s->b[i]);
break;
case 32:
- s->palette[i] = rgb_to_pixel32(s->r[i], s->g[i], s->b[i]);
+ if (s->ds->bgr)
+ s->palette[i] = rgb_to_pixel32bgr(s->r[i], s->g[i], s->b[i]);
+ else
+ s->palette[i] = rgb_to_pixel32(s->r[i], s->g[i], s->b[i]);
break;
}
}
Index: qemu/hw/vga.c
===================================================================
--- qemu.orig/hw/vga.c 2007-06-08 16:40:44.000000000 +0000
+++ qemu/hw/vga.c 2007-06-08 18:56:32.000000000 +0000
@@ -23,6 +23,7 @@
*/
#include "vl.h"
#include "vga_int.h"
+#include "pixel_ops.h"
//#define DEBUG_VGA
//#define DEBUG_VGA_MEM
@@ -812,37 +813,20 @@
typedef void vga_draw_line_func(VGAState *s1, uint8_t *d,
const uint8_t *s, int width);
-static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b)
-{
- return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6);
-}
-
-static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, unsigned b)
-{
- return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
-}
-
-static inline unsigned int rgb_to_pixel16(unsigned int r, unsigned int g, unsigned b)
-{
- return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
-}
-
-static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsigned b)
-{
- return (r << 16) | (g << 8) | b;
-}
-
-static inline unsigned int rgb_to_pixel32bgr(unsigned int r, unsigned int g, unsigned b)
-{
- return (b << 16) | (g << 8) | r;
-}
-
#define DEPTH 8
#include "vga_template.h"
#define DEPTH 15
#include "vga_template.h"
+#define BGR_FORMAT
+#define DEPTH 15
+#include "vga_template.h"
+
+#define DEPTH 16
+#include "vga_template.h"
+
+#define BGR_FORMAT
#define DEPTH 16
#include "vga_template.h"
@@ -870,6 +854,15 @@
return col;
}
+static unsigned int rgb_to_pixel15bgr_dup(unsigned int r, unsigned int g,
+ unsigned int b)
+{
+ unsigned int col;
+ col = rgb_to_pixel15bgr(r, g, b);
+ col |= col << 16;
+ return col;
+}
+
static unsigned int rgb_to_pixel16_dup(unsigned int r, unsigned int g, unsigned b)
{
unsigned int col;
@@ -878,6 +871,15 @@
return col;
}
+static unsigned int rgb_to_pixel16bgr_dup(unsigned int r, unsigned int g,
+ unsigned int b)
+{
+ unsigned int col;
+ col = rgb_to_pixel16bgr(r, g, b);
+ col |= col << 16;
+ return col;
+}
+
static unsigned int rgb_to_pixel32_dup(unsigned int r, unsigned int g, unsigned b)
{
unsigned int col;
@@ -998,7 +1000,7 @@
return full_update;
}
-#define NB_DEPTHS 5
+#define NB_DEPTHS 7
static inline int get_depth_index(DisplayState *s)
{
@@ -1007,9 +1009,15 @@
case 8:
return 0;
case 15:
- return 1;
+ if (s->bgr)
+ return 5;
+ else
+ return 1;
case 16:
- return 2;
+ if (s->bgr)
+ return 6;
+ else
+ return 2;
case 32:
if (s->bgr)
return 4;
@@ -1024,6 +1032,8 @@
vga_draw_glyph8_16,
vga_draw_glyph8_32,
vga_draw_glyph8_32,
+ vga_draw_glyph8_16,
+ vga_draw_glyph8_16,
};
static vga_draw_glyph8_func *vga_draw_glyph16_table[NB_DEPTHS] = {
@@ -1032,6 +1042,8 @@
vga_draw_glyph16_16,
vga_draw_glyph16_32,
vga_draw_glyph16_32,
+ vga_draw_glyph16_16,
+ vga_draw_glyph16_16,
};
static vga_draw_glyph9_func *vga_draw_glyph9_table[NB_DEPTHS] = {
@@ -1040,6 +1052,8 @@
vga_draw_glyph9_16,
vga_draw_glyph9_32,
vga_draw_glyph9_32,
+ vga_draw_glyph9_16,
+ vga_draw_glyph9_16,
};
static const uint8_t cursor_glyph[32 * 4] = {
@@ -1260,60 +1274,80 @@
vga_draw_line2_16,
vga_draw_line2_32,
vga_draw_line2_32,
+ vga_draw_line2_16,
+ vga_draw_line2_16,
vga_draw_line2d2_8,
vga_draw_line2d2_16,
vga_draw_line2d2_16,
vga_draw_line2d2_32,
vga_draw_line2d2_32,
+ vga_draw_line2d2_16,
+ vga_draw_line2d2_16,
vga_draw_line4_8,
vga_draw_line4_16,
vga_draw_line4_16,
vga_draw_line4_32,
vga_draw_line4_32,
+ vga_draw_line4_16,
+ vga_draw_line4_16,
vga_draw_line4d2_8,
vga_draw_line4d2_16,
vga_draw_line4d2_16,
vga_draw_line4d2_32,
vga_draw_line4d2_32,
+ vga_draw_line4d2_16,
+ vga_draw_line4d2_16,
vga_draw_line8d2_8,
vga_draw_line8d2_16,
vga_draw_line8d2_16,
vga_draw_line8d2_32,
vga_draw_line8d2_32,
+ vga_draw_line8d2_16,
+ vga_draw_line8d2_16,
vga_draw_line8_8,
vga_draw_line8_16,
vga_draw_line8_16,
vga_draw_line8_32,
vga_draw_line8_32,
+ vga_draw_line8_16,
+ vga_draw_line8_16,
vga_draw_line15_8,
vga_draw_line15_15,
vga_draw_line15_16,
vga_draw_line15_32,
vga_draw_line15_32bgr,
+ vga_draw_line15_15bgr,
+ vga_draw_line15_16bgr,
vga_draw_line16_8,
vga_draw_line16_15,
vga_draw_line16_16,
vga_draw_line16_32,
vga_draw_line16_32bgr,
+ vga_draw_line16_15bgr,
+ vga_draw_line16_16bgr,
vga_draw_line24_8,
vga_draw_line24_15,
vga_draw_line24_16,
vga_draw_line24_32,
vga_draw_line24_32bgr,
+ vga_draw_line24_15bgr,
+ vga_draw_line24_16bgr,
vga_draw_line32_8,
vga_draw_line32_15,
vga_draw_line32_16,
vga_draw_line32_32,
vga_draw_line32_32bgr,
+ vga_draw_line32_15bgr,
+ vga_draw_line32_16bgr,
};
typedef unsigned int rgb_to_pixel_dup_func(unsigned int r, unsigned int g, unsigned b);
@@ -1324,6 +1358,8 @@
rgb_to_pixel16_dup,
rgb_to_pixel32_dup,
rgb_to_pixel32bgr_dup,
+ rgb_to_pixel15bgr_dup,
+ rgb_to_pixel16bgr_dup,
};
static int vga_get_bpp(VGAState *s)
Index: qemu/Makefile.target
===================================================================
--- qemu.orig/Makefile.target 2007-06-08 16:40:44.000000000 +0000
+++ qemu/Makefile.target 2007-06-08 17:09:59.000000000 +0000
@@ -592,6 +592,10 @@
signal.o: signal.c
$(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
+vga.o: pixel_ops.h
+
+tcx.o: pixel_ops.h
+
ifeq ($(TARGET_BASE_ARCH), i386)
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
endif
Index: qemu/sdl.c
===================================================================
--- qemu.orig/sdl.c 2007-06-09 06:44:06.000000000 +0000
+++ qemu/sdl.c 2007-06-09 06:52:18.000000000 +0000
@@ -87,7 +87,7 @@
ds->data = screen->pixels;
ds->linesize = screen->pitch;
ds->depth = screen->format->BitsPerPixel;
- if (ds->depth == 32 && screen->format->Rshift == 0) {
+ if (screen->format->Bshift > screen->format->Rshift) {
ds->bgr = 1;
} else {
ds->bgr = 0;
Index: qemu/cocoa.m
===================================================================
--- qemu.orig/cocoa.m 2007-06-09 07:56:04.000000000 +0000
+++ qemu/cocoa.m 2007-06-09 07:57:18.000000000 +0000
@@ -164,7 +164,12 @@
ds->depth = device_bpp;
ds->width = w;
ds->height = h;
-
+#ifdef __LITTLE_ENDIAN__
+ ds->bgr = 1;
+#else
+ ds->bgr = 0;
+#endif
+
current_ds = *ds;
}
next prev parent reply other threads:[~2007-06-09 8:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-05 22:17 [Qemu-devel] Sparc32 network problems Andreas Färber
2007-06-06 7:42 ` Nigel Horne
2007-06-06 12:51 ` Andreas Färber
2007-06-06 18:27 ` Blue Swirl
2007-06-06 18:35 ` Aurelien Jarno
2007-06-06 18:52 ` Blue Swirl
2007-06-06 20:45 ` Andreas Färber
2007-06-07 11:47 ` Andreas Färber
2007-06-09 12:13 ` Andreas Färber
2007-06-10 15:49 ` Blue Swirl
2007-06-10 16:26 ` Andreas Färber
2007-06-10 16:44 ` Blue Swirl
2007-06-07 19:59 ` Blue Swirl
2007-06-07 21:04 ` Thiemo Seufer
2007-06-07 21:41 ` Andreas Färber
2007-06-08 16:25 ` Blue Swirl
2007-06-08 18:35 ` Thiemo Seufer
2007-06-08 19:04 ` Blue Swirl
2007-06-09 14:48 ` Thiemo Seufer
2007-06-08 20:44 ` Andreas Färber
2007-06-09 7:05 ` Blue Swirl
2007-06-09 8:05 ` Blue Swirl [this message]
2007-06-09 10:30 ` Andreas Färber
2007-06-10 15:40 ` Blue Swirl
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=f43fc5580706090105r7cae2eebtd88de21cce1ba430@mail.gmail.com \
--to=blauwirbel@gmail.com \
--cc=andreas.faerber@web.de \
--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).