]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/video/cfb_console.c
karo: tx6ul: make board string dependent on cpurev
[karo-tx-uboot.git] / drivers / video / cfb_console.c
index e384b71401f8c144bd80e647460ea394a59971a2..aa7ca8646db1a0527122974373d4ac58fc4cddf2 100644 (file)
@@ -2,23 +2,7 @@
  * (C) Copyright 2002 ELTEC Elektronik AG
  * Frank Gottschling <fgottschling@eltec.de>
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
  */
 
 #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
 #include <linux/types.h>
 #include <stdio_dev.h>
 #include <video_font.h>
-#include <video_font_data.h>
 
 #if defined(CONFIG_CMD_DATE)
 #include <rtc.h>
@@ -312,9 +283,10 @@ void console_cursor(int state);
 
 #define VIDEO_COLS             VIDEO_VISIBLE_COLS
 #define VIDEO_ROWS             VIDEO_VISIBLE_ROWS
-#define VIDEO_SIZE             (VIDEO_ROWS*VIDEO_COLS*VIDEO_PIXEL_SIZE)
-#define VIDEO_PIX_BLOCKS       (VIDEO_SIZE >> 2)
-#define VIDEO_LINE_LEN         (VIDEO_COLS*VIDEO_PIXEL_SIZE)
+#ifndef VIDEO_LINE_LEN
+#define VIDEO_LINE_LEN         (VIDEO_COLS * VIDEO_PIXEL_SIZE)
+#endif
+#define VIDEO_SIZE             (VIDEO_ROWS * VIDEO_LINE_LEN)
 #define VIDEO_BURST_LEN                (VIDEO_COLS/8)
 
 #ifdef CONFIG_VIDEO_LOGO
@@ -329,7 +301,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
@@ -447,6 +423,16 @@ static const int video_font_draw_table32[16][4] = {
        {0x00ffffff, 0x00ffffff, 0x00ffffff, 0x00ffffff}
 };
 
+/*
+ * Implement a weak default function for boards that optionally
+ * need to skip the cfb initialization.
+ */
+__weak int board_cfb_skip(void)
+{
+       /* As default, don't skip cfb init */
+       return 0;
+}
+
 static void video_drawchars(int xx, int yy, unsigned char *s, int count)
 {
        u8 *cdat, *dest, *dest0;
@@ -468,6 +454,10 @@ static void video_drawchars(int xx, int yy, unsigned char *s, int count)
                                ((u32 *) dest)[0] =
                                        (video_font_draw_table8[bits >> 4] &
                                         eorx) ^ bgx;
+
+                               if (VIDEO_FONT_WIDTH == 4)
+                                       continue;
+
                                ((u32 *) dest)[1] =
                                        (video_font_draw_table8[bits & 15] &
                                         eorx) ^ bgx;
@@ -493,6 +483,10 @@ static void video_drawchars(int xx, int yy, unsigned char *s, int count)
                                        SHORTSWAP32((video_font_draw_table15
                                                     [bits >> 4 & 3] & eorx) ^
                                                    bgx);
+
+                               if (VIDEO_FONT_WIDTH == 4)
+                                       continue;
+
                                ((u32 *) dest)[2] =
                                        SHORTSWAP32((video_font_draw_table15
                                                     [bits >> 2 & 3] & eorx) ^
@@ -523,6 +517,10 @@ static void video_drawchars(int xx, int yy, unsigned char *s, int count)
                                        SHORTSWAP32((video_font_draw_table16
                                                     [bits >> 4 & 3] & eorx) ^
                                                    bgx);
+
+                               if (VIDEO_FONT_WIDTH == 4)
+                                       continue;
+
                                ((u32 *) dest)[2] =
                                        SHORTSWAP32((video_font_draw_table16
                                                     [bits >> 2 & 3] & eorx) ^
@@ -557,6 +555,11 @@ static void video_drawchars(int xx, int yy, unsigned char *s, int count)
                                ((u32 *) dest)[3] =
                                        SWAP32((video_font_draw_table32
                                                [bits >> 4][3] & eorx) ^ bgx);
+
+
+                               if (VIDEO_FONT_WIDTH == 4)
+                                       continue;
+
                                ((u32 *) dest)[4] =
                                        SWAP32((video_font_draw_table32
                                                [bits & 15][0] & eorx) ^ bgx);
@@ -592,6 +595,10 @@ static void video_drawchars(int xx, int yy, unsigned char *s, int count)
                                ((u32 *) dest)[2] =
                                        (video_font_draw_table24[bits >> 4][2]
                                         & eorx) ^ bgx;
+
+                               if (VIDEO_FONT_WIDTH == 4)
+                                       continue;
+
                                ((u32 *) dest)[3] =
                                        (video_font_draw_table24[bits & 15][0]
                                         & eorx) ^ bgx;
@@ -739,26 +746,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)
@@ -870,9 +884,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;
        }
 }
 
