From f029f90e7df9ad566d0bb7f9ea80de108be67fb0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 6 Oct 2022 08:36:06 -0600 Subject: [PATCH] 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 +++++++++++++++++++++++++++++++ drivers/video/Kconfig | 8 ---- drivers/video/vidconsole-uclass.c | 50 ------------------------- 5 files changed, 75 insertions(+), 58 deletions(-) create mode 100644 cmd/video.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 41cf1d46fb..51dbbf8564 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 c95e09d058..ac9226fd4d 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 0000000000..942f81c163 --- /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", + " " +); diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 4ecc158c46..c9fc4a3a58 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -85,14 +85,6 @@ config BACKLIGHT_GPIO it understands the standard device tree (leds/backlight/gpio-backlight.txt) -config CMD_VIDCONSOLE - bool "Enable vidconsole commands 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 video framebuffer. - config VIDEO_BPP8 bool "Support 8-bit-per-pixel displays" depends on DM_VIDEO diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index d5667191e0..6bdfb6e37d 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -617,7 +617,6 @@ int vidconsole_memmove(struct udevice *dev, void *dst, const void *src, } #endif -#if CONFIG_IS_ENABLED(CMD_VIDCONSOLE) void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); @@ -629,52 +628,3 @@ void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row) y = min_t(short, row * priv->y_charsize, vid_priv->ysize - 1); vidconsole_set_cursor_pos(dev, x, y); } - -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", - " " -); -#endif /* CONFIG_IS_ENABLED(CMD_VIDCONSOLE) */