Commit ff8fb56b6f7edafc1bcba8ef008b3f368cabe60d

Authored by Anatolij Gustschin
1 parent 327598945b

video: consolidate splash screen alignment code

Code for checking "splashpos" environment variable is
duplicated in drivers, move it to the common function.
Call this function also in the bmp display command to
consider "splashpos" settings.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Acked-by: Otavio Salvador <otavio@ossystems.com.br>

Showing 5 changed files with 39 additions and 39 deletions Side-by-side Diff

... ... @@ -31,6 +31,7 @@
31 31 #include <command.h>
32 32 #include <asm/byteorder.h>
33 33 #include <malloc.h>
  34 +#include <splash.h>
34 35 #include <video.h>
35 36  
36 37 static int bmp_info (ulong addr);
... ... @@ -124,6 +125,8 @@
124 125 {
125 126 ulong addr;
126 127 int x = 0, y = 0;
  128 +
  129 + splash_get_pos(&x, &y);
127 130  
128 131 switch (argc) {
129 132 case 1: /* use load_addr as default address */
... ... @@ -1089,23 +1089,8 @@
1089 1089 return (void *)lcd_base;
1090 1090  
1091 1091 addr = simple_strtoul (s, NULL, 16);
1092   -#ifdef CONFIG_SPLASH_SCREEN_ALIGN
1093   - s = getenv("splashpos");
1094   - if (s != NULL) {
1095   - if (s[0] == 'm')
1096   - x = BMP_ALIGN_CENTER;
1097   - else
1098   - x = simple_strtol(s, NULL, 0);
1099 1092  
1100   - s = strchr(s + 1, ',');
1101   - if (s != NULL) {
1102   - if (s[1] == 'm')
1103   - y = BMP_ALIGN_CENTER;
1104   - else
1105   - y = simple_strtol (s + 1, NULL, 0);
1106   - }
1107   - }
1108   -#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
  1093 + splash_get_pos(&x, &y);
1109 1094  
1110 1095 if (bmp_display(addr, x, y) == 0)
1111 1096 return (void *)lcd_base;
... ... @@ -20,6 +20,7 @@
20 20 *
21 21 */
22 22  
  23 +#include <common.h>
23 24 #include <splash.h>
24 25  
25 26 int __splash_screen_prepare(void)
... ... @@ -29,4 +30,28 @@
29 30  
30 31 int splash_screen_prepare(void)
31 32 __attribute__ ((weak, alias("__splash_screen_prepare")));
  33 +
  34 +
  35 +#ifdef CONFIG_SPLASH_SCREEN_ALIGN
  36 +void splash_get_pos(int *x, int *y)
  37 +{
  38 + char *s = getenv("splashpos");
  39 +
  40 + if (!s)
  41 + return;
  42 +
  43 + if (s[0] == 'm')
  44 + *x = BMP_ALIGN_CENTER;
  45 + else
  46 + *x = simple_strtol(s, NULL, 0);
  47 +
  48 + s = strchr(s + 1, ',');
  49 + if (s != NULL) {
  50 + if (s[1] == 'm')
  51 + *y = BMP_ALIGN_CENTER;
  52 + else
  53 + *y = simple_strtol(s + 1, NULL, 0);
  54 + }
  55 +}
  56 +#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
drivers/video/cfb_console.c
... ... @@ -222,13 +222,9 @@
222 222 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
223 223 #include <watchdog.h>
224 224 #include <bmp_layout.h>
225   -
226   -#ifdef CONFIG_SPLASH_SCREEN_ALIGN
227   -#define BMP_ALIGN_CENTER 0x7FFF
  225 +#include <splash.h>
228 226 #endif
229 227  
230   -#endif
231   -
232 228 /*
233 229 * Cursor definition:
234 230 * CONFIG_CONSOLE_CURSOR: Uses a timer function (see drivers/input/i8042.c)
... ... @@ -1976,23 +1972,7 @@
1976 1972 __maybe_unused ulong addr;
1977 1973 __maybe_unused char *s;
1978 1974  
1979   -#ifdef CONFIG_SPLASH_SCREEN_ALIGN
1980   - s = getenv("splashpos");
1981   - if (s != NULL) {
1982   - if (s[0] == 'm')
1983   - video_logo_xpos = BMP_ALIGN_CENTER;
1984   - else
1985   - video_logo_xpos = simple_strtol(s, NULL, 0);
1986   -
1987   - s = strchr(s + 1, ',');
1988   - if (s != NULL) {
1989   - if (s[1] == 'm')
1990   - video_logo_ypos = BMP_ALIGN_CENTER;
1991   - else
1992   - video_logo_ypos = simple_strtol(s + 1, NULL, 0);
1993   - }
1994   - }
1995   -#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
  1975 + splash_get_pos(&video_logo_xpos, &video_logo_ypos);
1996 1976  
1997 1977 #ifdef CONFIG_SPLASH_SCREEN
1998 1978 s = getenv("splashimage");
... ... @@ -25,6 +25,13 @@
25 25  
26 26 int splash_screen_prepare(void);
27 27  
  28 +#ifdef CONFIG_SPLASH_SCREEN_ALIGN
  29 +void splash_get_pos(int *x, int *y);
  30 +#else
  31 +static inline void splash_get_pos(int *x, int *y) { }
  32 +#endif
  33 +
  34 +#define BMP_ALIGN_CENTER 0x7FFF
28 35  
29 36 #endif