]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/video/cfb_console.c
ARM: bcm283x: Allocate all mailbox buffers cacheline aligned
[karo-tx-uboot.git] / drivers / video / cfb_console.c
index 6db40735961e934a2f57e82c0a1dfe3f77037e9d..7f2ddc10c62b88e519c29fb14627c1e237db3c85 100644 (file)
@@ -87,6 +87,7 @@
  */
 
 #include <common.h>
+#include <fdtdec.h>
 #include <version.h>
 #include <malloc.h>
 #include <linux/compiler.h>
  * Defines for the SED13806 driver
  */
 #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
-
 #ifdef CONFIG_VIDEO_MXS
 #define VIDEO_FB_16BPP_WORD_SWAP
 #endif
@@ -312,7 +300,11 @@ void console_cursor(int state);
 #define CONSOLE_ROW_SECOND     (video_console_address + CONSOLE_ROW_SIZE)
 #define CONSOLE_ROW_LAST       (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE)
 #define CONSOLE_SIZE           (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
-#define CONSOLE_SCROLL_SIZE    (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
+
+/* By default we scroll by a single line */
+#ifndef CONFIG_CONSOLE_SCROLL_LINES
+#define CONFIG_CONSOLE_SCROLL_LINES 1
+#endif
 
 /* Macros */
 #ifdef VIDEO_FB_LITTLE_ENDIAN
@@ -753,26 +745,33 @@ static void console_clear_line(int line, int begin, int end)
 
 static void console_scrollup(void)
 {
+       const int rows = CONFIG_CONSOLE_SCROLL_LINES;
+       int i;
+
        /* copy up rows ignoring the first one */
 
 #ifdef VIDEO_HW_BITBLT
        video_hw_bitblt(VIDEO_PIXEL_SIZE,       /* bytes per pixel */
                        0,                      /* source pos x */
                        video_logo_height +
-                               VIDEO_FONT_HEIGHT, /* source pos y */
+                               VIDEO_FONT_HEIGHT * rows, /* source pos y */
                        0,                      /* dest pos x */
                        video_logo_height,      /* dest pos y */
                        VIDEO_VISIBLE_COLS,     /* frame width */
                        VIDEO_VISIBLE_ROWS
                        - video_logo_height
-                       - VIDEO_FONT_HEIGHT     /* frame height */
+                       - VIDEO_FONT_HEIGHT * rows      /* frame height */
                );
 #else
-       memcpyl(CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND,
-               CONSOLE_SCROLL_SIZE >> 2);
+       memcpyl(CONSOLE_ROW_FIRST, CONSOLE_ROW_FIRST + rows * CONSOLE_ROW_SIZE,
+               (CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows) >> 2);
 #endif
        /* clear the last one */
-       console_clear_line(CONSOLE_ROWS - 1, 0, CONSOLE_COLS - 1);
+       for (i = 1; i <= rows; i++)
+               console_clear_line(CONSOLE_ROWS - i, 0, CONSOLE_COLS - 1);
+
+       /* Decrement row number */
+       console_row -= rows;
 }
 
 static void console_back(void)
@@ -884,9 +883,6 @@ static void console_newline(int n)
        if (console_row >= CONSOLE_ROWS) {
                /* Scroll everything up */
                console_scrollup();
-
-               /* Decrement row number */
-               console_row = CONSOLE_ROWS - 1;
        }
 }
 
@@ -944,7 +940,7 @@ static void parse_putc(const char c)
                CURSOR_SET;
 }
 
-void video_putc(const char c)
+static void video_putc(struct stdio_dev *dev, const char c)
 {
 #ifdef CONFIG_CFB_CONSOLE_ANSI
        int i;
@@ -1158,12 +1154,21 @@ void video_putc(const char c)
                flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
 }
 
