diff options
author | Simon Glass <sjg@chromium.org> | 2022-10-06 08:36:16 -0600 |
---|---|---|
committer | Anatolij Gustschin <agust@denx.de> | 2022-10-30 20:01:40 +0100 |
commit | 430e1676a76bf8b7112c64e19cf64b988c281ee0 (patch) | |
tree | 97d40e3ae1f3305177622818c23d7195b3370e22 /cmd | |
parent | 3f425f9ca75c8d1938579044fde37a6f7d5abe16 (diff) | |
download | u-boot-430e1676a76bf8b7112c64e19cf64b988c281ee0.zip u-boot-430e1676a76bf8b7112c64e19cf64b988c281ee0.tar.gz u-boot-430e1676a76bf8b7112c64e19cf64b988c281ee0.tar.bz2 |
video: Add commands to list and change fonts
Add a new 'font' command which allows the fonts to be listed as well as
selecting a different font and size.
Allow the test to run on sandbox, where multiple font/size combinations
are supported, as well as sandbox_flattree, where they are not.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/Makefile | 1 | ||||
-rw-r--r-- | cmd/font.c | 81 |
2 files changed, 82 insertions, 0 deletions
diff --git a/cmd/Makefile b/cmd/Makefile index ac9226f..ca9ed10 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -74,6 +74,7 @@ obj-$(CONFIG_CMD_EXT2) += ext2.o obj-$(CONFIG_CMD_FAT) += fat.o obj-$(CONFIG_CMD_FDT) += fdt.o obj-$(CONFIG_CMD_SQUASHFS) += sqfs.o +obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o obj-$(CONFIG_CMD_FLASH) += flash.o obj-$(CONFIG_CMD_FPGA) += fpga.o obj-$(CONFIG_CMD_FPGAD) += fpgad.o diff --git a/cmd/font.c b/cmd/font.c new file mode 100644 index 0000000..3e522f3 --- /dev/null +++ b/cmd/font.c @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * video commands + * + * Copyright 2022 Google LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#include <common.h> +#include <command.h> +#include <dm.h> +#include <video.h> +#include <video_console.h> + +static int do_font_list(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + vidconsole_list_fonts(); + + return 0; +} + +static int do_font_select(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + const char *name; + uint size = 0; + int ret; + + if (argc < 2) + return CMD_RET_USAGE; + + if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) + return CMD_RET_FAILURE; + name = argv[1]; + if (argc == 3) + size = dectoul(argv[2], NULL); + ret = vidconsole_select_font(dev, name, size); + if (ret) { + printf("Failed (error %d)\n", ret); + return CMD_RET_FAILURE; + } + + return 0; +} +static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + uint size; + int ret; + + if (argc != 2) + return CMD_RET_USAGE; + + if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) + return CMD_RET_FAILURE; + + size = dectoul(argv[1], NULL); + ret = vidconsole_select_font(dev, NULL, size); + if (ret) { + printf("Failed (error %d)\n", ret); + return CMD_RET_FAILURE; + } + + return 0; +} + + +#ifdef CONFIG_SYS_LONGHELP +static char font_help_text[] = + "list - list available fonts\n" + "font select <name> [<size>] - select font to use\n" + "font size <size> - select font size to"; +#endif + +U_BOOT_CMD_WITH_SUBCMDS(font, "Fonts", font_help_text, + U_BOOT_SUBCMD_MKENT(list, 1, 1, do_font_list), + U_BOOT_SUBCMD_MKENT(select, 3, 1, do_font_select), + U_BOOT_SUBCMD_MKENT(size, 2, 1, do_font_size)); |