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