]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - drivers/video/cfb_console.c
cfb_console: fix build breakage
[karo-tx-uboot.git] / drivers / video / cfb_console.c
index d1f47c9157130a20678199d72e30a4c1c57c3004..b56197fd480fd0f0f24812c21104aafac2d480ba 100644 (file)
@@ -91,6 +91,7 @@ CONFIG_VIDEO_HW_CURSOR:            - Uses the hardware cursor capability of the
 */
 
 #include <common.h>
+#include <version.h>
 
 #include <malloc.h>
 
@@ -230,8 +231,8 @@ CONFIG_VIDEO_HW_CURSOR:          - Uses the hardware cursor capability of the
 #error only one of CONFIG_CONSOLE_CURSOR,CONFIG_VIDEO_SW_CURSOR,CONFIG_VIDEO_HW_CURSOR can be defined
 #endif
 void   console_cursor (int state);
-#define CURSOR_ON  console_cursor(1);
-#define CURSOR_OFF console_cursor(0);
+#define CURSOR_ON  console_cursor(1)
+#define CURSOR_OFF console_cursor(0)
 #define CURSOR_SET
 #ifndef CONFIG_I8042_KBD
 #warning Cursor drawing on/off needs timer function s.a. drivers/input/i8042.c
@@ -248,8 +249,8 @@ void        console_cursor (int state);
 #endif
 #define CURSOR_ON
 #define CURSOR_OFF video_putchar(console_col * VIDEO_FONT_WIDTH,\
-                                console_row * VIDEO_FONT_HEIGHT, ' ');
-#define CURSOR_SET video_set_cursor();
+                                console_row * VIDEO_FONT_HEIGHT, ' ')
+#define CURSOR_SET video_set_cursor()
 #endif /* CONFIG_VIDEO_SW_CURSOR */
 
 
@@ -260,7 +261,7 @@ void        console_cursor (int state);
 #define CURSOR_ON
 #define CURSOR_OFF
 #define CURSOR_SET video_set_hw_cursor(console_col * VIDEO_FONT_WIDTH, \
-                 (console_row * VIDEO_FONT_HEIGHT) + video_logo_height);
+                 (console_row * VIDEO_FONT_HEIGHT) + video_logo_height)
 #endif /* CONFIG_VIDEO_HW_CURSOR */
 
 #ifdef CONFIG_VIDEO_LOGO
@@ -651,7 +652,8 @@ static void console_scrollup (void)
 
 static void console_back (void)
 {
-       CURSOR_OFF console_col--;
+       CURSOR_OFF;
+       console_col--;
 
        if (console_col < 0) {
                console_col = CONSOLE_COLS - 1;
@@ -674,7 +676,7 @@ static void console_newline (void)
           is >= CONSOLE_COLS
         */
        if (console_col < CONSOLE_COLS)
-               CURSOR_OFF
+               CURSOR_OFF;
        console_row++;
        console_col = 0;
 
@@ -690,7 +692,8 @@ static void console_newline (void)
 
 static void console_cr (void)
 {
-       CURSOR_OFF console_col = 0;
+       CURSOR_OFF;
+       console_col = 0;
 }
 
 /*****************************************************************************/
@@ -711,7 +714,8 @@ void video_putc (const char c)
                break;
 
        case 9:         /* tab 8 */
-               CURSOR_OFF console_col |= 0x0008;
+               CURSOR_OFF;
+               console_col |= 0x0008;
                console_col &= ~0x0007;
 
                if (console_col >= CONSOLE_COLS)
@@ -734,7 +738,8 @@ void video_putc (const char c)
                        nl = 0;
                }
        }
-CURSOR_SET}
+       CURSOR_SET;
+}
 
 
 /*****************************************************************************/
@@ -749,6 +754,18 @@ void video_puts (const char *s)
 
 /*****************************************************************************/
 
+/*
+ * Do not enforce drivers (or board code) to provide empty
+ * video_set_lut() if they do not support 8 bpp format.
+ * Implement weak default function instead.
+ */
+void __video_set_lut (unsigned int index, unsigned char r,
+                     unsigned char g, unsigned char b)
+{
+}
+void video_set_lut (unsigned int, unsigned char, unsigned char, unsigned char)
+                       __attribute__((weak, alias("__video_set_lut")));
+
 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
 
 #define FILL_8BIT_332RGB(r,g,b)        {                       \
