Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2002 |
wdenk | b9bbd24 | 2003-06-30 16:24:52 +0000 | [diff] [blame] | 4 | * Detlev Zundel, DENX Software Engineering, dzu@denx.de. |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * BMP handling routines |
| 9 | */ |
| 10 | |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 11 | #include <command.h> |
Simon Glass | 85f1378 | 2019-12-28 10:45:03 -0700 | [diff] [blame] | 12 | #include <image.h> |
Simon Glass | cd161d8 | 2016-01-05 09:30:58 -0700 | [diff] [blame] | 13 | #include <mapmem.h> |
Anatolij Gustschin | b9b5eaf | 2013-07-02 00:04:05 +0200 | [diff] [blame] | 14 | #include <splash.h> |
Stefan Reinauer | 987d1d8 | 2012-09-28 15:11:11 +0000 | [diff] [blame] | 15 | #include <video.h> |
Nikhil M Jain | 737d2ed | 2023-04-20 17:41:06 +0530 | [diff] [blame] | 16 | #include <stdlib.h> |
Hans-Christian Egtvedt | 68d89dc | 2007-11-30 17:29:59 +0100 | [diff] [blame] | 17 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 18 | static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc, |
| 19 | char *const argv[]) |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 20 | { |
| 21 | ulong addr; |
Hans-Christian Egtvedt | 68d89dc | 2007-11-30 17:29:59 +0100 | [diff] [blame] | 22 | |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 23 | switch (argc) { |
Simon Glass | 892265d | 2019-12-28 10:45:02 -0700 | [diff] [blame] | 24 | case 1: /* use image_load_addr as default address */ |
| 25 | addr = image_load_addr; |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 26 | break; |
| 27 | case 2: /* use argument */ |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 28 | addr = hextoul(argv[1], NULL); |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 29 | break; |
| 30 | default: |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 31 | return CMD_RET_USAGE; |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | return (bmp_info(addr)); |
| 35 | } |
| 36 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 37 | static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc, |
| 38 | char *const argv[]) |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 39 | { |
| 40 | ulong addr; |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 41 | int x = 0, y = 0; |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 42 | |
Anatolij Gustschin | b9b5eaf | 2013-07-02 00:04:05 +0200 | [diff] [blame] | 43 | splash_get_pos(&x, &y); |
| 44 | |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 45 | switch (argc) { |
Simon Glass | 892265d | 2019-12-28 10:45:02 -0700 | [diff] [blame] | 46 | case 1: /* use image_load_addr as default address */ |
| 47 | addr = image_load_addr; |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 48 | break; |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 49 | case 2: /* use argument */ |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 50 | addr = hextoul(argv[1], NULL); |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 51 | break; |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 52 | case 4: |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 53 | addr = hextoul(argv[1], NULL); |
Patrick Delaunay | 28e07f3 | 2018-12-01 14:41:07 +0100 | [diff] [blame] | 54 | if (!strcmp(argv[2], "m")) |
| 55 | x = BMP_ALIGN_CENTER; |
| 56 | else |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 57 | x = dectoul(argv[2], NULL); |
Patrick Delaunay | 28e07f3 | 2018-12-01 14:41:07 +0100 | [diff] [blame] | 58 | if (!strcmp(argv[3], "m")) |
| 59 | y = BMP_ALIGN_CENTER; |
| 60 | else |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 61 | y = dectoul(argv[3], NULL); |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 62 | break; |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 63 | default: |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 64 | return CMD_RET_USAGE; |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Nikhil M Jain | 737d2ed | 2023-04-20 17:41:06 +0530 | [diff] [blame] | 67 | return (bmp_display(addr, x, y)); |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 68 | } |
| 69 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 70 | static struct cmd_tbl cmd_bmp_sub[] = { |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 71 | U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""), |
| 72 | U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""), |
| 73 | }; |
| 74 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 75 | static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 76 | { |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 77 | struct cmd_tbl *c; |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 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 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 85 | if (c) |
Frans Meulenbroeks | c59bc50 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 86 | return c->cmd(cmdtp, flag, argc, argv); |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 87 | else |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 88 | return CMD_RET_USAGE; |
wdenk | f5f146e | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 89 | } |
| 90 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 91 | U_BOOT_CMD( |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 92 | bmp, 5, 1, do_bmp, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 93 | "manipulate BMP image data", |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 94 | "info <imageAddr> - display image info\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 95 | "bmp display <imageAddr> [x y] - display image at x,y" |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 96 | ); |