Merge branch 'denx-coldfire' into coldfire-aug2007
[oweals/u-boot.git] / drivers / cfb_console.c
index 138b9689b565d8a84dc53b2f538f139c994c7908..bcf877194e0fdbc5b08514f017c33de8e7decf19 100644 (file)
@@ -63,7 +63,7 @@
                               loop in VIDEO_TSTC_FCT (i8042)
  CFG_CONSOLE_BLINK_COUNT     - value for delay loop - blink rate
  CONFIG_CONSOLE_TIME        - display time/date in upper right corner,
-                              needs CFG_CMD_DATE and CONFIG_CONSOLE_CURSOR
+                              needs CONFIG_CMD_DATE and CONFIG_CONSOLE_CURSOR
  CONFIG_VIDEO_LOGO          - display Linux Logo in upper left corner
  CONFIG_VIDEO_BMP_LOGO      - use bmp_logo instead of linux_logo
  CONFIG_CONSOLE_EXTRA_INFO   - display additional board information strings
@@ -123,11 +123,23 @@ CONFIG_VIDEO_HW_CURSOR:        - Uses the hardware cursor capability of the
 /*****************************************************************************/
 #ifdef CONFIG_VIDEO_SED13806
 
+#ifndef CONFIG_TOTAL5200
 #define VIDEO_FB_LITTLE_ENDIAN
+#endif
 #define VIDEO_HW_RECTFILL
 #define VIDEO_HW_BITBLT
 #endif
 
+/*****************************************************************************/
+/* Defines for the SED13806 driver                                          */
+/*****************************************************************************/
+#ifdef CONFIG_VIDEO_SM501
+
+#ifdef CONFIG_HH405
+#define VIDEO_FB_LITTLE_ENDIAN
+#endif
+#endif
+
 /*****************************************************************************/
 /* Include video_fb.h after definitions of VIDEO_HW_RECTFILL etc            */
 /*****************************************************************************/
@@ -163,15 +175,15 @@ CONFIG_VIDEO_HW_CURSOR:        - Uses the hardware cursor capability of the
 #include <linux/types.h>
 #include <devices.h>
 #include <video_font.h>
-#ifdef CFG_CMD_DATE
-#include <rtc.h>
 
+#if defined(CONFIG_CMD_DATE)
+#include <rtc.h>
 #endif
 
-#if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
+#if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
 #include <watchdog.h>
 #include <bmp_layout.h>
-#endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */
+#endif
 
 /*****************************************************************************/
 /* Cursor definition:                                                       */
@@ -370,6 +382,8 @@ static const int video_font_draw_table32[16][4] = {
            { 0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff } };
 
 
+int gunzip(void *, int, unsigned char *, unsigned long *);
+
 /******************************************************************************/
 
 static void video_drawchars (int xx, int yy, unsigned char *s, int count)
@@ -487,7 +501,7 @@ static void video_drawchars (int xx, int yy, unsigned char *s, int count)
 
 static inline void video_drawstring (int xx, int yy, unsigned char *s)
 {
-       video_drawchars (xx, yy, s, strlen (s));
+       video_drawchars (xx, yy, s, strlen ((char *)s));
 }
 
 /*****************************************************************************/
@@ -534,12 +548,12 @@ void console_cursor (int state)
                sprintf (info, " %02d:%02d:%02d ", tm.tm_hour, tm.tm_min,
                         tm.tm_sec);
                video_drawstring (VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
-                                 VIDEO_INFO_Y, info);
+                                 VIDEO_INFO_Y, (uchar *)info);
 
                sprintf (info, "%02d.%02d.%04d", tm.tm_mday, tm.tm_mon,
                         tm.tm_year);
                video_drawstring (VIDEO_VISIBLE_COLS - 10 * VIDEO_FONT_WIDTH,
-                                 VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT, info);
+                                 VIDEO_INFO_Y + 1 * VIDEO_FONT_HEIGHT, (uchar *)info);
        }
 #endif
 
@@ -695,7 +709,7 @@ void video_puts (const char *s)
 
 /*****************************************************************************/
 
