2009-07-31 13:08:49 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <fb.h>
|
2012-09-26 09:59:00 +00:00
|
|
|
#include <gui/image_renderer.h>
|
|
|
|
#include <gui/graphic_utils.h>
|
2009-07-31 13:08:49 +00:00
|
|
|
|
2012-09-12 13:42:39 +00:00
|
|
|
static int do_splash(int argc, char *argv[])
|
2009-07-31 13:08:49 +00:00
|
|
|
{
|
2012-09-26 09:59:02 +00:00
|
|
|
struct surface s;
|
|
|
|
struct screen sc;
|
2009-07-31 13:08:49 +00:00
|
|
|
int ret, opt, fd;
|
|
|
|
char *fbdev = "/dev/fb0";
|
2012-09-12 13:42:44 +00:00
|
|
|
char *image_file;
|
2009-07-31 13:08:49 +00:00
|
|
|
int offscreen = 0;
|
2012-09-12 13:42:45 +00:00
|
|
|
u32 bg_color = 0x00000000;
|
|
|
|
bool do_bg = false;
|
2012-09-26 09:59:02 +00:00
|
|
|
|
2012-11-21 09:07:46 +00:00
|
|
|
memset(&s, 0, sizeof(s));
|
|
|
|
memset(&sc, 0, sizeof(sc));
|
|
|
|
|
2012-09-26 09:59:02 +00:00
|
|
|
s.x = -1;
|
|
|
|
s.y = -1;
|
|
|
|
s.width = -1;
|
|
|
|
s.height = -1;
|
2009-07-31 13:08:49 +00:00
|
|
|
|
2012-09-12 13:42:45 +00:00
|
|
|
while((opt = getopt(argc, argv, "f:x:y:ob:")) > 0) {
|
2009-07-31 13:08:49 +00:00
|
|
|
switch(opt) {
|
|
|
|
case 'f':
|
|
|
|
fbdev = optarg;
|
|
|
|
break;
|
2012-09-12 13:42:45 +00:00
|
|
|
case 'b':
|
|
|
|
bg_color = simple_strtoul(optarg, NULL, 0);
|
|
|
|
do_bg = true;
|
|
|
|
break;
|
2009-07-31 13:08:49 +00:00
|
|
|
case 'x':
|
2012-09-26 09:59:02 +00:00
|
|
|
s.x = simple_strtoul(optarg, NULL, 0);
|
2009-07-31 13:08:49 +00:00
|
|
|
break;
|
|
|
|
case 'y':
|
2012-09-26 09:59:02 +00:00
|
|
|
s.y = simple_strtoul(optarg, NULL, 0);
|
2009-07-31 13:08:49 +00:00
|
|
|
case 'o':
|
|
|
|
offscreen = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (optind == argc) {
|
|
|
|
printf("no filename given\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2012-09-12 13:42:44 +00:00
|
|
|
image_file = argv[optind];
|
2009-07-31 13:08:49 +00:00
|
|
|
|
2012-09-26 09:59:03 +00:00
|
|
|
fd = fb_open(fbdev, &sc, offscreen);
|
2009-07-31 13:08:49 +00:00
|
|
|
if (fd < 0) {
|
2012-09-26 09:59:03 +00:00
|
|
|
perror("fd_open");
|
2009-07-31 13:08:49 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-09-26 09:59:03 +00:00
|
|
|
if (sc.offscreenbuf) {
|
|
|
|
if (do_bg)
|
2013-03-12 19:59:09 +00:00
|
|
|
memset_pixel(&sc.info, sc.offscreenbuf, bg_color,
|
2012-09-26 09:59:03 +00:00
|
|
|
sc.s.width * sc.s.height);
|
|
|
|
else
|
|
|
|
memcpy(sc.offscreenbuf, sc.fb, sc.fbsize);
|
2012-09-12 13:42:45 +00:00
|
|
|
} else if (do_bg) {
|
2013-03-12 19:59:09 +00:00
|
|
|
memset_pixel(&sc.info, sc.fb, bg_color, sc.s.width * sc.s.height);
|
2009-07-31 13:08:49 +00:00
|
|
|
}
|
|
|
|
|
2012-09-26 09:59:02 +00:00
|
|
|
if (image_renderer_file(&sc, &s, image_file) < 0)
|
2012-09-12 13:42:40 +00:00
|
|
|
ret = 1;
|
2009-07-31 13:08:49 +00:00
|
|
|
|
2012-09-26 09:59:04 +00:00
|
|
|
screen_blit(&sc);
|
|
|
|
|
2012-09-26 09:59:03 +00:00
|
|
|
fb_close(&sc);
|
2009-07-31 13:08:49 +00:00
|
|
|
|
2012-09-12 13:42:40 +00:00
|
|
|
return ret;
|
2009-07-31 13:08:49 +00:00
|
|
|
}
|
|
|
|
|
2012-09-12 13:42:39 +00:00
|
|
|
BAREBOX_CMD_HELP_START(splash)
|
|
|
|
BAREBOX_CMD_HELP_USAGE("splash [OPTIONS] FILE\n")
|
2010-07-11 10:13:22 +00:00
|
|
|
BAREBOX_CMD_HELP_SHORT("Show the bitmap FILE on the framebuffer.\n")
|
|
|
|
BAREBOX_CMD_HELP_OPT ("-f <fb>", "framebuffer device (/dev/fb0)\n")
|
|
|
|
BAREBOX_CMD_HELP_OPT ("-x <xofs>", "x offset (default center)\n")
|
|
|
|
BAREBOX_CMD_HELP_OPT ("-y <yofs>", "y offset (default center)\n")
|
2012-09-12 13:42:45 +00:00
|
|
|
BAREBOX_CMD_HELP_OPT ("-b <color>", "background color in 0xttrrggbb\n")
|
2010-07-11 10:13:22 +00:00
|
|
|
BAREBOX_CMD_HELP_OPT ("-o", "render offscreen\n")
|
|
|
|
BAREBOX_CMD_HELP_END
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @page bmp_command
|
|
|
|
|
|
|
|
This command displays a graphics in the bitmap (.bmp) format on the
|
|
|
|
framebuffer. Currently the bmp command supports images with 8 and 24 bit
|
|
|
|
color depth.
|
|
|
|
|
|
|
|
\todo What does the -o (offscreen) option do?
|
|
|
|
|
|
|
|
*/
|
2009-07-31 13:08:49 +00:00
|
|
|
|
2012-09-12 13:42:39 +00:00
|
|
|
BAREBOX_CMD_START(splash)
|
|
|
|
.cmd = do_splash,
|
2009-07-31 13:08:49 +00:00
|
|
|
.usage = "show a bmp image",
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
BAREBOX_CMD_GROUP(CMD_GRP_CONSOLE)
|
2012-09-12 13:42:39 +00:00
|
|
|
BAREBOX_CMD_HELP(cmd_splash_help)
|
2009-12-15 08:11:09 +00:00
|
|
|
BAREBOX_CMD_END
|