Commit Graph

1511 Commits

Author SHA1 Message Date
Michal Simek
948530bdd3 video: zynqmp: Add support for reset
In Kria SOM configuration DP is under reset and access to DP is causing
hang that's why call reset at probe to avoid this situation.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/0504474a91a9839828aecd37f8855fd154cdf2e1.1733742708.git.michal.simek@amd.com
(cherry picked from commit 8b81010a2f)
2025-12-17 14:02:15 -07:00
Simon Glass
69d2f4ab58 video: truetype: Use pre-allocated buffer for glyph rendering
The TrueType console driver calls malloc/free for every character
rendered, which causes significant memory fragmentation and allocation
traffic.

Add CONFIG_CONSOLE_TRUETYPE_GLYPH_BUF to enable a pre-allocated buffer
in the driver's private data. The buffer starts at 4KB and grows via
realloc() as needed. When rendering a glyph, use this buffer to avoid
malloc/free for normal characters.

The buffer is allocated lazily after relocation to avoid consuming
early malloc space before the full heap is available.

Add CONFIG_VIDEO_GLYPH_STATS (default y on sandbox) to track the number
of glyphs rendered. Use 'font info' to view the count.

Series-changes: 2
- Rename the Kconfig to just enable the feature: always allocate

Co-developed-by: Claude Opus 4 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:00 -07:00
Simon Glass
b766b80826 video: Add a lock image
Add an image which represents a locked disk.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 17:18:57 -07:00
Simon Glass
a9027c8eb5 video: Document the quirk in truetype_get_cursor_info()
The current code is written to suggest that the cursor position
(priv->pos_ptr) might be respected. In fact a bug means that it never
is, since index is set to priv->pos_ptr, so the if() condition always
fails.

Further, when editing textline objects, the cursor index is always the
same as priv->pos_ptr anyway. Fix the bug but keep the current
behaviour, adding a comment for future readers.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 11:42:34 -07:00
Simon Glass
be5644b176 treewide: Add missing string.h includes
Add string.h to files that use string functions like strdup, strcmp,
strcpy, etc. These are implicitly available through the malloc.h header
but that will soon change.

For bouncebuf, take this opportunity to sort the headers correctly.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:57:27 +00:00
Simon Glass
b54d2ae5b9 bootctl: Bring in some additional images
Provide some sample images for use with the 'multi' theme.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-18 09:38:25 +01:00
Simon Glass
52ae67a954 efi: video: Add some more debugging for the modes
This driver can operate in various modes, e.g. with VIDEO_COPY and with
different colour depths or in blit mode. Add some debugging to help
debug problems on particular boards. Fix an errant blank line while we
are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
3246bd787c video: Add a little more documentation to the uclass
The copy buffer is a bit confusing, so add some more documentation for
it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 10:54:13 +00:00
Simon Glass
e71efe3d1f video: Do the sync timing within video_sync()
The timer is used in a different function from that where it is set up.
Move setup into video_sync() so that the code is all together.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 10:54:13 +00:00
Simon Glass
4a7ccfee27 video: sandbox: Add test for sync() damage rectangle
Add a test that verifies the sandbox SDL driver receives the correct
damage rectangle in its sync() method. The test:

- Clears the display and verifies full-screen damage is passed to sync()
- Writes text at a specific position and verifies smaller damage region
- Draws a box and verifies the damage matches the box dimensions

The damage rectangle is recorded in sandbox_sdl_plat.last_sync_damage
and can be retrieved using sandbox_sdl_get_sync_damage() for testing
purposes.

Series-to: concept
Series-cc: heinrich
Cover-letter:
video: Enhancements to support a pointer
The video subsystem has a video_sync() function which does quite a few
things and is rather hard to predict and control:

- it may or may not actually sync, depending on a timer, etc
- it may be called when U-Boot is idle, so any time delays can cause a
  sync

These two problems make it hard to test.

This series introduces a deterministic video_manual_sync() which does
exactly what it is told, using a set of flags:

   VIDSYNC_FORCE - the force flag was provided (info for the driver)
   VIDSYNC_FLUSH - framebuffer changes should be flushed to hardware
   VIDSYNC_COPY - the copy framebuffer (if any) should be updated

