Skip to content

Commit

Permalink
offb: Add palette hack for little endian
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Benjamin Herrenschmidt <[email protected]>
  • Loading branch information
Cedric Le Goater authored and ozbenh committed Dec 10, 2013
1 parent 212c0cb commit e1edf18
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/video/offb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit e1edf18

Please sign in to comment.