2 * Copyright (C) 2013, Boundary Devices <info@boundarydevices.com>
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., http://www.fsf.org/about/contact/
28 static struct splash_location default_splash_locations[] = {
31 .storage = SPLASH_STORAGE_SF,
32 .flags = SPLASH_STORAGE_RAW,
37 .storage = SPLASH_STORAGE_MMC,
38 .flags = SPLASH_STORAGE_FS,
43 .storage = SPLASH_STORAGE_USB,
44 .flags = SPLASH_STORAGE_FS,
49 .storage = SPLASH_STORAGE_SATA,
50 .flags = SPLASH_STORAGE_FS,
55 #if defined(CONFIG_DM_VIDEO) && defined(CONFIG_VIDEO_LOGO)
57 #include <bmp_logo_data.h>
59 static int splash_video_logo_load(void)
64 splashimage = env_get("splashimage");
68 bmp_load_addr = hextoul(splashimage, 0);
70 printf("Error: bad 'splashimage' address\n");
74 memcpy((void *)bmp_load_addr, bmp_logo_bitmap,
75 ARRAY_SIZE(bmp_logo_bitmap));
80 static inline int splash_video_logo_load(void) { return -ENOSYS; }
83 __weak int splash_screen_prepare(void)
85 if (CONFIG_IS_ENABLED(SPLASH_SOURCE))
86 return splash_source_load(default_splash_locations,
87 ARRAY_SIZE(default_splash_locations));
89 return splash_video_logo_load();
92 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
93 void splash_get_pos(int *x, int *y)
95 char *s = env_get("splashpos");
101 *x = BMP_ALIGN_CENTER;
103 *x = simple_strtol(s, NULL, 0);
105 s = strchr(s + 1, ',');
108 *y = BMP_ALIGN_CENTER;
110 *y = simple_strtol(s + 1, NULL, 0);
113 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
115 #if defined(CONFIG_DM_VIDEO) && !defined(CONFIG_HIDE_LOGO_VERSION)
117 #ifdef CONFIG_VIDEO_LOGO
118 #include <bmp_logo.h>
121 #include <video_console.h>
122 #include <video_font.h>
124 void splash_display_banner(void)
127 char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
130 ret = uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &dev);
134 #ifdef CONFIG_VIDEO_LOGO
135 col = BMP_LOGO_WIDTH / VIDEO_FONT_WIDTH + 1;
136 row = BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT + 1;
142 display_options_get_banner(false, buf, sizeof(buf));
143 vidconsole_position_cursor(dev, col, 1);
144 vidconsole_put_string(dev, buf);
145 vidconsole_position_cursor(dev, 0, row);
147 #endif /* CONFIG_DM_VIDEO && !CONFIG_HIDE_LOGO_VERSION */
150 * Common function to show a splash image if env("splashimage") is set.
151 * Is used for both dm_video and lcd video stacks. For additional
152 * details please refer to doc/README.splashprepare.
154 #if defined(CONFIG_SPLASH_SCREEN) && defined(CONFIG_CMD_BMP)
155 int splash_display(void)
159 int x = 0, y = 0, ret;
161 s = env_get("splashimage");
165 addr = hextoul(s, NULL);
166 ret = splash_screen_prepare();
170 splash_get_pos(&x, &y);
172 ret = bmp_display(addr, x, y);
174 /* Skip banner output on video console if the logo is not at 0,0 */
178 #if defined(CONFIG_DM_VIDEO) && !defined(CONFIG_HIDE_LOGO_VERSION)
179 splash_display_banner();