]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
059ae173 WD |
2 | /* |
3 | * (C) Copyright 2002 | |
b37c7e5e | 4 | * Detlev Zundel, DENX Software Engineering, [email protected]. |
059ae173 WD |
5 | */ |
6 | ||
7 | /* | |
8 | * BMP handling routines | |
9 | */ | |
10 | ||
059ae173 | 11 | #include <command.h> |
8e8ccfe1 | 12 | #include <image.h> |
72b335e9 | 13 | #include <mapmem.h> |
ff8fb56b | 14 | #include <splash.h> |
f674f7cf | 15 | #include <video.h> |
58182b2d | 16 | #include <stdlib.h> |
43ef1c38 | 17 | |
09140113 SG |
18 | static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc, |
19 | char *const argv[]) | |
9acd4f0e FM |
20 | { |
21 | ulong addr; | |
43ef1c38 | 22 | |
9acd4f0e | 23 | switch (argc) { |
bb872dd9 SG |
24 | case 1: /* use image_load_addr as default address */ |
25 | addr = image_load_addr; | |
9acd4f0e FM |
26 | break; |
27 | case 2: /* use argument */ | |
7e5f460e | 28 | addr = hextoul(argv[1], NULL); |
9acd4f0e FM |
29 | break; |
30 | default: | |
4c12eeb8 | 31 | return CMD_RET_USAGE; |
9acd4f0e FM |
32 | } |
33 | ||
34 | return (bmp_info(addr)); | |
35 | } | |
36 | ||
09140113 SG |
37 | static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc, |
38 | char *const argv[]) | |
059ae173 WD |
39 | { |
40 | ulong addr; | |
4b248f3f | 41 | int x = 0, y = 0; |
059ae173 | 42 | |
ff8fb56b AG |
43 | splash_get_pos(&x, &y); |
44 | ||
059ae173 | 45 | switch (argc) { |
bb872dd9 SG |
46 | case 1: /* use image_load_addr as default address */ |
47 | addr = image_load_addr; | |
059ae173 | 48 | break; |
9acd4f0e | 49 | case 2: /* use argument */ |
7e5f460e | 50 | addr = hextoul(argv[1], NULL); |
059ae173 | 51 | break; |
9acd4f0e | 52 | case 4: |
7e5f460e | 53 | addr = hextoul(argv[1], NULL); |
b0fcedb7 PD |
54 | if (!strcmp(argv[2], "m")) |
55 | x = BMP_ALIGN_CENTER; | |
56 | else | |
0b1284eb | 57 | x = dectoul(argv[2], NULL); |
b0fcedb7 PD |
58 | if (!strcmp(argv[3], "m")) |
59 | y = BMP_ALIGN_CENTER; | |
60 | else | |
0b1284eb | 61 | y = dectoul(argv[3], NULL); |
93e14596 | 62 | break; |
059ae173 | 63 | default: |
4c12eeb8 | 64 | return CMD_RET_USAGE; |
059ae173 WD |
65 | } |
66 | ||
58182b2d | 67 | return (bmp_display(addr, x, y)); |
9acd4f0e FM |
68 | } |
69 | ||
09140113 | 70 | static struct cmd_tbl cmd_bmp_sub[] = { |
9acd4f0e FM |
71 | U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""), |
72 | U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""), | |
73 | }; | |
74 | ||
09140113 | 75 | static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
9acd4f0e | 76 | { |
09140113 | 77 | struct cmd_tbl *c; |
9acd4f0e FM |
78 | |
79 | /* Strip off leading 'bmp' command argument */ | |
80 | argc--; | |
81 | argv++; | |
82 | ||
83 | c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub)); | |
84 | ||
47e26b1b | 85 | if (c) |
9acd4f0e | 86 | return c->cmd(cmdtp, flag, argc, argv); |
47e26b1b | 87 | else |
4c12eeb8 | 88 | return CMD_RET_USAGE; |
059ae173 WD |
89 | } |
90 | ||
0d498393 | 91 | U_BOOT_CMD( |
4b248f3f | 92 | bmp, 5, 1, do_bmp, |
2fb2604d | 93 | "manipulate BMP image data", |
4b248f3f | 94 | "info <imageAddr> - display image info\n" |
a89c33db | 95 | "bmp display <imageAddr> [x y] - display image at x,y" |
b0fce99b | 96 | ); |