From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fdwes-00021x-H7 for qemu-devel@nongnu.org; Wed, 10 May 2006 17:55:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fdweo-000204-Pa for qemu-devel@nongnu.org; Wed, 10 May 2006 17:55:49 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fdweo-000201-Jo for qemu-devel@nongnu.org; Wed, 10 May 2006 17:55:46 -0400 Received: from [199.232.41.67] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FdtVz-00027i-ES for qemu-devel@nongnu.org; Wed, 10 May 2006 14:34:28 -0400 Received: from [32.97.182.143] (helo=e3.ny.us.ibm.com) by mx20.gnu.org with esmtp (Exim 4.52) id 1FdtUO-0003MY-Nk for qemu-devel@nongnu.org; Wed, 10 May 2006 14:32:49 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e3.ny.us.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k4AIWKN8020760 for ; Wed, 10 May 2006 14:32:20 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.12.10/NCO/VER6.8) with ESMTP id k4AIWKDO207752 for ; Wed, 10 May 2006 14:32:20 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11/8.13.3) with ESMTP id k4AIWJuB017987 for ; Wed, 10 May 2006 14:32:19 -0400 Message-ID: <446231A9.8060809@us.ibm.com> Date: Wed, 10 May 2006 13:32:09 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] PATCH: fix bgr color mapping on qemu on Solaris/SPARC References: <9893291.1147284983406.JavaMail.root@eastrmwml06.mgt.cox.net> In-Reply-To: <9893291.1147284983406.JavaMail.root@eastrmwml06.mgt.cox.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: sol10x86@cox.net, qemu-devel@nongnu.org Ben Taylor wrote: > 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. > This is going to almost certainly going to have a negative performance consequence. A better solution would be introduce a second set of functions that were byte swapped and set the rgb_to_pixel function pointer appropriately if bgr is enabled. I would expect that you can automate the selecting of bgr too based on the host architecture and the target architecture. There shouldn't be a need for a new command line option. If you added a byte_order member to the DisplayState, this would fix the vnc case too. Regards, Anthony Liguori > Ben > ------------------------------------------------------------------------ > > 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; > > ------------------------------------------------------------------------ > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel >