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