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 <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-10-01 15:17:30 -06:00
parent 431605bedb
commit ecfaa2cd48
3 changed files with 63 additions and 2 deletions

View File

@@ -8,6 +8,7 @@
#include <command.h>
#include <dm.h>
#include <linker_lists.h>
#include <video.h>
#include <video_console.h>
@@ -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 <col> <row> - Set cursor position\n"
"video puts <string> - Write string at current position");
"video puts <string> - 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));

View File

@@ -11,6 +11,7 @@ Synopsis
video setcursor <col> <row>
video puts <string>
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
-------------

View File

@@ -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);