The video_sync() method is renamed to sync() and is passed the flags,
so that drivers can find out what to do. This allows the
sandbox-specific code in video_sync() to move to the driver.

These features will (later) be used by expo to provide a better user
experience, e.g. to sync only part of the display, or to sync quickly
when there is mouse movement.

The pointer also needs to be drawn with transparency which is not well
supported by the BMP code. This series adds support for a simple
transparency colour for now, although an alpha channel may be
appropriate in the future.
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:45
Series-version: 2
2025-10-06 06:29:29 -06:00
Simon Glass
0902eb2bfb video: sandbox: Add sync() method for video
At present, video_sync() has a special case for sandbox. Remove this and
add a sync() method in the sandbox_sdl driver instead.

The sync() method checks the VIDSYNC_FLUSH flag and skips sync operation
if it's not set, avoiding unnecessary SDL updates.

If CONFIG_VIDEO_DAMAGE is enabled, the SDL portion accepts an optional
damage rectangle parameter to support only updating the damaged region.

Use the struct video_bbox definition from the video_defs.h header as
this avoids trying to include too many U-Boot headers in code that is
build with system headers.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
69b02023ad video: Refactor video_sync() to use video_manual_sync()
Extract the core sync logic from video_sync() into a new
video_manual_sync() function that accepts flags directly. This allows
callers to perform sync operations with explicit control over the sync
behavior.

The video_sync() function now:
- Determines the appropriate flags (VIDSYNC_FORCE, VIDSYNC_FLUSH,
  VIDSYNC_COPY) based on the force parameter and timing
- Calls video_manual_sync() with those flags

The video_manual_sync() function:
- Takes explicit flags as a parameter
- Handles VIDSYNC_COPY flag to control copy framebuffer flush
- Performs the actual sync operations

This separation allows manual-sync mode users (and tests) to call
video_manual_sync() directly with custom flags while video_sync()
continues to work as before for normal scenarios.

Add tests for video_manual_sync() to check the behaviour with
different flag combinations.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
ad7c596829 video: Add flags parameter to sync() operation
Add an enum video_sync_flags with VIDSYNC_FORCE, VIDSYNC_FLUSH, and
VIDSYNC_COPY flags and update the sync() operation in struct video_ops
to accept a flags parameter. This allows for more flexible control of
video sync behavior.

The VIDSYNC_FLUSH flag is set when a full flush should be performed, and
the VIDSYNC_COPY flag indicates whether the framebuffer should be
flushed to the copy buffer.

The logic is now calculated before calling sync() so drivers can
observe these states.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
f277931d19 video: Provide a way for expo to control video sync
When expo is being used, it should only redraw the display when it has
made changes. Add a new 'manual sync' mode which tells the video
subsystem to ignore video syncs from other sources.

This also disables the idle feature, since it can interfere with tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
c22c6aa06b video: Rename video_sync() to sync() in struct video_ops
Shorten the video_sync member in struct video_ops to just sync() since
the struct name already provides the context that this is a video
operation.

Update all implementations and callers of this operation.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
01b88f5819 video: Add a struct vid_bbox for damage tracking
Replace the anonymous struct in video_priv with struct vid_bbox for
the damage field.

Update all references from xstart/ystart/xend/yend to x0/y0/x1/y1 to
match the video_bbox field names. Add local video_bbox pointers in
functions that access damage fields repeatedly to improve readability.

Series-changes: 2
- Call it vid_bbox instead as it is shorter and less video-centric

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
55d408d4d9 video: Export a function to draw a BMP with transparency
Provide a new BMP function which can draw a bitmap while regarding a
chosen colour as transparent.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
b1bfb5ae92 video: Support transparency with BMP palette
Check the palette entry against the transparency colour and skip writing
it to the display if it matches.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
674c3eaa49 video: Support transparency with 24bpp BMP image
When the pixel colour matches the transparency colour, skip writing it
to the display.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
253a24a5de video: Use variables for each colour component
Add red, green and blue variables when processing a 24bpp BMP image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
2f5339524b video: Support transparency in the inner bmp functions
Provide an alpha and acol parameter to control whether transparency is
used. For now alpha is always false so this does nothing.

