video: omap: fix pixel-per-line bitfield setting
[oweals/u-boot.git] / drivers / video / cfb_console.c
index 3c0696eb118d074403a6d7ea96dcde6bcc4ede63..5442bac4c6f3f294b8c9ac60855a035b04177ab6 100644 (file)
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2002 ELTEC Elektronik AG
  * Frank Gottschling <fgottschling@eltec.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
  */
 
 #include <common.h>
+#include <cpu_func.h>
+#include <env.h>
 #include <fdtdec.h>
+#include <gzip.h>
 #include <version.h>
 #include <malloc.h>
 #include <video.h>
 #include <linux/compiler.h>
 
-/*
- * Defines for the CT69000 driver
- */
-#ifdef CONFIG_VIDEO_CT69000
-
-#define VIDEO_FB_LITTLE_ENDIAN
-#define VIDEO_HW_RECTFILL
-#define VIDEO_HW_BITBLT
-#endif
-
 #if defined(CONFIG_VIDEO_MXS)
 #define VIDEO_FB_16BPP_WORD_SWAP
 #endif
@@ -778,7 +770,7 @@ static void parse_putc(const char c)
                break;
 
        case '\n':              /* next line */
-               if (console_col || (!console_col && nl))
+               if (console_col || nl)
                        console_newline(1);
                nl = 1;
                break;
@@ -1079,8 +1071,8 @@ __weak void video_set_lut(unsigned int index, unsigned char r,
 }
 
 #define FILL_32BIT_X888RGB(r,g,b) {                    \
-       *(unsigned long *)fb =                          \
-               SWAP32((unsigned long)(((r<<16) |       \
+       *(u32 *)fb =                            \
+               SWAP32((unsigned int)(((r<<16) |        \
                                        (g<<8)  |       \
                                         b)));          \
        fb += 4;                                        \
@@ -1161,7 +1153,7 @@ static void draw_bitmap(uchar **fb, uchar *bm, struct palette *p,
                break;
        case GDF_32BIT_X888RGB:
                for (i = 0; i < cnt; i++) {
-                       *(unsigned long *) addr = p[bm[*off]].ce.dw;
+                       *(u32 *) addr = p[bm[*off]].ce.dw;
                        addr += 4;
                }
                break;
@@ -1308,6 +1300,10 @@ next_run:
                        break;
                }
        }
+
+       if (cfb_do_flush_cache)
+               flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
+
        return 0;
 error:
        printf("Error: Too much encoded pixel data, validate your bitmap\n");
@@ -1825,8 +1821,8 @@ static void plot_logo_or_black(void *screen, int x, int y, int black)
                                                         (b >> 3)));
                                break;
                        case GDF_32BIT_X888RGB:
-                               *(unsigned long *) dest =
-                                       SWAP32((unsigned long) (
+                               *(u32 *) dest =
+                                       SWAP32((u32) (
                                                        (r << 16) |
                                                        (g <<  8) |
                                                         b));
@@ -1866,7 +1862,7 @@ static void *video_logo(void)
        splash_get_pos(&video_logo_xpos, &video_logo_ypos);
 
 #ifdef CONFIG_SPLASH_SCREEN
-       s = getenv("splashimage");
+       s = env_get("splashimage");
        if (s != NULL) {
                ret = splash_screen_prepare();
                if (ret < 0)
@@ -1910,16 +1906,32 @@ static void *video_logo(void)
        sprintf(info, " %s", version_string);
 
 #ifndef CONFIG_HIDE_LOGO_VERSION
-       space = (VIDEO_LINE_LEN / 2 - VIDEO_INFO_X) / VIDEO_FONT_WIDTH;
+       space = (VIDEO_COLS - VIDEO_INFO_X) / VIDEO_FONT_WIDTH;
        len = strlen(info);
 
        if (len > space) {
-               video_drawchars(VIDEO_INFO_X, VIDEO_INFO_Y,
-                               (uchar *) info, space);
-               video_drawchars(VIDEO_INFO_X + VIDEO_FONT_WIDTH,
-                               VIDEO_INFO_Y + VIDEO_FONT_HEIGHT,
-                               (uchar *) info + space, len - space);
-               y_off = 1;
+               int xx = VIDEO_INFO_X, yy = VIDEO_INFO_Y;
+               uchar *p = (uchar *) info;
+
+               while (len) {
+                       if (len > space) {
+                               video_drawchars(xx, yy, p, space);
+                               len -= space;
+
+                               p = (uchar *)p + space;
+
+                               if (!y_off) {
+                                       xx += VIDEO_FONT_WIDTH;
+                                       space--;
+                               }
+                               yy += VIDEO_FONT_HEIGHT;
+
+                               y_off++;
+                       } else {
+                               video_drawchars(xx, yy, p, len);
+                               len = 0;
+                       }
+               }
        } else
                video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *) info);
 
@@ -1968,7 +1980,7 @@ static void *video_logo(void)
 static int cfb_fb_is_in_dram(void)
 {
        bd_t *bd = gd->bd;
-#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) || defined(CONFIG_NDS32) || \
+#if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || \
 defined(CONFIG_SANDBOX) || defined(CONFIG_X86)
        ulong start, end;
        int i;
@@ -2091,7 +2103,8 @@ static int cfg_video_init(void)
        }
        eorx = fgx ^ bgx;
 
-       video_clear();
+       if (!CONFIG_IS_ENABLED(NO_FB_CLEAR))
+               video_clear();
 
 #ifdef CONFIG_VIDEO_LOGO
        /* Plot the logo and get start point of console */