-void video_puts(const char *s)
+static void video_puts(struct stdio_dev *dev, const char *s)
 {
+       int flush = cfb_do_flush_cache;
        int count = strlen(s);
 
+       /* temporarily disable cache flush */
+       cfb_do_flush_cache = 0;
+
        while (count--)
-               video_putc(*s++);
+               video_putc(dev, *s++);
+
+       if (flush) {
+               cfb_do_flush_cache = flush;
+               flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
+       }
 }
 
 /*
@@ -1171,14 +1176,11 @@ void video_puts(const char *s)
  * 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,
+__weak 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)        {                       \
@@ -1293,7 +1295,7 @@ static void draw_bitmap(uchar **fb, uchar *bm, struct palette *p,
        *fb = (uchar *) addr;   /* return modified address */
 }
 
-static int display_rle8_bitmap(bmp_image_t *img, int xoff, int yoff,
+static int display_rle8_bitmap(struct bmp_image *img, int xoff, int yoff,
                               int width, int height)
 {
        unsigned char *bm;
@@ -1302,7 +1304,7 @@ static int display_rle8_bitmap(bmp_image_t *img, int xoff, int yoff,
        int decode = 1;
        int x, y, bpp, i, ncolors;
        struct palette p[256];
-       bmp_color_table_entry_t cte;
+       struct bmp_color_table_entry cte;
        int green_shift, red_off;
        int limit = VIDEO_COLS * VIDEO_ROWS;
        int pixels = 0;
@@ -1445,13 +1447,13 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 {
        ushort xcount, ycount;
        uchar *fb;
-       bmp_image_t *bmp = (bmp_image_t *) bmp_image;
+       struct bmp_image *bmp = (struct bmp_image *)bmp_image;
        uchar *bmap;
        ushort padded_line;
        unsigned long width, height, bpp;
        unsigned colors;
        unsigned long compression;
-       bmp_color_table_entry_t cte;
+       struct bmp_color_table_entry cte;
 
 #ifdef CONFIG_VIDEO_BMP_GZIP
        unsigned char *dst = NULL;
@@ -1473,7 +1475,11 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                        printf("Error: malloc in gunzip failed!\n");
                        return 1;
                }
-               if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE,
+               /*
+                * NB: we need to force offset of +2
+                * See doc/README.displaying-bmps
+                */
+               if (gunzip(dst+2, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE-2,
                           (uchar *) bmp_image,
                           &len) != 0) {
                        printf("Error: no valid bmp or bmp.gz image at %lx\n",
@@ -1489,7 +1495,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                /*
                 * Set addr to decompressed image
                 */
-               bmp = (bmp_image_t *) dst;
+               bmp = (struct bmp_image *)(dst+2);
 
                if (!((bmp->header.signature[0] == 'B') &&
                      (bmp->header.signature[1] == 'M'))) {
@@ -1531,14 +1537,14 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 
 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
        if (x == BMP_ALIGN_CENTER)
-               x = max(0, (VIDEO_VISIBLE_COLS - width) / 2);
+               x = max(0, (int)(VIDEO_VISIBLE_COLS - width) / 2);
        else if (x < 0)
-               x = max(0, VIDEO_VISIBLE_COLS - width + x + 1);
+               x = max(0, (int)(VIDEO_VISIBLE_COLS - width + x + 1));
 
        if (y == BMP_ALIGN_CENTER)
-               y = max(0, (VIDEO_VISIBLE_ROWS - height) / 2);
+               y = max(0, (int)(VIDEO_VISIBLE_ROWS - height) / 2);
        else if (y < 0)
-               y = max(0, VIDEO_VISIBLE_ROWS - height + y + 1);
+               y = max(0, (int)(VIDEO_VISIBLE_ROWS - height + y + 1));
 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
 
        /*
@@ -1864,14 +1870,14 @@ static void plot_logo_or_black(void *screen, int width, int x, int y, int black)
 
 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
        if (x == BMP_ALIGN_CENTER)
-               x = max(0, (VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH) / 2);
+               x = max(0, (int)(VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH) / 2);
        else if (x < 0)
-               x = max(0, VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH + x + 1);
+               x = max(0, (int)(VIDEO_VISIBLE_COLS - VIDEO_LOGO_WIDTH + x + 1));
 
        if (y == BMP_ALIGN_CENTER)
-               y = max(0, (VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT) / 2);
+               y = max(0, (int)(VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT) / 2);
        else if (y < 0)
-               y = max(0, VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT + y + 1);
+               y = max(0, (int)(VIDEO_VISIBLE_ROWS - VIDEO_LOGO_HEIGHT + y + 1));
 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
 
        dest = (unsigned char *)screen + (y * width  + x) * VIDEO_PIXEL_SIZE;
@@ -2018,7 +2024,7 @@ static void *video_logo(void)
                 * we need to adjust the logo height
                 */
                if (video_logo_ypos == BMP_ALIGN_CENTER)
-                       video_logo_height += max(0, (VIDEO_VISIBLE_ROWS - \
+                       video_logo_height += max(0, (int)(VIDEO_VISIBLE_ROWS -
                                                     VIDEO_LOGO_HEIGHT) / 2);
                else if (video_logo_ypos > 0)
                        video_logo_height += video_logo_ypos;
@@ -2236,19 +2242,17 @@ static int video_init(void)
  * Implement a weak default function for boards that optionally
  * need to skip the video initialization.
  */
-int __board_video_skip(void)
+__weak int board_video_skip(void)
 {
        /* As default, don't skip test */
        return 0;
 }
 
-int board_video_skip(void)
-       __attribute__ ((weak, alias("__board_video_skip")));
-
 int drv_video_init(void)
 {
        int skip_dev_init;
        struct stdio_dev console_dev;
+       bool have_keyboard;
 
        /* Check if video initialization should be skipped */
        if (board_video_skip())
@@ -2260,11 +2264,20 @@ int drv_video_init(void)
        if (board_cfb_skip())
                return 0;
 
+#if defined(CONFIG_VGA_AS_SINGLE_DEVICE)
+       have_keyboard = false;
+#elif defined(CONFIG_OF_CONTROL)
+       have_keyboard = !fdtdec_get_config_bool(gd->fdt_blob,
+                                               "u-boot,no-keyboard");
+#else
+       have_keyboard = true;
+#endif
+       if (have_keyboard) {
+               debug("KBD: Keyboard init ...\n");
 #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
-       debug("KBD: Keyboard init ...\n");
-       skip_dev_init |= (VIDEO_KBD_INIT_FCT == -1);
+               skip_dev_init |= (VIDEO_KBD_INIT_FCT == -1);
 #endif
-
+       }
        if (skip_dev_init)
                return 0;
 
@@ -2275,15 +2288,15 @@ int drv_video_init(void)
        console_dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_SYSTEM;
        console_dev.putc = video_putc;  /* 'putc' function */
        console_dev.puts = video_puts;  /* 'puts' function */
-       console_dev.tstc = NULL;        /* 'tstc' function */
-       console_dev.getc = NULL;        /* 'getc' function */
 
 #if !defined(CONFIG_VGA_AS_SINGLE_DEVICE)
-       /* Also init console device */
-       console_dev.flags |= DEV_FLAGS_INPUT;
-       console_dev.tstc = VIDEO_TSTC_FCT;      /* 'tstc' function */
-       console_dev.getc = VIDEO_GETC_FCT;      /* 'getc' function */
-#endif /* CONFIG_VGA_AS_SINGLE_DEVICE */
+       if (have_keyboard) {
+               /* Also init console device */
+               console_dev.flags |= DEV_FLAGS_INPUT;
+               console_dev.tstc = VIDEO_TSTC_FCT;      /* 'tstc' function */
+               console_dev.getc = VIDEO_GETC_FCT;      /* 'getc' function */
+       }
+#endif
 
        if (stdio_register(&console_dev) != 0)
                return 0;