-#if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
+#if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
 
 #define FILL_8BIT_332RGB(r,g,b)        {                       \
        *fb = ((r>>5)<<5) | ((g>>5)<<2) | (b>>6);       \
@@ -749,13 +763,49 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
        unsigned colors;
        unsigned long compression;
        bmp_color_table_entry_t cte;
+#ifdef CONFIG_VIDEO_BMP_GZIP
+       unsigned char *dst = NULL;
+       ulong len;
+#endif
 
        WATCHDOG_RESET ();
 
        if (!((bmp->header.signature[0] == 'B') &&
              (bmp->header.signature[1] == 'M'))) {
+
+#ifdef CONFIG_VIDEO_BMP_GZIP
+               /*
+                * Could be a gzipped bmp image, try to decrompress...
+                */
+               len = CFG_VIDEO_LOGO_MAX_SIZE;
+               dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE);
+               if (dst == NULL) {
+                       printf("Error: malloc in gunzip failed!\n");
+                       return(1);
+               }
+               if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)bmp_image, &len) != 0) {
+                       printf ("Error: no valid bmp or bmp.gz image at %lx\n", bmp_image);
+                       free(dst);
+                       return 1;
+               }
+               if (len == CFG_VIDEO_LOGO_MAX_SIZE) {
+                       printf("Image could be truncated (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n");
+               }
+
+               /*
+                * Set addr to decompressed image
+                */
+               bmp = (bmp_image_t *)dst;
+
+               if (!((bmp->header.signature[0] == 'B') &&
+                     (bmp->header.signature[1] == 'M'))) {
+                       printf ("Error: no valid bmp.gz image at %lx\n", bmp_image);
+                       return 1;
+               }
+#else
                printf ("Error: no valid bmp image at %lx\n", bmp_image);
                return 1;
+#endif /* CONFIG_VIDEO_BMP_GZIP */
        }
 
        width = le32_to_cpu (bmp->header.width);
@@ -945,9 +995,16 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
                        le16_to_cpu (bmp->header.bit_count));
                break;
        }
+
+#ifdef CONFIG_VIDEO_BMP_GZIP
+       if (dst) {
+               free(dst);
+       }
+#endif
+
        return (0);
 }
-#endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */
+#endif
 
 /*****************************************************************************/
 
@@ -1059,11 +1116,10 @@ static void *video_logo (void)
        }
 #endif /* CONFIG_SPLASH_SCREEN */
 
-
        logo_plot (video_fb_address, VIDEO_COLS, 0, 0);
 
        sprintf (info, " %s", &version_string);
-       video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, info);
+       video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *)info);
 
 #ifdef CONFIG_CONSOLE_EXTRA_INFO
        {
@@ -1074,7 +1130,7 @@ static void *video_logo (void)
                        if (*info)
                                video_drawstring (VIDEO_INFO_X,
                                                  VIDEO_INFO_Y + i * VIDEO_FONT_HEIGHT,
-                                                 info);
+                                                 (uchar *)info);
                }
        }
 #endif
@@ -1169,7 +1225,6 @@ int drv_video_init (void)
 {
        int skip_dev_init;
        device_t console_dev;
-       char *penv;
 
        skip_dev_init = 0;
 
@@ -1177,11 +1232,6 @@ int drv_video_init (void)
        if (video_init () == -1)
                skip_dev_init = 1;
 
-       /* Force console i/o to serial ? */
-       if ((penv = getenv ("console")) != NULL)
-               if (strcmp (penv, "serial") == 0)
-                       return 0;
-
 #ifdef CONFIG_VGA_AS_SINGLE_DEVICE
        /* Devices VGA and Keyboard will be assigned seperately */
        /* Init vga device */
@@ -1206,7 +1256,7 @@ int drv_video_init (void)
        /* Init console device */
        if (!skip_dev_init) {
                memset (&console_dev, 0, sizeof (console_dev));
-               strcpy (console_dev.name, "console");
+               strcpy (console_dev.name, "vga");
                console_dev.ext = DEV_EXT_VIDEO;        /* Video extensions */
                console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
                console_dev.putc = video_putc;  /* 'putc' function */