]> git.ipfire.org Git - thirdparty/u-boot.git/blob - cmd/bmp.c
Merge branch 'for-2023.07-2' of https://source.denx.de/u-boot/custodians/u-boot-mpc8xx
[thirdparty/u-boot.git] / cmd / bmp.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * (C) Copyright 2002
4 * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
5 */
6
7 /*
8 * BMP handling routines
9 */
10
11 #include <common.h>
12 #include <command.h>
13 #include <image.h>
14 #include <mapmem.h>
15 #include <splash.h>
16 #include <video.h>
17 #include <stdlib.h>
18
19 static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc,
20 char *const argv[])
21 {
22 ulong addr;
23
24 switch (argc) {
25 case 1: /* use image_load_addr as default address */
26 addr = image_load_addr;
27 break;
28 case 2: /* use argument */
29 addr = hextoul(argv[1], NULL);
30 break;
31 default:
32 return CMD_RET_USAGE;
33 }
34
35 return (bmp_info(addr));
36 }
37
38 static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc,
39 char *const argv[])
40 {
41 ulong addr;
42 int x = 0, y = 0;
43
44 splash_get_pos(&x, &y);
45
46 switch (argc) {
47 case 1: /* use image_load_addr as default address */
48 addr = image_load_addr;
49 break;
50 case 2: /* use argument */
51 addr = hextoul(argv[1], NULL);
52 break;
53 case 4:
54 addr = hextoul(argv[1], NULL);
55 if (!strcmp(argv[2], "m"))
56 x = BMP_ALIGN_CENTER;
57 else
58 x = dectoul(argv[2], NULL);
59 if (!strcmp(argv[3], "m"))
60 y = BMP_ALIGN_CENTER;
61 else
62 y = dectoul(argv[3], NULL);
63 break;
64 default:
65 return CMD_RET_USAGE;
66 }
67
68 return (bmp_display(addr, x, y));
69 }
70
71 static struct cmd_tbl cmd_bmp_sub[] = {
72 U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""),
73 U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""),
74 };
75
76 static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
77 {
78 struct cmd_tbl *c;
79
80 /* Strip off leading 'bmp' command argument */
81 argc--;
82 argv++;
83
84 c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
85
86 if (c)
87 return c->cmd(cmdtp, flag, argc, argv);
88 else
89 return CMD_RET_USAGE;
90 }
91
92 U_BOOT_CMD(
93 bmp, 5, 1, do_bmp,
94 "manipulate BMP image data",
95 "info <imageAddr> - display image info\n"
96 "bmp display <imageAddr> [x y] - display image at x,y"
97 );