]>
Commit | Line | Data |
---|---|---|
4e92e60d AG |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * (C) Copyright 2018 | |
4 | * DENX Software Engineering, Anatolij Gustschin <[email protected]> | |
5 | * | |
6 | * cls - clear screen command | |
7 | */ | |
8 | #include <common.h> | |
9 | #include <command.h> | |
10 | #include <dm.h> | |
a76b60f8 | 11 | #include <video_console.h> |
4e92e60d | 12 | |
bfaa51dd HS |
13 | #define CSI "\x1b[" |
14 | ||
09140113 | 15 | static int do_video_clear(struct cmd_tbl *cmdtp, int flag, int argc, |
4e92e60d AG |
16 | char *const argv[]) |
17 | { | |
bfaa51dd | 18 | __maybe_unused struct udevice *dev; |
4e92e60d | 19 | |
61a62105 SG |
20 | /* |
21 | * Send clear screen and home | |
22 | * | |
23 | * FIXME(Heinrich Schuchardt <[email protected]>): This should go | |
24 | * through an API and only be written to serial terminals, not video | |
25 | * displays | |
26 | */ | |
bfaa51dd | 27 | printf(CSI "2J" CSI "1;1H"); |
a76b60f8 SG |
28 | if (IS_ENABLED(CONFIG_VIDEO_ANSI)) |
29 | return 0; | |
30 | ||
31 | if (IS_ENABLED(CONFIG_VIDEO)) { | |
32 | if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) | |
63de2161 | 33 | return CMD_RET_FAILURE; |
a76b60f8 | 34 | if (vidconsole_clear_and_reset(dev)) |
63de2161 HS |
35 | return CMD_RET_FAILURE; |
36 | } | |
a76b60f8 | 37 | |
4e92e60d AG |
38 | return CMD_RET_SUCCESS; |
39 | } | |
40 | ||
41 | U_BOOT_CMD(cls, 1, 1, do_video_clear, "clear screen", ""); |