diff options
author | Tom Rini <trini@konsulko.com> | 2023-01-17 08:55:40 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-01-17 08:55:40 -0500 |
commit | 5b958dea5c678dbdb2aeb6ac3c0c8cc8dfea065c (patch) | |
tree | 172424111d1a39640cf5245eefd080fae3b5fb27 /drivers | |
parent | 6d03688e75041a7bae4d33815de28da781c37dd6 (diff) | |
parent | b5c8fea7b830c0304051237ad1501431a958b0e6 (diff) |
Merge branch '2022-01-16-bootstd-updates'
To quote the author:
So far standard boot lacks a boot menu, although it is possible to create
a rudimentary one using the existing 'bootmenu' command.
Even then, this text-based menu offer only basic functionality and does
not take full advantage of the displays which are common on many devices.
This series provides a 'bootflow menu' command which allows the user to
select from the available bootflows. An attempt is made to show the name
of the available operating systems, by reading more information into the
bootflow. A logo can be read also, where supported, so that this can be
presented to the user when an option is highlighted.
Full use is made of TrueType fonts, if enabled. For cases where only a
serial console is available, it falls back to a simple text-based menu.
All of this is implementing using a new 'expo' construct, a collection of
scenes (like menu screens) which can be navigated by the user to view
information and select options. This is fairly general and should be able
to cope with a wider array of use cases, with less hacking of the menu
code, such as is currently needed for CMD_BOOTEFI_BOOTMGR.
Of course it would be possible to enhance the existing menu rather than
creating a new setup. Instead it seems better to make the existing menu
use expo, if code space permits. It avoids the event-loop problem and
should be more extensible, given its loosely coupled components and use of
IDs instead of pointers. Further motivation is provided in the
documentation.
For now the CLI keypress-decoding code is split out to be used by the new
menu. The key codes defined by menu.h are reused also.
This is of course just a starting point. Some ideas for future work are
included in the documentation.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/f_sdp.c | 2 | ||||
-rw-r--r-- | drivers/video/Kconfig | 7 | ||||
-rw-r--r-- | drivers/video/console_truetype.c | 37 | ||||
-rw-r--r-- | drivers/video/vidconsole-uclass.c | 33 |
4 files changed, 63 insertions, 16 deletions
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c index 5ae5b62741..9ea43f29cf 100644 --- a/drivers/usb/gadget/f_sdp.c +++ b/drivers/usb/gadget/f_sdp.c @@ -868,7 +868,7 @@ static int sdp_handle_in_ep(struct spl_image_info *spl_image, jump_to_image_no_args(&spl_image); #else /* In U-Boot, allow jumps to scripts */ - image_source_script(sdp_func->jmp_address, NULL, NULL); + cmd_source_script(sdp_func->jmp_address, NULL, NULL); #endif } diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index f539977d9b..440b161b84 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -112,10 +112,13 @@ config VIDEO_BPP32 config VIDEO_ANSI bool "Support ANSI escape sequences in video console" - default y + default y if EFI_LOADER help Enable ANSI escape sequence decoding for a more fully functional - console. + console. Functionality includes changing the text colour and moving + the cursor. These date from the 1970s and are still widely used today + to control a text terminal. U-Boot implements these by decoding the + sequences and performing the appropriate operation. config VIDEO_MIPI_DSI bool "Support MIPI DSI interface" diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 6859c9fa11..9cac9a6de4 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -584,18 +584,24 @@ static struct font_info *console_truetype_find_font(void) return NULL; } -void vidconsole_list_fonts(void) +int console_truetype_get_font(struct udevice *dev, int seq, + struct vidfont_info *info) { struct font_info *tab; + int i; - for (tab = font_table; tab->begin; tab++) { - if (abs(tab->begin - tab->end) > 4) - printf("%s\n", tab->name); + for (i = 0, tab = font_table; tab->begin; tab++, i++) { + if (i == seq && font_valid(tab)) { + info->name = tab->name; + return 0; + } } + + return -ENOENT; } /** - * vidconsole_add_metrics() - Add a new font/size combination + * truetype_add_metrics() - Add a new font/size combination * * @dev: Video console device to update * @font_name: Name of font @@ -604,8 +610,8 @@ void vidconsole_list_fonts(void) * @return 0 if OK, -EPERM if stbtt failed, -E2BIG if the the metrics table is * full */ -static int vidconsole_add_metrics(struct udevice *dev, const char *font_name, - uint font_size, const void *font_data) +static int truetype_add_metrics(struct udevice *dev, const char *font_name, + uint font_size, const void *font_data) { struct console_tt_priv *priv = dev_get_priv(dev); struct console_tt_metrics *met; @@ -674,7 +680,8 @@ static void select_metrics(struct udevice *dev, struct console_tt_metrics *met) vc_priv->tab_width_frac = VID_TO_POS(met->font_size) * 8 / 2; } -int vidconsole_select_font(struct udevice *dev, const char *name, uint size) +static int truetype_select_font(struct udevice *dev, const char *name, + uint size) { struct console_tt_priv *priv = dev_get_priv(dev); struct console_tt_metrics *met; @@ -684,7 +691,7 @@ int vidconsole_select_font(struct udevice *dev, const char *name, uint size) if (!size) size = CONFIG_CONSOLE_TRUETYPE_SIZE; if (!name) - name = priv->cur_met->font_name; + name = font_table->name; met = find_metrics(dev, name, size); if (!met) { @@ -693,8 +700,10 @@ int vidconsole_select_font(struct udevice *dev, const char *name, uint size) !strcmp(name, tab->name)) { int ret; - ret = vidconsole_add_metrics(dev, - tab->name, size, tab->begin); + ret = truetype_add_metrics(dev, + tab->name, + size, + tab->begin); if (ret < 0) return log_msg_ret("add", ret); @@ -715,7 +724,7 @@ int vidconsole_select_font(struct udevice *dev, const char *name, uint size) return 0; } -const char *vidconsole_get_font(struct udevice *dev, uint *sizep) +const char *vidconsole_get_font_size(struct udevice *dev, uint *sizep) { struct console_tt_priv *priv = dev_get_priv(dev); struct console_tt_metrics *met = priv->cur_met; @@ -745,7 +754,7 @@ static int console_truetype_probe(struct udevice *dev) return -EBFONT; } - ret = vidconsole_add_metrics(dev, tab->name, font_size, tab->begin); + ret = truetype_add_metrics(dev, tab->name, font_size, tab->begin); if (ret < 0) return log_msg_ret("add", ret); priv->cur_met = &priv->metrics[ret]; @@ -763,6 +772,8 @@ struct vidconsole_ops console_truetype_ops = { .set_row = console_truetype_set_row, .backspace = console_truetype_backspace, .entry_start = console_truetype_entry_start, + .get_font = console_truetype_get_font, + .select_font = truetype_select_font, }; U_BOOT_DRIVER(vidconsole_truetype) = { diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 6bdfb6e37d..aadd54bfd4 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -557,6 +557,39 @@ static void vidconsole_puts(struct stdio_dev *sdev, const char *s) } } +void vidconsole_list_fonts(struct udevice *dev) +{ + struct vidfont_info info; + int ret, i; + + for (i = 0, ret = 0; !ret; i++) { + ret = vidconsole_get_font(dev, i, &info); + if (!ret) + printf("%s\n", info.name); + } +} + +int vidconsole_get_font(struct udevice *dev, int seq, + struct vidfont_info *info) +{ + struct vidconsole_ops *ops = vidconsole_get_ops(dev); + + if (!ops->get_font) + return -ENOSYS; + + return ops->get_font(dev, seq, info); +} + +int vidconsole_select_font(struct udevice *dev, const char *name, uint size) +{ + struct vidconsole_ops *ops = vidconsole_get_ops(dev); + + if (!ops->select_font) + return -ENOSYS; + + return ops->select_font(dev, name, size); +} + /* Set up the number of rows and colours (rotated drivers override this) */ static int vidconsole_pre_probe(struct udevice *dev) { |