]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/lcd.c
Fix memory commands for 64-bit platforms
[karo-tx-uboot.git] / common / lcd.c
index 3a60484eea615a4f20bd78109f738de26478c88f..aa81522fffef5e763dfbcb1f89b46d55ac0e1911 100644 (file)
@@ -4,23 +4,7 @@
  * (C) Copyright 2001-2002
  * Wolfgang Denk, DENX Software Engineering -- wd@denx.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+
  */
 
 /************************************************************************/
@@ -42,6 +26,8 @@
 #endif
 #include <lcd.h>
 #include <watchdog.h>
+#include <asm/unaligned.h>
+#include <splash.h>
 
 #if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \
        defined(CONFIG_CPU_MONAHANS)
@@ -65,7 +51,6 @@
 /* ** FONT DATA                                                                */
 /************************************************************************/
 #include <video_font.h>                /* Get font data, width and height      */
-#include <video_font_data.h>
 
 /************************************************************************/
 /* ** LOGO DATA                                                                */
@@ -401,8 +386,13 @@ static void test_pattern(void)
 /************************************************************************/
 /* ** GENERIC Initialization Routines                                  */
 /************************************************************************/
-
-int lcd_get_size(int *line_length)
+/*
+ * With most lcd drivers the line length is set up
+ * by calculating it from panel_info parameters. Some
+ * drivers need to calculate the line length differently,
+ * so make the function weak to allow overriding it.
+ */
+__weak int lcd_get_size(int *line_length)
 {
        *line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8;
        return *line_length * panel_info.vl_row;
@@ -510,7 +500,6 @@ static int lcd_init(void *lcdbase)
        debug("[LCD] Using LCD frambuffer at %p\n", lcd_base);
 
        lcd_get_size(&lcd_line_length);
-       lcd_line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8;
        lcd_is_enabled = 1;
        lcd_clear();
        lcd_enable();
@@ -788,9 +777,9 @@ static void lcd_display_rle8_bitmap(bmp_image_t *bmp, ushort *cmap, uchar *fb,
        int x, y;
        int decode = 1;
 
-       width = le32_to_cpu(bmp->header.width);
-       height = le32_to_cpu(bmp->header.height);
-       bmap = (uchar *)bmp + le32_to_cpu(bmp->header.data_offset);
+       width = get_unaligned_le32(&bmp->header.width);
+       height = get_unaligned_le32(&bmp->header.height);
+       bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
 
        x = 0;
        y = height - 1;
@@ -911,9 +900,10 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                return 1;
        }
 
-       width = le32_to_cpu(bmp->header.width);
-       height = le32_to_cpu(bmp->header.height);
-       bmp_bpix = le16_to_cpu(bmp->header.bit_count);
+       width = get_unaligned_le32(&bmp->header.width);
+       height = get_unaligned_le32(&bmp->header.height);
+       bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);
+
        colors = 1 << bmp_bpix;
 
        bpix = NBITS(panel_info.vl_bpix);
@@ -928,9 +918,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        /* We support displaying 8bpp BMPs on 16bpp LCDs */
        if (bpix != bmp_bpix && !(bmp_bpix == 8 && bpix == 16)) {
                printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
-                       bpix,
-                       le16_to_cpu(bmp->header.bit_count));
-
+                       bpix, get_unaligned_le16(&bmp->header.bit_count));
                return 1;
        }
 
@@ -967,7 +955,6 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                }
        }
 #endif
-
        /*
         *  BMP format for Monochrome assumes that the state of a
         * pixel is described on a per Bit basis, not per Byte.
@@ -998,15 +985,16 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        if ((y + height) > panel_info.vl_row)
                height = panel_info.vl_row - y;
 
-       bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset);
-       fb   = (uchar *) (lcd_base +
+       bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
+       fb   = (uchar *)(lcd_base +
                (y + height - 1) * lcd_line_length + x * bpix / 8);
 
        switch (bmp_bpix) {
        case 1: /* pass through */
        case 8:
 #ifdef CONFIG_LCD_BMP_RLE8
-               if (le32_to_cpu(bmp->header.compression) == BMP_BI_RLE8) {
+               u32 compression = get_unaligned_le32(&bmp->header.compression);
+               if (compression == BMP_BI_RLE8) {
                        if (bpix != 16) {
                                /* TODO implement render code for bpix != 16 */
                                printf("Error: only support 16 bpix");
@@ -1072,18 +1060,6 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 }
 #endif
 
-#ifdef CONFIG_SPLASH_SCREEN_PREPARE
-static inline int splash_screen_prepare(void)
-{
-       return board_splash_screen_prepare();
-}
-#else
-static inline int splash_screen_prepare(void)
-{
-       return 0;
-}
-#endif
-
 static void *lcd_logo(void)
 {
 #ifdef CONFIG_SPLASH_SCREEN
@@ -1096,26 +1072,11 @@ static void *lcd_logo(void)
                do_splash = 0;
 
                if (splash_screen_prepare())
-                       return (void *)gd->fb_base;
+                       return (void *)lcd_base;
 
                addr = simple_strtoul (s, NULL, 16);
-#ifdef CONFIG_SPLASH_SCREEN_ALIGN
-               s = getenv("splashpos");
-               if (s != NULL) {
-                       if (s[0] == 'm')
-                               x = BMP_ALIGN_CENTER;
-                       else
-                               x = simple_strtol(s, NULL, 0);
-
-                       s = strchr(s + 1, ',');
-                       if (s != NULL) {
-                               if (s[1] == 'm')
-                                       y = BMP_ALIGN_CENTER;
-                               else
-                                       y = simple_strtol (s + 1, NULL, 0);
-                       }
-               }
-#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
+
+               splash_get_pos(&x, &y);
 
                if (bmp_display(addr, x, y) == 0)
                        return (void *)lcd_base;
@@ -1193,7 +1154,7 @@ static int lcd_dt_simplefb_configure_node(void *blob, int off)
        u32 stride;
        fdt32_t cells[2];
        int ret;
-       const char format[] =
+       static const char format[] =
 #if LCD_BPP == LCD_COLOR16
                "r5g6b5";
 #else
@@ -1239,8 +1200,8 @@ static int lcd_dt_simplefb_configure_node(void *blob, int off)
 
 int lcd_dt_simplefb_add_node(void *blob)
 {
-       const char compat[] = "simple-framebuffer";
-       const char disabled[] = "disabled";
+       static const char compat[] = "simple-framebuffer";
+       static const char disabled[] = "disabled";
        int off, ret;
 
        off = fdt_add_subnode(blob, 0, "framebuffer");