From ecfaa2cd48c22fbb15d5ddea838571be064d47e1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 1 Oct 2025 15:17:30 -0600 Subject: [PATCH] video: Provide a command to list built-in images Add a new 'video images' command which lists the graphical images that are compiled into U-Boot. Generally the only one is the logo. Series-to: concept Series-cc: heinrich Cover-letter: video: Tidy up embedded graphical images U-Boot includes a few graphical images which are compiled in, such as the logo and the BGRT logo used for EFI. At present these are handled by a Makefile rule which looks for files ending with '_logo.bmp'. This series moves these into a new drivers/video/images directory and puts them in a linker list, so it is possible to see what images are available. Adding a new image is simpler, just requiring the addition of the normal 'obj-y += file.bmp' rule. This series also adds a new 'video' command which provides the existing 'setcurs' and 'lcdputs' as subcommands, along with documentation and tests. END Co-developed-by: Claude Signed-off-by: Simon Glass --- cmd/video.c | 30 ++++++++++++++++++++++++++++-- doc/usage/cmd/video.rst | 19 +++++++++++++++++++ test/dm/video.c | 16 ++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/cmd/video.c b/cmd/video.c index c9f2d91a0ba..6f3fa29a147 100644 --- a/cmd/video.c +++ b/cmd/video.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -47,6 +48,29 @@ static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc, return ret ? CMD_RET_FAILURE : 0; } +static int do_video_images(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct video_image *image; + int count, i; + + image = ll_entry_start(struct video_image, video_image); + count = ll_entry_count(struct video_image, video_image); + + printf("%-20s %10s\n", "Name", "Size"); + printf("%-20s %10s\n", "--------------------", "----------"); + + for (i = 0; i < count; i++, image++) { + ulong size = (ulong)image->end - (ulong)image->begin; + + printf("%-20s %10lu\n", image->name, size); + } + + printf("\nTotal images: %d\n", count); + + return 0; +} + U_BOOT_CMD( setcurs, 3, 1, do_video_setcursor, "set cursor position within screen", @@ -61,8 +85,10 @@ U_BOOT_CMD( U_BOOT_LONGHELP(video, "setcursor - Set cursor position\n" - "video puts - Write string at current position"); + "video puts - Write string at current position\n" + "video images - List images compiled into U-Boot"); U_BOOT_CMD_WITH_SUBCMDS(video, "Video commands", video_help_text, U_BOOT_SUBCMD_MKENT(setcursor, 3, 1, do_video_setcursor), - U_BOOT_SUBCMD_MKENT(puts, 2, 1, do_video_puts)); + U_BOOT_SUBCMD_MKENT(puts, 2, 1, do_video_puts), + U_BOOT_SUBCMD_MKENT(images, 1, 1, do_video_images)); diff --git a/doc/usage/cmd/video.rst b/doc/usage/cmd/video.rst index 139f90bd3ff..d7e2527805a 100644 --- a/doc/usage/cmd/video.rst +++ b/doc/usage/cmd/video.rst @@ -11,6 +11,7 @@ Synopsis video setcursor video puts + video images Description ----------- @@ -40,6 +41,15 @@ Write a string to the video console at the current cursor position. string Text string to display +video images +~~~~~~~~~~~~ + + video images + +List all images that are compiled into U-Boot. This shows the name and size +of each image that was built from .bmp files in the drivers/video/images +directory. + Examples -------- @@ -55,6 +65,15 @@ Print at different positions:: => video setcursor 0 10 => video puts "Line 10" +List compiled-in images:: + + => video images + Name Size + -------------------- ---------- + u_boot 6932 + + Total images: 1 + Configuration ------------- diff --git a/test/dm/video.c b/test/dm/video.c index 98bb0057b18..1f1bf7c59c8 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -1105,3 +1105,19 @@ static int dm_test_video_cmd(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_video_cmd, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +/* video images command */ +static int dm_test_video_images(struct unit_test_state *uts) +{ + ut_assertok(run_command("video images", 0)); + ut_assert_nextline("Name Size"); + ut_assert_nextline("-------------------- ----------"); + ut_assert_nextline("bgrt 43926"); + ut_assert_nextline("u_boot 6932"); + ut_assert_skip_to_line(""); + ut_assert_nextline("Total images: 2"); + ut_assert_console_end(); + + return 0; +} +DM_TEST(dm_test_video_images, UTF_SCAN_PDATA | UTF_SCAN_FDT | UTF_CONSOLE);