Anatolij Gustschin | e0455a4 | 2018-12-01 10:47:20 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * (C) Copyright 2018 |
| 4 | * DENX Software Engineering, Anatolij Gustschin <agust@denx.de> |
| 5 | * |
| 6 | * cls - clear screen command |
| 7 | */ |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | #include <dm.h> |
Anatolij Gustschin | e0455a4 | 2018-12-01 10:47:20 +0100 | [diff] [blame] | 11 | #include <video.h> |
| 12 | |
Heinrich Schuchardt | ced5d41 | 2022-02-11 18:11:05 +0100 | [diff] [blame] | 13 | #define CSI "\x1b[" |
| 14 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 15 | static int do_video_clear(struct cmd_tbl *cmdtp, int flag, int argc, |
Anatolij Gustschin | e0455a4 | 2018-12-01 10:47:20 +0100 | [diff] [blame] | 16 | char *const argv[]) |
| 17 | { |
Heinrich Schuchardt | ced5d41 | 2022-02-11 18:11:05 +0100 | [diff] [blame] | 18 | __maybe_unused struct udevice *dev; |
Anatolij Gustschin | e0455a4 | 2018-12-01 10:47:20 +0100 | [diff] [blame] | 19 | |
Heinrich Schuchardt | ced5d41 | 2022-02-11 18:11:05 +0100 | [diff] [blame] | 20 | /* Send clear screen and home */ |
| 21 | printf(CSI "2J" CSI "1;1H"); |
Simon Glass | 52cb504 | 2022-10-18 07:46:31 -0600 | [diff] [blame] | 22 | if (CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(VIDEO_ANSI)) { |
Heinrich Schuchardt | 9c0486b | 2022-07-14 08:53:46 +0200 | [diff] [blame] | 23 | if (uclass_first_device_err(UCLASS_VIDEO, &dev)) |
| 24 | return CMD_RET_FAILURE; |
| 25 | if (video_clear(dev)) |
| 26 | return CMD_RET_FAILURE; |
| 27 | } |
Anatolij Gustschin | e0455a4 | 2018-12-01 10:47:20 +0100 | [diff] [blame] | 28 | return CMD_RET_SUCCESS; |
| 29 | } |
| 30 | |
| 31 | U_BOOT_CMD(cls, 1, 1, do_video_clear, "clear screen", ""); |