@@ -930,7 +941,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;
@@ -1144,12 +1155,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);
+       }
 }
 
 /*
@@ -1157,14 +1177,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)        {                       \
@@ -1279,7 +1296,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;
@@ -1288,9 +1305,9 @@ 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 limit = (VIDEO_LINE_LEN / VIDEO_PIXEL_SIZE) * VIDEO_ROWS;
        int pixels = 0;
 
        x = 0;
@@ -1298,7 +1315,8 @@ static int display_rle8_bitmap(bmp_image_t *img, int xoff, int yoff,
        ncolors = __le32_to_cpu(img->header.colors_used);
        bpp = VIDEO_PIXEL_SIZE;
        fbp = (unsigned char *) ((unsigned int) video_fb_address +
-                                (((y + yoff) * VIDEO_COLS) + xoff) * bpp);
+                                (y + yoff) * VIDEO_LINE_LEN +
+                                xoff * bpp);
 
        bm = (uchar *) img + __le32_to_cpu(img->header.data_offset);
 
@@ -1352,8 +1370,8 @@ static int display_rle8_bitmap(bmp_image_t *img, int xoff, int yoff,
                                y--;
                                fbp = (unsigned char *)
                                        ((unsigned int) video_fb_address +
-                                        (((y + yoff) * VIDEO_COLS) +
-                                         xoff) * bpp);
+                                        (y + yoff) * VIDEO_LINE_LEN +
+                                        xoff * bpp);
                                continue;
                        case 1:
                                /* end of bitmap data marker */
@@ -1365,8 +1383,8 @@ static int display_rle8_bitmap(bmp_image_t *img, int xoff, int yoff,
                                y -= bm[3];
                                fbp = (unsigned char *)
                                        ((unsigned int) video_fb_address +
-                                        (((y + yoff) * VIDEO_COLS) +
-                                         x + xoff) * bpp);
+                                        (y + yoff) * VIDEO_LINE_LEN +
+                                        xoff * bpp);
                                bm += 4;
                                break;
                        default:
@@ -1431,13 +1449,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;
@@ -1459,7 +1477,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",
@@ -1475,7 +1497,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'))) {
@@ -1517,14 +1539,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 */
 
        /*
@@ -1541,7 +1563,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 
        bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset);
        fb = (uchar *) (video_fb_address +
-                       ((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) +
+                       ((y + height - 1) * VIDEO_LINE_LEN) +
                        x * VIDEO_PIXEL_SIZE);
 
 #ifdef CONFIG_VIDEO_BMP_RLE8
@@ -1577,7 +1599,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                                           cte.blue);
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
+                               fb -= VIDEO_LINE_LEN + width *
                                        VIDEO_PIXEL_SIZE;
                        }
                        break;
@@ -1608,8 +1630,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                        *fb++ = *bmap++;
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                case GDF__8BIT_332RGB:
@@ -1622,8 +1644,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                                         cte.blue);
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                case GDF_15BIT_555RGB:
@@ -1646,8 +1668,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 #endif
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                case GDF_16BIT_565RGB:
@@ -1660,8 +1682,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                                          cte.blue);
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                case GDF_32BIT_X888RGB:
@@ -1674,8 +1696,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                                           cte.blue);
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                case GDF_24BIT_888RGB:
@@ -1688,8 +1710,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                                          cte.blue);
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                }
@@ -1708,8 +1730,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                        bmap += 3;
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                case GDF_15BIT_555RGB:
@@ -1731,8 +1753,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                        bmap += 3;
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                case GDF_16BIT_565RGB:
@@ -1745,8 +1767,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                        bmap += 3;
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                case GDF_32BIT_X888RGB:
@@ -1759,8 +1781,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                        bmap += 3;
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                case GDF_24BIT_888RGB:
@@ -1773,8 +1795,8 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
                                        bmap += 3;
                                }
                                bmap += padded_line;
-                               fb -= (VIDEO_VISIBLE_COLS + width) *
-                                                       VIDEO_PIXEL_SIZE;
+                               fb -= VIDEO_LINE_LEN + width *
+                                       VIDEO_PIXEL_SIZE;
                        }
                        break;
                default:
@@ -1806,20 +1828,16 @@ int video_display_bitmap(ulong bmp_image, int x, int y)
 static int video_logo_xpos;
 static int video_logo_ypos;
 
-static void plot_logo_or_black(void *screen, int width, int x, int y,  \
-                       int black);
+static void plot_logo_or_black(void *screen, int x, int y, int black);
 
-static void logo_plot(void *screen, int width, int x, int y)
+static void logo_plot(void *screen, int x, int y)
 {
-       plot_logo_or_black(screen, width, x, y, 0);
+       plot_logo_or_black(screen, x, y, 0);
 }
 
 static void logo_black(void)
 {
-       plot_logo_or_black(video_fb_address, \
-                       VIDEO_COLS, \
-                       video_logo_xpos, \
-                       video_logo_ypos, \
+       plot_logo_or_black(video_fb_address, video_logo_xpos, video_logo_ypos,
                        1);
 }
 
@@ -1838,11 +1856,11 @@ U_BOOT_CMD(
           " "
           );
 
-static void plot_logo_or_black(void *screen, int width, int x, int y, int black)
+static void plot_logo_or_black(void *screen, int x, int y, int black)
 {
 
        int xcount, i;
-       int skip = (width - VIDEO_LOGO_WIDTH) * VIDEO_PIXEL_SIZE;
+       int skip = VIDEO_LINE_LEN - VIDEO_LOGO_WIDTH * VIDEO_PIXEL_SIZE;
        int ycount = video_logo_height;
        unsigned char r, g, b, *logo_red, *logo_blue, *logo_green;
        unsigned char *source;
@@ -1850,17 +1868,17 @@ 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;
+       dest = (unsigned char *)screen + y * VIDEO_LINE_LEN + x * VIDEO_PIXEL_SIZE;
 
 #ifdef CONFIG_VIDEO_BMP_LOGO
        source = bmp_logo_bitmap;
@@ -1989,8 +2007,7 @@ static void *video_logo(void)
        }
 #endif /* CONFIG_SPLASH_SCREEN */
 
