Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013, Boundary Devices <info@boundarydevices.com> |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 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. |
| 11 | * |
| 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. |
| 16 | * |
| 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/ |
| 20 | * |
| 21 | */ |
| 22 | |
Anatolij Gustschin | ff8fb56 | 2013-07-02 00:04:05 +0200 | [diff] [blame] | 23 | #include <common.h> |
Simon Glass | 4e4bf94 | 2022-07-31 12:28:48 -0600 | [diff] [blame] | 24 | #include <display_options.h> |
Simon Glass | 7b51b57 | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 25 | #include <env.h> |
Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame] | 26 | #include <splash.h> |
Nikita Kiryanov | 7bf71d1 | 2015-02-03 13:32:32 +0200 | [diff] [blame] | 27 | #include <lcd.h> |
Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame] | 28 | |
Alexey Brodkin | b6de2cd | 2016-07-01 22:48:16 +0300 | [diff] [blame] | 29 | static struct splash_location default_splash_locations[] = { |
| 30 | { |
| 31 | .name = "sf", |
| 32 | .storage = SPLASH_STORAGE_SF, |
| 33 | .flags = SPLASH_STORAGE_RAW, |
| 34 | .offset = 0x0, |
| 35 | }, |
| 36 | { |
| 37 | .name = "mmc_fs", |
| 38 | .storage = SPLASH_STORAGE_MMC, |
| 39 | .flags = SPLASH_STORAGE_FS, |
| 40 | .devpart = "0:1", |
| 41 | }, |
| 42 | { |
| 43 | .name = "usb_fs", |
| 44 | .storage = SPLASH_STORAGE_USB, |
| 45 | .flags = SPLASH_STORAGE_FS, |
| 46 | .devpart = "0:1", |
| 47 | }, |
| 48 | { |
| 49 | .name = "sata_fs", |
| 50 | .storage = SPLASH_STORAGE_SATA, |
| 51 | .flags = SPLASH_STORAGE_FS, |
| 52 | .devpart = "0:1", |
| 53 | }, |
| 54 | }; |
| 55 | |
Simon Glass | 64cfeda | 2021-11-19 13:24:01 -0700 | [diff] [blame] | 56 | #ifdef CONFIG_VIDEO_LOGO |
Anatolij Gustschin | 7600d62 | 2019-09-18 16:47:33 +0200 | [diff] [blame] | 57 | |
| 58 | #include <bmp_logo_data.h> |
| 59 | |
| 60 | static int splash_video_logo_load(void) |
| 61 | { |
| 62 | char *splashimage; |
Ye Li | 70b06d9 | 2020-06-10 02:52:22 -0700 | [diff] [blame] | 63 | ulong bmp_load_addr; |
Anatolij Gustschin | 7600d62 | 2019-09-18 16:47:33 +0200 | [diff] [blame] | 64 | |
| 65 | splashimage = env_get("splashimage"); |
| 66 | if (!splashimage) |
| 67 | return -ENOENT; |
| 68 | |
Simon Glass | 7e5f460 | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 69 | bmp_load_addr = hextoul(splashimage, 0); |
Anatolij Gustschin | 7600d62 | 2019-09-18 16:47:33 +0200 | [diff] [blame] | 70 | if (!bmp_load_addr) { |
| 71 | printf("Error: bad 'splashimage' address\n"); |
| 72 | return -EFAULT; |
| 73 | } |
| 74 | |
| 75 | memcpy((void *)bmp_load_addr, bmp_logo_bitmap, |
| 76 | ARRAY_SIZE(bmp_logo_bitmap)); |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | #else |
| 81 | static inline int splash_video_logo_load(void) { return -ENOSYS; } |
| 82 | #endif |
| 83 | |
Jeroen Hofstee | cc64b92 | 2014-06-26 19:53:16 +0200 | [diff] [blame] | 84 | __weak int splash_screen_prepare(void) |
Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame] | 85 | { |
Anatolij Gustschin | 7600d62 | 2019-09-18 16:47:33 +0200 | [diff] [blame] | 86 | if (CONFIG_IS_ENABLED(SPLASH_SOURCE)) |
| 87 | return splash_source_load(default_splash_locations, |
| 88 | ARRAY_SIZE(default_splash_locations)); |
| 89 | |
| 90 | return splash_video_logo_load(); |
Robert Winkler | dd4425e | 2013-06-17 11:31:29 -0700 | [diff] [blame] | 91 | } |
Robert Winkler | 59b1592 | 2013-06-17 11:31:30 -0700 | [diff] [blame] | 92 | |
Anatolij Gustschin | ff8fb56 | 2013-07-02 00:04:05 +0200 | [diff] [blame] | 93 | #ifdef CONFIG_SPLASH_SCREEN_ALIGN |
| 94 | void splash_get_pos(int *x, int *y) |
| 95 | { |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 96 | char *s = env_get("splashpos"); |
Anatolij Gustschin | ff8fb56 | 2013-07-02 00:04:05 +0200 | [diff] [blame] | 97 | |
| 98 | if (!s) |
| 99 | return; |
| 100 | |
| 101 | if (s[0] == 'm') |
| 102 | *x = BMP_ALIGN_CENTER; |
| 103 | else |
| 104 | *x = simple_strtol(s, NULL, 0); |
| 105 | |
| 106 | s = strchr(s + 1, ','); |
| 107 | if (s != NULL) { |
| 108 | if (s[1] == 'm') |
| 109 | *y = BMP_ALIGN_CENTER; |
| 110 | else |
| 111 | *y = simple_strtol(s + 1, NULL, 0); |
| 112 | } |
| 113 | } |
| 114 | #endif /* CONFIG_SPLASH_SCREEN_ALIGN */ |
Nikita Kiryanov | 7bf71d1 | 2015-02-03 13:32:32 +0200 | [diff] [blame] | 115 | |
Anatolij Gustschin | d2a8271 | 2019-09-20 17:23:41 +0200 | [diff] [blame] | 116 | #if defined(CONFIG_DM_VIDEO) && !defined(CONFIG_HIDE_LOGO_VERSION) |
| 117 | |
| 118 | #ifdef CONFIG_VIDEO_LOGO |
| 119 | #include <bmp_logo.h> |
| 120 | #endif |
| 121 | #include <dm.h> |
| 122 | #include <video_console.h> |
| 123 | #include <video_font.h> |
| 124 | |
| 125 | void splash_display_banner(void) |
| 126 | { |
| 127 | struct udevice *dev; |
| 128 | char buf[DISPLAY_OPTIONS_BANNER_LENGTH]; |
| 129 | int col, row, ret; |
| 130 | |
| 131 | ret = uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &dev); |
| 132 | if (ret) |
| 133 | return; |
| 134 | |
| 135 | #ifdef CONFIG_VIDEO_LOGO |
| 136 | col = BMP_LOGO_WIDTH / VIDEO_FONT_WIDTH + 1; |
| 137 | row = BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT + 1; |
| 138 | #else |
| 139 | col = 0; |
| 140 | row = 0; |
| 141 | #endif |
| 142 | |
| 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); |
| 147 | } |
Anatolij Gustschin | d2a8271 | 2019-09-20 17:23:41 +0200 | [diff] [blame] | 148 | #endif /* CONFIG_DM_VIDEO && !CONFIG_HIDE_LOGO_VERSION */ |
| 149 | |
Igor Opaniuk | 5eb83c0 | 2019-05-29 09:01:43 +0000 | [diff] [blame] | 150 | /* |
| 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. |
| 154 | */ |
| 155 | #if defined(CONFIG_SPLASH_SCREEN) && defined(CONFIG_CMD_BMP) |
| 156 | int splash_display(void) |
Nikita Kiryanov | 7bf71d1 | 2015-02-03 13:32:32 +0200 | [diff] [blame] | 157 | { |
Igor Opaniuk | 5eb83c0 | 2019-05-29 09:01:43 +0000 | [diff] [blame] | 158 | ulong addr; |
| 159 | char *s; |
Nikita Kiryanov | 7bf71d1 | 2015-02-03 13:32:32 +0200 | [diff] [blame] | 160 | int x = 0, y = 0, ret; |
| 161 | |
Igor Opaniuk | 5eb83c0 | 2019-05-29 09:01:43 +0000 | [diff] [blame] | 162 | s = env_get("splashimage"); |
| 163 | if (!s) |
| 164 | return -EINVAL; |
| 165 | |
Simon Glass | 7e5f460 | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 166 | addr = hextoul(s, NULL); |
Nikita Kiryanov | 7bf71d1 | 2015-02-03 13:32:32 +0200 | [diff] [blame] | 167 | ret = splash_screen_prepare(); |
| 168 | if (ret) |
| 169 | return ret; |
| 170 | |
| 171 | splash_get_pos(&x, &y); |
| 172 | |
Anatolij Gustschin | d2a8271 | 2019-09-20 17:23:41 +0200 | [diff] [blame] | 173 | ret = bmp_display(addr, x, y); |
| 174 | |
| 175 | /* Skip banner output on video console if the logo is not at 0,0 */ |
| 176 | if (x || y) |
| 177 | goto end; |
| 178 | |
Anatolij Gustschin | 2ad8494 | 2019-10-30 15:04:10 +0100 | [diff] [blame] | 179 | #if defined(CONFIG_DM_VIDEO) && !defined(CONFIG_HIDE_LOGO_VERSION) |
Anatolij Gustschin | d2a8271 | 2019-09-20 17:23:41 +0200 | [diff] [blame] | 180 | splash_display_banner(); |
Anatolij Gustschin | 2ad8494 | 2019-10-30 15:04:10 +0100 | [diff] [blame] | 181 | #endif |
Anatolij Gustschin | d2a8271 | 2019-09-20 17:23:41 +0200 | [diff] [blame] | 182 | end: |
| 183 | return ret; |
Nikita Kiryanov | 7bf71d1 | 2015-02-03 13:32:32 +0200 | [diff] [blame] | 184 | } |
| 185 | #endif |