From 832b23a22ac81ccd339b468402ee69750e351ad2 Mon Sep 17 00:00:00 2001 From: Bhanu Chetlapalli Date: Tue, 31 Jan 2012 16:36:59 -0800 Subject: [ENDIAN] Fix goldfish fb for bigendian targets Swap bytes in the display buffer if the host endianess does not match the target endianess. This fixes a problem with the wrong colour being displayed in the text framebuffer console. Not sure if the is the correct place to fix it.. It might be better to have the kernel goldfish framebuffer driver swap the bytes. Change-Id: I8c7ada6e5cb6de7745511f3b83f07f0ac95276af Signed-off-by: Chris Dearman --- hw/goldfish_fb.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'hw') diff --git a/hw/goldfish_fb.c b/hw/goldfish_fb.c index d74d797..16450b3 100644 --- a/hw/goldfish_fb.c +++ b/hw/goldfish_fb.c @@ -319,7 +319,11 @@ compute_fb_update_rect_linear(FbUpdateState* fbs, xx1 = 0; DUFF4(width, { - if (src[xx1] != dst[xx1]) + uint16_t spix = src[xx1]; +#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) + spix = (uint16_t)((spix << 8) | (spix >> 8)); +#endif + if (spix != dst[xx1]) break; xx1++; }); @@ -332,8 +336,8 @@ compute_fb_update_rect_linear(FbUpdateState* fbs, break; xx2--; }); -#if HOST_WORDS_BIGENDIAN - /* Convert the guest little-endian pixels into big-endian ones */ +#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) + /* Convert the guest pixels into host ones */ int xx = xx1; DUFF4(xx2-xx1+1,{ unsigned spix = src[xx]; @@ -382,7 +386,12 @@ compute_fb_update_rect_linear(FbUpdateState* fbs, xx1 = 0; DUFF4(width, { - if (src[xx1] != dst[xx1]) { + uint32_t spix = src[xx1]; +#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) + spix = (spix << 16) | (spix >> 16); + spix = ((spix << 8) & 0xff00ff00) | ((spix >> 8) & 0x00ff00ff); +#endif + if (spix != dst[xx1]) { break; } xx1++; @@ -397,8 +406,8 @@ compute_fb_update_rect_linear(FbUpdateState* fbs, } xx2--; }); -#if HOST_WORDS_BIGENDIAN - /* Convert the guest little-endian pixels into big-endian ones */ +#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) + /* Convert the guest pixels into host ones */ int xx = xx1; DUFF4(xx2-xx1+1,{ uint32_t spix = src[xx]; -- cgit v1.1