-       logo_plot(video_fb_address, VIDEO_COLS,
-                 video_logo_xpos, video_logo_ypos);
+       logo_plot(video_fb_address, video_logo_xpos, video_logo_ypos);
 
 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
        /*
@@ -2004,7 +2021,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;
@@ -2012,6 +2029,8 @@ static void *video_logo(void)
                return video_fb_address + video_logo_height * VIDEO_LINE_LEN;
        }
 #endif
+       if (board_cfb_skip())
+               return 0;
 
        sprintf(info, " %s", version_string);
 
@@ -2092,6 +2111,24 @@ defined(CONFIG_SANDBOX) || defined(CONFIG_X86)
        return 0;
 }
 
+void video_clear(void)
+{
+       if (!video_fb_address)
+               return;
+#ifdef VIDEO_HW_RECTFILL
+       video_hw_rectfill(VIDEO_PIXEL_SIZE,     /* bytes per pixel */
+                         0,                    /* dest pos x */
+                         0,                    /* dest pos y */
+                         VIDEO_VISIBLE_COLS,   /* frame width */
+                         VIDEO_VISIBLE_ROWS,   /* frame height */
+                         bgx                   /* fill color */
+       );
+#else
+       memsetl(video_fb_address,
+               (VIDEO_VISIBLE_ROWS * VIDEO_LINE_LEN) / sizeof(int), bgx);
+#endif
+}
+
 static int video_init(void)
 {
        unsigned char color8;
@@ -2178,6 +2215,8 @@ static int video_init(void)
        }
        eorx = fgx ^ bgx;
 
+       video_clear();
+
 #ifdef CONFIG_VIDEO_LOGO
        /* Plot the logo and get start point of console */
        debug("Video: Drawing the logo ...\n");
@@ -2200,34 +2239,43 @@ 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;
+       bool __maybe_unused keyboard_ok = false;
 
        /* Check if video initialization should be skipped */
        if (board_video_skip())
                return 0;
 
        /* Init video chip - returns with framebuffer cleared */
-       skip_dev_init = (video_init() == -1);
+       if (video_init() == -1)
+               return 0;
 
+       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);
+               keyboard_ok = !(VIDEO_KBD_INIT_FCT == -1);
 #endif
-
-       if (skip_dev_init)
-               return 0;
+       }
 
        /* Init vga device */
        memset(&console_dev, 0, sizeof(console_dev));
@@ -2236,15 +2284,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 && keyboard_ok) {
+               /* 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;
@@ -2278,21 +2326,3 @@ int video_get_screen_columns(void)
 {
        return CONSOLE_COLS;
 }
-
-void video_clear(void)
-{
-       if (!video_fb_address)
-               return;
-#ifdef VIDEO_HW_RECTFILL
-       video_hw_rectfill(VIDEO_PIXEL_SIZE,     /* bytes per pixel */
-                         0,                    /* dest pos x */
-                         0,                    /* dest pos y */
-                         VIDEO_VISIBLE_COLS,   /* frame width */
-                         VIDEO_VISIBLE_ROWS,   /* frame height */
-                         bgx                   /* fill color */
-       );
-#else
-       memsetl(video_fb_address,
-               (VIDEO_VISIBLE_ROWS * VIDEO_LINE_LEN) / sizeof(int), bgx);
-#endif
-}