u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] cmd: add serial console support for the cls command
@ 2022-01-29 20:31 Heinrich Schuchardt
  2022-02-11 15:05 ` Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2022-01-29 20:31 UTC (permalink / raw)
  To: Tom Rini; +Cc: Simon Glass, u-boot, Heinrich Schuchardt

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;
 }
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] cmd: add serial console support for the cls command
  2022-01-29 20:31 [PATCH 1/1] cmd: add serial console support for the cls command Heinrich Schuchardt
@ 2022-02-11 15:05 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2022-02-11 15:05 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: Tom Rini, U-Boot Mailing List

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-11 15:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-29 20:31 [PATCH 1/1] cmd: add serial console support for the cls command Heinrich Schuchardt
2022-02-11 15:05 ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).