Commit Graph

3124 Commits

Author SHA1 Message Date
Simon Glass
92cc80eab9 expo: Allow searching for any object type by position
At present only highlightable objects can be clicked on, i.e. menus and
textlines. Update scene_find_obj_within() so that it can find any type
of object, if requested. Update all the callers to false, so things work
the same.

Since the scene is drawn by iterating through the list of objects, when
the user clicks somewhere we should look at the top-most object under
the mouse first. So reverse the direction of the object search.

Update the tests to cover this new feature.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 03:11:12 +01:00
Simon Glass
d221a4178c expo: Allow searching click positions from top to bottom
Since the scene is drawn by iterating through the list of objects, when
the user clicks somewhere we should look at the top-most object under
the mouse first.

This is not true when a menu is popped up, since we only care about the
menu in that case.

Add a way to reverse the direction of the object search. For now there
are no new test cases, since OBJ_OVERLAP is a text object and cannot
currently be clicked on.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 03:10:42 +01:00
Simon Glass
4d4caecd26 expo: Export scene_find_obj_within() and add a test
It is easier to test this function directly than via click_check(). Set up
a test expo with an extra overlapping object and add some tests.

Update the existing render test to take account of the new object.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 03:10:36 +01:00
Simon Glass
7d91a4b457 expo: Provide a way to dump an expo
For debugging it is sometimes helpful to dump an expo. Add an
implementation of this, writing to a membuf.

Add a MAINTAINERS entry for expo, including this next file.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 02:24:07 +01:00
Simon Glass
9c11744488 expo: Provide user-friendly output of scene enums
Add a few functions which can convert a flag and an object type to
strings.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 02:24:07 +01:00
Simon Glass
d387a08ee2 test: Add a way to printf() into a membuf
Add a membuf_printf() function which supports writing a formatted string
into a membuf.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 02:24:06 +01:00
Simon Glass
dd4b6ad746 test: video: Fix 16bpp BMP pixel format conversion
The video_write_bmp() function was writing 16bpp framebuffer data
directly to BMP files without proper format conversion. The framebuffer
uses RGB565 format (5 red, 6 green, 5 blue), but standard Windows BMP
16bpp format uses RGB555 (5 red, 5 green, 5 blue).

Convert pixels from RGB565 to RGB555 by:
- Extracting the 5-bit red, 6-bit green, and 5-bit blue components
- Dropping the LSB of the green channel to convert from 6 to 5 bits
- Reconstructing as RGB555 with the same R/B order

This fixes incorrect colors in BMP output files (e.g., orange appearing
as blue).

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-09 17:14:48 +01:00
Simon Glass
03c65c2b94 mouse: Replace press_state with bool pressed
Change the mouse_button structure to use a bool pressed field instead
of an unsigned char press_state. This simplifies the API by using a
natural boolean type for a binary state.

Remove the BUTTON_PRESSED/BUTTON_RELEASED defines as they're no longer
needed.

Update all mouse drivers, tests, and the mouse command to use the new
field name and type.

Series-changes: 2
- Add new patch to replace press_state with bool pressed

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:54:43 -06:00
Simon Glass
9d9e00b3de expo: Add FPS tracking to test mode
In test mode, show the FPS (frames per second) below the frame count.
This is helpful for performance monitoring during development.

The FPS calculation averages over the last 5 seconds to provide a
stable reading.

Add a test for the FPS calculation logic as well.

Mention expo's test mode in the documentation.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 10:54:13 +00:00
Simon Glass
6825579c41 expo: Add test mode to display frame count
When expo-test is enabled, show the frame count in the top right of the
display. This allows an easy visual check that expo is working correctly,
and provides an indication of performance.

Add a test for this also.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 10:54:13 +00:00
Simon Glass
8751de0715 sandbox: mouse: Add test for pointer visibility
Add a test for the mouse set_ptr_visible() method. This uses a back-door
function to read the visibility state from the sandbox mouse driver.

Also add documentation for struct sandbox_mouse_priv.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 10:54:13 +00:00
Simon Glass
f2909a4cde expo: Set dirty flag when an object bbox changes
Add a flag to indicate that am object must be redrawn. Set this flag
when an object's bounding box changes.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 10:11:04 -06:00
Simon Glass
00692afa1c mouse: Update mouse_get_click() to use struct vid_pos
Change the API to use struct vid_pos instead of separate x/y pointers.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-03 06:41:11 -06: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
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
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
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
ac08c90df1 video: Check drawing the mouse pointer
Add some simple tests for drawing the mouse pointer on a white and black
background.

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
6853b7d8ad sandbox: Add --video_frames option to capture test frames
Add a new --video_frames option to sandbox which accepts a directory path.
When set, every video test assertion writes a BMP file (frame0.bmp,
frame1.bmp, etc.) to the specified directory, allowing visual inspection
of the framebuffer at each test step.

