blob: 3b61844862450743167fbe5d1e3769361bcfa873 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk059ae172003-04-20 16:52:09 +00002/*
3 * (C) Copyright 2002
wdenkb37c7e52003-06-30 16:24:52 +00004 * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
wdenk059ae172003-04-20 16:52:09 +00005 */
6
7/*
8 * BMP handling routines
9 */
10
wdenk059ae172003-04-20 16:52:09 +000011#include <command.h>
Simon Glass8e8ccfe2019-12-28 10:45:03 -070012#include <image.h>
Simon Glass72b335e2016-01-05 09:30:58 -070013#include <mapmem.h>
Anatolij Gustschinff8fb562013-07-02 00:04:05 +020014#include <splash.h>
Stefan Reinauerf674f7c2012-09-28 15:11:11 +000015#include <video.h>
Nikhil M Jain58182b22023-04-20 17:41:06 +053016#include <stdlib.h>
Hans-Christian Egtvedt43ef1c32007-11-30 17:29:59 +010017
Simon Glass09140112020-05-10 11:40:03 -060018static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc,
19 char *const argv[])
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010020{
21 ulong addr;
22
23 switch (argc) {
Simon Glassbb872dd2019-12-28 10:45:02 -070024 case 1: /* use image_load_addr as default address */
25 addr = image_load_addr;
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010026 break;
27 case 2: /* use argument */
Simon Glass7e5f4602021-07-24 09:03:29 -060028 addr = hextoul(argv[1], NULL);
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010029 break;
30 default:
Simon Glass4c12eeb2011-12-10 08:44:01 +000031 return CMD_RET_USAGE;
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010032 }
33
34 return (bmp_info(addr));
35}
36
Simon Glass09140112020-05-10 11:40:03 -060037static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc,
38 char *const argv[])
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010039{
40 ulong addr;
41 int x = 0, y = 0;
42
Anatolij Gustschinff8fb562013-07-02 00:04:05 +020043 splash_get_pos(&x, &y);
44
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010045 switch (argc) {
Simon Glassbb872dd2019-12-28 10:45:02 -070046 case 1: /* use image_load_addr as default address */
47 addr = image_load_addr;
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010048 break;
49 case 2: /* use argument */
Simon Glass7e5f4602021-07-24 09:03:29 -060050 addr = hextoul(argv[1], NULL);
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010051 break;
52 case 4:
Simon Glass7e5f4602021-07-24 09:03:29 -060053 addr = hextoul(argv[1], NULL);
Patrick Delaunayb0fcedb2018-12-01 14:41:07 +010054 if (!strcmp(argv[2], "m"))
55 x = BMP_ALIGN_CENTER;
56 else
Simon Glass0b1284e2021-07-24 09:03:30 -060057 x = dectoul(argv[2], NULL);
Patrick Delaunayb0fcedb2018-12-01 14:41:07 +010058 if (!strcmp(argv[3], "m"))
59 y = BMP_ALIGN_CENTER;
60 else
Simon Glass0b1284e2021-07-24 09:03:30 -060061 y = dectoul(argv[3], NULL);
Wolfgang Denk93e14592013-10-04 17:43:24 +020062 break;
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010063 default:
Simon Glass4c12eeb2011-12-10 08:44:01 +000064 return CMD_RET_USAGE;
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010065 }
66
Nikhil M Jain58182b22023-04-20 17:41:06 +053067 return (bmp_display(addr, x, y));
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010068}
69
Simon Glass09140112020-05-10 11:40:03 -060070static struct cmd_tbl cmd_bmp_sub[] = {
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010071 U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""),
72 U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""),
73};
Hans-Christian Egtvedt43ef1c32007-11-30 17:29:59 +010074
Simon Glass09140112020-05-10 11:40:03 -060075static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
wdenk059ae172003-04-20 16:52:09 +000076{
Simon Glass09140112020-05-10 11:40:03 -060077 struct cmd_tbl *c;
wdenk059ae172003-04-20 16:52:09 +000078
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010079 /* Strip off leading 'bmp' command argument */
80 argc--;
81 argv++;
wdenk059ae172003-04-20 16:52:09 +000082
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010083 c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
84
Wolfgang Denk47e26b12010-07-17 01:06:04 +020085 if (c)
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010086 return c->cmd(cmdtp, flag, argc, argv);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020087 else
Simon Glass4c12eeb2011-12-10 08:44:01 +000088 return CMD_RET_USAGE;
wdenk059ae172003-04-20 16:52:09 +000089}
90
wdenk0d498392003-07-01 21:06:45 +000091U_BOOT_CMD(
wdenk4b248f32004-03-14 16:51:43 +000092 bmp, 5, 1, do_bmp,
Peter Tyser2fb26042009-01-27 18:03:12 -060093 "manipulate BMP image data",
wdenk4b248f32004-03-14 16:51:43 +000094 "info <imageAddr> - display image info\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +020095 "bmp display <imageAddr> [x y] - display image at x,y"
wdenkb0fce992003-06-29 21:03:46 +000096);