travis: Split bcm SoCs into their own build job
[oweals/u-boot.git] / cmd / bmp.c
index fd5b7db28852a7dcf225b066744e4591658dcb28..d2a39f677fda9fa567da98ef1ca67467ef0bdd40 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 <lcd.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 +57,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) {
@@ -125,8 +124,14 @@ static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const ar
                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;
@@ -246,20 +251,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 +273,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;
 }