Anatolij Gustschin | 4e92e60 | 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> |
| 11 | #include <lcd.h> |
| 12 | #include <video.h> |
| 13 | |
Heinrich Schuchardt | bfaa51d | 2022-02-11 18:11:05 +0100 | [diff] [blame] | 14 | #define CSI "\x1b[" |
| 15 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 16 | static int do_video_clear(struct cmd_tbl *cmdtp, int flag, int argc, |
Anatolij Gustschin | 4e92e60 | 2018-12-01 10:47:20 +0100 | [diff] [blame] | 17 | char *const argv[]) |
| 18 | { |
Heinrich Schuchardt | bfaa51d | 2022-02-11 18:11:05 +0100 | [diff] [blame] | 19 | __maybe_unused struct udevice *dev; |
Anatolij Gustschin | 4e92e60 | 2018-12-01 10:47:20 +0100 | [diff] [blame] | 20 | |
Heinrich Schuchardt | bfaa51d | 2022-02-11 18:11:05 +0100 | [diff] [blame] | 21 | /* Send clear screen and home */ |
| 22 | printf(CSI "2J" CSI "1;1H"); |
| 23 | #if defined(CONFIG_DM_VIDEO) |
| 24 | #if !defined(CONFIG_VIDEO_ANSI) |
Anatolij Gustschin | 4e92e60 | 2018-12-01 10:47:20 +0100 | [diff] [blame] | 25 | if (uclass_first_device_err(UCLASS_VIDEO, &dev)) |
| 26 | return CMD_RET_FAILURE; |
| 27 | |
| 28 | if (video_clear(dev)) |
| 29 | return CMD_RET_FAILURE; |
Heinrich Schuchardt | bfaa51d | 2022-02-11 18:11:05 +0100 | [diff] [blame] | 30 | #endif |
Anatolij Gustschin | 4e92e60 | 2018-12-01 10:47:20 +0100 | [diff] [blame] | 31 | #elif defined(CONFIG_LCD) |
| 32 | lcd_clear(); |
| 33 | #else |
| 34 | return CMD_RET_FAILURE; |
| 35 | #endif |
| 36 | return CMD_RET_SUCCESS; |
| 37 | } |
| 38 | |
| 39 | U_BOOT_CMD(cls, 1, 1, do_video_clear, "clear screen", ""); |