In tests it is useful to fake a mouse click to check that expo handles
it correctly. Create a function for this.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
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()")
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Add tracking of the last mouse position received, separate from the
click position. This allows callers to query the current mouse position
using mouse_get_pos() regardless of whether a click occurred.
The position is updated in mouse_get_event() for both motion and button
events, ensuring it always reflects the most recent mouse coordinates.
This avoid the problem of mouse_get_click() 'swallowing' motion events
so that a position change is not noticed, e.g. for showing a pointer.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
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>
Use the new vid_pos struct instead of separate x/y fields.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a keyboard driver which returns keys produced by EFI.
This is basically the same as the serial driver but it doesn't combine
input and output into one driver, allowing more control when using a
separate screen.
Add the required devicetree fragment for ARM (only).
Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: Tidy up some commands and provide a keyboard driver
This series collect various odds and ends to make the ARM EFI app show
a menu that looks reasonable, including truetype fonts and a new
keyboard driver, selectable by setting stdin to 'efi-kbd'.
Some highlights:
- fix some bugs in addr_find and part_find and adds docs / tests
- reset pager when clearing the console
- use at least 1G of memory with EFI since the app allocates 512M
- allow NEON registers so floating point can work (truetype)
- show the global_data flags with bdinfo
END
Signed-off-by: Simon Glass <sjg@chromium.org>
Enable the mouse when running on QEMU, for ARM and x86.
This requires 'usb start' on x86. For ARM, the mouse does not work,
perhaps related to the fact that the display does not work either.
Series-to: concept
Series-cc: heinrich
Cover-letter:
mouse: Provide some support for using a mouse
This series resurects some old code that was never submitted, related to
using Nuklear with U-Boot.
It includes:
- a very simple mouse uclass
- sandbox mouse driver
- USB mouse driver, useful on x86
- EFI mouse driver, useful when running as an EFI app
- script updates to use the above with build-qemu and build-efi
It also includes a few small patches for sandbox, tests and membuf
Not everything is fully working at present:
- Mouse works on x86 QEMU (after 'usb start') but not ARM
- Mouse works on real hardware with EFI, but not with build-efi script
- Mouse times out with 'usb start', even though it does actually work
More work will be needed to tidy up these remaining issues.
END
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:33
Series-version: 2
In some cases the device may have a touchpad or mouse, so it is useful
to be able to use this in U-Boot. Add a simple driver for a mouse that
uses the EFI simple-pointer protocol.
Series-changes: 2
- Add missed Claude credit
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
A mouse click is defined as pressing the mouse and then releasing it
over a given spot. Add a function the tracks the mouse state and
returns the most recent mouse click, if any.
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a basic mouse driver for USB mice. It only handles very basic mice so
assumes that the reports are in the basic format described by the USB HID
specification 1.11.
Change-Id: I74dbe55eb065be1782737c8b2b86558e53e0292a
Signed-off-by: Simon Glass <sjg@chromium.org>
When running a simple GUI it is useful to support a mouse. This is
similar to what is provided in UEFI's boot menu. Add a simple uclass and
a way to read the mouse position.
For sandbox add a driver that reads the position from SDL. Disable input
for the tools-only build, since it is of no use there and causes build
failures.
Signed-off-by: Simon Glass <sjg@chromium.org>
Use PHASE_ as the symbol to select a particular XPL build. This means
that SPL_TPL_ is no-longer set.
Update the comment in bootstage to refer to this symbol, instead of
SPL_
Signed-off-by: Simon Glass <sjg@chromium.org>
As part of bringing the master branch back in to next, we need to allow
for all of these changes to exist here.
Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay
Ethernet"' I failed to notice that b4 noticed it was based on next and
so took that as the base commit and merged that part of next to master.
This reverts commit c8ffd1356d, reversing
changes made to 2ee6f3a5f7.
Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>
If a button device fails to probe, it will still be added to the uclass
device list, and therefore will still be iterated over in
button_read_keys() resulting in a UAF on the buttons private data.
Resolve this by unbinding button devices that aren't active after
probing, and print a warning so it's clear that the button is broken.
Fixes: e877996289 ("dm: input: add button_kbd driver")
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Before using the result of env_get("stdin") we must check if it is NULL.
Avoid #if. This resolves the -Wunused-but-set-variable issue and we don't
need a dummy assignment in the else branch. Anyway this warning is
disabled in the Makefile.
For sake of readability use an early return after the configuration check.
Checking CONFIG_SPL_BUILD is incorrect as env_get() is only defined if
CONFIG_$(SPL_TPL)ENV_SUPPORT=y.
Fixes: 985ca3945f ("spl: input: Allow input in SPL and TPL")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
If U-Boot is not the first-stage bootloader the keyboard may already be
set up. Make sure to flush any data before trying to reset it. This
avoids a long timeout / hang.
Add some comments and a log category while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Remove need of dts binding for button keyboard since it reuses
gpio-keys binding. Select gpio-keys driver if button keyboard
is selected since button keyboard can not operate on its own.
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Bootmenu requires an input device with arrows and enter key.
A common smartphone luckily has power, volume up/down buttons,
which may be used for controlling bootmenu.
To use driver, add 'button-kbd' to stdin.
Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
There are no platforms that have not migrated to using DM_KEYBOARD,
remove the legacy option.
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This driver adds support for the keyboard on Apple Silicon laptops.
The controller for this keyboard sits on an SPI bus and uses an
Apple-specific HID over SPI protocol. The packets sent by this
controller for key presses and key releases are fairly simple and
are decoded directly by the code in this driver and converted into
standard Linux keycodes. The same controller handles the touchpad
found on these laptops. Packets for touchpad events are simply
ignored.
Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested on: Macbook Air M1
Tested-by: Simon Glass <sjg@chromium.org>
This driver uses the CONFIG namespace to set the chips internal CONFIG
namespace related bits. However, CONFIG is reserved for the top-level
Kconfig based configuration system. Use CFG as the namespace here
instead to avoid pollution.
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Define LOG_CATEGORY for all uclass to allow filtering with
log command.
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Move this out of the common header and include it only where needed. In
a number of cases this requires adding "struct udevice;" to avoid adding
another large header or in other cases replacing / adding missing header
files that had been pulled in, very indirectly. Finally, we have a few
cases where we did not need to include <asm/global_data.h> at all, so
remove that include.
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
This construct is quite long-winded. In earlier days it made some sense
since auto-allocation was a strange concept. But with driver model now
used pretty universally, we can shorten this to 'auto'. This reduces
verbosity and makes it easier to read.
Coincidentally it also ensures that every declaration is on one line,
thus making dtoc's job easier.
Signed-off-by: Simon Glass <sjg@chromium.org>
Chromebooks and the sandbox use a crosswire keyboard with function keys
FN1 - FN10. These keys are needed when running UEFI applications like GRUB
or the UEFI SCT.
Add support for these keys when translating from key codes to
ECMA-48 (or withdrawn ANSI 3.64) escape sequences.
All escape sequences start with 0x1b. So we should not repeat this
byte in the kbd_to_ansi364 table.
For testing use:
sandbox_defconfig + CONFIG_EFI_SELFTEST=y
$ ./u-boot -D -l
=> setenv efi_selftest extended text input
=> bootefi selftest
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
The cros_ec_keyb driver currently uses EC_CMD_MKBP_STATE to scan the
keyboard, but this host command was superseded by EC_CMD_GET_NEXT_EVENT
and unavailable on more recent devices (including gru-kevin), as it was
removed in cros-ec commit 87a071941b89 ("mkbp: Add support for buttons
and switches.") dated 2016-07-06.
The EC_CMD_GET_NEXT_EVENT has been available since cros-ec commit
d1ed75815efe ("MKBP event signalling implementation") dated 2014-10-20,
but it looks like it isn't included in firmware-* branches for at least
link, nyan-big, samus, snow, spring, panther and peach-pit which have
defconfigs in U-Boot. So this patch falls back to the old method if the
EC doesn't recognize the newer command.
The implementation is mostly adapted from Depthcharge commit
f88af26b44fc ("cros_ec: Change keyboard scanning method.").
On a gru-kevin, the current driver before this patch fails to read the
pressed keys with:
out: cmd=0x60: 03 9d 60 00 00 00 00 00
in-header: 03 fc 01 00 00 00 00 00
in-data:
ec_command_inptr: len=-1, din=0000000000000000
check_for_keys: keyboard scan failed
However the keyboard works fine with the newer command:
out: cmd=0x67: 03 96 67 00 00 00 00 00
in-header: 03 ef 00 00 0e 00 00 00
in-data: 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ec_command_inptr: len=14, din=00000000f412df30
key_matrix_decode: num_keys = 0
0 valid keycodes found
out: cmd=0x67: 03 96 67 00 00 00 00 00
in-header: 03 df 00 00 0e 00 00 00
in-data: 00 00 00 00 00 00 00 00 00 00 00 00 10 00
ec_command_inptr: len=14, din=00000000f412df30
key_matrix_decode: num_keys = 1
valid=1, row=4, col=11
keycode=28
1 valid keycodes found
{0d}
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>