[PATCH 1/1] cmd: add serial console support for the cls command

Currently the cls command does not support the serial console
The screen can be cleared in the video uclass, the colored frame buffer console, and the serial console by sending the same escape sequence. The cls command only needs a single printf() statement in most cases.
This patch drops support for clearing the DM video without CONFIG_VIDEO_ANSI=y (which is enabled by default).
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- cmd/cls.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/cmd/cls.c b/cmd/cls.c index eab4e6993b..d58b0facbe 100644 --- a/cmd/cls.c +++ b/cmd/cls.c @@ -11,23 +11,18 @@ #include <lcd.h> #include <video.h>
+#define ESC "\x1b" + static int do_video_clear(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { -#if defined(CONFIG_DM_VIDEO) - struct udevice *dev; - - if (uclass_first_device_err(UCLASS_VIDEO, &dev)) - return CMD_RET_FAILURE; - - if (video_clear(dev)) - return CMD_RET_FAILURE; -#elif defined(CONFIG_CFB_CONSOLE) - video_clear(); -#elif defined(CONFIG_LCD) - lcd_clear(); -#else - return CMD_RET_FAILURE; + /* Send clear screen and home */ + printf(ESC "[2J" ESC "[1;1H"); +#if !defined(CONFIG_DM_VIDEO) && !defined(CONFIG_CFB_CONSOLE_ANSI) + if (CONFIG_IS_ENABLED(CFB_CONSOLE)) + video_clear(); + else if (CONFIG_IS_ENABLED(LCD) + lcd_clear(); #endif return CMD_RET_SUCCESS; }

Hi Heinrich,
On Sat, 29 Jan 2022 at 13:32, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
Currently the cls command does not support the serial console
The screen can be cleared in the video uclass, the colored frame buffer console, and the serial console by sending the same escape sequence. The cls command only needs a single printf() statement in most cases.
This patch drops support for clearing the DM video without CONFIG_VIDEO_ANSI=y (which is enabled by default).
No we can't do that :-)
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
cmd/cls.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/cmd/cls.c b/cmd/cls.c index eab4e6993b..d58b0facbe 100644 --- a/cmd/cls.c +++ b/cmd/cls.c @@ -11,23 +11,18 @@ #include <lcd.h> #include <video.h>
+#define ESC "\x1b"
static int do_video_clear(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { -#if defined(CONFIG_DM_VIDEO)
struct udevice *dev;
if (uclass_first_device_err(UCLASS_VIDEO, &dev))
return CMD_RET_FAILURE;
if (video_clear(dev))
return CMD_RET_FAILURE;
-#elif defined(CONFIG_CFB_CONSOLE)
video_clear();
-#elif defined(CONFIG_LCD)
lcd_clear();
-#else
return CMD_RET_FAILURE;
/* Send clear screen and home */
printf(ESC "[2J" ESC "[1;1H");
+#if !defined(CONFIG_DM_VIDEO) && !defined(CONFIG_CFB_CONSOLE_ANSI)
if (CONFIG_IS_ENABLED(CFB_CONSOLE))
video_clear();
else if (CONFIG_IS_ENABLED(LCD)
CFB_CONSOLE and LCD are deprecated so we can drop these.
lcd_clear();
#endif return CMD_RET_SUCCESS; } -- 2.33.1
Regards, Simon
participants (2)
-
Heinrich Schuchardt
-
Simon Glass