From f029f90e7df9ad566d0bb7f9ea80de108be67fb0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 6 Oct 2022 08:36:06 -0600 Subject: video: Move the console commands to cmd/ Move these commands and the implementation to the cmd/ directory, which is where most commands are kept. Signed-off-by: Simon Glass Acked-by: Ilias Apalodimas [agust: keep vidconsole_position_cursor() in vidconsole uclass] Signed-off-by: Anatolij Gustschin --- cmd/Kconfig | 12 ++++++++++++ cmd/Makefile | 2 ++ cmd/video.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 cmd/video.c (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index 41cf1d46fb1..51dbbf85646 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2161,6 +2161,18 @@ config CMD_UUID The two commands are very similar except for the endianness of the output. +config CMD_VIDCONSOLE + bool "lcdputs and setcurs" + depends on DM_VIDEO + default y + help + Enabling this will provide 'setcurs' and 'lcdputs' commands which + support cursor positioning and drawing strings on the video + console (framebuffer). + + The name 'lcdputs' is a bit of a misnomer, but so named because the + video device is often an LCD. + endmenu source "cmd/ti/Kconfig" diff --git a/cmd/Makefile b/cmd/Makefile index c95e09d0580..ac9226fd4d2 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -178,6 +178,8 @@ obj-$(CONFIG_CMD_WDT) += wdt.o obj-$(CONFIG_CMD_LZMADEC) += lzmadec.o obj-$(CONFIG_CMD_UFS) += ufs.o obj-$(CONFIG_CMD_USB) += usb.o disk.o +obj-$(CONFIG_CMD_VIDCONSOLE) += video.o + obj-$(CONFIG_CMD_FASTBOOT) += fastboot.o obj-$(CONFIG_CMD_FS_UUID) += fs_uuid.o diff --git a/cmd/video.c b/cmd/video.c new file mode 100644 index 00000000000..942f81c1633 --- /dev/null +++ b/cmd/video.c @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * video commands + * + * Copyright 2022 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include + +static int do_video_setcursor(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + unsigned int col, row; + struct udevice *dev; + + if (argc != 3) + return CMD_RET_USAGE; + + if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) + return CMD_RET_FAILURE; + col = dectoul(argv[1], NULL); + row = dectoul(argv[2], NULL); + vidconsole_position_cursor(dev, col, row); + + return 0; +} + +static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct udevice *dev; + int ret; + + if (argc != 2) + return CMD_RET_USAGE; + + if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) + return CMD_RET_FAILURE; + ret = vidconsole_put_string(dev, argv[1]); + if (!ret) + ret = video_sync(dev->parent, false); + + return ret ? CMD_RET_FAILURE : 0; +} + +U_BOOT_CMD( + setcurs, 3, 1, do_video_setcursor, + "set cursor position within screen", + " in character" +); + +U_BOOT_CMD( + lcdputs, 2, 1, do_video_puts, + "print string on video framebuffer", + " " +); -- cgit v1.2.3 From 3f425f9ca75c8d1938579044fde37a6f7d5abe16 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 6 Oct 2022 08:36:15 -0600 Subject: video: Enable the cls command by default This is enabled for LCD but not for VIDEO. Enable it since it is useful to be able to clear the screen and adds very little code. Signed-off-by: Simon Glass --- cmd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index 51dbbf85646..54197160116 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1939,7 +1939,7 @@ config CMD_CONITRACE config CMD_CLS bool "Enable clear screen command 'cls'" - default y if LCD + default y if LCD || DM_VIDEO help Enable the 'cls' command which clears the screen contents on video frame buffer. -- cgit v1.2.3 From 430e1676a76bf8b7112c64e19cf64b988c281ee0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 6 Oct 2022 08:36:16 -0600 Subject: 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 --- cmd/Makefile | 1 + cmd/font.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 cmd/font.c (limited to 'cmd') diff --git a/cmd/Makefile b/cmd/Makefile index ac9226fd4d2..ca9ed1054d7 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 00000000000..3e522f3aaa1 --- /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 + */ + +#include +#include +#include +#include +#include + +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 [] - select font to use\n" + "font 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)); -- cgit v1.2.3 From 988d19dd5bd38181f3bfcafb2c159f367e39d627 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 18 Oct 2022 06:24:16 -0600 Subject: video: Split SPLASH_SCREEN_ALIGN from bmp command The bmp command already has a way to centre the image. Using this CONFIG option to also centre it makes it impossible to control where images are placed on the screen. Drop the extra check. Simplify the Kconfig file we are here. Signed-off-by: Simon Glass --- cmd/bmp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/bmp.c b/cmd/bmp.c index 45f4c1296de..d72a826ae74 100644 --- a/cmd/bmp.c +++ b/cmd/bmp.c @@ -259,9 +259,7 @@ int bmp_display(ulong addr, int x, int y) if (!ret) { bool align = false; - if (CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN) || - x == BMP_ALIGN_CENTER || - y == BMP_ALIGN_CENTER) + if (x == BMP_ALIGN_CENTER || y == BMP_ALIGN_CENTER) align = true; ret = video_bmp_display(dev, addr, x, y, align); -- cgit v1.2.3 From e65500338427b64e83a59432242a1ef295dd95f0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 18 Oct 2022 06:46:08 -0600 Subject: video: Rename CONFIG_SYS_VIDEO_LOGO_MAX_SIZE This option should not have the SYS_ in it. Drop it so it fits in with the other video options. Also simplify the alignment code in gunzip_bmp(), since malloc() always returns a 32-bit-aligned pointer. Signed-off-by: Simon Glass --- cmd/bmp.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'cmd') diff --git a/cmd/bmp.c b/cmd/bmp.c index d72a826ae74..5a3c8ddf8c8 100644 --- a/cmd/bmp.c +++ b/cmd/bmp.c @@ -48,27 +48,24 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp, /* * Decompress bmp image */ - len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE; + len = CONFIG_VIDEO_LOGO_MAX_SIZE; /* allocate extra 3 bytes for 32-bit-aligned-address + 2 alignment */ - dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE + 3); - if (dst == NULL) { + dst = malloc(CONFIG_VIDEO_LOGO_MAX_SIZE + 3); + if (!dst) { puts("Error: malloc in gunzip failed!\n"); return NULL; } - bmp = dst; - /* align to 32-bit-aligned-address + 2 */ - bmp = (struct bmp_image *)((((uintptr_t)dst + 1) & ~3) + 2); + bmp = dst + 2; - if (gunzip(bmp, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, map_sysmem(addr, 0), - &len) != 0) { + if (gunzip(bmp, CONFIG_VIDEO_LOGO_MAX_SIZE, map_sysmem(addr, 0), + &len)) { free(dst); return NULL; } - if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) - puts("Image could be truncated" - " (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n"); + if (len == CONFIG_VIDEO_LOGO_MAX_SIZE) + puts("Image could be truncated (increase CONFIG_VIDEO_LOGO_MAX_SIZE)!\n"); /* * Check for bmp mark 'BM' -- cgit v1.2.3 From f24404d85f2d226110a3fd9aa169f25f9f454e35 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 18 Oct 2022 07:41:14 -0600 Subject: video: Move bmp_display() prototype to video.h The lcd.h header is about to be deleted, so move this prototype. Signed-off-by: Simon Glass --- cmd/bmp.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'cmd') diff --git a/cmd/bmp.c b/cmd/bmp.c index 5a3c8ddf8c8..880edad8898 100644 --- a/cmd/bmp.c +++ b/cmd/bmp.c @@ -221,16 +221,6 @@ static int bmp_info(ulong addr) return(0); } -/* - * Subroutine: bmp_display - * - * Description: Display bmp file located in memory - * - * Inputs: addr address of the bmp file - * - * Return: None - * - */ int bmp_display(ulong addr, int x, int y) { #ifdef CONFIG_DM_VIDEO -- cgit v1.2.3 From f9b7bd7e91ee5340611799846c92c698db4d28c4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 16 Oct 2022 15:57:41 -0600 Subject: video: cmd: Drop old LCD code This relies on the old LCD implementation which is to be removed. Drop it. Signed-off-by: Simon Glass --- cmd/bmp.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'cmd') diff --git a/cmd/bmp.c b/cmd/bmp.c index 880edad8898..46d0d916e86 100644 --- a/cmd/bmp.c +++ b/cmd/bmp.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -223,9 +222,7 @@ static int bmp_info(ulong addr) int bmp_display(ulong addr, int x, int y) { -#ifdef CONFIG_DM_VIDEO struct udevice *dev; -#endif int ret; struct bmp_image *bmp = map_sysmem(addr, 0); void *bmp_alloc_addr = NULL; @@ -241,7 +238,6 @@ int bmp_display(ulong addr, int x, int y) } addr = map_to_sysmem(bmp); -#ifdef CONFIG_DM_VIDEO ret = uclass_first_device_err(UCLASS_VIDEO, &dev); if (!ret) { bool align = false; @@ -251,11 +247,6 @@ int bmp_display(ulong addr, int x, int y) ret = video_bmp_display(dev, addr, x, y, align); } -#elif defined(CONFIG_LCD) - ret = lcd_display_bitmap(addr, x, y); -#else -# error bmp_display() requires CONFIG_LCD -#endif if (bmp_alloc_addr) free(bmp_alloc_addr); -- cgit v1.2.3 From 0f9b86f811f9062a01329ebb060c0e719256c43e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 16 Oct 2022 15:59:22 -0600 Subject: video: Drop remaining references to CONFIG_LCD These rely on the old LCD implementation which is to be removed. Drop it all. Signed-off-by: Simon Glass --- cmd/bdinfo.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'cmd') diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index af2e9757db5..c454e6eee18 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -124,9 +124,6 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) bdinfo_print_num_l("fdt_size", (ulong)gd->fdt_size); if (IS_ENABLED(CONFIG_DM_VIDEO)) show_video_info(); -#if defined(CONFIG_LCD) - bdinfo_print_num_l("FB base ", gd->fb_base); -#endif #if CONFIG_IS_ENABLED(MULTI_DTB_FIT) bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit); #endif -- cgit v1.2.3 From d32eb92e9138214694efc9091f3760e445ce3905 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 18 Oct 2022 07:24:15 -0600 Subject: video: Drop CONFIG_VIDEO This option is not used anymore. Drop it. Signed-off-by: Simon Glass --- cmd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index 54197160116..6cbc8f1fa2e 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1877,7 +1877,7 @@ menu "Misc commands" config CMD_BMP bool "Enable 'bmp' command" - depends on LCD || DM_VIDEO || VIDEO + depends on LCD || DM_VIDEO help This provides a way to obtain information about a BMP-format image and to display it. BMP (which presumably stands for BitMaP) is a -- cgit v1.2.3 From 8b1129588cc66cee3dc5ee2dd969007a641f21b0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 18 Oct 2022 07:19:42 -0600 Subject: video: Drop CONFIG_LCD This option is not used anymore. Drop it. Signed-off-by: Simon Glass --- cmd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index 6cbc8f1fa2e..9aac5344162 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1877,7 +1877,7 @@ menu "Misc commands" config CMD_BMP bool "Enable 'bmp' command" - depends on LCD || DM_VIDEO + depends on DM_VIDEO help This provides a way to obtain information about a BMP-format image and to display it. BMP (which presumably stands for BitMaP) is a -- cgit v1.2.3 From b86986c7b314f1378ca5be8df49310a6ce7302f8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 18 Oct 2022 07:46:31 -0600 Subject: video: Rename CONFIG_DM_VIDEO to CONFIG_VIDEO Now that all the old code is gone, rename this option. Driver model migration is now complete. Signed-off-by: Simon Glass --- cmd/Kconfig | 4 ++-- cmd/bdinfo.c | 2 +- cmd/cls.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index 9aac5344162..3f6bc70d43a 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1877,7 +1877,7 @@ menu "Misc commands" config CMD_BMP bool "Enable 'bmp' command" - depends on DM_VIDEO + depends on VIDEO help This provides a way to obtain information about a BMP-format image and to display it. BMP (which presumably stands for BitMaP) is a @@ -2163,7 +2163,7 @@ config CMD_UUID config CMD_VIDCONSOLE bool "lcdputs and setcurs" - depends on DM_VIDEO + depends on VIDEO default y help Enabling this will provide 'setcurs' and 'lcdputs' commands which diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index c454e6eee18..bf002f84475 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -122,7 +122,7 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) bdinfo_print_num_l("fdt_blob", (ulong)gd->fdt_blob); bdinfo_print_num_l("new_fdt", (ulong)gd->new_fdt); bdinfo_print_num_l("fdt_size", (ulong)gd->fdt_size); - if (IS_ENABLED(CONFIG_DM_VIDEO)) + if (IS_ENABLED(CONFIG_VIDEO)) show_video_info(); #if CONFIG_IS_ENABLED(MULTI_DTB_FIT) bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit); diff --git a/cmd/cls.c b/cmd/cls.c index ba36220d9e1..18643ec0243 100644 --- a/cmd/cls.c +++ b/cmd/cls.c @@ -19,7 +19,7 @@ static int do_video_clear(struct cmd_tbl *cmdtp, int flag, int argc, /* Send clear screen and home */ printf(CSI "2J" CSI "1;1H"); - if (CONFIG_IS_ENABLED(DM_VIDEO) && !CONFIG_IS_ENABLED(VIDEO_ANSI)) { + if (CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(VIDEO_ANSI)) { if (uclass_first_device_err(UCLASS_VIDEO, &dev)) return CMD_RET_FAILURE; if (video_clear(dev)) -- cgit v1.2.3