A new video_write_bmp() function writes 16/32bpp framebuffer contents as
Windows BMP files. On startup, any existing frame*.bmp files in the
directory are removed to ensure a clean state.

Usage example:

  ./u-boot --video_frames /tmp/frames -c "ut dm video_text"

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
12572f5a00 sandbox: Add -V flag for video test delay
Add a new -V flag to sandbox which accepts a delay in milliseconds. This
causes video tests to pause after each assertion, allowing the display
output to be visually inspected.

This is useful for debugging video tests and understanding what is being
drawn at each step.

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
366ae61115 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.

It also adds a more convenient 'write' subcommand.

END
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 2:44 1:43
Series-version: 3
2025-10-02 13:51:03 -06:00
Simon Glass
85e1dae80c video: Add a write subcommand
This allows writing strings at particular positions on the display,
using either character or pixel positions.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-10-02 13:50:32 -06:00
Simon Glass
8db8f801ae video: Add video command with subcommands
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.

Series-changes: 2
- Correct confusing output text which should be 16 instead of 10
- Improve docs for row and col

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-02 13:50:32 -06:00
Simon Glass
a85820f86c video: Add tests for the video commands
Add a simple test for the setcurs and lcdputs commands.

Series-changes: 2
- Pull out the docs into a separate patch
- Update test result for hex

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-02 13:50:32 -06:00
Simon Glass
9f00a0e3f3 boot: Run the EFI bootmgr just before network devices
At present the EFI bootmgr scans all devices in the system before
deciding which one to boot. Ideally it would use the bootstd iterator
for this, but in the meantime, give it a lower priority, so it runs
just before the network devices.

Note that if there are no hunted network devices hunted, then it will
run at the end, after all bootdevs are exhausted. In other words, it
will always run.

Series-changes: 2
- Update commit message to indicate the bootmeth will always run
- Document how the priority was chosen

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-30 17:23:58 -06:00
Simon Glass
1200d2b52f boot: Don't change the method count after global bootmeths
At present before scanning global bootmeths, the iterator sets the
method count to the index of the first global bootmeth. Now that we
support scanning the global bootmeths multiple times, we must leave this
count alone.

Check against have_global and first_glob_method instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-30 17:14:45 -06:00
Simon Glass
07326c0baf boot: Keep track of which bootmeths have been used
Add a bitfield which tracks when bootmeths have been used. This will be
needed when global bootmeths can be used later in the iteration.

Fix a missing bootflow_free() while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-30 17:14:45 -06:00
Simon Glass
37cabfe0b1 boot: Add a flag for whether there are global bootmeths
The current 'doing_global' refers to being in the state of processing
global bootmeths. Since global bootmeths are currently used once at the
start, it becomes false once the last global bootmeth has been used.

In preparation for allowing bootmeths to run at other points in the
bootstd interation, add a new 'have_global' flag which tracks whether
there are any global bootmeths in the method_order[] list. It is set up
when iteration starts. Unlike doing_global which resets back to false
after the global bootmeths have been handled, once have_global is set to
true, it remains true for the entire iteration process. This provides a
quick check as to whether global-bootmeth processing is needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-30 17:14:45 -06:00
Simon Glass
cd6424c4c3 boot: Update first_glob_method when dropping a bootmeth
For now we only support dropping non-global bootmeths from the
iteration. Update first_glob_method in that case and add a few checks
that things are correct.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-30 17:14:45 -06:00
Simon Glass
7e9ee27101 boot: Add a new test for global bootmeths
These have different behaviour from normal bootmeths and we are about to
enhance it. So add a test and also an extra check in bootflow_iter()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-30 17:14:45 -06:00
Simon Glass
f89d2779c3 boot: Improve comments related to global bootmeths
Add a few comments about global bootmeths and first_glob_method

Fix a broken line in bootmeth_setup_iter_order() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-09-30 17:10:48 -06:00
Simon Glass
d9152ea75e bootctl: Initial experimentation
This provides a basic prototype for boot control.

