Merge branch 'master' of http://git.denx.de/u-boot
[kernel/u-boot.git] / common / lcd.c
index fef17eb..4ed6b90 100644 (file)
@@ -64,7 +64,7 @@
 /************************************************************************/
 #ifdef CONFIG_LCD_LOGO
 # include <bmp_logo.h>         /* Get logo data, width and height      */
-# if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET)
+# if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16)
 #  error Default Color Map overlaps with Logo Color Map
 # endif
 #endif
@@ -219,8 +219,12 @@ static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
 
        for (row=0;  row < VIDEO_FONT_HEIGHT;  ++row, dest += lcd_line_length)  {
                uchar *s = str;
-               uchar *d = dest;
                int i;
+#if LCD_BPP == LCD_COLOR16
+               ushort *d = (ushort *)dest;
+#else
+               uchar *d = dest;
+#endif
 
 #if LCD_BPP == LCD_MONOCHROME
                uchar rest = *d & -(1 << (8-off));
@@ -245,7 +249,7 @@ static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
                                bits <<= 1;
                        }
 #elif LCD_BPP == LCD_COLOR16
-                       for (c=0; c<16; ++c) {
+                       for (c=0; c<8; ++c) {
                                *d++ = (bits & 0x80) ?
                                                lcd_color_fg : lcd_color_bg;
                                bits <<= 1;
@@ -532,6 +536,13 @@ void bitmap_plot (int x, int y)
                cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]);
 #elif defined(CONFIG_ATMEL_LCD)
                cmap = (uint *) (panel_info.mmio + ATMEL_LCDC_LUT(0));
+#else
+               /*
+                * default case: generic system with no cmap (most likely 16bpp)
+                * We set cmap to the source palette, so no change is done.
+                * This avoids even more ifdef in the next stanza
+                */
+               cmap = bmp_logo_palette;
 #endif
 
                WATCHDOG_RESET();
@@ -570,10 +581,15 @@ void bitmap_plot (int x, int y)
                }
        }
        else { /* true color mode */
+               u16 col16;
                fb16 = (ushort *)(lcd_base + y * lcd_line_length + x);
                for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
                        for (j=0; j<BMP_LOGO_WIDTH; j++) {
-                               fb16[j] = bmp_logo_palette[(bmap[j])];
+                               col16 = bmp_logo_palette[(bmap[j]-16)];
+                               fb16[j] =
+                                       ((col16 & 0x000F) << 1) |
+                                       ((col16 & 0x00F0) << 3) |
+                                       ((col16 & 0x0F00) << 4);
                                }
                        bmap += BMP_LOGO_WIDTH;
                        fb16 += panel_info.vl_col;
@@ -854,6 +870,7 @@ static void *lcd_logo (void)
 #ifdef CONFIG_SPLASH_SCREEN
        char *s;
        ulong addr;
+       int allocated = 0;
        static int do_splash = 1;
 
        if (do_splash && (s = getenv("splashimage")) != NULL) {
@@ -884,18 +901,20 @@ static void *lcd_logo (void)
                if (!((bmp->header.signature[0]=='B') &&
                      (bmp->header.signature[1]=='M'))) {
                        addr = (ulong)gunzip_bmp(addr, &len);
+                       if (addr)
+                               allocated = 1;
                }
 #endif
 
                if (lcd_display_bitmap (addr, x, y) == 0) {
 #ifdef CONFIG_VIDEO_BMP_GZIP
-                       if (addr)
+                       if (addr && allocated)
                                free((void *)addr);
 #endif
                        return ((void *)lcd_base);
                }
 #ifdef CONFIG_VIDEO_BMP_GZIP
-               if (addr)
+               if (addr && allocated)
                        free((void *)addr);
 #endif
        }