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/
24 #include <display_options.h>
29 static struct splash_location default_splash_locations[] = {
32 .storage = SPLASH_STORAGE_SF,
33 .flags = SPLASH_STORAGE_RAW,
38 .storage = SPLASH_STORAGE_MMC,
39 .flags = SPLASH_STORAGE_FS,
44 .storage = SPLASH_STORAGE_USB,
45 .flags = SPLASH_STORAGE_FS,
50 .storage = SPLASH_STORAGE_SATA,
51 .flags = SPLASH_STORAGE_FS,
56 #ifdef CONFIG_VIDEO_LOGO
58 #include <bmp_logo_data.h>
60 static int splash_video_logo_load(void)
65 splashimage = env_get("splashimage");
69 bmp_load_addr = hextoul(splashimage, 0);
71 printf("Error: bad 'splashimage' address\n");
75 memcpy((void *)bmp_load_addr, bmp_logo_bitmap,
76 ARRAY_SIZE(bmp_logo_bitmap));
81 static inline int splash_video_logo_load(void) { return -ENOSYS; }
84 __weak int splash_screen_prepare(void)
86 if (CONFIG_IS_ENABLED(SPLASH_SOURCE))
87 return splash_source_load(default_splash_locations,
88 ARRAY_SIZE(default_splash_locations));
90 return splash_video_logo_load();
93 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
94 void splash_get_pos(int *x, int *y)
96 char *s = env_get("splashpos");
102 *x = BMP_ALIGN_CENTER;
104 *x = simple_strtol(s, NULL, 0);
106 s = strchr(s + 1, ',');
109 *y = BMP_ALIGN_CENTER;
111 *y = simple_strtol(s + 1, NULL, 0);
114 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
116 #if defined(CONFIG_DM_VIDEO) && !defined(CONFIG_HIDE_LOGO_VERSION)
118 #ifdef CONFIG_VIDEO_LOGO
119 #include <bmp_logo.h>
122 #include <video_console.h>
123 #include <video_font.h>
125 void splash_display_banner(void)
128 char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
131 ret = uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &dev);
135 #ifdef CONFIG_VIDEO_LOGO
136 col = BMP_LOGO_WIDTH / VIDEO_FONT_WIDTH + 1;
137 row = BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT + 1;
143 display_options_get_banner(false, buf, sizeof(buf));
144 vidconsole_position_cursor(dev, col, 1);
145 vidconsole_put_string(dev, buf);
146 vidconsole_position_cursor(dev, 0, row);
148 #endif /* CONFIG_DM_VIDEO && !CONFIG_HIDE_LOGO_VERSION */
151 * Common function to show a splash image if env("splashimage") is set.
152 * Is used for both dm_video and lcd video stacks. For additional
153 * details please refer to doc/README.splashprepare.
155 #if defined(CONFIG_SPLASH_SCREEN) && defined(CONFIG_CMD_BMP)
156 int splash_display(void)
160 int x = 0, y = 0, ret;
162 s = env_get("splashimage");
166 addr = hextoul(s, NULL);
167 ret = splash_screen_prepare();
171 splash_get_pos(&x, &y);
173 ret = bmp_display(addr, x, y);
175 /* Skip banner output on video console if the logo is not at 0,0 */
179 #if defined(CONFIG_DM_VIDEO) && !defined(CONFIG_HIDE_LOGO_VERSION)
180 splash_display_banner();