Some documentation is in boot/bootctl/README.rst
2025-09-28 14:32:36 -06:00
Simon Glass
6d58e9f8b6 doc: test: Add docs and test for addr_find
Add documentation and a test for this command.

Drop the use of config.h while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-25 09:47:09 -06:00
Simon Glass
6e79f1f503 doc: test: Add docs and test for part_find
Add some documentation and a test for this new command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-25 09:47:09 -06:00
Simon Glass
2f4e1b291f test: Allow creating disks with a different Ubuntu version
Add a way to specify the (fake) Ubuntu release being used, so that we
can (later) add more tests for this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-25 09:43:54 -06:00
Simon Glass
4e38954a41 test: Drop an unwanted blank line in dm_test_video_box()
This test has a blank line which separates one part of the test from
another. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-24 18:29:40 -06:00
Simon Glass
d7c51083a6 bdinfo: Show the flags
The flags contain lots of little pieces of information. Print them out
with the bdinfo command, so the user can look them up if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-24 18:29:38 -06:00
Simon Glass
c3646ef52e test: Deal with the silent menu in grub
The distro test for EFI in the EFI ARM app is currently flaky.

If the test does not send an 'escape' character, then the board may boot
straight into Ubuntu. If it does, but didn't need to, then grub sits at
the command prompt.

Handle this by pressing escape twice (which should always go to the grub
command line), then using the 'normal' command to start the menu.

Series-to: concept
Series-cc: heinrich

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-23 13:45:23 -06:00
Simon Glass
16a1847b06 efi: test: Update distro EFI-app tests for new naming
The EFI-media devices names were recently changed to make it easier to
tell them apart. Update the tests as well, since this change caused them
to fail.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: dea4ea00a7 ("efi: Set the efi_media device name when binding")
2025-09-23 12:25:40 -06:00
Simon Glass
dd80fd963c console: Add a way to quit pager with no further output
Add support for pressing 'q' to throw away any further output until the
prompt is reached.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-22 11:23:04 -06:00
Simon Glass
c7ba355d1f console: Add bypass keypress to disable paging
Add support for pressing 'Q' to put the pager into bypass mode,disabling
further paging for the current session.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-22 11:23:04 -06:00
Simon Glass
b54422a25d console: Restore old pager test-bypass value
The test.py tests pass -P to sandbox to tell it to bypass the pager.
Tests which change this value must restore it to the old value.

Fix this, so that the -P setting remains in place across test runs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-22 11:23:04 -06:00
Simon Glass
08faed68c3 scripts: Fix RST formatting in release_version.py
Fix line continuation in generate_schedule() that caused Sphinx to fail
with "Bullet list ends without a blank line; unexpected unindent" error.
Add tests to validate RST formatting of generated documentation.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-22 11:23:04 -06:00
Simon Glass
1fd04ae30a console: Add some cursor tests
Add a few tests of cursor operation.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

Series-to: concept
Series-cc: heinrich
Cover-letter:
video: Support a cursor more generally
At present U-Boot does not support displaying a cursor on the console,
except with expo.

It is quite useful to have a cursor, particularly when using the
command-line editor.

This series adds tracking of the cursor position for both truetype and
normal consoles. The cursor is shown when U-Boot is idle and is removed
before writing characters to the display. A save-buffer ensures that the
old display contents are provided.

Some related improvements in this series include:
- expo lineedit support with normal console
- arrow keys now render correctly when editing commands with truetype
- truetype console now also supports bitmap fonts

The cursor is not currently supported for rotated consoles.

A README for claude is provided, although so far I have not had too much
success with it.

A fix for an intermittent build is added as well, along with silencing
some build messages noticed from Rust ulib.
END
2025-09-19 13:21: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
cca7523800 video: truetype: Handle rendering of bitmap fonts
Complete the support for this feature by dealing with rendering, the
moving to a particular row/column and scrolling.

Provide a simple test to check that things look right.

Allow omitting the font name to request the default font.

Fix an errant tab nearby.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
1fe8824fb9 video: Allow selection of bitmap fonts in truetype
It is sometimes useful to use a bitmap font for the console even when
truetype fonts are available. As a starting point, pull in the
font table and provide information about font sizes. Allow selection of
a bitmap font by name, as well as listing available bitmap fonts.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:01 -06:00
Simon Glass
1ecfbbcbad test: video: Split long strings
Some strings in this file are quite long and it is a pain to look at
them within an 80-column editor. Split them.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 11:42:51 -06:00