]>
Commit | Line | Data |
---|---|---|
430e1676 SG |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * video commands | |
4 | * | |
5 | * Copyright 2022 Google LLC | |
6 | * Written by Simon Glass <[email protected]> | |
7 | */ | |
8 | ||
430e1676 SG |
9 | #include <command.h> |
10 | #include <dm.h> | |
11 | #include <video.h> | |
12 | #include <video_console.h> | |
13 | ||
14 | static int do_font_list(struct cmd_tbl *cmdtp, int flag, int argc, | |
15 | char *const argv[]) | |
16 | { | |
0e38bd84 SG |
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); | |
430e1676 SG |
22 | |
23 | return 0; | |
24 | } | |
25 | ||
26 | static 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 | } | |
50 | static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, | |
51 | char *const argv[]) | |
52 | { | |
0e38bd84 | 53 | const char *font_name; |
430e1676 SG |
54 | struct udevice *dev; |
55 | uint size; | |
56 | int ret; | |
57 | ||
58 | if (argc != 2) | |
59 | return CMD_RET_USAGE; | |
60 | ||
61 | if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) | |
62 | return CMD_RET_FAILURE; | |
4f6e3481 DS |
63 | ret = vidconsole_get_font_size(dev, &font_name, &size); |
64 | if (ret) { | |
65 | printf("Failed (error %d)\n", ret); | |
66 | return CMD_RET_FAILURE; | |
67 | } | |
430e1676 SG |
68 | |
69 | size = dectoul(argv[1], NULL); | |
0e38bd84 SG |
70 | |
71 | ret = vidconsole_select_font(dev, font_name, size); | |
430e1676 SG |
72 | if (ret) { |
73 | printf("Failed (error %d)\n", ret); | |
74 | return CMD_RET_FAILURE; | |
75 | } | |
76 | ||
77 | return 0; | |
78 | } | |
79 | ||
3616218b | 80 | U_BOOT_LONGHELP(font, |
430e1676 SG |
81 | "list - list available fonts\n" |
82 | "font select <name> [<size>] - select font to use\n" | |
3616218b | 83 | "font size <size> - select font size to"); |
430e1676 SG |
84 | |
85 | U_BOOT_CMD_WITH_SUBCMDS(font, "Fonts", font_help_text, | |
86 | U_BOOT_SUBCMD_MKENT(list, 1, 1, do_font_list), | |
87 | U_BOOT_SUBCMD_MKENT(select, 3, 1, do_font_select), | |
88 | U_BOOT_SUBCMD_MKENT(size, 2, 1, do_font_size)); |