Merge tag 'efi-2020-07-rc6' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
[oweals/u-boot.git] / cmd / bmp.c
index fd5b7db28852a7dcf225b066744e4591658dcb28..6040fa5d95d62f0dcb0f32a66eadb07328ad84f2 100644 (file)
--- a/cmd/bmp.c
+++ b/cmd/bmp.c
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2002
  * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
  */
 
 #include <common.h>
-#include <dm.h>
-#include <lcd.h>
-#include <mapmem.h>
 #include <bmp_layout.h>
 #include <command.h>
-#include <asm/byteorder.h>
+#include <dm.h>
+#include <gzip.h>
+#include <image.h>
+#include <lcd.h>
+#include <log.h>
 #include <malloc.h>
 #include <mapmem.h>
 #include <splash.h>
 #include <video.h>
+#include <asm/byteorder.h>
 
 static int bmp_info (ulong addr);
 
@@ -58,7 +59,7 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
        bmp = dst;
 
        /* align to 32-bit-aligned-address + 2 */
-       bmp = (struct bmp_image *)((((unsigned int)dst + 1) & ~3) + 2);
+       bmp = (struct bmp_image *)((((uintptr_t)dst + 1) & ~3) + 2);
 
        if (gunzip(bmp, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, map_sysmem(addr, 0),
                   &len) != 0) {
@@ -91,13 +92,14 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
 }
 #endif
 
-static int do_bmp_info(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc,
+                      char *const argv[])
 {
        ulong addr;
 
        switch (argc) {
-       case 1:         /* use load_addr as default address */
-               addr = load_addr;
+       case 1:         /* use image_load_addr as default address */
+               addr = image_load_addr;
                break;
        case 2:         /* use argument */
                addr = simple_strtoul(argv[1], NULL, 16);
@@ -109,7 +111,8 @@ static int do_bmp_info(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[
        return (bmp_info(addr));
 }
 
-static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc,
+                         char *const argv[])
 {
        ulong addr;
        int x = 0, y = 0;
@@ -117,16 +120,22 @@ static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const ar
        splash_get_pos(&x, &y);
 
        switch (argc) {
-       case 1:         /* use load_addr as default address */
-               addr = load_addr;
+       case 1:         /* use image_load_addr as default address */
+               addr = image_load_addr;
                break;
        case 2:         /* use argument */
                addr = simple_strtoul(argv[1], NULL, 16);
                break;
        case 4:
                addr = simple_strtoul(argv[1], NULL, 16);
-               x = simple_strtoul(argv[2], NULL, 10);
-               y = simple_strtoul(argv[3], NULL, 10);
+               if (!strcmp(argv[2], "m"))
+                       x = BMP_ALIGN_CENTER;
+               else
+                       x = simple_strtoul(argv[2], NULL, 10);
+               if (!strcmp(argv[3], "m"))
+                       y = BMP_ALIGN_CENTER;
+               else
+                       y = simple_strtoul(argv[3], NULL, 10);
                break;
        default:
                return CMD_RET_USAGE;
@@ -135,7 +144,7 @@ static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const ar
         return (bmp_display(addr, x, y));
 }
 
-static cmd_tbl_t cmd_bmp_sub[] = {
+static struct cmd_tbl cmd_bmp_sub[] = {
        U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""),
        U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""),
 };
@@ -156,9 +165,9 @@ void bmp_reloc(void) {
  * Return:      None
  *
  */
-static int do_bmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
-       cmd_tbl_t *c;
+       struct cmd_tbl *c;
 
        /* Strip off leading 'bmp' command argument */
        argc--;
@@ -246,20 +255,17 @@ int bmp_display(ulong addr, int x, int y)
        addr = map_to_sysmem(bmp);
 
 #ifdef CONFIG_DM_VIDEO
-       ret = uclass_first_device(UCLASS_VIDEO, &dev);
+       ret = uclass_first_device_err(UCLASS_VIDEO, &dev);
        if (!ret) {
-               if (!dev)
-                       ret = -ENODEV;
-               if (!ret) {
-                       bool align = false;
+               bool align = false;
 
-# ifdef CONFIG_SPLASH_SCREEN_ALIGN
+               if (CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN) ||
+                   x == BMP_ALIGN_CENTER ||
+                   y == BMP_ALIGN_CENTER)
                        align = true;
-# endif /* CONFIG_SPLASH_SCREEN_ALIGN */
-                       ret = video_bmp_display(dev, addr, x, y, align);
-               }
+
+               ret = video_bmp_display(dev, addr, x, y, align);
        }
-       return ret ? CMD_RET_FAILURE : 0;
 #elif defined(CONFIG_LCD)
        ret = lcd_display_bitmap(addr, x, y);
 #elif defined(CONFIG_VIDEO)
@@ -271,5 +277,5 @@ int bmp_display(ulong addr, int x, int y)
        if (bmp_alloc_addr)
                free(bmp_alloc_addr);
 
-       return ret;
+       return ret ? CMD_RET_FAILURE : 0;
 }