qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] PATCH: fix bgr color mapping on qemu on Solaris/SPARC
@ 2006-05-10 18:16 Ben Taylor
  2006-05-10 18:32 ` Anthony Liguori
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Ben Taylor @ 2006-05-10 18:16 UTC (permalink / raw)
  To: Qemu-devel

[-- Attachment #1: Type: text/plain, Size: 631 bytes --]


Enclosed is a patch that fixes the color mapping when running qemu on a Solaris/Sparc
system.  To enable the color mapping bgr, call qemu with the flag "-bgr".

This patch *requires* the qemu-0.8.1cvs-sparc-solaris.patch diff that was posted
earlier today.

I separated out this patch as there has been much discussion about fixing the bgr
problem, but I haven't seen any other code posted.  This has been tested with
Win98SE and DamnSmallLinux on an Ultra 80 running Solaris 10.

Note:  VNC and Sparc are still not playing nicely, so you will see inverted colors if
you run qemu on a Solaris Sparc host and display with vnc.

Ben

[-- Attachment #2: qemu-0.8.1cvs-solaris-bgr.patch --]
[-- Type: text/x-patch, Size: 3586 bytes --]

diff -ruN qemu-solaris-sparc/hw/vga.c qemu/hw/vga.c
--- qemu-solaris-sparc/hw/vga.c	2006-04-08 21:06:34.000000000 -0400
+++ qemu/hw/vga.c	2006-05-10 12:31:31.059297000 -0400
@@ -790,23 +790,43 @@
 
 static inline unsigned int rgb_to_pixel8(unsigned int r, unsigned int g, unsigned b)
 {
+if (bgr_display_enabled) {
+    return ((b >> 5) << 5) | ((g >> 5) << 2) | (r >> 6);
+}
+else {
     return ((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6);
 }
+}
 
 static inline unsigned int rgb_to_pixel15(unsigned int r, unsigned int g, unsigned b)
 {
+if (bgr_display_enabled) {
+    return ((b >> 3) << 10) | ((g >> 3) << 5) | (r >> 3);
+}
+else {
     return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
 }
+}
 
 static inline unsigned int rgb_to_pixel16(unsigned int r, unsigned int g, unsigned b)
 {
+if (bgr_display_enabled) {
+    return ((b >> 3) << 11) | ((g >> 2) << 5) | (r >> 3);
+}
+else {
     return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
 }
+}
 
 static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsigned b)
 {
+if (bgr_display_enabled) {
+    return (b << 16) | (g << 8) | r;
+}
+else {
     return (r << 16) | (g << 8) | b;
 }
+}
 
 #define DEPTH 8
 #include "vga_template.h"
@@ -1366,6 +1386,8 @@
 
     if (disp_width != s->last_width ||
         height != s->last_height) {
+        if (cirrus_vga_enabled && s->get_bpp(s) >= 8)
+            memset(s->vram_ptr, 0xff, s->vram_size);
         dpy_resize(s->ds, disp_width, height);
         s->last_scr_width = disp_width;
         s->last_scr_height = height;
diff -ruN qemu-solaris-sparc/vl.c qemu/vl.c
--- qemu-solaris-sparc/vl.c	2006-05-10 12:37:40.467126000 -0400
+++ qemu/vl.c	2006-05-10 12:31:46.354278000 -0400
@@ -130,6 +130,7 @@
 int vm_running;
 int rtc_utc = 1;
 int cirrus_vga_enabled = 1;
+int bgr_display_enabled = 0;
 #ifdef TARGET_SPARC
 int graphic_width = 1024;
 int graphic_height = 768;
@@ -4626,6 +4627,7 @@
            "-m megs         set virtual RAM size to megs MB [default=%d]\n"
            "-smp n          set the number of CPUs to 'n' [default=1]\n"
            "-nographic      disable graphical output and redirect serial I/Os to console\n"
+           "-bgr            invert colors for HOSTS using certain SPARC frame buffers\n"
 #ifndef _WIN32
 	   "-k language     use keyboard layout (for example \"fr\" for French)\n"
 #endif
@@ -4782,6 +4784,7 @@
     QEMU_OPTION_cirrusvga,
     QEMU_OPTION_g,
     QEMU_OPTION_std_vga,
+    QEMU_OPTION_bgr,
     QEMU_OPTION_monitor,
     QEMU_OPTION_serial,
     QEMU_OPTION_parallel,
@@ -4861,6 +4864,7 @@
     { "full-screen", 0, QEMU_OPTION_full_screen },
     { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
     { "win2k-hack", 0, QEMU_OPTION_win2k_hack },
+    { "bgr", 0, QEMU_OPTION_bgr },
     { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
     { "smp", HAS_ARG, QEMU_OPTION_smp },
     { "vnc", HAS_ARG, QEMU_OPTION_vnc },
@@ -5365,6 +5369,9 @@
             case QEMU_OPTION_std_vga:
                 cirrus_vga_enabled = 0;
                 break;
+            case QEMU_OPTION_bgr:
+                bgr_display_enabled = 1;
+                break;
             case QEMU_OPTION_g:
                 {
                     const char *p;
diff -ruN qemu-solaris-sparc/vl.h qemu/vl.h
--- qemu-solaris-sparc/vl.h	2006-05-03 18:02:44.000000000 -0400
+++ qemu/vl.h	2006-05-10 12:31:51.368923000 -0400
@@ -135,6 +135,7 @@
 extern int bios_size;
 extern int rtc_utc;
 extern int cirrus_vga_enabled;
+extern int bgr_display_enabled;
 extern int graphic_width;
 extern int graphic_height;
 extern int graphic_depth;

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: [Qemu-devel] PATCH: fix bgr color mapping on qemu on Solaris/SPARC
@ 2006-05-11  0:14 Ben Taylor
  0 siblings, 0 replies; 20+ messages in thread
From: Ben Taylor @ 2006-05-11  0:14 UTC (permalink / raw)
  To: qemu-devel


---- Fabrice Bellard <fabrice@bellard.org> wrote: 
> In order to stop the release of incomplete BGR patches, I am 
> implementing a more complete patch. I am just adding depth = 32 with BGR 
> instead of RGB. If other pixel formats are wanted, you should signal it now.

I added an "int bgr;" to the displaystruct in vl.h, but that is now causing a core dump
upon starting qemu with the rest of your patch.

here's the back trace:

#0  0x00033204 in console_show_cursor (s=0x11f95bd8, show=301554760) at vl.h:692
#1  0x0003373c in console_puts (chr=0x36, buf=0x140c18 "QEMU 0.8.1 monitor - type 'help' for more information\n", len=54)
    at /export/src/qemu/May10-V2/qemu-solaris/console.c:825
#2  0x00024eb8 in qemu_chr_write (s=0x36, buf=0x140c18 "QEMU 0.8.1 monitor - type 'help' for more information\n", len=54)
    at /export/src/qemu/May10-V2/qemu-solaris/vl.c:1096
#3  0x0002d208 in term_flush () at /export/src/qemu/May10-V2/qemu-solaris/monitor.c:72
#4  0x0002d27c in term_puts (str=0xffbfb78e "") at /export/src/qemu/May10-V2/qemu-solaris/monitor.c:88
#5  0x0002d2d0 in term_vprintf (fmt=0xfcd68 "QEMU %s monitor - type 'help' for more information\n", ap=0xffbfc820)
    at /export/src/qemu/May10-V2/qemu-solaris/monitor.c:96
#6  0x0002d304 in term_printf (fmt=0xfcd68 "QEMU %s monitor - type 'help' for more information\n")
    at /export/src/qemu/May10-V2/qemu-solaris/monitor.c:103
#7  0x00030470 in monitor_init (hd=0x11f82f38, show_banner=1) at /export/src/qemu/May10-V2/qemu-solaris/monitor.c:2288
#8  0x00029804 in main (argc=7, argv=0xffbff33c) at /export/src/qemu/May10-V2/qemu-solaris/vl.c:5658


Ideas?

Ben

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2006-05-12 16:54 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-10 18:16 [Qemu-devel] PATCH: fix bgr color mapping on qemu on Solaris/SPARC Ben Taylor
2006-05-10 18:32 ` Anthony Liguori
2006-05-10 22:07   ` Leonardo E. Reiter
2006-05-10 21:30 ` Paul Brook
2006-05-10 22:21   ` Julian Seward
2006-05-10 22:05 ` Fabrice Bellard
2006-05-11  0:33   ` Paul Brook
2006-05-11 13:04     ` Dan Sandberg
2006-05-11 14:57       ` Jan Marten Simons
2006-05-11 15:48         ` Jim C. Brown
2006-05-11 14:57       ` Oliver Gerlich
2006-05-11 17:50       ` Anthony Liguori
2006-05-11 21:39       ` Fabrice Bellard
2006-05-12  8:36         ` Dan Sandberg
2006-05-12 13:26           ` Jamie Lokier
2006-05-12 15:36             ` Dan Sandberg
2006-05-12 15:53               ` Jamie Lokier
2006-05-12 16:40                 ` Dan Sandberg
2006-05-12 16:54                   ` Paul Brook
  -- strict thread matches above, loose matches on Subject: below --
2006-05-11  0:14 Ben Taylor

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).