blob: 3b61844862450743167fbe5d1e3769361bcfa873 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenkf5f146e2003-04-20 16:52:09 +00002/*
3 * (C) Copyright 2002
wdenkb9bbd242003-06-30 16:24:52 +00004 * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
wdenkf5f146e2003-04-20 16:52:09 +00005 */
6
7/*
8 * BMP handling routines
9 */
10
wdenkf5f146e2003-04-20 16:52:09 +000011#include <command.h>
Simon Glass85f13782019-12-28 10:45:03 -070012#include <image.h>
Simon Glasscd161d82016-01-05 09:30:58 -070013#include <mapmem.h>
Anatolij Gustschinb9b5eaf2013-07-02 00:04:05 +020014#include <splash.h>
Stefan Reinauer987d1d82012-09-28 15:11:11 +000015#include <video.h>
Nikhil M Jain737d2ed2023-04-20 17:41:06 +053016#include <stdlib.h>
Hans-Christian Egtvedt68d89dc2007-11-30 17:29:59 +010017
Simon Glassed38aef2020-05-10 11:40:03 -060018static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc,
19 char *const argv[])
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010020{
21 ulong addr;
Hans-Christian Egtvedt68d89dc2007-11-30 17:29:59 +010022
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010023 switch (argc) {
Simon Glass892265d2019-12-28 10:45:02 -070024 case 1: /* use image_load_addr as default address */
25 addr = image_load_addr;
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010026 break;
27 case 2: /* use argument */
Simon Glass3ff49ec2021-07-24 09:03:29 -060028 addr = hextoul(argv[1], NULL);
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010029 break;
30 default:
Simon Glassa06dfc72011-12-10 08:44:01 +000031 return CMD_RET_USAGE;
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010032 }
33
34 return (bmp_info(addr));
35}
36
Simon Glassed38aef2020-05-10 11:40:03 -060037static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc,
38 char *const argv[])
wdenkf5f146e2003-04-20 16:52:09 +000039{
40 ulong addr;
wdenke55402c2004-03-14 16:51:43 +000041 int x = 0, y = 0;
wdenkf5f146e2003-04-20 16:52:09 +000042
Anatolij Gustschinb9b5eaf2013-07-02 00:04:05 +020043 splash_get_pos(&x, &y);
44
wdenkf5f146e2003-04-20 16:52:09 +000045 switch (argc) {
Simon Glass892265d2019-12-28 10:45:02 -070046 case 1: /* use image_load_addr as default address */
47 addr = image_load_addr;
wdenkf5f146e2003-04-20 16:52:09 +000048 break;
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010049 case 2: /* use argument */
Simon Glass3ff49ec2021-07-24 09:03:29 -060050 addr = hextoul(argv[1], NULL);
wdenkf5f146e2003-04-20 16:52:09 +000051 break;
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010052 case 4:
Simon Glass3ff49ec2021-07-24 09:03:29 -060053 addr = hextoul(argv[1], NULL);
Patrick Delaunay28e07f32018-12-01 14:41:07 +010054 if (!strcmp(argv[2], "m"))
55 x = BMP_ALIGN_CENTER;
56 else
Simon Glassff9b9032021-07-24 09:03:30 -060057 x = dectoul(argv[2], NULL);
Patrick Delaunay28e07f32018-12-01 14:41:07 +010058 if (!strcmp(argv[3], "m"))
59 y = BMP_ALIGN_CENTER;
60 else
Simon Glassff9b9032021-07-24 09:03:30 -060061 y = dectoul(argv[3], NULL);
Wolfgang Denkec7fbf52013-10-04 17:43:24 +020062 break;
wdenkf5f146e2003-04-20 16:52:09 +000063 default:
Simon Glassa06dfc72011-12-10 08:44:01 +000064 return CMD_RET_USAGE;
wdenkf5f146e2003-04-20 16:52:09 +000065 }
66
Nikhil M Jain737d2ed2023-04-20 17:41:06 +053067 return (bmp_display(addr, x, y));
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010068}
69
Simon Glassed38aef2020-05-10 11:40:03 -060070static struct cmd_tbl cmd_bmp_sub[] = {
Frans Meulenbroeksc59bc502010-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};
74
Simon Glassed38aef2020-05-10 11:40:03 -060075static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010076{
Simon Glassed38aef2020-05-10 11:40:03 -060077 struct cmd_tbl *c;
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010078
79 /* Strip off leading 'bmp' command argument */
80 argc--;
81 argv++;
82
83 c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
84
Wolfgang Denk3b683112010-07-17 01:06:04 +020085 if (c)
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010086 return c->cmd(cmdtp, flag, argc, argv);
Wolfgang Denk3b683112010-07-17 01:06:04 +020087 else
Simon Glassa06dfc72011-12-10 08:44:01 +000088 return CMD_RET_USAGE;
wdenkf5f146e2003-04-20 16:52:09 +000089}
90
wdenkf287a242003-07-01 21:06:45 +000091U_BOOT_CMD(
wdenke55402c2004-03-14 16:51:43 +000092 bmp, 5, 1, do_bmp,
Peter Tyserdfb72b82009-01-27 18:03:12 -060093 "manipulate BMP image data",
wdenke55402c2004-03-14 16:51:43 +000094 "info <imageAddr> - display image info\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +020095 "bmp display <imageAddr> [x y] - display image at x,y"
wdenkf12e3962003-06-29 21:03:46 +000096);