blob: 8f43a40dafdd430e36e1e19764982848037e8094 [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
11#include <common.h>
wdenkf5f146e2003-04-20 16:52:09 +000012#include <command.h>
Simon Glass85f13782019-12-28 10:45:03 -070013#include <image.h>
Simon Glasscd161d82016-01-05 09:30:58 -070014#include <mapmem.h>
Anatolij Gustschinb9b5eaf2013-07-02 00:04:05 +020015#include <splash.h>
Stefan Reinauer987d1d82012-09-28 15:11:11 +000016#include <video.h>
Nikhil M Jain737d2ed2023-04-20 17:41:06 +053017#include <stdlib.h>
Hans-Christian Egtvedt68d89dc2007-11-30 17:29:59 +010018
Simon Glassed38aef2020-05-10 11:40:03 -060019static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc,
20 char *const argv[])
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010021{
22 ulong addr;
Hans-Christian Egtvedt68d89dc2007-11-30 17:29:59 +010023
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010024 switch (argc) {
Simon Glass892265d2019-12-28 10:45:02 -070025 case 1: /* use image_load_addr as default address */
26 addr = image_load_addr;
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010027 break;
28 case 2: /* use argument */
Simon Glass3ff49ec2021-07-24 09:03:29 -060029 addr = hextoul(argv[1], NULL);
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010030 break;
31 default:
Simon Glassa06dfc72011-12-10 08:44:01 +000032 return CMD_RET_USAGE;
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010033 }
34
35 return (bmp_info(addr));
36}
37
Simon Glassed38aef2020-05-10 11:40:03 -060038static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc,
39 char *const argv[])
wdenkf5f146e2003-04-20 16:52:09 +000040{
41 ulong addr;
wdenke55402c2004-03-14 16:51:43 +000042 int x = 0, y = 0;
wdenkf5f146e2003-04-20 16:52:09 +000043
Anatolij Gustschinb9b5eaf2013-07-02 00:04:05 +020044 splash_get_pos(&x, &y);
45
wdenkf5f146e2003-04-20 16:52:09 +000046 switch (argc) {
Simon Glass892265d2019-12-28 10:45:02 -070047 case 1: /* use image_load_addr as default address */
48 addr = image_load_addr;
wdenkf5f146e2003-04-20 16:52:09 +000049 break;
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010050 case 2: /* use argument */
Simon Glass3ff49ec2021-07-24 09:03:29 -060051 addr = hextoul(argv[1], NULL);
wdenkf5f146e2003-04-20 16:52:09 +000052 break;
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010053 case 4:
Simon Glass3ff49ec2021-07-24 09:03:29 -060054 addr = hextoul(argv[1], NULL);
Patrick Delaunay28e07f32018-12-01 14:41:07 +010055 if (!strcmp(argv[2], "m"))
56 x = BMP_ALIGN_CENTER;
57 else
Simon Glassff9b9032021-07-24 09:03:30 -060058 x = dectoul(argv[2], NULL);
Patrick Delaunay28e07f32018-12-01 14:41:07 +010059 if (!strcmp(argv[3], "m"))
60 y = BMP_ALIGN_CENTER;
61 else
Simon Glassff9b9032021-07-24 09:03:30 -060062 y = dectoul(argv[3], NULL);
Wolfgang Denkec7fbf52013-10-04 17:43:24 +020063 break;
wdenkf5f146e2003-04-20 16:52:09 +000064 default:
Simon Glassa06dfc72011-12-10 08:44:01 +000065 return CMD_RET_USAGE;
wdenkf5f146e2003-04-20 16:52:09 +000066 }
67
Nikhil M Jain737d2ed2023-04-20 17:41:06 +053068 return (bmp_display(addr, x, y));
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010069}
70
Simon Glassed38aef2020-05-10 11:40:03 -060071static struct cmd_tbl cmd_bmp_sub[] = {
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010072 U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""),
73 U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""),
74};
75
Simon Glassed38aef2020-05-10 11:40:03 -060076static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010077{
Simon Glassed38aef2020-05-10 11:40:03 -060078 struct cmd_tbl *c;
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010079
80 /* Strip off leading 'bmp' command argument */
81 argc--;
82 argv++;
83
84 c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
85
Wolfgang Denk3b683112010-07-17 01:06:04 +020086 if (c)
Frans Meulenbroeksc59bc502010-03-27 11:16:10 +010087 return c->cmd(cmdtp, flag, argc, argv);
Wolfgang Denk3b683112010-07-17 01:06:04 +020088 else
Simon Glassa06dfc72011-12-10 08:44:01 +000089 return CMD_RET_USAGE;
wdenkf5f146e2003-04-20 16:52:09 +000090}
91
wdenkf287a242003-07-01 21:06:45 +000092U_BOOT_CMD(
wdenke55402c2004-03-14 16:51:43 +000093 bmp, 5, 1, do_bmp,
Peter Tyserdfb72b82009-01-27 18:03:12 -060094 "manipulate BMP image data",
wdenke55402c2004-03-14 16:51:43 +000095 "info <imageAddr> - display image info\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +020096 "bmp display <imageAddr> [x y] - display image at x,y"
wdenkf12e3962003-06-29 21:03:46 +000097);