Simon Glass | f029f90 | 2022-10-06 08:36:06 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * video commands |
| 4 | * |
| 5 | * Copyright 2022 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
Tom Rini | d678a59 | 2024-05-18 20:20:43 -0600 | [diff] [blame] | 9 | #include <common.h> |
Simon Glass | f029f90 | 2022-10-06 08:36:06 -0600 | [diff] [blame] | 10 | #include <command.h> |
| 11 | #include <dm.h> |
| 12 | #include <video.h> |
| 13 | #include <video_console.h> |
| 14 | |
| 15 | static int do_video_setcursor(struct cmd_tbl *cmdtp, int flag, int argc, |
| 16 | char *const argv[]) |
| 17 | { |
| 18 | unsigned int col, row; |
| 19 | struct udevice *dev; |
| 20 | |
| 21 | if (argc != 3) |
| 22 | return CMD_RET_USAGE; |
| 23 | |
| 24 | if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) |
| 25 | return CMD_RET_FAILURE; |
| 26 | col = dectoul(argv[1], NULL); |
| 27 | row = dectoul(argv[2], NULL); |
| 28 | vidconsole_position_cursor(dev, col, row); |
| 29 | |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc, |
| 34 | char *const argv[]) |
| 35 | { |
| 36 | struct udevice *dev; |
| 37 | int ret; |
| 38 | |
| 39 | if (argc != 2) |
| 40 | return CMD_RET_USAGE; |
| 41 | |
| 42 | if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) |
| 43 | return CMD_RET_FAILURE; |
| 44 | ret = vidconsole_put_string(dev, argv[1]); |
| 45 | if (!ret) |
| 46 | ret = video_sync(dev->parent, false); |
| 47 | |
| 48 | return ret ? CMD_RET_FAILURE : 0; |
| 49 | } |
| 50 | |
| 51 | U_BOOT_CMD( |
| 52 | setcurs, 3, 1, do_video_setcursor, |
| 53 | "set cursor position within screen", |
| 54 | " <col> <row> in character" |
| 55 | ); |
| 56 | |
| 57 | U_BOOT_CMD( |
| 58 | lcdputs, 2, 1, do_video_puts, |
| 59 | "print string on video framebuffer", |
| 60 | " <string>" |
| 61 | ); |