Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 059ae17 | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2002 |
wdenk | b37c7e5 | 2003-06-30 16:24:52 +0000 | [diff] [blame] | 4 | * Detlev Zundel, DENX Software Engineering, dzu@denx.de. |
wdenk | 059ae17 | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * BMP handling routines |
| 9 | */ |
| 10 | |
| 11 | #include <common.h> |
wdenk | 059ae17 | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 12 | #include <command.h> |
Simon Glass | 8e8ccfe | 2019-12-28 10:45:03 -0700 | [diff] [blame] | 13 | #include <image.h> |
Simon Glass | 72b335e | 2016-01-05 09:30:58 -0700 | [diff] [blame] | 14 | #include <mapmem.h> |
Anatolij Gustschin | ff8fb56 | 2013-07-02 00:04:05 +0200 | [diff] [blame] | 15 | #include <splash.h> |
Stefan Reinauer | f674f7c | 2012-09-28 15:11:11 +0000 | [diff] [blame] | 16 | #include <video.h> |
Nikhil M Jain | 58182b2 | 2023-04-20 17:41:06 +0530 | [diff] [blame] | 17 | #include <stdlib.h> |
Hans-Christian Egtvedt | 43ef1c3 | 2007-11-30 17:29:59 +0100 | [diff] [blame] | 18 | |
Simon Glass | 0914011 | 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 | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 21 | { |
| 22 | ulong addr; |
| 23 | |
| 24 | switch (argc) { |
Simon Glass | bb872dd | 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 | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 27 | break; |
| 28 | case 2: /* use argument */ |
Simon Glass | 7e5f460 | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 29 | addr = hextoul(argv[1], NULL); |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 30 | break; |
| 31 | default: |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 32 | return CMD_RET_USAGE; |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | return (bmp_info(addr)); |
| 36 | } |
| 37 | |
Simon Glass | 0914011 | 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[]) |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 40 | { |
| 41 | ulong addr; |
| 42 | int x = 0, y = 0; |
| 43 | |
Anatolij Gustschin | ff8fb56 | 2013-07-02 00:04:05 +0200 | [diff] [blame] | 44 | splash_get_pos(&x, &y); |
| 45 | |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 46 | switch (argc) { |
Simon Glass | bb872dd | 2019-12-28 10:45:02 -0700 | [diff] [blame] | 47 | case 1: /* use image_load_addr as default address */ |
| 48 | addr = image_load_addr; |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 49 | break; |
| 50 | case 2: /* use argument */ |
Simon Glass | 7e5f460 | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 51 | addr = hextoul(argv[1], NULL); |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 52 | break; |
| 53 | case 4: |
Simon Glass | 7e5f460 | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 54 | addr = hextoul(argv[1], NULL); |
Patrick Delaunay | b0fcedb | 2018-12-01 14:41:07 +0100 | [diff] [blame] | 55 | if (!strcmp(argv[2], "m")) |
| 56 | x = BMP_ALIGN_CENTER; |
| 57 | else |
Simon Glass | 0b1284e | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 58 | x = dectoul(argv[2], NULL); |
Patrick Delaunay | b0fcedb | 2018-12-01 14:41:07 +0100 | [diff] [blame] | 59 | if (!strcmp(argv[3], "m")) |
| 60 | y = BMP_ALIGN_CENTER; |
| 61 | else |
Simon Glass | 0b1284e | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 62 | y = dectoul(argv[3], NULL); |
Wolfgang Denk | 93e1459 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 63 | break; |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 64 | default: |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 65 | return CMD_RET_USAGE; |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 66 | } |
| 67 | |
Nikhil M Jain | 58182b2 | 2023-04-20 17:41:06 +0530 | [diff] [blame] | 68 | return (bmp_display(addr, x, y)); |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 69 | } |
| 70 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 71 | static struct cmd_tbl cmd_bmp_sub[] = { |
Frans Meulenbroeks | 9acd4f0 | 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 | }; |
Hans-Christian Egtvedt | 43ef1c3 | 2007-11-30 17:29:59 +0100 | [diff] [blame] | 75 | |
Simon Glass | 0914011 | 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[]) |
wdenk | 059ae17 | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 77 | { |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 78 | struct cmd_tbl *c; |
wdenk | 059ae17 | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 79 | |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 80 | /* Strip off leading 'bmp' command argument */ |
| 81 | argc--; |
| 82 | argv++; |
wdenk | 059ae17 | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 83 | |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 84 | c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub)); |
| 85 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 86 | if (c) |
Frans Meulenbroeks | 9acd4f0 | 2010-03-27 11:16:10 +0100 | [diff] [blame] | 87 | return c->cmd(cmdtp, flag, argc, argv); |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 88 | else |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 89 | return CMD_RET_USAGE; |
wdenk | 059ae17 | 2003-04-20 16:52:09 +0000 | [diff] [blame] | 90 | } |
| 91 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 92 | U_BOOT_CMD( |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 93 | bmp, 5, 1, do_bmp, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 94 | "manipulate BMP image data", |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 95 | "info <imageAddr> - display image info\n" |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 96 | "bmp display <imageAddr> [x y] - display image at x,y" |
wdenk | b0fce99 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 97 | ); |