2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2003-04-20 16:52:09 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002
|
2003-06-30 16:24:52 +00:00
|
|
|
* Detlev Zundel, DENX Software Engineering, dzu@denx.de.
|
2003-04-20 16:52:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BMP handling routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2019-12-28 17:45:03 +00:00
|
|
|
#include <image.h>
|
2016-01-05 16:30:58 +00:00
|
|
|
#include <mapmem.h>
|
2013-07-01 22:04:05 +00:00
|
|
|
#include <splash.h>
|
2012-09-28 15:11:11 +00:00
|
|
|
#include <video.h>
|
2023-04-20 12:11:06 +00:00
|
|
|
#include <stdlib.h>
|
2007-11-30 16:29:59 +00:00
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2010-03-27 10:16:10 +00:00
|
|
|
{
|
|
|
|
ulong addr;
|
2007-11-30 16:29:59 +00:00
|
|
|
|
2010-03-27 10:16:10 +00:00
|
|
|
switch (argc) {
|
2019-12-28 17:45:02 +00:00
|
|
|
case 1: /* use image_load_addr as default address */
|
|
|
|
addr = image_load_addr;
|
2010-03-27 10:16:10 +00:00
|
|
|
break;
|
|
|
|
case 2: /* use argument */
|
2021-07-24 15:03:29 +00:00
|
|
|
addr = hextoul(argv[1], NULL);
|
2010-03-27 10:16:10 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-12-10 08:44:01 +00:00
|
|
|
return CMD_RET_USAGE;
|
2010-03-27 10:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (bmp_info(addr));
|
|
|
|
}
|
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2003-04-20 16:52:09 +00:00
|
|
|
{
|
|
|
|
ulong addr;
|
2004-03-14 16:51:43 +00:00
|
|
|
int x = 0, y = 0;
|
2003-04-20 16:52:09 +00:00
|
|
|
|
2013-07-01 22:04:05 +00:00
|
|
|
splash_get_pos(&x, &y);
|
|
|
|
|
2003-04-20 16:52:09 +00:00
|
|
|
switch (argc) {
|
2019-12-28 17:45:02 +00:00
|
|
|
case 1: /* use image_load_addr as default address */
|
|
|
|
addr = image_load_addr;
|
2003-04-20 16:52:09 +00:00
|
|
|
break;
|
2010-03-27 10:16:10 +00:00
|
|
|
case 2: /* use argument */
|
2021-07-24 15:03:29 +00:00
|
|
|
addr = hextoul(argv[1], NULL);
|
2003-04-20 16:52:09 +00:00
|
|
|
break;
|
2010-03-27 10:16:10 +00:00
|
|
|
case 4:
|
2021-07-24 15:03:29 +00:00
|
|
|
addr = hextoul(argv[1], NULL);
|
2018-12-01 13:41:07 +00:00
|
|
|
if (!strcmp(argv[2], "m"))
|
|
|
|
x = BMP_ALIGN_CENTER;
|
|
|
|
else
|
2021-07-24 15:03:30 +00:00
|
|
|
x = dectoul(argv[2], NULL);
|
2018-12-01 13:41:07 +00:00
|
|
|
if (!strcmp(argv[3], "m"))
|
|
|
|
y = BMP_ALIGN_CENTER;
|
|
|
|
else
|
2021-07-24 15:03:30 +00:00
|
|
|
y = dectoul(argv[3], NULL);
|
2013-10-04 15:43:24 +00:00
|
|
|
break;
|
2003-04-20 16:52:09 +00:00
|
|
|
default:
|
2011-12-10 08:44:01 +00:00
|
|
|
return CMD_RET_USAGE;
|
2003-04-20 16:52:09 +00:00
|
|
|
}
|
|
|
|
|
2023-04-20 12:11:06 +00:00
|
|
|
return (bmp_display(addr, x, y));
|
2010-03-27 10:16:10 +00:00
|
|
|
}
|
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
static struct cmd_tbl cmd_bmp_sub[] = {
|
2010-03-27 10:16:10 +00:00
|
|
|
U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""),
|
|
|
|
U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""),
|
|
|
|
};
|
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
2010-03-27 10:16:10 +00:00
|
|
|
{
|
2020-05-10 17:40:03 +00:00
|
|
|
struct cmd_tbl *c;
|
2010-03-27 10:16:10 +00:00
|
|
|
|
|
|
|
/* Strip off leading 'bmp' command argument */
|
|
|
|
argc--;
|
|
|
|
argv++;
|
|
|
|
|
|
|
|
c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
|
|
|
|
|
2010-07-16 23:06:04 +00:00
|
|
|
if (c)
|
2010-03-27 10:16:10 +00:00
|
|
|
return c->cmd(cmdtp, flag, argc, argv);
|
2010-07-16 23:06:04 +00:00
|
|
|
else
|
2011-12-10 08:44:01 +00:00
|
|
|
return CMD_RET_USAGE;
|
2003-04-20 16:52:09 +00:00
|
|
|
}
|
|
|
|
|
2003-07-01 21:06:45 +00:00
|
|
|
U_BOOT_CMD(
|
2004-03-14 16:51:43 +00:00
|
|
|
bmp, 5, 1, do_bmp,
|
2009-01-28 00:03:12 +00:00
|
|
|
"manipulate BMP image data",
|
2004-03-14 16:51:43 +00:00
|
|
|
"info <imageAddr> - display image info\n"
|
2009-05-24 15:06:54 +00:00
|
|
|
"bmp display <imageAddr> [x y] - display image at x,y"
|
2003-06-29 21:03:46 +00:00
|
|
|
);
|