blob: 942f81c1633627bd1fddf40392c3d743d1824f82 [file] [log] [blame]
Simon Glassf029f902022-10-06 08:36:06 -06001// 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 Rinid678a592024-05-18 20:20:43 -06009#include <common.h>
Simon Glassf029f902022-10-06 08:36:06 -060010#include <command.h>
11#include <dm.h>
12#include <video.h>
13#include <video_console.h>
14
15static 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
33static 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
51U_BOOT_CMD(
52 setcurs, 3, 1, do_video_setcursor,
53 "set cursor position within screen",
54 " <col> <row> in character"
55);
56
57U_BOOT_CMD(
58 lcdputs, 2, 1, do_video_puts,
59 "print string on video framebuffer",
60 " <string>"
61);