
From: Simon Glass <sjg@chromium.org> Add a new 'video' command with 'setcursor' and 'puts' subcommands that provide an alternative interface to the existing setcurs and lcdputs commands. Update the test is updated to test both the legacy commands and the new 'video' command. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org> --- Changes in v2: - Correct confusing output text which should be 16 instead of 10 - Improve docs for row and col cmd/video.c | 8 +++++ doc/usage/cmd/lcdputs.rst | 1 + doc/usage/cmd/setcurs.rst | 1 + doc/usage/cmd/video.rst | 72 +++++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + test/dm/video.c | 5 +++ 6 files changed, 88 insertions(+) create mode 100644 doc/usage/cmd/video.rst diff --git a/cmd/video.c b/cmd/video.c index d11472c3ef6..9f3a91959df 100644 --- a/cmd/video.c +++ b/cmd/video.c @@ -58,3 +58,11 @@ U_BOOT_CMD( "print string on video framebuffer", " <string>" ); + +U_BOOT_LONGHELP(video, + "setcursor <col> <row> - Set cursor position\n" + "video puts <string> - Write string at current position"); + +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)); diff --git a/doc/usage/cmd/lcdputs.rst b/doc/usage/cmd/lcdputs.rst index f34dbb3e3f1..26e777970d5 100644 --- a/doc/usage/cmd/lcdputs.rst +++ b/doc/usage/cmd/lcdputs.rst @@ -49,6 +49,7 @@ The lcdputs command is available if CONFIG_CMD_VIDEO=y. See also -------- +* :doc:`video` - video command with subcommands * :doc:`setcurs` - set cursor position Return value diff --git a/doc/usage/cmd/setcurs.rst b/doc/usage/cmd/setcurs.rst index 4619206fb40..aca2fc34e7f 100644 --- a/doc/usage/cmd/setcurs.rst +++ b/doc/usage/cmd/setcurs.rst @@ -48,6 +48,7 @@ The setcurs command is available if CONFIG_CMD_VIDEO=y. See also -------- +* :doc:`video` - video command with subcommands * :doc:`lcdputs` - print string on video framebuffer Return value diff --git a/doc/usage/cmd/video.rst b/doc/usage/cmd/video.rst new file mode 100644 index 00000000000..1e7c7f0c050 --- /dev/null +++ b/doc/usage/cmd/video.rst @@ -0,0 +1,72 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +.. index:: + single: video (command) + +video command +============= + +Synopsis +-------- + +:: + + video setcursor <col> <row> + video puts <string> + +Description +----------- + +The video command provides access to the video-console subsystem. + +video setcursor +~~~~~~~~~~~~~~~ + + video setcursor <col> <row> + +Set the cursor position on the video console. + +col + Column position in hex, with 0 being the left side. Note that this is the + text-column position, so the number of pixels per position depends on the + font size. + +row + Row position in hex, with 0 being the top edge. Note that this is the + text-row position, so the number of pixels per position depends on the + font size. + +video puts +~~~~~~~~~~ + + video puts <string> + +Write a string to the video console at the current cursor position. + +string + Text string to display + +Examples +-------- + +Set cursor and print text:: + + => video setcursor 10 5 + => video puts "Hello World" + +Print at different positions:: + + => video setcursor 0 0 + => video puts "Top left" + => video setcursor 0 10 + => video puts "Line 16" + +Configuration +------------- + +The video command is available if CONFIG_CMD_VIDEO=y. + +Return value +------------ + +The return value $? is 0 (true) on success, 1 (false) on failure. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 0f271c1280d..d1887f7d26a 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -137,6 +137,7 @@ Shell commands cmd/ums cmd/unbind cmd/ut + cmd/video cmd/virtio cmd/wdt cmd/wget diff --git a/test/dm/video.c b/test/dm/video.c index 847342891fd..af305e60268 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -1097,6 +1097,11 @@ static int dm_test_video_cmd(struct unit_test_state *uts) ut_asserteq(187, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); + ut_assertok(run_command("video setcursor 0 0", 0)); + ut_assertok(run_command("video puts \"Top left\"", 0)); + ut_asserteq(272, video_compress_fb(uts, dev, false)); + ut_assertok(video_check_copy_fb(uts, dev)); + return 0; } DM_TEST(dm_test_video_cmd, UTF_SCAN_PDATA | UTF_SCAN_FDT); -- 2.43.0