Make the current video_bmp_display() an internal static function and
add a new video_bmp_display() to call it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
5956d4835d video: Move setting of cte in write_pix8() to the top
The compiler can deal with the complexity of deciding whether to set up
this local. Move it to the top of the function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
fe15b7cb6f video: Add a pointer image
When the mouse is being used we need a suitable pointer image to draw on
the display. Add the RISC OS pointer, in honour of the first GUI
available on ARM devices.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
49beefc398 video: Add a missing comment in struct video_uc_priv
Document the cyc_active member and arrange things in the correct order.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
ed6674e5be acpi: bgrt: Move the BGRT image into the images directory
Move the BGRT image to use the same video_image linker-list approach
as the other embedded image. Move it into the drivers/video/images
directory and rename it to 'bgrt.bmp' since we know it is an image.

Drop the old bgrt Makefile rule as it is no-longer needed.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-02 13:51:03 -06:00
Simon Glass
1ad737c2ab video: Move the logo into the new video-images directory
Move u_boot_logo.bmp into drivers/video/images and include it in the
build.

Make use of the new video_image_get() macro to obtain the logo.

Drop the old SPLASH_...() macros.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-02 13:51:03 -06:00
Simon Glass
d9d653b08b video: truetype: Avoid clearing on backspace
Now that the truetype console properly handles clearing text from the
display during editing, we don't need to clear the character when
processing a backspace.

This allows arrow keys to work as expected on the truetype console.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
81675eff4a video: truetype: Clear after the current char on insert
Within the CLI, inserting a character works by writing out the new char
and then all the ones after it.

With the truetype console this results in gibberish since the new
chars are written on top of the old. To resolve this, clear the rest of
the input when a character is inserted. Consider that the end of the
input, at least until furture characters are written.

As an optimisation, don't clear if the new character is the same as the
old.

This cleans up a dot above the 'g' of greatness which should not be
there, so update the dm_test_video_truetype() test.

It also clean up the part of the 't' of 'not be' which should not be
there, so update dm_test_video_truetype_bs() too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
e38a1ae08e video: Show the cursor when idle
When the console is idle and at the CLI, ensure the cursor is visible.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
8962a5fbe2 video: Save overwritten pixels when drawing the cursor
Save the pixels overwritten by the cursor into the save area.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
d59d05dede video: Support reading the framebuffer when writing
Create a variant of fill_pixel_and_goto_next() function which returns
the old pixel value. This will make it easy to save the framebuffer
pixels as they are overwritten by drawing the cursor.

Leave the current function alone, since it increases code size about
16 bytes and may slow down blitting.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
aebedeac44 video: Provide a buffer to hold pixels behind the cursor
Drawing the cursor is a destructive operation, so we must save the
previous contents of the affected part of the framebuffer, so it can be
restored afterwards.

Add this to the cursor info and set it up when probing the console
device.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
f7b1a67327 video: Drop extra parameters from vidconsole_show_cursor()
Now that both console drivers use the CLI index, we don't need the extra
parameters for this. Drop them.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
082bed3807 video: Support a cursor in multi-line text
For expo, lineedit only supports a single line.

For the CLI, the text can extend across multiple lines. Add support for
this in the normal console, calculating the x and y offset of the cursor
position based on the display width and font size.

The truetype console already works, since it has had this tracking for a
while.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
ea3440a535 video: Drop extra parameters from get_cursor_info()
Now that the console tracks the CLI index, remove the unnecessary
parameters. Both the normal and truetype consoles use the information
provided by the console.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
4e5c96fbcf video: Add save and restore drivers for normal console
Provide these two methods so that we can use expo lineedits with the
normal console (i.e. no truetype). This allows the cursor to be
positioned correctly when editing the lineedit and rendering the expo.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
0ab8584e3c video: Update normal console to use tracking information
The console supports keeping track of the index and the start position
of the CLI entry. Use this instead of the passed-in values.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
54f7d358cd video: Drop vidconsole_set_cursor_visible()
There is only one user of this function. Update it to use the new
vidconsole_show_cursor() instead.

