blob: 3ff65f3232958bbe364b21dd226e7c03b1cf1c27 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass83510762016-01-18 19:52:17 -07002/*
3 * Copyright (c) 2015 Google, Inc
4 * (C) Copyright 2001-2015
5 * DENX Software Engineering -- wd@denx.de
6 * Compulab Ltd - http://compulab.co.il/
7 * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
Simon Glass83510762016-01-18 19:52:17 -07008 */
9
10#include <common.h>
Rob Clarka085aa12017-09-13 18:12:21 -040011#include <linux/ctype.h>
Simon Glass83510762016-01-18 19:52:17 -070012#include <dm.h>
13#include <video.h>
14#include <video_console.h>
Heinrich Schuchardt5fba5322018-03-02 20:50:17 +010015#include <video_font.h> /* Bitmap font for code page 437 */
Simon Glass83510762016-01-18 19:52:17 -070016
Heinrich Schuchardt5c30fbb2018-02-08 21:47:11 +010017/*
18 * Structure to describe a console color
19 */
20struct vid_rgb {
21 u32 r;
22 u32 g;
23 u32 b;
24};
25
Simon Glass83510762016-01-18 19:52:17 -070026/* By default we scroll by a single line */
27#ifndef CONFIG_CONSOLE_SCROLL_LINES
28#define CONFIG_CONSOLE_SCROLL_LINES 1
29#endif
30
31int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch)
32{
33 struct vidconsole_ops *ops = vidconsole_get_ops(dev);
34
35 if (!ops->putc_xy)
36 return -ENOSYS;
37 return ops->putc_xy(dev, x, y, ch);
38}
39
40int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc,
41 uint count)
42{
43 struct vidconsole_ops *ops = vidconsole_get_ops(dev);
44
45 if (!ops->move_rows)
46 return -ENOSYS;
47 return ops->move_rows(dev, rowdst, rowsrc, count);
48}
49
50int vidconsole_set_row(struct udevice *dev, uint row, int clr)
51{
52 struct vidconsole_ops *ops = vidconsole_get_ops(dev);
53
54 if (!ops->set_row)
55 return -ENOSYS;
56 return ops->set_row(dev, row, clr);
57}
58
Simon Glass58c733a2016-01-14 18:10:40 -070059static int vidconsole_entry_start(struct udevice *dev)
60{
61 struct vidconsole_ops *ops = vidconsole_get_ops(dev);
62
63 if (!ops->entry_start)
64 return -ENOSYS;
65 return ops->entry_start(dev);
66}
67
Simon Glass83510762016-01-18 19:52:17 -070068/* Move backwards one space */
Simon Glass7b9f7e42016-01-14 18:10:41 -070069static int vidconsole_back(struct udevice *dev)
Simon Glass83510762016-01-18 19:52:17 -070070{
71 struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
Simon Glass7b9f7e42016-01-14 18:10:41 -070072 struct vidconsole_ops *ops = vidconsole_get_ops(dev);
73 int ret;
74
75 if (ops->backspace) {
76 ret = ops->backspace(dev);
77 if (ret != -ENOSYS)
78 return ret;
79 }
Simon Glass83510762016-01-18 19:52:17 -070080
Simon Glassf2661782016-01-14 18:10:37 -070081 priv->xcur_frac -= VID_TO_POS(priv->x_charsize);
Simon Glassc5b77d02016-01-14 18:10:39 -070082 if (priv->xcur_frac < priv->xstart_frac) {
Simon Glassf2661782016-01-14 18:10:37 -070083 priv->xcur_frac = (priv->cols - 1) *
84 VID_TO_POS(priv->x_charsize);
85 priv->ycur -= priv->y_charsize;
86 if (priv->ycur < 0)
87 priv->ycur = 0;
Simon Glass83510762016-01-18 19:52:17 -070088 }
Simon Glass55d39912018-10-01 11:55:14 -060089 video_sync(dev->parent, false);
Simon Glass7b9f7e42016-01-14 18:10:41 -070090
91 return 0;
Simon Glass83510762016-01-18 19:52:17 -070092}
93
94/* Move to a newline, scrolling the display if necessary */
95static void vidconsole_newline(struct udevice *dev)
96{
97 struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
98 struct udevice *vid_dev = dev->parent;
99 struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
100 const int rows = CONFIG_CONSOLE_SCROLL_LINES;
101 int i;
102
Simon Glassc5b77d02016-01-14 18:10:39 -0700103 priv->xcur_frac = priv->xstart_frac;
Simon Glassf2661782016-01-14 18:10:37 -0700104 priv->ycur += priv->y_charsize;
Simon Glass83510762016-01-18 19:52:17 -0700105
106 /* Check if we need to scroll the terminal */
Simon Glassf2661782016-01-14 18:10:37 -0700107 if ((priv->ycur + priv->y_charsize) / priv->y_charsize > priv->rows) {
Simon Glass83510762016-01-18 19:52:17 -0700108 vidconsole_move_rows(dev, 0, rows, priv->rows - rows);
109 for (i = 0; i < rows; i++)
110 vidconsole_set_row(dev, priv->rows - i - 1,
111 vid_priv->colour_bg);
Simon Glassf2661782016-01-14 18:10:37 -0700112 priv->ycur -= rows * priv->y_charsize;
Simon Glass83510762016-01-18 19:52:17 -0700113 }
Simon Glass58c733a2016-01-14 18:10:40 -0700114 priv->last_ch = 0;
115
Simon Glass55d39912018-10-01 11:55:14 -0600116 video_sync(dev->parent, false);
Simon Glass83510762016-01-18 19:52:17 -0700117}
118
Heinrich Schuchardt5c30fbb2018-02-08 21:47:11 +0100119static const struct vid_rgb colors[VID_COLOR_COUNT] = {
Rob Clark703d8852017-09-13 18:12:22 -0400120 { 0x00, 0x00, 0x00 }, /* black */
Heinrich Schuchardt9ffa4d12018-02-08 21:47:12 +0100121 { 0xc0, 0x00, 0x00 }, /* red */
122 { 0x00, 0xc0, 0x00 }, /* green */
123 { 0xc0, 0x60, 0x00 }, /* brown */
124 { 0x00, 0x00, 0xc0 }, /* blue */
125 { 0xc0, 0x00, 0xc0 }, /* magenta */
126 { 0x00, 0xc0, 0xc0 }, /* cyan */
127 { 0xc0, 0xc0, 0xc0 }, /* light gray */
128 { 0x80, 0x80, 0x80 }, /* gray */
129 { 0xff, 0x00, 0x00 }, /* bright red */
130 { 0x00, 0xff, 0x00 }, /* bright green */
Rob Clark703d8852017-09-13 18:12:22 -0400131 { 0xff, 0xff, 0x00 }, /* yellow */
Heinrich Schuchardt9ffa4d12018-02-08 21:47:12 +0100132 { 0x00, 0x00, 0xff }, /* bright blue */
133 { 0xff, 0x00, 0xff }, /* bright magenta */
134 { 0x00, 0xff, 0xff }, /* bright cyan */
Rob Clark703d8852017-09-13 18:12:22 -0400135 { 0xff, 0xff, 0xff }, /* white */
136};
137
Heinrich Schuchardt5c30fbb2018-02-08 21:47:11 +0100138u32 vid_console_color(struct video_priv *priv, unsigned int idx)
Rob Clark703d8852017-09-13 18:12:22 -0400139{
140 switch (priv->bpix) {
141 case VIDEO_BPP16:
Heinrich Schuchardt5c30fbb2018-02-08 21:47:11 +0100142 return ((colors[idx].r >> 3) << 11) |
143 ((colors[idx].g >> 2) << 5) |
144 ((colors[idx].b >> 3) << 0);
Rob Clark703d8852017-09-13 18:12:22 -0400145 case VIDEO_BPP32:
Heinrich Schuchardt5c30fbb2018-02-08 21:47:11 +0100146 return (colors[idx].r << 16) |
147 (colors[idx].g << 8) |
148 (colors[idx].b << 0);
Rob Clark703d8852017-09-13 18:12:22 -0400149 default:
Heinrich Schuchardt5c30fbb2018-02-08 21:47:11 +0100150 /*
151 * For unknown bit arrangements just support
152 * black and white.
153 */
154 if (idx)
155 return 0xffffff; /* white */
156 else
157 return 0x000000; /* black */
Rob Clark703d8852017-09-13 18:12:22 -0400158 }
159}
160
Rob Clarka085aa12017-09-13 18:12:21 -0400161static char *parsenum(char *s, int *num)
162{
163 char *end;
164 *num = simple_strtol(s, &end, 10);
165 return end;
166}
167
Heinrich Schuchardt662f3812018-09-19 21:31:48 +0200168/**
169 * set_cursor_position() - set cursor position
170 *
171 * @priv: private data of the video console
172 * @row: new row
173 * @col: new column
174 */
175static void set_cursor_position(struct vidconsole_priv *priv, int row, int col)
176{
177 /*
178 * Ensure we stay in the bounds of the screen.
179 */
180 if (row >= priv->rows)
181 row = priv->rows - 1;
182 if (col >= priv->cols)
183 col = priv->cols - 1;
184
185 priv->ycur = row * priv->y_charsize;
186 priv->xcur_frac = priv->xstart_frac +
187 VID_TO_POS(col * priv->x_charsize);
188}
189
190/**
191 * get_cursor_position() - get cursor position
192 *
193 * @priv: private data of the video console
194 * @row: row
195 * @col: column
196 */
197static void get_cursor_position(struct vidconsole_priv *priv,
198 int *row, int *col)
199{
200 *row = priv->ycur / priv->y_charsize;
201 *col = VID_TO_PIXEL(priv->xcur_frac - priv->xstart_frac) /
202 priv->x_charsize;
203}
204
Rob Clarka085aa12017-09-13 18:12:21 -0400205/*
206 * Process a character while accumulating an escape string. Chars are
207 * accumulated into escape_buf until the end of escape sequence is
208 * found, at which point the sequence is parsed and processed.
209 */
210static void vidconsole_escape_char(struct udevice *dev, char ch)
211{
212 struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
213
214 if (!IS_ENABLED(CONFIG_VIDEO_ANSI))
215 goto error;
216
217 /* Sanity checking for bogus ESC sequences: */
218 if (priv->escape_len >= sizeof(priv->escape_buf))
219 goto error;
Heinrich Schuchardt662f3812018-09-19 21:31:48 +0200220 if (priv->escape_len == 0) {
221 switch (ch) {
222 case '7':
223 /* Save cursor position */
224 get_cursor_position(priv, &priv->row_saved,
225 &priv->col_saved);
226 priv->escape = 0;
227
228 return;
229 case '8': {
230 /* Restore cursor position */
231 int row = priv->row_saved;
232 int col = priv->col_saved;
233
234 set_cursor_position(priv, row, col);
235 priv->escape = 0;
236 return;
237 }
238 case '[':
239 break;
240 default:
241 goto error;
242 }
243 }
Rob Clarka085aa12017-09-13 18:12:21 -0400244
245 priv->escape_buf[priv->escape_len++] = ch;
246
247 /*
248 * Escape sequences are terminated by a letter, so keep
249 * accumulating until we get one:
250 */
251 if (!isalpha(ch))
252 return;
253
254 /*
255 * clear escape mode first, otherwise things will get highly
256 * surprising if you hit any debug prints that come back to
257 * this console.
258 */
259 priv->escape = 0;
260
261 switch (ch) {
262 case 'H':
263 case 'f': {
264 int row, col;
265 char *s = priv->escape_buf;
266
267 /*
268 * Set cursor position: [%d;%df or [%d;%dH
269 */
270 s++; /* [ */
271 s = parsenum(s, &row);
272 s++; /* ; */
273 s = parsenum(s, &col);
274
Heinrich Schuchardt118f0202018-11-10 19:55:48 +0100275 /*
276 * Video origin is [0, 0], terminal origin is [1, 1].
277 */
278 if (row)
279 --row;
280 if (col)
281 --col;
282
Heinrich Schuchardt662f3812018-09-19 21:31:48 +0200283 set_cursor_position(priv, row, col);
Rob Clarka085aa12017-09-13 18:12:21 -0400284
285 break;
286 }
287 case 'J': {
288 int mode;
289
290 /*
291 * Clear part/all screen:
292 * [J or [0J - clear screen from cursor down
293 * [1J - clear screen from cursor up
294 * [2J - clear entire screen
295 *
296 * TODO we really only handle entire-screen case, others
297 * probably require some additions to video-uclass (and
298 * are not really needed yet by efi_console)
299 */
300 parsenum(priv->escape_buf + 1, &mode);
301
302 if (mode == 2) {
303 video_clear(dev->parent);
Simon Glass55d39912018-10-01 11:55:14 -0600304 video_sync(dev->parent, false);
Rob Clarka085aa12017-09-13 18:12:21 -0400305 priv->ycur = 0;
306 priv->xcur_frac = priv->xstart_frac;
307 } else {
308 debug("unsupported clear mode: %d\n", mode);
309 }
310 break;
311 }
Rob Clark703d8852017-09-13 18:12:22 -0400312 case 'm': {
313 struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
314 char *s = priv->escape_buf;
315 char *end = &priv->escape_buf[priv->escape_len];
316
317 /*
318 * Set graphics mode: [%d;...;%dm
319 *
320 * Currently only supports the color attributes:
321 *
322 * Foreground Colors:
323 *
324 * 30 Black
325 * 31 Red
326 * 32 Green
327 * 33 Yellow
328 * 34 Blue
329 * 35 Magenta
330 * 36 Cyan
331 * 37 White
332 *
333 * Background Colors:
334 *
335 * 40 Black
336 * 41 Red
337 * 42 Green
338 * 43 Yellow
339 * 44 Blue
340 * 45 Magenta
341 * 46 Cyan
342 * 47 White
343 */
344
345 s++; /* [ */
346 while (s < end) {
347 int val;
348
349 s = parsenum(s, &val);
350 s++;
351
352 switch (val) {
Heinrich Schuchardt9ffa4d12018-02-08 21:47:12 +0100353 case 0:
354 /* all attributes off */
Simon Glassb9f210a2018-11-06 15:21:36 -0700355 video_set_default_colors(dev->parent, false);
Heinrich Schuchardt9ffa4d12018-02-08 21:47:12 +0100356 break;
357 case 1:
358 /* bold */
359 vid_priv->fg_col_idx |= 8;
360 vid_priv->colour_fg = vid_console_color(
361 vid_priv, vid_priv->fg_col_idx);
362 break;
Andre Przywaraeabb0722019-03-23 01:29:56 +0000363 case 7:
364 /* reverse video */
365 vid_priv->colour_fg = vid_console_color(
366 vid_priv, vid_priv->bg_col_idx);
367 vid_priv->colour_bg = vid_console_color(
368 vid_priv, vid_priv->fg_col_idx);
369 break;
Rob Clark703d8852017-09-13 18:12:22 -0400370 case 30 ... 37:
Heinrich Schuchardt5c30fbb2018-02-08 21:47:11 +0100371 /* foreground color */
Heinrich Schuchardt9ffa4d12018-02-08 21:47:12 +0100372 vid_priv->fg_col_idx &= ~7;
373 vid_priv->fg_col_idx |= val - 30;
Heinrich Schuchardt5c30fbb2018-02-08 21:47:11 +0100374 vid_priv->colour_fg = vid_console_color(
Heinrich Schuchardt9ffa4d12018-02-08 21:47:12 +0100375 vid_priv, vid_priv->fg_col_idx);
Rob Clark703d8852017-09-13 18:12:22 -0400376 break;
377 case 40 ... 47:
Andre Przywaraeabb0722019-03-23 01:29:56 +0000378 /* background color, also mask the bold bit */
379 vid_priv->bg_col_idx &= ~0xf;
380 vid_priv->bg_col_idx |= val - 40;
Heinrich Schuchardt5c30fbb2018-02-08 21:47:11 +0100381 vid_priv->colour_bg = vid_console_color(
Andre Przywaraeabb0722019-03-23 01:29:56 +0000382 vid_priv, vid_priv->bg_col_idx);
Rob Clark703d8852017-09-13 18:12:22 -0400383 break;
384 default:
Heinrich Schuchardt5c30fbb2018-02-08 21:47:11 +0100385 /* ignore unsupported SGR parameter */
Rob Clark703d8852017-09-13 18:12:22 -0400386 break;
387 }
388 }
389
390 break;
391 }
Rob Clarka085aa12017-09-13 18:12:21 -0400392 default:
393 debug("unrecognized escape sequence: %*s\n",
394 priv->escape_len, priv->escape_buf);
395 }
396
397 return;
398
399error:
400 /* something went wrong, just revert to normal mode: */
401 priv->escape = 0;
402}
403
Simon Glass83510762016-01-18 19:52:17 -0700404int vidconsole_put_char(struct udevice *dev, char ch)
405{
406 struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
407 int ret;
408
Rob Clarka085aa12017-09-13 18:12:21 -0400409 if (priv->escape) {
410 vidconsole_escape_char(dev, ch);
411 return 0;
412 }
413
Simon Glass83510762016-01-18 19:52:17 -0700414 switch (ch) {
Rob Clarka085aa12017-09-13 18:12:21 -0400415 case '\x1b':
416 priv->escape_len = 0;
417 priv->escape = 1;
418 break;
Simon Glass5508f102016-01-14 18:10:38 -0700419 case '\a':
420 /* beep */
421 break;
Simon Glass83510762016-01-18 19:52:17 -0700422 case '\r':
Simon Glassc5b77d02016-01-14 18:10:39 -0700423 priv->xcur_frac = priv->xstart_frac;
Simon Glass83510762016-01-18 19:52:17 -0700424 break;
425 case '\n':
426 vidconsole_newline(dev);
Simon Glass58c733a2016-01-14 18:10:40 -0700427 vidconsole_entry_start(dev);
Simon Glass83510762016-01-18 19:52:17 -0700428 break;
429 case '\t': /* Tab (8 chars alignment) */
Simon Glassf2661782016-01-14 18:10:37 -0700430 priv->xcur_frac = ((priv->xcur_frac / priv->tab_width_frac)
431 + 1) * priv->tab_width_frac;
Simon Glass83510762016-01-18 19:52:17 -0700432
Simon Glassf2661782016-01-14 18:10:37 -0700433 if (priv->xcur_frac >= priv->xsize_frac)
Simon Glass83510762016-01-18 19:52:17 -0700434 vidconsole_newline(dev);
435 break;
436 case '\b':
437 vidconsole_back(dev);
Simon Glass58c733a2016-01-14 18:10:40 -0700438 priv->last_ch = 0;
Simon Glass83510762016-01-18 19:52:17 -0700439 break;
440 default:
441 /*
442 * Failure of this function normally indicates an unsupported
443 * colour depth. Check this and return an error to help with
444 * diagnosis.
445 */
Simon Glassf2661782016-01-14 18:10:37 -0700446 ret = vidconsole_putc_xy(dev, priv->xcur_frac, priv->ycur, ch);
447 if (ret == -EAGAIN) {
448 vidconsole_newline(dev);
449 ret = vidconsole_putc_xy(dev, priv->xcur_frac,
450 priv->ycur, ch);
451 }
452 if (ret < 0)
Simon Glass83510762016-01-18 19:52:17 -0700453 return ret;
Simon Glassf2661782016-01-14 18:10:37 -0700454 priv->xcur_frac += ret;
Simon Glass58c733a2016-01-14 18:10:40 -0700455 priv->last_ch = ch;
Simon Glassf2661782016-01-14 18:10:37 -0700456 if (priv->xcur_frac >= priv->xsize_frac)
Simon Glass83510762016-01-18 19:52:17 -0700457 vidconsole_newline(dev);
458 break;
459 }
460
461 return 0;
462}
463
464static void vidconsole_putc(struct stdio_dev *sdev, const char ch)
465{
466 struct udevice *dev = sdev->priv;
467
468 vidconsole_put_char(dev, ch);
Simon Glass55d39912018-10-01 11:55:14 -0600469 video_sync(dev->parent, false);
Simon Glass83510762016-01-18 19:52:17 -0700470}
471
472static void vidconsole_puts(struct stdio_dev *sdev, const char *s)
473{
474 struct udevice *dev = sdev->priv;
475
476 while (*s)
477 vidconsole_put_char(dev, *s++);
Simon Glass55d39912018-10-01 11:55:14 -0600478 video_sync(dev->parent, false);
Simon Glass83510762016-01-18 19:52:17 -0700479}
480
481/* Set up the number of rows and colours (rotated drivers override this) */
482static int vidconsole_pre_probe(struct udevice *dev)
483{
484 struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
485 struct udevice *vid = dev->parent;
486 struct video_priv *vid_priv = dev_get_uclass_priv(vid);
487
Simon Glassf2661782016-01-14 18:10:37 -0700488 priv->xsize_frac = VID_TO_POS(vid_priv->xsize);
Simon Glass83510762016-01-18 19:52:17 -0700489
490 return 0;
491}
492
493/* Register the device with stdio */
494static int vidconsole_post_probe(struct udevice *dev)
495{
496 struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
497 struct stdio_dev *sdev = &priv->sdev;
Simon Glass83510762016-01-18 19:52:17 -0700498
Simon Glassf2661782016-01-14 18:10:37 -0700499 if (!priv->tab_width_frac)
500 priv->tab_width_frac = VID_TO_POS(priv->x_charsize) * 8;
501
Simon Glassf1a12472016-01-21 19:44:51 -0700502 if (dev->seq) {
503 snprintf(sdev->name, sizeof(sdev->name), "vidconsole%d",
504 dev->seq);
505 } else {
506 strcpy(sdev->name, "vidconsole");
507 }
Simon Glassf2661782016-01-14 18:10:37 -0700508
Simon Glass83510762016-01-18 19:52:17 -0700509 sdev->flags = DEV_FLAGS_OUTPUT;
510 sdev->putc = vidconsole_putc;
511 sdev->puts = vidconsole_puts;
512 sdev->priv = dev;
Simon Glass83510762016-01-18 19:52:17 -0700513
Masahiro Yamada720873b2016-09-06 22:17:33 +0900514 return stdio_register(sdev);
Simon Glass83510762016-01-18 19:52:17 -0700515}
516
517UCLASS_DRIVER(vidconsole) = {
518 .id = UCLASS_VIDEO_CONSOLE,
519 .name = "vidconsole0",
520 .pre_probe = vidconsole_pre_probe,
521 .post_probe = vidconsole_post_probe,
522 .per_device_auto_alloc_size = sizeof(struct vidconsole_priv),
523};
524
525void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row)
526{
527 struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
Simon Glassf2661782016-01-14 18:10:37 -0700528 struct udevice *vid_dev = dev->parent;
529 struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
Simon Glass83510762016-01-18 19:52:17 -0700530
Simon Glass9949ee82018-10-01 12:22:47 -0600531 col *= priv->x_charsize;
532 row *= priv->y_charsize;
Simon Glassf2661782016-01-14 18:10:37 -0700533 priv->xcur_frac = VID_TO_POS(min_t(short, col, vid_priv->xsize - 1));
534 priv->ycur = min_t(short, row, vid_priv->ysize - 1);
Simon Glass83510762016-01-18 19:52:17 -0700535}
536
537static int do_video_setcursor(cmd_tbl_t *cmdtp, int flag, int argc,
538 char *const argv[])
539{
540 unsigned int col, row;
541 struct udevice *dev;
542
543 if (argc != 3)
544 return CMD_RET_USAGE;
545
Simon Glass3f603cb2016-02-11 13:23:26 -0700546 if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
Simon Glass83510762016-01-18 19:52:17 -0700547 return CMD_RET_FAILURE;
548 col = simple_strtoul(argv[1], NULL, 10);
549 row = simple_strtoul(argv[2], NULL, 10);
550 vidconsole_position_cursor(dev, col, row);
551
552 return 0;
553}
554
555static int do_video_puts(cmd_tbl_t *cmdtp, int flag, int argc,
556 char *const argv[])
557{
558 struct udevice *dev;
559 const char *s;
560
561 if (argc != 2)
562 return CMD_RET_USAGE;
563
Simon Glass3f603cb2016-02-11 13:23:26 -0700564 if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
Simon Glass83510762016-01-18 19:52:17 -0700565 return CMD_RET_FAILURE;
566 for (s = argv[1]; *s; s++)
567 vidconsole_put_char(dev, *s);
568
Simon Glass55d39912018-10-01 11:55:14 -0600569 video_sync(dev->parent, false);
Rob Clark889808d2017-09-13 18:12:20 -0400570
Simon Glass83510762016-01-18 19:52:17 -0700571 return 0;
572}
573
574U_BOOT_CMD(
575 setcurs, 3, 1, do_video_setcursor,
576 "set cursor position within screen",
577 " <col> <row> in character"
578);
579
580U_BOOT_CMD(
581 lcdputs, 2, 1, do_video_puts,
582 "print string on video framebuffer",
583 " <string>"
584);