blob: e4fc776e2d3db32e49459a17fa33d664b150f661 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass84c7fb32016-01-18 19:52:17 -07002/*
3 * Copyright (c) 2015 Google, Inc
Simon Glass84c7fb32016-01-18 19:52:17 -07004 */
5
6#ifndef __video_console_h
7#define __video_console_h
8
Simon Glass95bcad42025-04-02 06:29:36 +13009#include <alist.h>
Heinrich Schuchardt290e1d82018-02-08 21:47:11 +010010#include <video.h>
11
Simon Glass34b5c252023-10-01 19:13:19 -060012struct abuf;
Simon Glassbac91502020-07-02 21:12:18 -060013struct video_priv;
14
Simon Glass52c10c52016-01-14 18:10:37 -070015#define VID_FRAC_DIV 256
16
17#define VID_TO_PIXEL(x) ((x) / VID_FRAC_DIV)
18#define VID_TO_POS(x) ((x) * VID_FRAC_DIV)
19
Simon Glass377f79aa2023-10-01 19:13:21 -060020enum {
21 /* cursor width in pixels */
22 VIDCONSOLE_CURSOR_WIDTH = 2,
23};
24
Simon Glass84c7fb32016-01-18 19:52:17 -070025/**
26 * struct vidconsole_priv - uclass-private data about a console device
27 *
Simon Glass52c10c52016-01-14 18:10:37 -070028 * Drivers must set up @rows, @cols, @x_charsize, @y_charsize in their probe()
29 * method. Drivers may set up @xstart_frac if desired.
30 *
Simon Glassaea571d2024-10-14 16:31:54 -060031 * Note that these values relate to the rotated console, so that an 80x25
32 * console which is rotated 90 degrees will have rows=80 and cols=25
33 *
34 * The xcur_frac and ycur values refer to the unrotated coordinates, that is
35 * xcur_frac always advances with each character, even if its limit might be
36 * vid_priv->ysize instead of vid_priv->xsize if the console is rotated 90 or
37 * 270 degrees.
38 *
Heinrich Schuchardt9e933f12018-09-19 21:31:48 +020039 * @sdev: stdio device, acting as an output sink
40 * @xcur_frac: Current X position, in fractional units (VID_TO_POS(x))
41 * @ycur: Current Y position in pixels (0=top)
42 * @rows: Number of text rows
43 * @cols: Number of text columns
44 * @x_charsize: Character width in pixels
45 * @y_charsize: Character height in pixels
Simon Glass52c10c52016-01-14 18:10:37 -070046 * @tab_width_frac: Tab width in fractional units
Heinrich Schuchardt9e933f12018-09-19 21:31:48 +020047 * @xsize_frac: Width of the display in fractional units
Simon Glassa74451d2016-01-14 18:10:39 -070048 * @xstart_frac: Left margin for the text console in fractional units
Heinrich Schuchardt9e933f12018-09-19 21:31:48 +020049 * @last_ch: Last character written to the text console on this line
50 * @escape: TRUE if currently accumulating an ANSI escape sequence
51 * @escape_len: Length of accumulated escape sequence so far
52 * @col_saved: Saved X position, in fractional units (VID_TO_POS(x))
53 * @row_saved: Saved Y position in pixels (0=top)
54 * @escape_buf: Buffer to accumulate escape sequence
Janne Grunau5548c362024-03-16 22:50:19 +010055 * @utf8_buf: Buffer to accumulate UTF-8 byte sequence
Simon Glass84c7fb32016-01-18 19:52:17 -070056 */
57struct vidconsole_priv {
58 struct stdio_dev sdev;
Simon Glass52c10c52016-01-14 18:10:37 -070059 int xcur_frac;
60 int ycur;
Simon Glass84c7fb32016-01-18 19:52:17 -070061 int rows;
62 int cols;
Simon Glass52c10c52016-01-14 18:10:37 -070063 int x_charsize;
64 int y_charsize;
65 int tab_width_frac;
66 int xsize_frac;
Simon Glassa74451d2016-01-14 18:10:39 -070067 int xstart_frac;
Simon Glassafee7432016-01-14 18:10:40 -070068 int last_ch;
Rob Clark06e7a0d2017-09-13 18:12:21 -040069 /*
70 * ANSI escape sequences are accumulated character by character,
71 * starting after the ESC char (0x1b) until the entire sequence
72 * is consumed at which point it is acted upon.
73 */
74 int escape;
75 int escape_len;
Heinrich Schuchardt9e933f12018-09-19 21:31:48 +020076 int row_saved;
77 int col_saved;
Rob Clark06e7a0d2017-09-13 18:12:21 -040078 char escape_buf[32];
Janne Grunau5548c362024-03-16 22:50:19 +010079 char utf8_buf[5];
Simon Glass84c7fb32016-01-18 19:52:17 -070080};
81
82/**
Simon Glass3b175ba2023-01-06 08:52:32 -060083 * struct vidfont_info - information about a font
84 *
85 * @name: Font name, e.g. nimbus_sans_l_regular
86 */
87struct vidfont_info {
88 const char *name;
89};
90
91/**
Simon Glassa73a8b82023-06-01 10:22:45 -060092 * struct vidconsole_colour - Holds colour information
93 *
94 * @colour_fg: Foreground colour (pixel value)
95 * @colour_bg: Background colour (pixel value)
96 */
97struct vidconsole_colour {
98 u32 colour_fg;
99 u32 colour_bg;
100};
101
102/**
Simon Glass5caf1252023-06-01 10:22:46 -0600103 * struct vidconsole_bbox - Bounding box of text
104 *
105 * This describes the bounding box of something, measured in pixels. The x0/y0
106 * pair is inclusive; the x1/y2 pair is exclusive, meaning that it is one pixel
107 * beyond the extent of the object
108 *
109 * @valid: Values are valid (bounding box is known)
110 * @x0: left x position, in pixels from left side
111 * @y0: top y position, in pixels from top
112 * @x1: right x position + 1
113 * @y1: botton y position + 1
114 */
115struct vidconsole_bbox {
116 bool valid;
117 int x0;
118 int y0;
119 int x1;
120 int y1;
121};
122
123/**
Simon Glass95bcad42025-04-02 06:29:36 +1300124 * vidconsole_mline - Holds information about a line of measured text
125 *
126 * @bbox: Bounding box of the line, assuming it starts at 0,0
127 * @start: String index of the first character in the line
128 * @len: Number of characters in the line
129 */
130struct vidconsole_mline {
131 struct vidconsole_bbox bbox;
132 int start;
133 int len;
134};
135
136/**
Simon Glass84c7fb32016-01-18 19:52:17 -0700137 * struct vidconsole_ops - Video console operations
138 *
139 * These operations work on either an absolute console position (measured
140 * in pixels) or a text row number (measured in rows, where each row consists
141 * of an entire line of text - typically 16 pixels).
142 */
143struct vidconsole_ops {
144 /**
145 * putc_xy() - write a single character to a position
146 *
147 * @dev: Device to write to
Simon Glass52c10c52016-01-14 18:10:37 -0700148 * @x_frac: Fractional pixel X position (0=left-most pixel) which
149 * is the X position multipled by VID_FRAC_DIV.
Simon Glass84c7fb32016-01-18 19:52:17 -0700150 * @y: Pixel Y position (0=top-most pixel)
Janne Grunau5548c362024-03-16 22:50:19 +0100151 * @cp: UTF-32 code point to write
Simon Glass52c10c52016-01-14 18:10:37 -0700152 * @return number of fractional pixels that the cursor should move,
153 * if all is OK, -EAGAIN if we ran out of space on this line, other -ve
154 * on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700155 */
Janne Grunau5548c362024-03-16 22:50:19 +0100156 int (*putc_xy)(struct udevice *dev, uint x_frac, uint y, int cp);
Simon Glass84c7fb32016-01-18 19:52:17 -0700157
158 /**
159 * move_rows() - Move text rows from one place to another
160 *
161 * @dev: Device to adjust
162 * @rowdst: Destination text row (0=top)
163 * @rowsrc: Source start text row
164 * @count: Number of text rows to move
165 * @return 0 if OK, -ve on error
166 */
167 int (*move_rows)(struct udevice *dev, uint rowdst, uint rowsrc,
168 uint count);
169
170 /**
171 * set_row() - Set the colour of a text row
172 *
173 * Every pixel contained within the text row is adjusted
174 *
175 * @dev: Device to adjust
176 * @row: Text row to adjust (0=top)
177 * @clr: Raw colour (pixel value) to write to each pixel
178 * @return 0 if OK, -ve on error
179 */
180 int (*set_row)(struct udevice *dev, uint row, int clr);
Simon Glassafee7432016-01-14 18:10:40 -0700181
182 /**
183 * entry_start() - Indicate that text entry is starting afresh
184 *
Simon Glass3b175ba2023-01-06 08:52:32 -0600185 * @dev: Device to adjust
186 * Returns: 0 on success, -ve on error
187 *
Simon Glassafee7432016-01-14 18:10:40 -0700188 * Consoles which use proportional fonts need to track the position of
189 * each character output so that backspace will return to the correct
190 * place. This method signals to the console driver that a new entry
191 * line is being start (e.g. the user pressed return to start a new
192 * command). The driver can use this signal to empty its list of
193 * positions.
194 */
195 int (*entry_start)(struct udevice *dev);
Simon Glass33bd3b62016-01-14 18:10:41 -0700196
197 /**
198 * backspace() - Handle erasing the last character
199 *
Simon Glass3b175ba2023-01-06 08:52:32 -0600200 * @dev: Device to adjust
201 * Returns: 0 on success, -ve on error
202 *
Simon Glass33bd3b62016-01-14 18:10:41 -0700203 * With proportional fonts the vidconsole uclass cannot itself erase
204 * the previous character. This optional method will be called when
205 * a backspace is needed. The driver should erase the previous
206 * character and update the cursor position (xcur_frac, ycur) to the
207 * start of the previous character.
208 *
209 * If not implement, default behaviour will work for fixed-width
210 * characters.
211 */
212 int (*backspace)(struct udevice *dev);
Simon Glass3b175ba2023-01-06 08:52:32 -0600213
214 /**
215 * get_font() - Obtain information about a font (optional)
216 *
217 * @dev: Device to check
218 * @seq: Font number to query (0=first, 1=second, etc.)
219 * @info: Returns font information on success
220 * Returns: 0 on success, -ENOENT if no such font
221 */
222 int (*get_font)(struct udevice *dev, int seq,
223 struct vidfont_info *info);
224
225 /**
Dzmitry Sankouski86c6a532023-03-07 13:21:15 +0300226 * get_font_size() - get the current font name and size
227 *
228 * @dev: vidconsole device
229 * @sizep: Place to put the font size (nominal height in pixels)
230 * Returns: Current font name
231 */
232 const char *(*get_font_size)(struct udevice *dev, uint *sizep);
233
234 /**
Simon Glass3b175ba2023-01-06 08:52:32 -0600235 * select_font() - Select a particular font by name / size
236 *
237 * @dev: Device to adjust
238 * @name: Font name to use (NULL to use default)
239 * @size: Font size to use (0 to use default)
240 * Returns: 0 on success, -ENOENT if no such font
241 */
242 int (*select_font)(struct udevice *dev, const char *name, uint size);
Simon Glass5caf1252023-06-01 10:22:46 -0600243
244 /**
Simon Glass95bcad42025-04-02 06:29:36 +1300245 * measure() - Measure the bounding box of some text
Simon Glass5caf1252023-06-01 10:22:46 -0600246 *
Simon Glass3c686e62025-04-02 06:29:38 +1300247 * The text can include newlines
248 *
Simon Glass95bcad42025-04-02 06:29:36 +1300249 * @dev: Console device to use
Simon Glass5caf1252023-06-01 10:22:46 -0600250 * @name: Font name to use (NULL to use default)
251 * @size: Font size to use (0 to use default)
252 * @text: Text to measure
Simon Glass3aa33582025-04-02 06:29:39 +1300253 * @limit: Width limit for each line, or -1 if none
Simon Glass5caf1252023-06-01 10:22:46 -0600254 * @bbox: Returns bounding box of text, assuming it is positioned
255 * at 0,0
Simon Glass95bcad42025-04-02 06:29:36 +1300256 * @lines: If non-NULL, this must be an alist of
257 * struct vidconsole_mline inited by caller. A separate
258 * record is added for each line of text
259 *
Simon Glass5caf1252023-06-01 10:22:46 -0600260 * Returns: 0 on success, -ENOENT if no such font
261 */
262 int (*measure)(struct udevice *dev, const char *name, uint size,
Simon Glass3aa33582025-04-02 06:29:39 +1300263 const char *text, int limit,
264 struct vidconsole_bbox *bbox, struct alist *lines);
Simon Glass8b82e592023-10-01 19:13:18 -0600265
266 /**
267 * nominal() - Measure the expected width of a line of text
268 *
269 * Uses an average font width and nominal height
270 *
271 * @dev: Console device to use
272 * @name: Font name, NULL for default
273 * @size: Font size, ignored if @name is NULL
274 * @num_chars: Number of characters to use
275 * @bbox: Returns nounding box of @num_chars characters
276 * Returns: 0 if OK, -ve on error
277 */
278 int (*nominal)(struct udevice *dev, const char *name, uint size,
279 uint num_chars, struct vidconsole_bbox *bbox);
Simon Glass34b5c252023-10-01 19:13:19 -0600280
281 /**
282 * entry_save() - Save any text-entry information for later use
283 *
284 * Saves text-entry context such as a list of positions for each
285 * character in the string.
286 *
287 * @dev: Console device to use
288 * @buf: Buffer to hold saved data
289 * Return: 0 if OK, -ENOMEM if out of memory
290 */
291 int (*entry_save)(struct udevice *dev, struct abuf *buf);
292
293 /**
294 * entry_restore() - Restore text-entry information for current use
295 *
296 * Restores text-entry context such as a list of positions for each
297 * character in the string.
298 *
299 * @dev: Console device to use
300 * @buf: Buffer containing data to restore
301 * Return: 0 if OK, -ve on error
302 */
303 int (*entry_restore)(struct udevice *dev, struct abuf *buf);
Simon Glass377f79aa2023-10-01 19:13:21 -0600304
305 /**
306 * set_cursor_visible() - Show or hide the cursor
307 *
308 * Shows or hides a cursor at the current position
309 *
310 * @dev: Console device to use
311 * @visible: true to show the cursor, false to hide it
312 * @x: X position in pixels
313 * @y: Y position in pixels
314 * @index: Character position (0 = at start)
315 * Return: 0 if OK, -ve on error
316 */
317 int (*set_cursor_visible)(struct udevice *dev, bool visible,
318 uint x, uint y, uint index);
Simon Glass84c7fb32016-01-18 19:52:17 -0700319};
320
321/* Get a pointer to the driver operations for a video console device */
322#define vidconsole_get_ops(dev) ((struct vidconsole_ops *)(dev)->driver->ops)
323
324/**
Simon Glass3b175ba2023-01-06 08:52:32 -0600325 * vidconsole_get_font() - Obtain information about a font
326 *
327 * @dev: Device to check
328 * @seq: Font number to query (0=first, 1=second, etc.)
329 * @info: Returns font information on success
330 * Returns: 0 on success, -ENOENT if no such font, -ENOSYS if there is no such
331 * method
332 */
333int vidconsole_get_font(struct udevice *dev, int seq,
334 struct vidfont_info *info);
335
336/**
337 * vidconsole_select_font() - Select a particular font by name / size
338 *
339 * @dev: Device to adjust
340 * @name: Font name to use (NULL to use default)
341 * @size: Font size to use (0 to use default)
342 */
343int vidconsole_select_font(struct udevice *dev, const char *name, uint size);
344
Simon Glass95bcad42025-04-02 06:29:36 +1300345/**
346 * vidconsole_measure() - Measure the bounding box of some text
347 *
Simon Glass3c686e62025-04-02 06:29:38 +1300348 * The text can include newlines
349 *
Simon Glass95bcad42025-04-02 06:29:36 +1300350 * @dev: Device to adjust
351 * @name: Font name to use (NULL to use default)
352 * @size: Font size to use (0 to use default)
353 * @text: Text to measure
Simon Glass3aa33582025-04-02 06:29:39 +1300354 * @limit: Width limit for each line, or -1 if none
Simon Glass95bcad42025-04-02 06:29:36 +1300355 * @bbox: Returns bounding box of text, assuming it is positioned
356 * at 0,0
357 * @lines: If non-NULL, this must be an alist of
358 * struct vidconsole_mline inited by caller. The list is emptied
359 * and then a separate record is added for each line of text
Simon Glass5caf1252023-06-01 10:22:46 -0600360 *
Simon Glass95bcad42025-04-02 06:29:36 +1300361 * Returns: 0 on success, -ENOENT if no such font
Simon Glass5caf1252023-06-01 10:22:46 -0600362 */
363int vidconsole_measure(struct udevice *dev, const char *name, uint size,
Simon Glass3aa33582025-04-02 06:29:39 +1300364 const char *text, int limit,
365 struct vidconsole_bbox *bbox, struct alist *lines);
Simon Glass3b175ba2023-01-06 08:52:32 -0600366/**
Simon Glass8b82e592023-10-01 19:13:18 -0600367 * vidconsole_nominal() - Measure the expected width of a line of text
368 *
369 * Uses an average font width and nominal height
370 *
371 * @dev: Console device to use
372 * @name: Font name, NULL for default
373 * @size: Font size, ignored if @name is NULL
374 * @num_chars: Number of characters to use
375 * @bbox: Returns nounding box of @num_chars characters
376 * Returns: 0 if OK, -ve on error
377 */
378int vidconsole_nominal(struct udevice *dev, const char *name, uint size,
379 uint num_chars, struct vidconsole_bbox *bbox);
380
381/**
Simon Glass34b5c252023-10-01 19:13:19 -0600382 * vidconsole_entry_save() - Save any text-entry information for later use
383 *
384 * Saves text-entry context such as a list of positions for each
385 * character in the string.
386 *
387 * @dev: Console device to use
388 * @buf: Buffer to hold saved data
389 * Return: 0 if OK, -ENOMEM if out of memory
390 */
391int vidconsole_entry_save(struct udevice *dev, struct abuf *buf);
392
393/**
394 * entry_restore() - Restore text-entry information for current use
395 *
396 * Restores text-entry context such as a list of positions for each
397 * character in the string.
398 *
399 * @dev: Console device to use
400 * @buf: Buffer containing data to restore
401 * Return: 0 if OK, -ve on error
402 */
403int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf);
404
405/**
Simon Glass377f79aa2023-10-01 19:13:21 -0600406 * vidconsole_set_cursor_visible() - Show or hide the cursor
407 *
408 * Shows or hides a cursor at the current position
409 *
410 * @dev: Console device to use
411 * @visible: true to show the cursor, false to hide it
412 * @x: X position in pixels
413 * @y: Y position in pixels
414 * @index: Character position (0 = at start)
415 * Return: 0 if OK, -ve on error
416 */
417int vidconsole_set_cursor_visible(struct udevice *dev, bool visible,
418 uint x, uint y, uint index);
419
420/**
Simon Glassa73a8b82023-06-01 10:22:45 -0600421 * vidconsole_push_colour() - Temporarily change the font colour
422 *
423 * @dev: Device to adjust
424 * @fg: Foreground colour to select
425 * @bg: Background colour to select
426 * @old: Place to store the current colour, so it can be restored
427 */
428void vidconsole_push_colour(struct udevice *dev, enum colour_idx fg,
429 enum colour_idx bg, struct vidconsole_colour *old);
430
431/**
432 * vidconsole_pop_colour() - Restore the original colour
433 *
434 * @dev: Device to adjust
435 * @old: Old colour to be restored
436 */
437void vidconsole_pop_colour(struct udevice *dev, struct vidconsole_colour *old);
438
439/**
Simon Glass84c7fb32016-01-18 19:52:17 -0700440 * vidconsole_putc_xy() - write a single character to a position
441 *
442 * @dev: Device to write to
Simon Glass52c10c52016-01-14 18:10:37 -0700443 * @x_frac: Fractional pixel X position (0=left-most pixel) which
444 * is the X position multipled by VID_FRAC_DIV.
Simon Glass84c7fb32016-01-18 19:52:17 -0700445 * @y: Pixel Y position (0=top-most pixel)
Janne Grunau5548c362024-03-16 22:50:19 +0100446 * @cp: UTF-32 code point to write
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100447 * Return: number of fractional pixels that the cursor should move,
Simon Glass52c10c52016-01-14 18:10:37 -0700448 * if all is OK, -EAGAIN if we ran out of space on this line, other -ve
449 * on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700450 */
Janne Grunau5548c362024-03-16 22:50:19 +0100451int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, int cp);
Simon Glass84c7fb32016-01-18 19:52:17 -0700452
453/**
454 * vidconsole_move_rows() - Move text rows from one place to another
455 *
456 * @dev: Device to adjust
457 * @rowdst: Destination text row (0=top)
458 * @rowsrc: Source start text row
459 * @count: Number of text rows to move
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100460 * Return: 0 if OK, -ve on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700461 */
462int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc,
463 uint count);
464
465/**
466 * vidconsole_set_row() - Set the colour of a text row
467 *
468 * Every pixel contained within the text row is adjusted
469 *
470 * @dev: Device to adjust
471 * @row: Text row to adjust (0=top)
472 * @clr: Raw colour (pixel value) to write to each pixel
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100473 * Return: 0 if OK, -ve on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700474 */
475int vidconsole_set_row(struct udevice *dev, uint row, int clr);
476
477/**
Simon Glass4446c4b2023-10-01 19:13:20 -0600478 * vidconsole_entry_start() - Set the start position of a vidconsole line
479 *
480 * Marks the current cursor position as the start of a line
481 *
482 * @dev: Device to adjust
483 */
484int vidconsole_entry_start(struct udevice *dev);
485
486/**
Simon Glass84c7fb32016-01-18 19:52:17 -0700487 * vidconsole_put_char() - Output a character to the current console position
488 *
489 * Outputs a character to the console and advances the cursor. This function
490 * handles wrapping to new lines and scrolling the console. Special
491 * characters are handled also: \n, \r, \b and \t.
492 *
493 * The device always starts with the cursor at position 0,0 (top left). It
494 * can be adjusted manually using vidconsole_position_cursor().
495 *
496 * @dev: Device to adjust
497 * @ch: Character to write
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100498 * Return: 0 if OK, -ve on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700499 */
500int vidconsole_put_char(struct udevice *dev, char ch);
501
502/**
Simon Glass6f5a8642025-04-02 06:29:40 +1300503 * vidconsole_put_stringn() - Output part of a string to the current console pos
504 *
505 * Outputs part of a string to the console and advances the cursor. This
506 * function handles wrapping to new lines and scrolling the console. Special
507 * characters are handled also: \n, \r, \b and \t.
508 *
509 * The device always starts with the cursor at position 0,0 (top left). It
510 * can be adjusted manually using vidconsole_position_cursor().
511 *
512 * @dev: Device to adjust
513 * @str: String to write
514 * @maxlen: Maximum chars to output, or -1 for all
515 * Return: 0 if OK, -ve on error
516 */
517int vidconsole_put_stringn(struct udevice *dev, const char *str, int maxlen);
518
519/**
Marek Vasuta89f9cb2019-05-17 20:22:31 +0200520 * vidconsole_put_string() - Output a string to the current console position
521 *
522 * Outputs a string to the console and advances the cursor. This function
523 * handles wrapping to new lines and scrolling the console. Special
524 * characters are handled also: \n, \r, \b and \t.
525 *
526 * The device always starts with the cursor at position 0,0 (top left). It
527 * can be adjusted manually using vidconsole_position_cursor().
528 *
529 * @dev: Device to adjust
530 * @str: String to write
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100531 * Return: 0 if OK, -ve on error
Marek Vasuta89f9cb2019-05-17 20:22:31 +0200532 */
533int vidconsole_put_string(struct udevice *dev, const char *str);
534
535/**
Simon Glass84c7fb32016-01-18 19:52:17 -0700536 * vidconsole_position_cursor() - Move the text cursor
537 *
538 * @dev: Device to adjust
539 * @col: New cursor text column
540 * @row: New cursor text row
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100541 * Return: 0 if OK, -ve on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700542 */
543void vidconsole_position_cursor(struct udevice *dev, unsigned col,
544 unsigned row);
545
Simon Glassd622c5b2022-10-06 08:36:04 -0600546/**
Simon Glass90679c62023-03-10 12:47:21 -0800547 * vidconsole_clear_and_reset() - Clear the console and reset the cursor
548 *
549 * The cursor is placed at the start of the console
550 *
551 * @dev: vidconsole device to adjust
552 */
553int vidconsole_clear_and_reset(struct udevice *dev);
554
555/**
Simon Glassd622c5b2022-10-06 08:36:04 -0600556 * vidconsole_set_cursor_pos() - set cursor position
557 *
558 * The cursor is set to the new position and the start-of-line information is
559 * updated to the same position, so that a newline will return to @x
560 *
561 * @dev: video console device to update
562 * @x: x position from left in pixels
563 * @y: y position from top in pixels
564 */
565void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y);
566
Simon Glass981f00b2022-10-06 08:36:14 -0600567/**
568 * vidconsole_list_fonts() - List the available fonts
569 *
Simon Glass3b175ba2023-01-06 08:52:32 -0600570 * @dev: vidconsole device to check
Simon Glass981f00b2022-10-06 08:36:14 -0600571 *
Simon Glass3b175ba2023-01-06 08:52:32 -0600572 * This shows a list of fonts known by this vidconsole. The list is displayed on
573 * the console (not necessarily @dev but probably)
Simon Glass981f00b2022-10-06 08:36:14 -0600574 */
Simon Glass3b175ba2023-01-06 08:52:32 -0600575void vidconsole_list_fonts(struct udevice *dev);
Simon Glass981f00b2022-10-06 08:36:14 -0600576
Simon Glass9e972c32022-10-06 08:36:16 -0600577/**
Simon Glass3b175ba2023-01-06 08:52:32 -0600578 * vidconsole_get_font_size() - get the current font name and size
Simon Glass9e972c32022-10-06 08:36:16 -0600579 *
580 * @dev: vidconsole device
581 * @sizep: Place to put the font size (nominal height in pixels)
Dzmitry Sankouski86c6a532023-03-07 13:21:15 +0300582 * @name: pointer to font name, a placeholder for result
583 * Return: 0 if OK, -ENOSYS if not implemented in driver
Simon Glass9e972c32022-10-06 08:36:16 -0600584 */
Dzmitry Sankouski86c6a532023-03-07 13:21:15 +0300585int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep);
Simon Glass9e972c32022-10-06 08:36:16 -0600586
Heinrich Schuchardt290e1d82018-02-08 21:47:11 +0100587#endif