All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pat Campbell <plc@novell.com>
To: xen-devel <xen-devel@lists.xensource.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: vnc client, 16 bit, strange colors when viewing a PV guest
Date: Tue, 26 Feb 2008 10:06:13 -0700	[thread overview]
Message-ID: <47C44705.3090008@novell.com> (raw)

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


Using tightVNC, the colors are messed up when viewing a PV guest running
on a 3.2 hypervisor from a client system with a 16 bit deep display.
virt-manager --> viewer works OK.
Standalone virt-viewer and other VNC clients have bad colors.  

This problem is new with Xen 3.2 and the qemu xenfb code.

As a short term fix I added a second macro in tools/ioemu/hw/xenfb.c to
munge the colors from 32 bit  to 16 bit based on an algorithm used by
RealVNC.  Patch I used is attached, not suggesting it be merged.

Is anybody else seeing this problem?

By the way, while looking at the original macro I think the last shift
for blue should of used BRS instead if GRS.  ( Changing that did not
make the colors better. )

#define BLT(SRC_T,DST_T,RLS,GLS,BLS,RRS,GRS,BRS,RM,GM,BM)               \
    for (line = y ; line < h ; line++) {                                \
        SRC_T *src = (SRC_T *)(xenfb->pixels                            \
                               + (line * xenfb->row_stride)             \
                               + (x * xenfb->depth / 8));               \
        DST_T *dst = (DST_T
*)(xenfb->ds->data                                 \
                               + (line *
xenfb->ds->linesize)                  \
                               + (x * xenfb->ds->depth /
8));                  \
        int col;                                                        \
        for (col = x ; col < w ; col++) {                               \
            *dst = (((*src >> RRS) & RM) << RLS) |                      \
                (((*src >> GRS) & GM) << GLS) |                         \
-                (((*src >> GRS) & BM) << BLS);                          \
+               (((*src >> BRS) & BM) << BLS);                          \
            src++;                                                      \
            dst++;                                                      \
        }                                                               \
    }



[-- Attachment #2: pv_32_16_color_trans.patch --]
[-- Type: text/x-patch, Size: 2302 bytes --]

Index: xen-3.2-testing/tools/ioemu/hw/xenfb.c
===================================================================
--- xen-3.2-testing.orig/tools/ioemu/hw/xenfb.c	2008-02-26 07:38:20.000000000 -0700
+++ xen-3.2-testing/tools/ioemu/hw/xenfb.c	2008-02-26 07:43:56.000000000 -0700
@@ -1103,6 +1103,25 @@
         }                                                               \
     }
 
+/* 32 bit to 16 bit pixel munging, dst algo came from RealVNC transInitTempl.h */
+#define BLT_32_16(SRC_T,DST_T,RRS,GRS,BRS,RLS,GLS,BLS,RIM,GIM,BIM,ROM,GOM,BOM)               \
+    for (line = y ; line < h ; line++) {                                   \
+        SRC_T *src = (SRC_T *)(xenfb->pixels                               \
+                               + (line * xenfb->row_stride)                \
+                               + (x * xenfb->depth / 8));                  \
+        DST_T *dst = (DST_T *)(xenfb->ds->data                             \
+                               + (line * xenfb->ds->linesize)              \
+                               + (x * xenfb->ds->depth / 8));              \
+        int col;                                                           \
+        for (col = x ; col < w ; col++) {                                  \
+            *dst = ((((*src >> RRS & RIM) * ROM + RIM/2) / RIM) << RLS) |  \
+                ((((*src >> GRS & GIM) * GOM + GIM/2) / GIM) << GLS ) |    \
+                ((((*src >> BRS & BIM) * BOM + BIM/2) / BIM) << BLS);      \
+            src++;                                                         \
+            dst++;                                                         \
+        }                                                                  \
+    }
+
 
 /* This copies data from the guest framebuffer region, into QEMU's copy
  * NB. QEMU's copy is stored in the pixel format of a) the local X 
@@ -1139,7 +1158,7 @@
             if (xenfb->ds->depth == 8) {
                 BLT(uint32_t, uint8_t,    16, 8, 0,   5, 2, 0,    255, 255, 255);
             } else if (xenfb->ds->depth == 16) {
-                BLT(uint32_t, uint16_t,   16, 8, 0,   11, 5, 0,   255, 255, 255);
+                BLT_32_16(uint32_t, uint16_t,   16, 8, 0,   11, 5, 0,   255, 255, 255,   31, 63, 31);
             }
         }
     }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2008-02-26 17:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-26 17:06 Pat Campbell [this message]
2008-02-26 17:17 ` vnc client, 16 bit, strange colors when viewing a PV guest Daniel P. Berrange

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=47C44705.3090008@novell.com \
    --to=plc@novell.com \
    --cc=berrange@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.