[PATCH v3 08/15] cmd: bmp: Split bmp commands and functions
Nikhil M Jain
n-jain1 at ti.com
Wed Mar 29 12:30:09 CEST 2023
To enable splash screen at spl, need to compile cmd/bmp.c which also
includes bmp commands, since SPL can't have commands split bmp.c into
common/bmp.c which includes all bmp functions and cmd/bmp_cmd contains
bmp commands.
Add delclaration for bmp_info in video.h.
Signed-off-by: Nikhil M Jain <n-jain1 at ti.com>
---
cmd/bmp_cmd.c | 98 +++++++++++++++++++++++++++++++++++++++
{cmd => common}/bmp.c | 104 +-----------------------------------------
include/video.h | 7 +++
3 files changed, 106 insertions(+), 103 deletions(-)
create mode 100644 cmd/bmp_cmd.c
rename {cmd => common}/bmp.c (62%)
diff --git a/cmd/bmp_cmd.c b/cmd/bmp_cmd.c
new file mode 100644
index 0000000000..735790fda7
--- /dev/null
+++ b/cmd/bmp_cmd.c
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2002
+ * Detlev Zundel, DENX Software Engineering, dzu at denx.de.
+ */
+
+/*
+ * BMP handling routines
+ */
+
+#include <common.h>
+#include <bmp_layout.h>
+#include <command.h>
+#include <image.h>
+#include <mapmem.h>
+#include <splash.h>
+#include <video.h>
+#include <stdlib.h>
+
+static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ ulong addr;
+
+ switch (argc) {
+ case 1: /* use image_load_addr as default address */
+ addr = image_load_addr;
+ break;
+ case 2: /* use argument */
+ addr = hextoul(argv[1], NULL);
+ break;
+ default:
+ return CMD_RET_USAGE;
+ }
+
+ return (bmp_info(addr));
+}
+
+static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ ulong addr;
+ int x = 0, y = 0;
+
+ splash_get_pos(&x, &y);
+
+ switch (argc) {
+ case 1: /* use image_load_addr as default address */
+ addr = image_load_addr;
+ break;
+ case 2: /* use argument */
+ addr = hextoul(argv[1], NULL);
+ break;
+ case 4:
+ addr = hextoul(argv[1], NULL);
+ if (!strcmp(argv[2], "m"))
+ x = BMP_ALIGN_CENTER;
+ else
+ x = dectoul(argv[2], NULL);
+ if (!strcmp(argv[3], "m"))
+ y = BMP_ALIGN_CENTER;
+ else
+ y = dectoul(argv[3], NULL);
+ break;
+ default:
+ return CMD_RET_USAGE;
+ }
+
+ return (bmp_display(addr, x, y));
+}
+
+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, "", ""),
+};
+
+static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ struct cmd_tbl *c;
+
+ /* Strip off leading 'bmp' command argument */
+ argc--;
+ argv++;
+
+ c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
+
+ if (c)
+ return c->cmd(cmdtp, flag, argc, argv);
+ else
+ return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+ bmp, 5, 1, do_bmp,
+ "manipulate BMP image data",
+ "info <imageAddr> - display image info\n"
+ "bmp display <imageAddr> [x y] - display image at x,y"
+);
diff --git a/cmd/bmp.c b/common/bmp.c
similarity index 62%
rename from cmd/bmp.c
rename to common/bmp.c
index 46d0d916e8..540d06e63f 100644
--- a/cmd/bmp.c
+++ b/common/bmp.c
@@ -13,7 +13,6 @@
#include <command.h>
#include <dm.h>
#include <gzip.h>
-#include <image.h>
#include <log.h>
#include <malloc.h>
#include <mapmem.h>
@@ -21,8 +20,6 @@
#include <video.h>
#include <asm/byteorder.h>
-static int bmp_info (ulong addr);
-
/*
* Allocate and decompress a BMP image using gunzip().
*
@@ -88,62 +85,6 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
}
#endif
-static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[])
-{
- ulong addr;
-
- switch (argc) {
- case 1: /* use image_load_addr as default address */
- addr = image_load_addr;
- break;
- case 2: /* use argument */
- addr = hextoul(argv[1], NULL);
- break;
- default:
- return CMD_RET_USAGE;
- }
-
- return (bmp_info(addr));
-}
-
-static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[])
-{
- ulong addr;
- int x = 0, y = 0;
-
- splash_get_pos(&x, &y);
-
- switch (argc) {
- case 1: /* use image_load_addr as default address */
- addr = image_load_addr;
- break;
- case 2: /* use argument */
- addr = hextoul(argv[1], NULL);
- break;
- case 4:
- addr = hextoul(argv[1], NULL);
- if (!strcmp(argv[2], "m"))
- x = BMP_ALIGN_CENTER;
- else
- x = dectoul(argv[2], NULL);
- if (!strcmp(argv[3], "m"))
- y = BMP_ALIGN_CENTER;
- else
- y = dectoul(argv[3], NULL);
- break;
- default:
- return CMD_RET_USAGE;
- }
-
- return (bmp_display(addr, x, y));
-}
-
-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, "", ""),
-};
#ifdef CONFIG_NEEDS_MANUAL_RELOC
void bmp_reloc(void) {
@@ -151,50 +92,7 @@ void bmp_reloc(void) {
}
#endif
-/*
- * Subroutine: do_bmp
- *
- * Description: Handler for 'bmp' command..
- *
- * Inputs: argv[1] contains the subcommand
- *
- * Return: None
- *
- */
-static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
- struct cmd_tbl *c;
-
- /* Strip off leading 'bmp' command argument */
- argc--;
- argv++;
-
- c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
-
- if (c)
- return c->cmd(cmdtp, flag, argc, argv);
- else
- return CMD_RET_USAGE;
-}
-
-U_BOOT_CMD(
- bmp, 5, 1, do_bmp,
- "manipulate BMP image data",
- "info <imageAddr> - display image info\n"
- "bmp display <imageAddr> [x y] - display image at x,y"
-);
-
-/*
- * Subroutine: bmp_info
- *
- * Description: Show information about bmp file in memory
- *
- * Inputs: addr address of the bmp file
- *
- * Return: None
- *
- */
-static int bmp_info(ulong addr)
+int bmp_info(ulong addr)
{
struct bmp_image *bmp = (struct bmp_image *)map_sysmem(addr, 0);
void *bmp_alloc_addr = NULL;
diff --git a/include/video.h b/include/video.h
index 3f67a93bc9..4b7e866c65 100644
--- a/include/video.h
+++ b/include/video.h
@@ -355,4 +355,11 @@ void *video_get_u_boot_logo(void);
*/
int bmp_display(ulong addr, int x, int y);
+/*
+ * bmp_info() - Show information about bmp file
+ *
+ * @addr: address of bmp file
+ */
+int bmp_info(ulong addr);
+
#endif
--
2.34.1
More information about the U-Boot
mailing list