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