1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright 2022 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
13 #include <video_console.h>
15 static int do_font_list(struct cmd_tbl *cmdtp, int flag, int argc,
20 if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
21 return CMD_RET_FAILURE;
22 vidconsole_list_fonts(dev);
27 static int do_font_select(struct cmd_tbl *cmdtp, int flag, int argc,
38 if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
39 return CMD_RET_FAILURE;
42 size = dectoul(argv[2], NULL);
43 ret = vidconsole_select_font(dev, name, size);
45 printf("Failed (error %d)\n", ret);
46 return CMD_RET_FAILURE;
51 static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc,
54 const char *font_name;
62 if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
63 return CMD_RET_FAILURE;
64 ret = vidconsole_get_font_size(dev, &font_name, &size);
66 printf("Failed (error %d)\n", ret);
67 return CMD_RET_FAILURE;
70 size = dectoul(argv[1], NULL);
72 ret = vidconsole_select_font(dev, font_name, size);
74 printf("Failed (error %d)\n", ret);
75 return CMD_RET_FAILURE;
82 #ifdef CONFIG_SYS_LONGHELP
83 static char font_help_text[] =
84 "list - list available fonts\n"
85 "font select <name> [<size>] - select font to use\n"
86 "font size <size> - select font size to";
89 U_BOOT_CMD_WITH_SUBCMDS(font, "Fonts", font_help_text,
90 U_BOOT_SUBCMD_MKENT(list, 1, 1, do_font_list),
91 U_BOOT_SUBCMD_MKENT(select, 3, 1, do_font_select),
92 U_BOOT_SUBCMD_MKENT(size, 2, 1, do_font_size));