Commit 9997b75e authored by Alexander Potashev's avatar Alexander Potashev

RT106080. lcd: Support display of 24-bit BMPs on 32-bit LCD

Imported existing code from u-boot-vybrid, implemented in RT89558.
parent 82bb6c2a
......@@ -217,8 +217,8 @@ static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
uchar *dest;
ushort off, row;
dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8);
off = x * (1 << LCD_BPP) % 8;
dest = (uchar *)(lcd_base + y * lcd_line_length + x * NBITS(LCD_BPP) / 8);
off = x * NBITS(LCD_BPP) % 8;
for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) {
uchar *s = str;
......@@ -640,17 +640,18 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
bpix = NBITS(panel_info.vl_bpix);
if ((bpix != 1) && (bpix != 8) && (bpix != 16)) {
if ((bpix != 1) && (bpix != 8) && (bpix != 16) && (bpix != 24) && (bpix != 32)) {
printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
bpix, bmp_bpix);
return 1;
}
/* We support displaying 8bpp BMPs on 16bpp LCDs */
if (bpix != bmp_bpix && (bmp_bpix != 8 || bpix != 16)) {
/* We support displaying 8bpp BMPs on 16bpp LCDs
* and 24 BMPs on 32bpp LCDs if they are enabled*/
if (bpix != bmp_bpix && (bmp_bpix != 8 || bpix != 16) &&
(bmp_bpix != 24 || bpix != 32)) {
printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
bpix,
le16_to_cpu(bmp->header.bit_count));
bpix, bmp_bpix);
return 1;
}
......@@ -786,6 +787,33 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
break;
#endif /* CONFIG_BMP_16BPP */
#if defined(CONFIG_BMP_24BPP)
case 24:
for (i = 0; i < height; ++i) {
WATCHDOG_RESET();
if (bpix == 24) {
for (j = 0; j < width; j++) {
*(fb++) = *(bmap++);
*(fb++) = *(bmap++);
*(fb++) = *(bmap++);
}
bmap += (padded_line - width) * 3;
fb -= (width * 3 + lcd_line_length);
}
else if (bpix == 32) {
for (j = 0; j < width; j++) {
*(fb++) = *(bmap++);
*(fb++) = *(bmap++);
*(fb++) = *(bmap++);
*(fb++) = 0xFF;
}
bmap += (padded_line - width) * 3;
fb -= (width * 4 + lcd_line_length);
}
}
break;
#endif /* CONFIG_BMP_24BPP */
default:
break;
};
......
......@@ -234,6 +234,8 @@ void lcd_show_board_info(void);
#define LCD_COLOR4 2
#define LCD_COLOR8 3
#define LCD_COLOR16 4
#define LCD_COLOR24 24
#define LCD_COLOR32 5
/*----------------------------------------------------------------------*/
#if defined(CONFIG_LCD_INFO_BELOW_LOGO)
......@@ -256,7 +258,9 @@ void lcd_show_board_info(void);
#endif
/* Calculate nr. of bits per pixel and nr. of colors */
#define NBITS(bit_code) (1 << (bit_code))
#define NBITS(bit_code) ((bit_code) <= 5 ? \
(1 << (bit_code)) : (bit_code))
#define NCOLORS(bit_code) (1 << NBITS(bit_code))
/************************************************************************/
......@@ -322,7 +326,8 @@ void lcd_show_board_info(void);
#if LCD_BPP == LCD_MONOCHROME
# define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \
(c) << 4 | (c) << 5 | (c) << 6 | (c) << 7)
#elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16)
#elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16) \
|| (LCD_BPP == LCD_COLOR24) || (LCD_BPP == LCD_COLOR32)
# define COLOR_MASK(c) (c)
#else
# error Unsupported LCD BPP.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment