]> git.sur5r.net Git - u-boot/blobdiff - common/lcd.c
mpc83xx: MPC8360E-RDK: configure pario pins for AD7843 and FHCI
[u-boot] / common / lcd.c
index 66506381a5d6e774454bc618366ac9efcad0c637..914dc2ef7ca5b1f30d1238317213e32650c9018d 100644 (file)
@@ -50,7 +50,6 @@
 #include <lcdvideo.h>
 #endif
 
-
 #ifdef CONFIG_LCD
 
 /************************************************************************/
 /************************************************************************/
 #include <video_font.h>                /* Get font data, width and height      */
 
+/************************************************************************/
+/* ** LOGO DATA                                                                */
+/************************************************************************/
+#ifdef CONFIG_LCD_LOGO
+# include <bmp_logo.h>         /* Get logo data, width and height      */
+# if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET)
+#  error Default Color Map overlaps with Logo Color Map
+# endif
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
 
 ulong lcd_setmem (ulong addr);
 
@@ -269,10 +279,10 @@ static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
 
 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s)
 {
-#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
-       lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen (s));
+#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
+       lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen ((char *)s));
 #else
-       lcd_drawchars (x, y, s, strlen (s));
+       lcd_drawchars (x, y, s, strlen ((char *)s));
 #endif
 }
 
@@ -280,7 +290,7 @@ static inline void lcd_puts_xy (ushort x, ushort y, uchar *s)
 
 static inline void lcd_putc_xy (ushort x, ushort y, uchar c)
 {
-#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
+#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
        lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1);
 #else
        lcd_drawchars (x, y, &c, 1);
@@ -330,8 +340,6 @@ static void test_pattern (void)
 
 int drv_lcd_init (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        device_t lcddev;
        int rc;
 
@@ -420,7 +428,7 @@ static int lcd_init (void *lcdbase)
 
        /* Initialize the console */
        console_col = 0;
-#ifdef LCD_INFO_BELOW_LOGO
+#ifdef CONFIG_LCD_INFO_BELOW_LOGO
        console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
 #else
        console_row = 1;        /* leave 1 blank line below logo */
@@ -517,7 +525,7 @@ void bitmap_plot (int x, int y)
                sizeof(bmp_logo_palette)/(sizeof(ushort)));
 
        bmap = &bmp_logo_bitmap[0];
-       fb   = (char *)(lcd_base + y * lcd_line_length + x);
+       fb   = (uchar *)(lcd_base + y * lcd_line_length + x);
 
        if (NBITS(panel_info.vl_bpix) < 12) {
                /* Leave room for default color map */
@@ -563,20 +571,23 @@ void bitmap_plot (int x, int y)
 #endif /* CONFIG_LCD_LOGO */
 
 /*----------------------------------------------------------------------*/
-#if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
+#if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
 /*
  * Display the BMP file located at address bmp_image.
  * Only uncompressed.
  */
 int lcd_display_bitmap(ulong bmp_image, int x, int y)
 {
+#if !defined(CONFIG_MCC200)
        ushort *cmap;
+#endif
        ushort i, j;
        uchar *fb;
        bmp_image_t *bmp=(bmp_image_t *)bmp_image;
        uchar *bmap;
        ushort padded_line;
        unsigned long width, height;
+       unsigned long pwidth = panel_info.vl_col;
        unsigned colors,bpix;
        unsigned long compression;
 #if defined(CONFIG_PXA250)
@@ -615,6 +626,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        debug ("Display-bmp: %d x %d  with %d colors\n",
                (int)width, (int)height, (int)colors);
 
+#if !defined(CONFIG_MCC200)
+       /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
        if (bpix==8) {
 #if defined(CONFIG_PXA250)
                cmap = (ushort *)fbi->palette;
@@ -629,9 +642,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                        bmp_color_table_entry_t cte = bmp->color_table[i];
                        ushort colreg =
                                ( ((cte.red)   << 8) & 0xf800) |
-                               ( ((cte.green) << 4) & 0x07e0) |
-                               ( (cte.blue) & 0x001f) ;
-
+                               ( ((cte.green) << 3) & 0x07e0) |
+                               ( ((cte.blue)  >> 3) & 0x001f) ;
 #ifdef CFG_INVERT_COLORS
                        *cmap = 0xffff - colreg;
 #else
@@ -644,10 +656,30 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 #endif
                }
        }
+#endif
+
+       /*
+        *  BMP format for Monochrome assumes that the state of a
+        * pixel is described on a per Bit basis, not per Byte.
+        *  So, in case of Monochrome BMP we should align widths
+        * on a byte boundary and convert them from Bit to Byte
+        * units.
+        *  Probably, PXA250 and MPC823 process 1bpp BMP images in
+        * their own ways, so make the converting to be MCC200
+        * specific.
+        */
+#if defined(CONFIG_MCC200)
+       if (bpix==1)
+       {
+               width = ((width + 7) & ~7) >> 3;
+               x     = ((x + 7) & ~7) >> 3;
+               pwidth= ((pwidth + 7) & ~7) >> 3;
+       }
+#endif
 
        padded_line = (width&0x3) ? ((width&~0x3)+4) : (width);
-       if ((x + width)>panel_info.vl_col)
-               width = panel_info.vl_col - x;
+       if ((x + width)>pwidth)
+               width = pwidth - x;
        if ((y + height)>panel_info.vl_row)
                height = panel_info.vl_row - y;
 
@@ -659,7 +691,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                for (j = 0; j < width ; j++)
 #if defined(CONFIG_PXA250)
                        *(fb++)=*(bmap++);
-#elif defined(CONFIG_MPC823)
+#elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
                        *(fb++)=255-*(bmap++);
 #endif
                bmap += (width - padded_line);
@@ -668,17 +700,15 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 
        return (0);
 }
