Prepare v2025.04-rc1
[u-boot.git] / cmd / video.c
blob91bd6de14dc16afb8c864533e2b088a4edda258f
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * video commands
5 * Copyright 2022 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
7 */
9 #include <command.h>
10 #include <dm.h>
11 #include <video.h>
12 #include <video_console.h>
14 static int do_video_setcursor(struct cmd_tbl *cmdtp, int flag, int argc,
15 char *const argv[])
17 unsigned int col, row;
18 struct udevice *dev;
20 if (argc != 3)
21 return CMD_RET_USAGE;
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);
29 return 0;
32 static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc,
33 char *const argv[])
35 struct udevice *dev;
36 int ret;
38 if (argc != 2)
39 return CMD_RET_USAGE;
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);
47 return ret ? CMD_RET_FAILURE : 0;
50 U_BOOT_CMD(
51 setcurs, 3, 1, do_video_setcursor,
52 "set cursor position within screen",
53 " <col> <row> in character"
56 U_BOOT_CMD(
57 lcdputs, 2, 1, do_video_puts,
58 "print string on video framebuffer",
59 " <string>"