Commit Graph

99383 Commits

Author SHA1 Message Date
Simon Glass
e94de63e6c expo: Add a way to select settings
In some cases it is useful to provide a settings scene, or perhaps just
a button to change the layout. Add support for this.
2025-10-10 03:11:26 +01:00
Simon Glass
f4e3c6f418 expo: Add another logo in the bootmenu
In some cases we want to show a logo other than the U-Boot one. Add a
field for this, so it can be used by layouts which need it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 03:11:23 +01:00
Simon Glass
47e05ed19e expo: Support clicking on any type of object
It is sometimes useful to be able to click on an image (sometimes called
an icon). Allow this within expo and return new click action.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 03:11:18 +01:00
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
9480aff0b5 expo: Provide a version of scene_within() with takes an obj
When the object pointer is already available we don't want to have to
look it up. Provide a new is_within() function which takes an object
pointer instead of an ID.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-10 02:24:07 +01:00
Simon Glass
9b1ab4b424 expo: Provide a command to dump a cedit expo
Add a new 'cedit dump' command which dumps the contents of an expo for
debugging.

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
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
6b1c188336 expo: Correct key-polling timeout
When a character is received it should reset the timeout, even if the
character does not result in output from cli_ch_process()

Fix this, so that keypresses which consist of escape codes are correctly
interpreted.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: a5c5b3b2fb ("expo: Speed up polling the keyboard")
2025-10-10 02:24:07 +01:00
Simon Glass
7f68ca8abc input: Correct handling of mouse clicks
It is possible that there is already a mouse click available, so
mouse_get_click() should check that first, before reading any further
events.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 90e109789e ("mouse: Move click detection into mouse_get_event()")
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
cfffa4bf16 Merge branch 'prof2' into 'master'
expo: Complete mouse operation in the EFI app

See merge request u-boot/u-boot!196
2025-10-07 17:09:18 +00:00
Simon Glass
99479f5b7c efi: mouse: Scale the pointer to the display
If a display is provided to the mouse uclass, use it to scale the coords
returned by the absolute-pointer protocol.

Series-to: concept
Series-cc: heinrich
Cover-letter:
expo: Complete mouse operation in the EFI app
This series includes various improvements which allow the mouse to be
used when running as an EFI app.

In particular:
- support for the absolute-pointer protocol, since this provides better
  integration when running under QEMU
- input tweaks to improve performance under QEMU

It also includes some x86-specific fixes for i8042 and MTRRs.

Finally, a new --bootcmd option is added to the build-qemu script to
allow passing a boot command to U-Boot.

This series is part F
END

Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:48
Series-version: 2
2025-10-07 09:55:13 -06:00
Simon Glass
8ba4a7e611 efi: mouse: Add support for an absolute pointer
The absolute-pointer protocol is useful particularly with QEMU since it
allows the position to be consistent between the host and the guest.

Add support for this new protocol and use it in preference to the simple
one, when both are available.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:13 -06:00
Simon Glass
e7b305014e efi: Add definitions for the absolute-pointer protocol
Add these definitions to the API so that we can make use of this feature
in drivers, etc.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
0558714801 efi: mouse: Split out event handling further
Create a function which handles getting the pointer position using the
simple-pointer protocol. Call this from efi_mouse_get_event()

Return immediately if there is a button event. Otherwise return a motion
event if motion is detected.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
e82cb90c65 efi: mouse: Move button handling into a function
Split out the code that handles button presses into its own function,
since efi_mouse_get_event() is already quite long.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
4ed3bc8bbe efi: mouse: Move simple-pointer code into a function
In preparation for supporting an absolute pointer, move the setup of
the simple pointer into its own function. Rename 'pointer' to simple
and last_state to simple_last. Take this opportunity to add comments
for struct efi_mouse_priv since it will be less obvious once the new
support is added.

Clean up some unnecessary cruft in the remove() path.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06: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
e5422499b5 efi: serial: Speed up reading from input
The serial driver is currently quite slow since it sets an event and
waits for at least 1ms for a keypress, which may never come.

On real hardware, the keyboard does not work correctly wihout waiting
for events. Reduce the time to 10us which should be enough to provide an
opportunity for event processing.

QEMU does not actually have this problem, so detect that and skip the
processing altogether.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
02fa448bcc efi: app: Detect running under QEMU
When the app is running under QEMU we may wish to do some things
differently. Add a flag for this and use the SMBIOS tables to detect it.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
6d5dc5ea55 efi: app: Support reading SMBIOS3 tables
Check for both GUIDs when looking for the SMBIOS tables. This allows
both table versions to be detected when running from OVMF.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
f2c7cf87da x86: efi: Disable i8042 in the x86 app
We should not try to directly access the keyboard when running as an EFI
app. Disable CONFIG_I8042_KEYB option to prevent that.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
b1f0d6b026 x86: efi: Avoid setting MTRRs in the app
The MTRRs have already been set by the previous phase so we should not
set them when the U-Boot app starts. Add a condition to prevent it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
a5c5b3b2fb expo: Speed up polling the keyboard
The current algorithm spends 10ms or more looking for keyboard input.
Since we expect the frame rate to be 50 or more, it should be OK to only
check once.

Handle the timeout by recording the timestamp of the last key and timing
out the CLI entry after 10ms. This allows an 'Escape' key to work,
rather than it just waiting forever for a terminal sequence that starts
with escape.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06:00
Simon Glass
90e109789e mouse: Move click detection into mouse_get_event()
Currently mouse_get_click() processes events by calling
mouse_get_event() and tracking the press->release transition. But if
other code calls mouse_get_event() directly, those button events are
consumed and mouse_get_click() never sees them.