-#endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */
+#endif
 
 
 static void *lcd_logo (void)
 {
-#ifdef LCD_INFO
-       DECLARE_GLOBAL_DATA_PTR;
-
+#ifdef CONFIG_LCD_INFO
        char info[80];
        char temp[32];
-#endif /* LCD_INFO */
+#endif /* CONFIG_LCD_INFO */
 
 #ifdef CONFIG_SPLASH_SCREEN
        char *s;
@@ -700,18 +730,18 @@ static void *lcd_logo (void)
 #endif /* CONFIG_LCD_LOGO */
 
 #ifdef CONFIG_MPC823
-#ifdef LCD_INFO
+# ifdef CONFIG_LCD_INFO
        sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__);
-       lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, info, strlen(info));
+       lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, (uchar *)info, strlen(info));
 
        sprintf (info, "(C) 2004 DENX Software Engineering");
        lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT,
-                                       info, strlen(info));
+                                       (uchar *)info, strlen(info));
 
        sprintf (info, "    Wolfgang DENK, wd@denx.de");
        lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2,
-                                       info, strlen(info));
-#ifdef LCD_INFO_BELOW_LOGO
+                                       (uchar *)info, strlen(info));
+#  ifdef CONFIG_LCD_INFO_BELOW_LOGO
        sprintf (info, "MPC823 CPU at %s MHz",
                strmhz(temp, gd->cpu_clk));
        lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3,
@@ -721,7 +751,7 @@ static void *lcd_logo (void)
                gd->bd->bi_flashsize >> 20 );
        lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
                                        info, strlen(info));
-#else
+#  else
        /* leave one blank line */
 
        sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash",
@@ -729,17 +759,17 @@ static void *lcd_logo (void)
                gd->ram_size >> 20,
                gd->bd->bi_flashsize >> 20 );
        lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
-                                       info, strlen(info));
+                                       (uchar *)info, strlen(info));
 
+#  endif /* CONFIG_LCD_INFO_BELOW_LOGO */
+# endif /* CONFIG_LCD_INFO */
 #endif /* CONFIG_MPC823 */
-#endif /* LCD_INFO_BELOW_LOGO */
-#endif /* LCD_INFO */
 
-#if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
+#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
        return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length));
 #else
        return ((void *)lcd_base);
-#endif /* CONFIG_LCD_LOGO */
+#endif /* CONFIG_LCD_LOGO && !CONFIG_LCD_INFO_BELOW_LOGO */
 }
 
 /************************************************************************/