Przemyslaw Marczak | 679549d | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 Samsung Electronics |
| 3 | * Przemyslaw Marczak <p.marczak@samsung.com> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <lcd.h> |
| 10 | #include <libtizen.h> |
| 11 | #include <samsung/misc.h> |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 12 | #include <errno.h> |
| 13 | #include <version.h> |
Przemyslaw Marczak | 1d07c10 | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 14 | #include <malloc.h> |
Alexey Brodkin | 1ace402 | 2014-02-26 17:47:58 +0400 | [diff] [blame] | 15 | #include <linux/sizes.h> |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 16 | #include <asm/arch/cpu.h> |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 17 | #include <asm/gpio.h> |
| 18 | #include <linux/input.h> |
| 19 | #include <power/pmic.h> |
| 20 | #include <mmc.h> |
| 21 | |
| 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
Przemyslaw Marczak | 1d07c10 | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 24 | #ifdef CONFIG_SET_DFU_ALT_INFO |
Przemyslaw Marczak | 899a528 | 2015-02-17 12:24:11 +0100 | [diff] [blame^] | 25 | void set_dfu_alt_info(char *interface, char *devstr) |
Przemyslaw Marczak | 1d07c10 | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 26 | { |
| 27 | size_t buf_size = CONFIG_SET_DFU_ALT_BUF_LEN; |
| 28 | ALLOC_CACHE_ALIGN_BUFFER(char, buf, buf_size); |
| 29 | char *alt_info = "Settings not found!"; |
| 30 | char *status = "error!\n"; |
| 31 | char *alt_setting; |
| 32 | char *alt_sep; |
| 33 | int offset = 0; |
| 34 | |
| 35 | puts("DFU alt info setting: "); |
| 36 | |
Przemyslaw Marczak | 899a528 | 2015-02-17 12:24:11 +0100 | [diff] [blame^] | 37 | alt_setting = get_dfu_alt_boot(interface, devstr); |
Przemyslaw Marczak | 1d07c10 | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 38 | if (alt_setting) { |
| 39 | setenv("dfu_alt_boot", alt_setting); |
| 40 | offset = snprintf(buf, buf_size, "%s", alt_setting); |
| 41 | } |
| 42 | |
Przemyslaw Marczak | 899a528 | 2015-02-17 12:24:11 +0100 | [diff] [blame^] | 43 | alt_setting = get_dfu_alt_system(interface, devstr); |
Przemyslaw Marczak | 1d07c10 | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 44 | if (alt_setting) { |
| 45 | if (offset) |
| 46 | alt_sep = ";"; |
| 47 | else |
| 48 | alt_sep = ""; |
| 49 | |
| 50 | offset += snprintf(buf + offset, buf_size - offset, |
| 51 | "%s%s", alt_sep, alt_setting); |
| 52 | } |
| 53 | |
| 54 | if (offset) { |
| 55 | alt_info = buf; |
| 56 | status = "done\n"; |
| 57 | } |
| 58 | |
| 59 | setenv("dfu_alt_info", alt_info); |
| 60 | puts(status); |
| 61 | } |
| 62 | #endif |
| 63 | |
Piotr Wilczek | eee2fab | 2014-01-22 15:54:32 +0100 | [diff] [blame] | 64 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 65 | void set_board_info(void) |
| 66 | { |
| 67 | char info[64]; |
| 68 | |
Przemyslaw Marczak | 0dc579f | 2014-09-01 13:50:42 +0200 | [diff] [blame] | 69 | snprintf(info, ARRAY_SIZE(info), "%u.%u", (s5p_cpu_rev & 0xf0) >> 4, |
| 70 | s5p_cpu_rev & 0xf); |
Piotr Wilczek | eee2fab | 2014-01-22 15:54:32 +0100 | [diff] [blame] | 71 | setenv("soc_rev", info); |
| 72 | |
| 73 | snprintf(info, ARRAY_SIZE(info), "%x", s5p_cpu_id); |
| 74 | setenv("soc_id", info); |
| 75 | |
| 76 | #ifdef CONFIG_REVISION_TAG |
| 77 | snprintf(info, ARRAY_SIZE(info), "%x", get_board_rev()); |
| 78 | setenv("board_rev", info); |
| 79 | #endif |
| 80 | #ifdef CONFIG_OF_LIBFDT |
Przemyslaw Marczak | c9c36bf | 2014-09-01 13:50:50 +0200 | [diff] [blame] | 81 | const char *bdtype = ""; |
| 82 | const char *bdname = CONFIG_SYS_BOARD; |
| 83 | |
| 84 | #ifdef CONFIG_BOARD_TYPES |
| 85 | bdtype = get_board_type(); |
| 86 | sprintf(info, "%s%s", bdname, bdtype); |
| 87 | setenv("boardname", info); |
| 88 | #endif |
| 89 | snprintf(info, ARRAY_SIZE(info), "%s%x-%s%s.dtb", |
| 90 | CONFIG_SYS_SOC, s5p_cpu_id, bdname, bdtype); |
Piotr Wilczek | eee2fab | 2014-01-22 15:54:32 +0100 | [diff] [blame] | 91 | setenv("fdtfile", info); |
| 92 | #endif |
| 93 | } |
| 94 | #endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */ |
| 95 | |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 96 | #ifdef CONFIG_LCD_MENU |
| 97 | static int power_key_pressed(u32 reg) |
| 98 | { |
| 99 | struct pmic *pmic; |
| 100 | u32 status; |
| 101 | u32 mask; |
| 102 | |
| 103 | pmic = pmic_get(KEY_PWR_PMIC_NAME); |
| 104 | if (!pmic) { |
| 105 | printf("%s: Not found\n", KEY_PWR_PMIC_NAME); |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | if (pmic_probe(pmic)) |
| 110 | return 0; |
| 111 | |
| 112 | if (reg == KEY_PWR_STATUS_REG) |
| 113 | mask = KEY_PWR_STATUS_MASK; |
| 114 | else |
| 115 | mask = KEY_PWR_INTERRUPT_MASK; |
| 116 | |
| 117 | if (pmic_reg_read(pmic, reg, &status)) |
| 118 | return 0; |
| 119 | |
| 120 | return !!(status & mask); |
| 121 | } |
| 122 | |
| 123 | static int key_pressed(int key) |
| 124 | { |
| 125 | int value; |
| 126 | |
| 127 | switch (key) { |
| 128 | case KEY_POWER: |
| 129 | value = power_key_pressed(KEY_PWR_INTERRUPT_REG); |
| 130 | break; |
| 131 | case KEY_VOLUMEUP: |
| 132 | value = !gpio_get_value(KEY_VOL_UP_GPIO); |
| 133 | break; |
| 134 | case KEY_VOLUMEDOWN: |
| 135 | value = !gpio_get_value(KEY_VOL_DOWN_GPIO); |
| 136 | break; |
| 137 | default: |
| 138 | value = 0; |
| 139 | break; |
| 140 | } |
| 141 | |
| 142 | return value; |
| 143 | } |
| 144 | |
| 145 | static int check_keys(void) |
| 146 | { |
| 147 | int keys = 0; |
| 148 | |
| 149 | if (key_pressed(KEY_POWER)) |
| 150 | keys += KEY_POWER; |
| 151 | if (key_pressed(KEY_VOLUMEUP)) |
| 152 | keys += KEY_VOLUMEUP; |
| 153 | if (key_pressed(KEY_VOLUMEDOWN)) |
| 154 | keys += KEY_VOLUMEDOWN; |
| 155 | |
| 156 | return keys; |
| 157 | } |
| 158 | |
| 159 | /* |
| 160 | * 0 BOOT_MODE_INFO |
| 161 | * 1 BOOT_MODE_THOR |
| 162 | * 2 BOOT_MODE_UMS |
| 163 | * 3 BOOT_MODE_DFU |
| 164 | * 4 BOOT_MODE_EXIT |
| 165 | */ |
| 166 | static char * |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 167 | mode_name[BOOT_MODE_EXIT + 1][2] = { |
| 168 | {"DEVICE", ""}, |
| 169 | {"THOR", "thor"}, |
| 170 | {"UMS", "ums"}, |
| 171 | {"DFU", "dfu"}, |
Przemyslaw Marczak | 5c7b8a3 | 2014-04-30 13:28:07 +0200 | [diff] [blame] | 172 | {"GPT", "gpt"}, |
Inha Song | 0954dd6 | 2014-04-30 13:28:08 +0200 | [diff] [blame] | 173 | {"ENV", "env"}, |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 174 | {"EXIT", ""}, |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | static char * |
| 178 | mode_info[BOOT_MODE_EXIT + 1] = { |
| 179 | "info", |
| 180 | "downloader", |
| 181 | "mass storage", |
| 182 | "firmware update", |
Przemyslaw Marczak | 5c7b8a3 | 2014-04-30 13:28:07 +0200 | [diff] [blame] | 183 | "restore", |
Inha Song | 0954dd6 | 2014-04-30 13:28:08 +0200 | [diff] [blame] | 184 | "default", |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 185 | "and run normal boot" |
| 186 | }; |
| 187 | |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 188 | static char * |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 189 | mode_cmd[BOOT_MODE_EXIT + 1] = { |
| 190 | "", |
| 191 | "thor 0 mmc 0", |
| 192 | "ums 0 mmc 0", |
| 193 | "dfu 0 mmc 0", |
Przemyslaw Marczak | 5c7b8a3 | 2014-04-30 13:28:07 +0200 | [diff] [blame] | 194 | "gpt write mmc 0 $partitions", |
Inha Song | 0954dd6 | 2014-04-30 13:28:08 +0200 | [diff] [blame] | 195 | "env default -a; saveenv", |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 196 | "", |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 197 | }; |
| 198 | |
| 199 | static void display_board_info(void) |
| 200 | { |
| 201 | #ifdef CONFIG_GENERIC_MMC |
| 202 | struct mmc *mmc = find_mmc_device(0); |
| 203 | #endif |
| 204 | vidinfo_t *vid = &panel_info; |
| 205 | |
| 206 | lcd_position_cursor(4, 4); |
| 207 | |
| 208 | lcd_printf("%s\n\t", U_BOOT_VERSION); |
| 209 | lcd_puts("\n\t\tBoard Info:\n"); |
| 210 | #ifdef CONFIG_SYS_BOARD |
| 211 | lcd_printf("\tBoard name: %s\n", CONFIG_SYS_BOARD); |
| 212 | #endif |
| 213 | #ifdef CONFIG_REVISION_TAG |
| 214 | lcd_printf("\tBoard rev: %u\n", get_board_rev()); |
| 215 | #endif |
| 216 | lcd_printf("\tDRAM banks: %u\n", CONFIG_NR_DRAM_BANKS); |
| 217 | lcd_printf("\tDRAM size: %u MB\n", gd->ram_size / SZ_1M); |
| 218 | |
| 219 | #ifdef CONFIG_GENERIC_MMC |
| 220 | if (mmc) { |
| 221 | if (!mmc->capacity) |
| 222 | mmc_init(mmc); |
| 223 | |
| 224 | lcd_printf("\teMMC size: %llu MB\n", mmc->capacity / SZ_1M); |
| 225 | } |
| 226 | #endif |
| 227 | if (vid) |
| 228 | lcd_printf("\tDisplay resolution: %u x % u\n", |
| 229 | vid->vl_col, vid->vl_row); |
| 230 | |
| 231 | lcd_printf("\tDisplay BPP: %u\n", 1 << vid->vl_bpix); |
| 232 | } |
| 233 | |
| 234 | static int mode_leave_menu(int mode) |
| 235 | { |
| 236 | char *exit_option; |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 237 | char *exit_reset = "reset"; |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 238 | char *exit_back = "back"; |
| 239 | cmd_tbl_t *cmd; |
| 240 | int cmd_result; |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 241 | int leave; |
| 242 | |
| 243 | lcd_clear(); |
| 244 | |
| 245 | switch (mode) { |
| 246 | case BOOT_MODE_EXIT: |
| 247 | return 1; |
| 248 | case BOOT_MODE_INFO: |
| 249 | display_board_info(); |
| 250 | exit_option = exit_back; |
| 251 | leave = 0; |
| 252 | break; |
| 253 | default: |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 254 | cmd = find_cmd(mode_name[mode][1]); |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 255 | if (cmd) { |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 256 | printf("Enter: %s %s\n", mode_name[mode][0], |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 257 | mode_info[mode]); |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 258 | lcd_printf("\n\n\t%s %s\n", mode_name[mode][0], |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 259 | mode_info[mode]); |
| 260 | lcd_puts("\n\tDo not turn off device before finish!\n"); |
| 261 | |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 262 | cmd_result = run_command(mode_cmd[mode], 0); |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 263 | |
| 264 | if (cmd_result == CMD_RET_SUCCESS) { |
| 265 | printf("Command finished\n"); |
| 266 | lcd_clear(); |
| 267 | lcd_printf("\n\n\t%s finished\n", |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 268 | mode_name[mode][0]); |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 269 | |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 270 | exit_option = exit_reset; |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 271 | leave = 1; |
| 272 | } else { |
| 273 | printf("Command error\n"); |
| 274 | lcd_clear(); |
| 275 | lcd_printf("\n\n\t%s command error\n", |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 276 | mode_name[mode][0]); |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 277 | |
| 278 | exit_option = exit_back; |
| 279 | leave = 0; |
| 280 | } |
| 281 | } else { |
| 282 | lcd_puts("\n\n\tThis mode is not supported.\n"); |
| 283 | exit_option = exit_back; |
| 284 | leave = 0; |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | lcd_printf("\n\n\tPress POWER KEY to %s\n", exit_option); |
| 289 | |
| 290 | /* Clear PWR button Rising edge interrupt status flag */ |
| 291 | power_key_pressed(KEY_PWR_INTERRUPT_REG); |
| 292 | |
| 293 | /* Wait for PWR key */ |
| 294 | while (!key_pressed(KEY_POWER)) |
| 295 | mdelay(1); |
| 296 | |
| 297 | lcd_clear(); |
| 298 | return leave; |
| 299 | } |
| 300 | |
| 301 | static void display_download_menu(int mode) |
| 302 | { |
| 303 | char *selection[BOOT_MODE_EXIT + 1]; |
| 304 | int i; |
| 305 | |
| 306 | for (i = 0; i <= BOOT_MODE_EXIT; i++) |
| 307 | selection[i] = "[ ]"; |
| 308 | |
| 309 | selection[mode] = "[=>]"; |
| 310 | |
| 311 | lcd_clear(); |
Przemyslaw Marczak | 605d7e2 | 2014-04-30 13:28:10 +0200 | [diff] [blame] | 312 | lcd_printf("\n\n\t\tDownload Mode Menu\n\n"); |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 313 | |
| 314 | for (i = 0; i <= BOOT_MODE_EXIT; i++) |
| 315 | lcd_printf("\t%s %s - %s\n\n", selection[i], |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 316 | mode_name[i][0], |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 317 | mode_info[i]); |
| 318 | } |
| 319 | |
| 320 | static void download_menu(void) |
| 321 | { |
| 322 | int mode = 0; |
| 323 | int last_mode = 0; |
| 324 | int run; |
Przemyslaw Marczak | 605d7e2 | 2014-04-30 13:28:10 +0200 | [diff] [blame] | 325 | int key = 0; |
| 326 | int timeout = 15; /* sec */ |
| 327 | int i; |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 328 | |
| 329 | display_download_menu(mode); |
| 330 | |
Przemyslaw Marczak | 605d7e2 | 2014-04-30 13:28:10 +0200 | [diff] [blame] | 331 | lcd_puts("\n"); |
| 332 | |
| 333 | /* Start count if no key is pressed */ |
| 334 | while (check_keys()) |
| 335 | continue; |
| 336 | |
| 337 | while (timeout--) { |
| 338 | lcd_printf("\r\tNormal boot will start in: %2.d seconds.", |
| 339 | timeout); |
| 340 | |
| 341 | /* about 1000 ms in for loop */ |
| 342 | for (i = 0; i < 10; i++) { |
| 343 | mdelay(100); |
| 344 | key = check_keys(); |
| 345 | if (key) |
| 346 | break; |
| 347 | } |
| 348 | if (key) |
| 349 | break; |
| 350 | } |
| 351 | |
| 352 | if (!key) { |
| 353 | lcd_clear(); |
| 354 | return; |
| 355 | } |
| 356 | |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 357 | while (1) { |
| 358 | run = 0; |
| 359 | |
| 360 | if (mode != last_mode) |
| 361 | display_download_menu(mode); |
| 362 | |
| 363 | last_mode = mode; |
Przemyslaw Marczak | f418a1c | 2014-04-30 13:28:09 +0200 | [diff] [blame] | 364 | mdelay(200); |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 365 | |
| 366 | key = check_keys(); |
| 367 | switch (key) { |
| 368 | case KEY_POWER: |
| 369 | run = 1; |
| 370 | break; |
| 371 | case KEY_VOLUMEUP: |
| 372 | if (mode > 0) |
| 373 | mode--; |
| 374 | break; |
| 375 | case KEY_VOLUMEDOWN: |
| 376 | if (mode < BOOT_MODE_EXIT) |
| 377 | mode++; |
| 378 | break; |
| 379 | default: |
| 380 | break; |
| 381 | } |
| 382 | |
| 383 | if (run) { |
| 384 | if (mode_leave_menu(mode)) |
Przemyslaw Marczak | e6bfe79 | 2014-04-30 13:28:06 +0200 | [diff] [blame] | 385 | run_command("reset", 0); |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 386 | |
| 387 | display_download_menu(mode); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | lcd_clear(); |
| 392 | } |
| 393 | |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 394 | void check_boot_mode(void) |
| 395 | { |
| 396 | int pwr_key; |
| 397 | |
| 398 | pwr_key = power_key_pressed(KEY_PWR_STATUS_REG); |
| 399 | if (!pwr_key) |
| 400 | return; |
| 401 | |
| 402 | /* Clear PWR button Rising edge interrupt status flag */ |
| 403 | power_key_pressed(KEY_PWR_INTERRUPT_REG); |
| 404 | |
| 405 | if (key_pressed(KEY_VOLUMEUP)) |
Przemyslaw Marczak | 605d7e2 | 2014-04-30 13:28:10 +0200 | [diff] [blame] | 406 | download_menu(); |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 407 | else if (key_pressed(KEY_VOLUMEDOWN)) |
| 408 | mode_leave_menu(BOOT_MODE_THOR); |
| 409 | } |
| 410 | |
| 411 | void keys_init(void) |
| 412 | { |
| 413 | /* Set direction to input */ |
Simon Glass | 7f19610 | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 414 | gpio_request(KEY_VOL_UP_GPIO, "volume-up"); |
| 415 | gpio_request(KEY_VOL_DOWN_GPIO, "volume-down"); |
Przemyslaw Marczak | 9d29a68 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 416 | gpio_direction_input(KEY_VOL_UP_GPIO); |
| 417 | gpio_direction_input(KEY_VOL_DOWN_GPIO); |
| 418 | } |
| 419 | #endif /* CONFIG_LCD_MENU */ |
Przemyslaw Marczak | 679549d | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 420 | |
| 421 | #ifdef CONFIG_CMD_BMP |
| 422 | void draw_logo(void) |
| 423 | { |
| 424 | int x, y; |
| 425 | ulong addr; |
| 426 | |
| 427 | addr = panel_info.logo_addr; |
| 428 | if (!addr) { |
| 429 | error("There is no logo data."); |
| 430 | return; |
| 431 | } |
| 432 | |
| 433 | if (panel_info.vl_width >= panel_info.logo_width) { |
| 434 | x = ((panel_info.vl_width - panel_info.logo_width) >> 1); |
Przemyslaw Marczak | 903afe1 | 2013-11-29 18:30:43 +0100 | [diff] [blame] | 435 | x += panel_info.logo_x_offset; /* For X center align */ |
Przemyslaw Marczak | 679549d | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 436 | } else { |
| 437 | x = 0; |
| 438 | printf("Warning: image width is bigger than display width\n"); |
| 439 | } |
| 440 | |
| 441 | if (panel_info.vl_height >= panel_info.logo_height) { |
| 442 | y = ((panel_info.vl_height - panel_info.logo_height) >> 1); |
Przemyslaw Marczak | 903afe1 | 2013-11-29 18:30:43 +0100 | [diff] [blame] | 443 | y += panel_info.logo_y_offset; /* For Y center align */ |
Przemyslaw Marczak | 679549d | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 444 | } else { |
| 445 | y = 0; |
| 446 | printf("Warning: image height is bigger than display height\n"); |
| 447 | } |
| 448 | |
| 449 | bmp_display(addr, x, y); |
| 450 | } |
| 451 | #endif /* CONFIG_CMD_BMP */ |