Fix this by moving the click detection logic into mouse_get_event()
itself. Add a click_pending flag to track when a click has been
detected, and simplify mouse_get_click() to just check and clear this
flag.

This ensures clicks are properly registered regardless of whether callers
use mouse_get_event() or mouse_get_click().

Series-changes: 2
- Add new patch to move click detection into mouse_get_event()

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:55:12 -06: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
90964bf740 mouse: Replace mouse_press_state_t enum with bool
Replace the mouse_press_state_t enum with a simpler bool left_pressed
field in mouse_uc_priv. Convert BUTTON_PRESSED/BUTTON_RELEASED to defines
since they're still used in the mouse_event button structure.

This simplifies the code by directly tracking whether the left button
is pressed rather than using an enum to represent a binary state.

Clarify the comment to struct mouse_uc_priv while here.

Series-changes: 2
- Add new patch to replace mouse_press_state_t enum with bool

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:54:26 -06:00
Simon Glass
fae5a7c0fc scripts: build-qemu: Add --bootcmd option to pass bootcmd via fw_cfg
Add a --bootcmd option to the build-qemu script that allows passing a
boot command to QEMU via fw_cfg. The bootcmd is written to the
"opt/u-boot/bootcmd" fw_cfg entry, which can be read by U-Boot's
EVT_BOOTCMD handler.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 06:13:49 -06:00
Simon Glass
d4ee1a8ae1 x86: qemu: Add EVT_BOOTCMD handler to get bootcmd from fw_cfg
Implement an EVT_BOOTCMD event handler that reads the bootcmd from
QEMU's fw_cfg interface using the "opt/u-boot/bootcmd" file. This
allows QEMU to provide a custom boot command to U-Boot at runtime.

Uses the newly exported qfw_locate_file() function to locate and
read the bootcmd file.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 06:13:49 -06:00
Simon Glass
69891885b7 event: Add EVT_BOOTCMD event for custom boot commands
Add a new event that is triggered in main_loop() before
autoboot_command(). This allows platform code to provide a custom
bootcmd string via the event system.

The event uses struct event_bootcmd which provides a buffer for the
bootcmd string and its size. Platform event handlers can write their
custom bootcmd to this buffer.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 06:13:49 -06:00
Simon Glass
1997712001 qfw: Export qfw_locate_file() for external use
Export the qfw_locate_file() function to allow other modules to locate
files in the QEMU firmware config without loading them into memory.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 06:13:49 -06:00
Simon Glass
036ed95857 Merge branch 'proe' into 'master'
expo: Support drawing only the dirty portion of an expo

See merge request u-boot/u-boot!194
2025-10-07 11:03:53 +00:00
Simon Glass
f5ccdc7ac0 expo: Use manual-sync mode
Make use of the manual-sync mode provided by the video subsystem. This
removes uncertainty about whether the display will actually be updated.

Series-to: concept
Series-cc: heinrich
Cover-letter:
expo: More mouse development for expo
This series adds support for hiding the system pointer, if one is
available, since it is confusing to have an expo pointer separate from
the system one.

It also introduces a simple test mode for expo, to check the frame rate,
etc.

Some minor tweaks in the video uclass are also included, as well as
improvements to the video documentation.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 10:54:13 +00:00
Simon Glass
aa83cf00ce expo: Expand timing to include render and poll
Provide more timing information for expo operation, including the time
taken to:

- render the scene
- sync the framebuffer to the display
- poll for keyboard / mouse input

These are averages calculated over the past second.

Update the documentation to mention these features.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 10:54:13 +00: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
f95a85e1a6 expo: Track the number of render calls
Keep track of the frame count, i.e. the number of times that
expo_render() has been called since expo_enter_mode() was invoked.

Allow test mode to be enabled (if compiled in) by setting the 'expotest'
environment variable to 1.

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
ea95076ac6 expo: Introduce a test mode
Add a test mode for expo which will display useful debugging
information.

Put this feature behind a CONFIG_EXPO_TEST option to avoid code-size
growth. Create a separate C file and a header. Use static inlines to
avoid lots of CONFIG checking in expo.c

Enable this feature for sandbox and the EFI app for now.

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
6af145ea6b expo: Hide system pointer when entering expo mode
When entering expo mode, hide the system mouse pointer so that only the
custom expo pointer is visible. Restore it when exiting expo mode.

This uses the new set_ptr_visible() method if a mouse is enabled.

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
53aad73a6b sandbox: mouse: Implement set_ptr_visible()
Implement this new method using the SDL layer.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 10:54:13 +00:00
Simon Glass
e99d2dc8ec mouse: Add support for scaling of video-device coordinates
Add a mouse_set_video() function to set up the video device associated
with the mouse. This allows mouse drivers to scale coordinates to match
the display resolution.

The video device information is stored in mouse_uc_priv rather than
being driver-specific, providing a common place for all mouse drivers to
access display dimensions for coordinate scaling.

Update expo_set_mouse_enable() to call mouse_set_video() to configure
the mouse with the display device.

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
07680c67f8 mouse: Add method to show/hide the system pointer
Add a new set_ptr_visible() method to the mouse uclass to allow hiding
and showing the system mouse pointer. This is useful with sandbox when
rendering a custom mouse pointer, such as in expo mode.

The method is optional and returns -ENOSYS if not supported by the
driver.

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
94bb322813 mouse: Add comment for mouse_get_event()
Document the mouse_get_event() function to explain what it does and its
return values.

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
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