[PATCH v3 2/2] offb: add palette hack for little endian

Cédric Le Goater clg at fr.ibm.com
Thu Dec 5 03:49:52 EST 2013


The pseudo palette color entries need to be ajusted for little
endian.

This patch byteswaps the values in the pseudo palette depending
on the host endian order and the screen depth.

Signed-off-by: Cédric Le Goater <clg at fr.ibm.com>
---

Tested on powerpc, little endian and big endian, for 8, 15, 16 and 32 
bpp using the qemu std vga device, with and without foreign endian 
support. I did pull my hair out :) 

The foreign endian support needs some more work to be sure the logic 
behind fb_be_math() is not broken. 

The palette used for the logo would need a similar fix.

Thanks,




 drivers/video/offb.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index 43a0a52fc527..7d44d669d5b6 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -91,6 +91,15 @@ extern boot_infos_t *boot_infos;
 #define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN        0x6cd4
 #define AVIVO_DC_LUTB_WHITE_OFFSET_RED          0x6cd8
 
+#define FB_RIGHT_POS(p, bpp)         (fb_be_math(p) ? 0 : (32 - (bpp)))
+
+static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
+{
+	u32 bpp = info->var.bits_per_pixel;
+
+	return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
+}
+
     /*
      *  Set a single color register. The values supplied are already
      *  rounded down to the hardware's capabilities (according to the
@@ -120,7 +129,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
 			mask <<= info->var.transp.offset;
 			value |= mask;
 		}
-		pal[regno] = value;
+		pal[regno] = offb_cmap_byteswap(info, value);
 		return 0;
 	}
 
-- 
1.7.10.4



More information about the Linuxppc-dev mailing list