"Das U-Boot" Source Tree
at master 89 lines 1.9 kB view raw
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * video commands 4 * 5 * Copyright 2022 Google LLC 6 * Written by Simon Glass <sjg@chromium.org> 7 */ 8 9#include <command.h> 10#include <dm.h> 11#include <video.h> 12#include <video_console.h> 13 14static int do_font_list(struct cmd_tbl *cmdtp, int flag, int argc, 15 char *const argv[]) 16{ 17 struct udevice *dev; 18 19 if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) 20 return CMD_RET_FAILURE; 21 vidconsole_list_fonts(dev); 22 23 return 0; 24} 25 26static int do_font_select(struct cmd_tbl *cmdtp, int flag, int argc, 27 char *const argv[]) 28{ 29 struct udevice *dev; 30 const char *name; 31 uint size = 0; 32 int ret; 33 34 if (argc < 2) 35 return CMD_RET_USAGE; 36 37 if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) 38 return CMD_RET_FAILURE; 39 name = argv[1]; 40 if (argc == 3) 41 size = dectoul(argv[2], NULL); 42 ret = vidconsole_select_font(dev, name, size); 43 if (ret) { 44 printf("Failed (error %d)\n", ret); 45 return CMD_RET_FAILURE; 46 } 47 48 return 0; 49} 50static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, 51 char *const argv[]) 52{ 53 const char *font_name; 54 struct udevice *dev; 55 uint size; 56 int ret; 57 58 if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) 59 return CMD_RET_FAILURE; 60 ret = vidconsole_get_font_size(dev, &font_name, &size); 61 if (ret) { 62 printf("Failed (error %d)\n", ret); 63 return CMD_RET_FAILURE; 64 } 65 66 if (argc < 2) { 67 printf("%d\n", size); 68 } else { 69 size = dectoul(argv[1], NULL); 70 71 ret = vidconsole_select_font(dev, font_name, size); 72 if (ret) { 73 printf("Failed (error %d)\n", ret); 74 return CMD_RET_FAILURE; 75 } 76 } 77 78 return 0; 79} 80 81U_BOOT_LONGHELP(font, 82 "list - list available fonts\n" 83 "font select <name> [<size>] - select font to use\n" 84 "font size <size> - select font size to"); 85 86U_BOOT_CMD_WITH_SUBCMDS(font, "Fonts", font_help_text, 87 U_BOOT_SUBCMD_MKENT(list, 1, 1, do_font_list), 88 U_BOOT_SUBCMD_MKENT(select, 3, 1, do_font_select), 89 U_BOOT_SUBCMD_MKENT(size, 2, 1, do_font_size));