Remove the now-unused vidconsole_set_cursor_visible()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
b59efb56f6 video: Track whether the cursor is enabled
The cursor should only be enabled if the user is entering something.
This can be at the CLI or in an expo. Provide a flag to track it, which
we can (later) use to determine whether or not to draw the cursor.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
8724cf302c video: truetype: Track characters and their widths
The Truetype driver maintains a list of x and y positions for every
character in the line being entered by the user. This allows it to
backspace reliably without having to re-measure lots of text.

For kerning, the video console maintains a last_ch variable which holds
the last character written to the console. This allows accurate kerning
between one character and the next. At present lash_ch is cleared on
backspace, since we cannot know what the character before last_ch is.

The slightly strange part is that the truetype console currently has no
knowledge about what the characters were, only their x and y positions,
with the x position being fractional. It also has no idea of the width
of each character, since it doesn't need to: the CLI will always write
out a new character in order to move forward during command-editing,
since there is no actual concept of 'move the cursor to the right'.

Part of the reason this works is that truetype implements backspace by
actually clearing the character from the display. So if you type some
text and then press the left arrow, it looks like it is doing a
backspace. This has been a known limitation for some time.

The correct way to implement left-arrow is to leave the display alone,
only clearing it if characters are later added. This is necessary since
Truetype fonts are OR'd onto the screen, which is assumed to be
initially cleared to the background colour.

We cannot do this clearing without knowing the width of the characters
we need to clear, so add a 'width' to the struct pos_info for that.

For kerning we must know the previous character to kern against, but we
cannot yet make that change, since we don't want to kern against
characters that were there before an erase. So that will be dealt with
later, in 'Clear after the current char on insert'.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
384e6156c5 video: truetype: Record the position where CLI entry starts
Implement the mark_start() method for the truetype console by recording
which pos[] record corresponds to this event. We can be sure that the
user will not be able to backspace past this point.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
86655de2bd console: Add debugging for kerning
Add some debugging which can be used to manually check that truetype is
kerning against the expected character. This is tested by the
image-based tests but they are sometimes hard to debug.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
691e10ead3 video: Provide a way to indicate the start of CLI entry
Add a new mark_start() method for the console, which indicates that the
CLI prompt has been written to the display and any following characters
will be user input.

There are two cases to consider, tracked by an indent flag in
struct vidconsole_cursor:

- normal CLI entry where new lines start at the left of the console
- expo entry where new lines start at the same position as the previous
  line (indent=true)

Record this position in the uclass info, so it is available to console
drivers.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
fdfdb84dcc video: Track the current CLI index
Keep track of the current character index in the current CLI entry. This
corresponds to the cursor position and is numbered from zero.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
6147153e56 video: Move cursor drawing into the uclass
Rather than having the truetype driver draw the cursor, make it just
return the information needed to draw the cursor. This will make it
possible for the normal console to support a cursor too.

Add a check for the cursor being entirely within the framebuffer.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
5e0625e3a0 video: Update cursor_show() to take a simple pointer
We don't need to pass a pointer to a pointer, so just pass a normal
pointer. This is simpler to understand.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
4a1aff1212 video: Rename draw_cursor_vertically() to cursor_show()
For now the cursor is always vertical, so part of this name is
redundant. Rename it to cursor_show(), which is what it does. We will
eventually have a cursor_hide() to match it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
4f5c8dcf7b video: Provide an idle function for the console
Add a way to tell the console that the machine is idle. This will be
used (later) to show the cursor.

Call the video console sync after that, so that any updates are shown.

Keep the video_sync_all() for the case where CONFIG_CURSOR is not
enabled, to reduce code size.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
2ce18b5a14 video: Convert to use uclass_id_foreach_dev()
Convert a few functions in the video uclass to use the new
uclass_id_foreach_dev() macro.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
7c17756634 video: Correct cursor handling when the the left side
There is normally a prompt which prevents the cursor ever being on the
far left. However we should check for this to avoid a potential crash.

Add a check for x being at least 0 in console_set_cursor_visible()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00