]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
lcd: split splash code into its own function
authorNikita Kiryanov <nikita@compulab.co.il>
Tue, 3 Feb 2015 11:32:32 +0000 (13:32 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 1 Sep 2015 11:50:43 +0000 (13:50 +0200)
lcd_logo() currently performs tasks well beyond just displaying the logo.
It has code which displays splash image, it has logic which determines
when the different display features are displayed, and it is coupled with
the lcd console because it holds the responsibility of returning the
lcd console base address.

Make lcd_logo() just about the logo by:
* Moving splash image display code into a dedicated function
* Moving the logic regarding when various features are displayed to
  lcd_clear() (which is arguably not the correct name for housing such
  code either, but it is currently the most fitting location code wise)
* Move the responsibility of setting the console base address to
  lcd_clear() too.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Bo Shen <voice.shen@atmel.com>
Tested-by: Josh Wu <josh.wu@atmel.com>
Cc: Bo Shen <voice.shen@atmel.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Anatolij Gustschin <agust@denx.de>
common/lcd.c
common/splash.c
include/splash.h

index 01125fdbb907958ff891d2a433a178bbabbbbf40..0c28f48e1465b053efb2ade407569e5b4ef48430 100644 (file)
@@ -46,7 +46,7 @@
 DECLARE_GLOBAL_DATA_PTR;
 
 static int lcd_init(void *lcdbase);
-static void *lcd_logo(void);
+static void lcd_logo(void);
 static void lcd_setfgcolor(int color);
 static void lcd_setbgcolor(int color);
 
@@ -179,6 +179,9 @@ void lcd_clear(void)
 {
        short console_rows, console_cols;
        int bg_color;
+       char *s;
+       ulong addr;
+       static int do_splash = 1;
 #if LCD_BPP == LCD_COLOR8
        /* Setting the palette */
        lcd_setcolreg(CONSOLE_COLOR_BLACK, 0, 0, 0);
@@ -228,7 +231,23 @@ void lcd_clear(void)
 #endif
        console_cols = panel_info.vl_col / VIDEO_FONT_WIDTH;
        lcd_init_console(lcd_base, console_rows, console_cols);
-       lcd_init_console(lcd_logo(), console_rows, console_cols);
+       if (do_splash) {
+               s = getenv("splashimage");
+               if (s) {
+                       do_splash = 0;
+                       addr = simple_strtoul(s, NULL, 16);
+                       if (lcd_splash(addr) == 0) {
+                               lcd_sync();
+                               return;
+                       }
+               }
+       }
+
+       lcd_logo();
+#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
+       addr = (ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length;
+       lcd_init_console((void *)addr, console_rows, console_cols);
+#endif
        lcd_sync();
 }
 
@@ -740,33 +759,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 }
 #endif
 
-static void *lcd_logo(void)
+static void lcd_logo(void)
 {
-#ifdef CONFIG_SPLASH_SCREEN
-       char *s;
-       ulong addr;
-       static int do_splash = 1;
-
-       if (do_splash && (s = getenv("splashimage")) != NULL) {
-               int x = 0, y = 0;
-               char *end;
-
-               do_splash = 0;
-
-               if (splash_screen_prepare())
-                       return (void *)lcd_base;
-
-               addr = simple_strtoul (s, &end, 16);
-               if (addr == 0 || *end != '\0')
-                       return lcd_base;
-
-               splash_get_pos(&x, &y);
-
-               if (bmp_display(addr, x, y) == 0)
-                       return (void *)lcd_base;
-       }
-#endif /* CONFIG_SPLASH_SCREEN */
-
        lcd_logo_plot(0, 0);
 
 #ifdef CONFIG_LCD_INFO
@@ -774,12 +768,6 @@ static void *lcd_logo(void)
        lcd_set_row(LCD_INFO_Y / VIDEO_FONT_HEIGHT);
        lcd_show_board_info();
 #endif /* CONFIG_LCD_INFO */
-
-#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
-       return lcd_base + BMP_LOGO_HEIGHT * lcd_line_length;
-#else
-       return lcd_base;
-#endif /* CONFIG_LCD_LOGO && !CONFIG_LCD_INFO_BELOW_LOGO */
 }
 
 #ifdef CONFIG_SPLASHIMAGE_GUARD
index 144fb10ddda36d1855d72ac8ac312e29346cc45b..561d35b4e41f9072d84e430d028e92ec8aecd8c3 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <common.h>
 #include <splash.h>
+#include <lcd.h>
 
 __weak int splash_screen_prepare(void)
 {
@@ -50,3 +51,18 @@ void splash_get_pos(int *x, int *y)
        }
 }
 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
+
+#if defined(CONFIG_SPLASH_SCREEN) && defined(CONFIG_LCD)
+int lcd_splash(ulong addr)
+{
+       int x = 0, y = 0, ret;
+
+       ret = splash_screen_prepare();
+       if (ret)
+               return ret;
+
+       splash_get_pos(&x, &y);
+
+       return bmp_display(addr, x, y);
+}
+#endif
index a60e89542343532b2356d86f0215f30d53e228c6..1b98ac40eec97a22a38170013fa72778c3a0055d 100644 (file)
@@ -21,6 +21,7 @@
 
 #ifndef _SPLASH_H_
 #define _SPLASH_H_
+#include <errno.h>
 
 enum splash_storage {
        SPLASH_STORAGE_NAND,
@@ -42,6 +43,15 @@ void splash_get_pos(int *x, int *y);
 static inline void splash_get_pos(int *x, int *y) { }
 #endif
 
+#if defined(CONFIG_SPLASH_SCREEN) && defined(CONFIG_LCD)
+int lcd_splash(ulong addr);
+#else
+static inline int lcd_splash(ulong addr)
+{
+       return -ENOSYS;
+}
+#endif
+
 #define BMP_ALIGN_CENTER       0x7FFF
 
 #endif