Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecfaa2cd48 | ||
|
|
431605bedb | ||
|
|
d8f07c16ff | ||
|
|
cf1ed72377 | ||
|
|
1ce962ec34 | ||
|
|
38266d911a |
68
cmd/video.c
68
cmd/video.c
@@ -23,8 +23,8 @@ static int do_video_setcursor(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
|
||||
if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
|
||||
return CMD_RET_FAILURE;
|
||||
col = hextoul(argv[1], NULL);
|
||||
row = hextoul(argv[2], NULL);
|
||||
col = dectoul(argv[1], NULL);
|
||||
row = dectoul(argv[2], NULL);
|
||||
vidconsole_position_cursor(dev, col, row);
|
||||
|
||||
return 0;
|
||||
@@ -48,59 +48,6 @@ static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
return ret ? CMD_RET_FAILURE : 0;
|
||||
}
|
||||
|
||||
static int do_video_write(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
struct vidconsole_priv *priv;
|
||||
bool use_pixels = false;
|
||||
struct udevice *dev;
|
||||
int ret, i;
|
||||
|
||||
if (argc < 3)
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
|
||||
return CMD_RET_FAILURE;
|
||||
priv = dev_get_uclass_priv(dev);
|
||||
|
||||
/* Check for -p flag */
|
||||
if (!strcmp(argv[1], "-p")) {
|
||||
use_pixels = true;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (argc < 3 || !(argc % 2))
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
for (i = 1; i < argc; i += 2) {
|
||||
uint col, row;
|
||||
char *pos = argv[i];
|
||||
char *colon = strchr(pos, ':');
|
||||
|
||||
if (!colon)
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
col = hextoul(pos, NULL);
|
||||
row = hextoul(colon + 1, NULL);
|
||||
|
||||
if (use_pixels)
|
||||
vidconsole_set_cursor_pos(dev, col, row);
|
||||
else
|
||||
vidconsole_position_cursor(dev, col, row);
|
||||
|
||||
ret = vidconsole_put_string(dev, argv[i + 1]);
|
||||
if (ret)
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
ret = video_sync(dev->parent, false);
|
||||
if (ret)
|
||||
return CMD_RET_FAILURE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_video_images(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
@@ -127,7 +74,7 @@ static int do_video_images(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
U_BOOT_CMD(
|
||||
setcurs, 3, 1, do_video_setcursor,
|
||||
"set cursor position within screen",
|
||||
" <col> <row> in hex characters"
|
||||
" <col> <row> in character"
|
||||
);
|
||||
|
||||
U_BOOT_CMD(
|
||||
@@ -137,14 +84,11 @@ U_BOOT_CMD(
|
||||
);
|
||||
|
||||
U_BOOT_LONGHELP(video,
|
||||
"setcursor <col> <row> - Set cursor position\n"
|
||||
"video puts <string> - Write string at current position\n"
|
||||
"video write [-p] [<col>:<row> <string>]... - Write strings at specified positions\n"
|
||||
" -p: Use pixel coordinates instead of character positions\n"
|
||||
"video images - List images compiled into U-Boot");
|
||||
"setcursor <col> <row> - Set cursor position\n"
|
||||
"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(write, CONFIG_SYS_MAXARGS, 1, do_video_write),
|
||||
U_BOOT_SUBCMD_MKENT(images, 1, 1, do_video_images));
|
||||
|
||||
@@ -19,20 +19,16 @@ Description
|
||||
The setcurs command sets 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.
|
||||
Column position in pixels (0-based)
|
||||
|
||||
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.
|
||||
Row position in pixels (0-based)
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Set cursor to column 0x10, row 5::
|
||||
Set cursor to column 10, row 5::
|
||||
|
||||
=> setcurs 10 5
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
.. SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
.. index::
|
||||
single: video (command)
|
||||
|
||||
@@ -13,24 +11,12 @@ Synopsis
|
||||
|
||||
video setcursor <col> <row>
|
||||
video puts <string>
|
||||
video write [-p] [<col>:<row> <string>]...
|
||||
video images
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The video command provides access to the video-console subsystem. Common
|
||||
arguments are as follows:
|
||||
|
||||
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.
|
||||
The video command provides access to the video-console subsystem.
|
||||
|
||||
video setcursor
|
||||
~~~~~~~~~~~~~~~
|
||||
@@ -39,6 +25,12 @@ video setcursor
|
||||
|
||||
Set the cursor position on the video console.
|
||||
|
||||
col
|
||||
Column position in pixels (0-based)
|
||||
|
||||
row
|
||||
Row position in pixels (0-based)
|
||||
|
||||
video puts
|
||||
~~~~~~~~~~
|
||||
|
||||
@@ -49,24 +41,6 @@ Write a string to the video console at the current cursor position.
|
||||
string
|
||||
Text string to display
|
||||
|
||||
video write
|
||||
~~~~~~~~~~~
|
||||
|
||||
video write [-p] [<col>:<row> <string>]...
|
||||
|
||||
Write one or more strings to the video console at specified positions. Each
|
||||
position/string pair sets the cursor to the specified location and writes the
|
||||
string. Multiple position/string pairs can be provided to write to multiple
|
||||
locations in a single command.
|
||||
|
||||
-p
|
||||
Use pixel coordinates instead of character positions. When specified, the
|
||||
col and row values are interpreted as pixel offsets and converted to
|
||||
character positions based on the current font size.
|
||||
|
||||
string
|
||||
Text string to display at the specified position
|
||||
|
||||
video images
|
||||
~~~~~~~~~~~~
|
||||
|
||||
@@ -89,16 +63,7 @@ Print at different positions::
|
||||
=> video setcursor 0 0
|
||||
=> video puts "Top left"
|
||||
=> video setcursor 0 10
|
||||
=> video puts "Line 16"
|
||||
|
||||
Write text at multiple positions::
|
||||
|
||||
=> video write 0:0 "Top left" 0:a "Line 10"
|
||||
=> video write 0:a "First column in line10" 2a:0 "Text column 42"
|
||||
|
||||
Write text using pixel coordinates::
|
||||
|
||||
=> video write -p 0:0 "Top left corner" a0:80 "Pixel position"
|
||||
=> video puts "Line 10"
|
||||
|
||||
List compiled-in images::
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright 2025 Canonical Ltd
|
||||
* Written by Simon Glass <simon.glass@canonical.com>
|
||||
* Copyright 2025 Google LLC
|
||||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#ifndef __VIDEO_IMAGE_H
|
||||
|
||||
@@ -1094,7 +1094,7 @@ static int dm_test_video_cmd(struct unit_test_state *uts)
|
||||
ut_assertok(run_command("setcurs 10 5", 0));
|
||||
|
||||
ut_assertok(run_command("lcdputs \"Test string\"", 0));
|
||||
ut_asserteq(187, video_compress_fb(uts, dev, false));
|
||||
ut_asserteq(188, video_compress_fb(uts, dev, false));
|
||||
ut_assertok(video_check_copy_fb(uts, dev));
|
||||
|
||||
ut_assertok(run_command("video setcursor 0 0", 0));
|
||||
@@ -1102,15 +1102,6 @@ static int dm_test_video_cmd(struct unit_test_state *uts)
|
||||
ut_asserteq(272, video_compress_fb(uts, dev, false));
|
||||
ut_assertok(video_check_copy_fb(uts, dev));
|
||||
|
||||
ut_assertok(run_command(
|
||||
"video write 14:6 \"Multi\" 19:7 \"Write\"", 0));
|
||||
ut_asserteq(381, video_compress_fb(uts, dev, false));
|
||||
ut_assertok(video_check_copy_fb(uts, dev));
|
||||
|
||||
ut_assertok(run_command("video write -p a3:34 \"Pixels\"", 0));
|
||||
ut_asserteq(440, 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);
|
||||
|
||||
Reference in New Issue
Block a user