blob: 8f43a40dafdd430e36e1e19764982848037e8094 [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
11#include <common.h>
wdenk059ae172003-04-20 16:52:09 +000012#include <command.h>
Simon Glass8e8ccfe2019-12-28 10:45:03 -070013#include <image.h>
Simon Glass72b335e2016-01-05 09:30:58 -070014#include <mapmem.h>
Anatolij Gustschinff8fb562013-07-02 00:04:05 +020015#include <splash.h>
Stefan Reinauerf674f7c2012-09-28 15:11:11 +000016#include <video.h>
Nikhil M Jain58182b22023-04-20 17:41:06 +053017#include <stdlib.h>
Hans-Christian Egtvedt43ef1c32007-11-30 17:29:59 +010018
Simon Glass09140112020-05-10 11:40:03 -060019static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc,
20 char *const argv[])
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010021{
22 ulong addr;
23
24 switch (argc) {
Simon Glassbb872dd2019-12-28 10:45:02 -070025 case 1: /* use image_load_addr as default address */
26 addr = image_load_addr;
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010027 break;
28 case 2: /* use argument */
Simon Glass7e5f4602021-07-24 09:03:29 -060029 addr = hextoul(argv[1], NULL);
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010030 break;
31 default:
Simon Glass4c12eeb2011-12-10 08:44:01 +000032 return CMD_RET_USAGE;
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010033 }
34
35 return (bmp_info(addr));
36}
37
Simon Glass09140112020-05-10 11:40:03 -060038static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, int argc,
39 char *const argv[])
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010040{
41 ulong addr;
42 int x = 0, y = 0;
43
Anatolij Gustschinff8fb562013-07-02 00:04:05 +020044 splash_get_pos(&x, &y);
45
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010046 switch (argc) {
Simon Glassbb872dd2019-12-28 10:45:02 -070047 case 1: /* use image_load_addr as default address */
48 addr = image_load_addr;
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010049 break;
50 case 2: /* use argument */
Simon Glass7e5f4602021-07-24 09:03:29 -060051 addr = hextoul(argv[1], NULL);
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010052 break;
53 case 4:
Simon Glass7e5f4602021-07-24 09:03:29 -060054 addr = hextoul(argv[1], NULL);
Patrick Delaunayb0fcedb2018-12-01 14:41:07 +010055 if (!strcmp(argv[2], "m"))
56 x = BMP_ALIGN_CENTER;
57 else
Simon Glass0b1284e2021-07-24 09:03:30 -060058 x = dectoul(argv[2], NULL);
Patrick Delaunayb0fcedb2018-12-01 14:41:07 +010059 if (!strcmp(argv[3], "m"))
60 y = BMP_ALIGN_CENTER;
61 else
Simon Glass0b1284e2021-07-24 09:03:30 -060062 y = dectoul(argv[3], NULL);
Wolfgang Denk93e14592013-10-04 17:43:24 +020063 break;
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010064 default:
Simon Glass4c12eeb2011-12-10 08:44:01 +000065 return CMD_RET_USAGE;
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010066 }
67
Nikhil M Jain58182b22023-04-20 17:41:06 +053068 return (bmp_display(addr, x, y));
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010069}
70
Simon Glass09140112020-05-10 11:40:03 -060071static struct cmd_tbl cmd_bmp_sub[] = {
Frans Meulenbroeks9acd4f02010-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};
Hans-Christian Egtvedt43ef1c32007-11-30 17:29:59 +010075
Simon Glass09140112020-05-10 11:40:03 -060076static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
wdenk059ae172003-04-20 16:52:09 +000077{
Simon Glass09140112020-05-10 11:40:03 -060078 struct cmd_tbl *c;
wdenk059ae172003-04-20 16:52:09 +000079
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010080 /* Strip off leading 'bmp' command argument */
81 argc--;
82 argv++;
wdenk059ae172003-04-20 16:52:09 +000083
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010084 c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
85
Wolfgang Denk47e26b12010-07-17 01:06:04 +020086 if (c)
Frans Meulenbroeks9acd4f02010-03-27 11:16:10 +010087 return c->cmd(cmdtp, flag, argc, argv);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020088 else
Simon Glass4c12eeb2011-12-10 08:44:01 +000089 return CMD_RET_USAGE;
wdenk059ae172003-04-20 16:52:09 +000090}
91
wdenk0d498392003-07-01 21:06:45 +000092U_BOOT_CMD(
wdenk4b248f32004-03-14 16:51:43 +000093 bmp, 5, 1, do_bmp,
Peter Tyser2fb26042009-01-27 18:03:12 -060094 "manipulate BMP image data",
wdenk4b248f32004-03-14 16:51:43 +000095 "info <imageAddr> - display image info\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +020096 "bmp display <imageAddr> [x y] - display image at x,y"
wdenkb0fce992003-06-29 21:03:46 +000097);