@@ -866,6 +883,8 @@ static int display_rle8_bitmap (bmp_image_t *img, int xoff, int yoff,
        struct palette p[256];
        bmp_color_table_entry_t cte;
        int green_shift, red_off;
+       int limit = VIDEO_COLS * VIDEO_ROWS;
+       int pixels = 0;
 
        x = 0;
        y = __le32_to_cpu(img->header.height) - 1;
@@ -946,6 +965,10 @@ static int display_rle8_bitmap (bmp_image_t *img, int xoff, int yoff,
                                /* unencoded run */
                                cnt = bm[1];
                                runlen = cnt;
+                               pixels += cnt;
+                               if (pixels > limit)
+                                       goto error;
+
                                bm += 2;
                                if (y < height) {
                                        if (x >= width) {
@@ -954,7 +977,6 @@ static int display_rle8_bitmap (bmp_image_t *img, int xoff, int yoff,
                                        }
                                        if (x + runlen > width)
                                                cnt = width - x;
-
                                        draw_bitmap (&fbp, bm, p, cnt, 0);
                                        x += runlen;
                                }
@@ -966,9 +988,13 @@ next_run:
                        break;
                default:
                        /* encoded run */
+                       cnt = bm[0];
+                       runlen = cnt;
+                       pixels += cnt;
+                       if (pixels > limit)
+                               goto error;
+
                        if (y < height) { /* only draw into visible area */
-                               cnt = bm[0];
-                               runlen = cnt;
                                if (x >= width) {
                                        x += runlen;
                                        bm += 2;
@@ -976,7 +1002,6 @@ next_run:
                                }
                                if (x + runlen > width)
                                        cnt = width - x;
-
                                draw_bitmap (&fbp, bm, p, cnt, 1);
                                x += runlen;
                        }
@@ -985,6 +1010,9 @@ next_run:
                }
        }
        return 0;
+error:
+       printf("Error: Too much encoded pixel data, validate your bitmap\n");
+       return -1;
 }
 #endif
 
@@ -1102,12 +1130,48 @@ int video_display_bitmap (ulong bmp_image, int x, int y)
        }
 #endif
 
-       /* We handle only 8bpp or 24 bpp bitmap */
+       /* We handle only 4, 8, or 24 bpp bitmaps */
        switch (le16_to_cpu (bmp->header.bit_count)) {
+       case 4:
+               padded_line -= width / 2;
+               ycount = height;
+
+               switch (VIDEO_DATA_FORMAT) {
+               case GDF_32BIT_X888RGB:
+                       while (ycount--) {
+                               WATCHDOG_RESET ();
+                               /*
+                                * Don't assume that 'width' is an
+                                * even number
+                                */
+                               for (xcount = 0; xcount < width; xcount++) {
+                                       uchar idx;
+
+                                       if (xcount & 1) {
+                                               idx = *bmap & 0xF;
+                                               bmap++;
+                                       } else
+                                               idx = *bmap >> 4;
+                                       cte = bmp->color_table[idx];
+                                       FILL_32BIT_X888RGB(cte.red, cte.green,
+                                                          cte.blue);
+                               }
+                               bmap += padded_line;
+                               fb -= (VIDEO_VISIBLE_COLS + width) *
+                                     VIDEO_PIXEL_SIZE;
+                       }
+                       break;
+               default:
+                       puts("4bpp bitmap unsupported with current "
+                            "video mode\n");
+                       break;
+               }
+               break;
+
        case 8:
                padded_line -= width;
                if (VIDEO_DATA_FORMAT == GDF__8BIT_INDEX) {
-                       /* Copy colormap                                             */
+                       /* Copy colormap */
                        for (xcount = 0; xcount < colors; ++xcount) {
                                cte = bmp->color_table[xcount];
                                video_set_lut (xcount, cte.red, cte.green, cte.blue);
@@ -1309,11 +1373,11 @@ void logo_plot (void *screen, int width, int x, int y)
 #ifdef CONFIG_VIDEO_BMP_LOGO
        source = bmp_logo_bitmap;
 
-       /* Allocate temporary space for computing colormap                       */
+       /* Allocate temporary space for computing colormap */
        logo_red = malloc (BMP_LOGO_COLORS);
        logo_green = malloc (BMP_LOGO_COLORS);
        logo_blue = malloc (BMP_LOGO_COLORS);
-       /* Compute color map                                                     */
+       /* Compute color map */
        for (i = 0; i < VIDEO_LOGO_COLORS; i++) {
                logo_red[i] = (bmp_logo_palette[i] & 0x0f00) >> 4;
                logo_green[i] = (bmp_logo_palette[i] & 0x00f0);
@@ -1395,7 +1459,6 @@ void logo_plot (void *screen, int width, int x, int y)
 static void *video_logo (void)
 {
        char info[128];
-       extern char version_string;
        int space, len, y_off = 0;
 
 #ifdef CONFIG_SPLASH_SCREEN
@@ -1431,7 +1494,7 @@ static void *video_logo (void)
 
        logo_plot (video_fb_address, VIDEO_COLS, 0, 0);
 
-       sprintf (info, " %s", &version_string);
+       sprintf (info, " %s", version_string);
 
        space = (VIDEO_LINE_LEN / 2 - VIDEO_INFO_X) / VIDEO_FONT_WIDTH;
        len = strlen(info);