2013-06-17 18:31:29 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013, Boundary Devices <info@boundarydevices.com>
|
|
|
|
*
|
|
|
|
* 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., http://www.fsf.org/about/contact/
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-07-01 22:04:05 +00:00
|
|
|
#include <common.h>
|
2022-07-31 18:28:48 +00:00
|
|
|
#include <display_options.h>
|
2019-08-01 15:46:52 +00:00
|
|
|
#include <env.h>
|
2013-06-17 18:31:29 +00:00
|
|
|
#include <splash.h>
|
2022-10-18 13:10:26 +00:00
|
|
|
#include <video.h>
|
2013-06-17 18:31:29 +00:00
|
|
|
|
2016-07-01 19:48:16 +00:00
|
|
|
static struct splash_location default_splash_locations[] = {
|
|
|
|
{
|
|
|
|
.name = "sf",
|
|
|
|
.storage = SPLASH_STORAGE_SF,
|
|
|
|
.flags = SPLASH_STORAGE_RAW,
|
|
|
|
.offset = 0x0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mmc_fs",
|
|
|
|
.storage = SPLASH_STORAGE_MMC,
|
|
|
|
.flags = SPLASH_STORAGE_FS,
|
|
|
|
.devpart = "0:1",
|
|
|
|
},
|
2022-10-17 08:33:21 +00:00
|
|
|
{
|
|
|
|
.name = "mmc_raw",
|
|
|
|
.storage = SPLASH_STORAGE_MMC,
|
|
|
|
.flags = SPLASH_STORAGE_RAW,
|
|
|
|
.devpart = "0:1",
|
|
|
|
},
|
2016-07-01 19:48:16 +00:00
|
|
|
{
|
|
|
|
.name = "usb_fs",
|
|
|
|
.storage = SPLASH_STORAGE_USB,
|
|
|
|
.flags = SPLASH_STORAGE_FS,
|
|
|
|
.devpart = "0:1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "sata_fs",
|
|
|
|
.storage = SPLASH_STORAGE_SATA,
|
|
|
|
.flags = SPLASH_STORAGE_FS,
|
|
|
|
.devpart = "0:1",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-11-19 20:24:01 +00:00
|
|
|
#ifdef CONFIG_VIDEO_LOGO
|
2019-09-18 14:47:33 +00:00
|
|
|
|
|
|
|
#include <bmp_logo_data.h>
|
|
|
|
|
|
|
|
static int splash_video_logo_load(void)
|
|
|
|
{
|
|
|
|
char *splashimage;
|
2020-06-10 09:52:22 +00:00
|
|
|
ulong bmp_load_addr;
|
2019-09-18 14:47:33 +00:00
|
|
|
|
|
|
|
splashimage = env_get("splashimage");
|
|
|
|
if (!splashimage)
|
|
|
|
return -ENOENT;
|
|
|
|
|
2021-07-24 15:03:29 +00:00
|
|
|
bmp_load_addr = hextoul(splashimage, 0);
|
2019-09-18 14:47:33 +00:00
|
|
|
if (!bmp_load_addr) {
|
|
|
|
printf("Error: bad 'splashimage' address\n");
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy((void *)bmp_load_addr, bmp_logo_bitmap,
|
|
|
|
ARRAY_SIZE(bmp_logo_bitmap));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline int splash_video_logo_load(void) { return -ENOSYS; }
|
|
|
|
#endif
|
|
|
|
|
2014-06-26 17:53:16 +00:00
|
|
|
__weak int splash_screen_prepare(void)
|
2013-06-17 18:31:29 +00:00
|
|
|
{
|
2023-04-20 12:11:09 +00:00
|
|
|
if (CONFIG_IS_ENABLED(SPLASH_SOURCE))
|
2019-09-18 14:47:33 +00:00
|
|
|
return splash_source_load(default_splash_locations,
|
|
|
|
ARRAY_SIZE(default_splash_locations));
|
|
|
|
|
|
|
|
return splash_video_logo_load();
|
2013-06-17 18:31:29 +00:00
|
|
|
}
|
2013-06-17 18:31:30 +00:00
|
|
|
|
2013-07-01 22:04:05 +00:00
|
|
|
void splash_get_pos(int *x, int *y)
|
|
|
|
{
|
2017-08-03 18:22:12 +00:00
|
|
|
char *s = env_get("splashpos");
|
2013-07-01 22:04:05 +00:00
|
|
|
|
2023-04-20 12:11:12 +00:00
|
|
|
if (!CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN) || !s)
|
2013-07-01 22:04:05 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2015-02-03 11:32:32 +00:00
|
|
|
|
2023-04-20 12:11:09 +00:00
|
|
|
#if CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(HIDE_LOGO_VERSION)
|
2019-09-20 15:23:41 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_VIDEO_LOGO
|
|
|
|
#include <bmp_logo.h>
|
|
|
|
#endif
|
|
|
|
#include <dm.h>
|
|
|
|
#include <video_console.h>
|
|
|
|
#include <video_font.h>
|
2023-03-07 10:21:14 +00:00
|
|
|
#include <video_font_data.h>
|
2019-09-20 15:23:41 +00:00
|
|
|
|
|
|
|
void splash_display_banner(void)
|
|
|
|
{
|
2023-03-07 10:21:14 +00:00
|
|
|
struct video_fontdata __maybe_unused *fontdata = fonts;
|
2019-09-20 15:23:41 +00:00
|
|
|
struct udevice *dev;
|
|
|
|
char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
|
|
|
|
int col, row, ret;
|
|
|
|
|
|
|
|
ret = uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &dev);
|
|
|
|
if (ret)
|
|
|
|
return;
|
|
|
|
|
2023-03-07 10:21:14 +00:00
|
|
|
#if IS_ENABLED(CONFIG_VIDEO_LOGO)
|
|
|
|
col = BMP_LOGO_WIDTH / fontdata->width + 1;
|
|
|
|
row = BMP_LOGO_HEIGHT / fontdata->height + 1;
|
2019-09-20 15:23:41 +00:00
|
|
|
#else
|
|
|
|
col = 0;
|
|
|
|
row = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
display_options_get_banner(false, buf, sizeof(buf));
|
|
|
|
vidconsole_position_cursor(dev, col, 1);
|
|
|
|
vidconsole_put_string(dev, buf);
|
|
|
|
vidconsole_position_cursor(dev, 0, row);
|
|
|
|
}
|
2022-10-18 13:46:31 +00:00
|
|
|
#endif /* CONFIG_VIDEO && !CONFIG_HIDE_LOGO_VERSION */
|
2019-09-20 15:23:41 +00:00
|
|
|
|
2019-05-29 09:01:43 +00:00
|
|
|
/*
|
|
|
|
* Common function to show a splash image if env("splashimage") is set.
|
2022-10-18 13:10:26 +00:00
|
|
|
* For additional details please refer to doc/README.splashprepare.
|
2019-05-29 09:01:43 +00:00
|
|
|
*/
|
|
|
|
int splash_display(void)
|
2015-02-03 11:32:32 +00:00
|
|
|
{
|
2019-05-29 09:01:43 +00:00
|
|
|
ulong addr;
|
|
|
|
char *s;
|
2015-02-03 11:32:32 +00:00
|
|
|
int x = 0, y = 0, ret;
|
2023-04-20 12:11:12 +00:00
|
|
|
if (!CONFIG_IS_ENABLED(SPLASH_SCREEN))
|
|
|
|
return -ENOSYS;
|
2019-05-29 09:01:43 +00:00
|
|
|
s = env_get("splashimage");
|
|
|
|
if (!s)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2021-07-24 15:03:29 +00:00
|
|
|
addr = hextoul(s, NULL);
|
2015-02-03 11:32:32 +00:00
|
|
|
ret = splash_screen_prepare();
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
splash_get_pos(&x, &y);
|
|
|
|
|
2023-04-20 12:11:12 +00:00
|
|
|
if (CONFIG_IS_ENABLED(BMP))
|
|
|
|
ret = bmp_display(addr, x, y);
|
|
|
|
else
|
|
|
|
return -ENOSYS;
|
2019-09-20 15:23:41 +00:00
|
|
|
|
|
|
|
/* Skip banner output on video console if the logo is not at 0,0 */
|
|
|
|
if (x || y)
|
|
|
|
goto end;
|
|
|
|
|
2023-04-20 12:11:09 +00:00
|
|
|
#if CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(HIDE_LOGO_VERSION)
|
2019-09-20 15:23:41 +00:00
|
|
|
splash_display_banner();
|
2019-10-30 14:04:10 +00:00
|
|
|
#endif
|
2019-09-20 15:23:41 +00:00
|
|
|
end:
|
|
|
|
return ret;
|
2015-02-03 11:32:32 +00:00
|
|
|
}
|