blob: 8f3f58f3aa92856af0eecf5436246ed21c147109 [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 Glassbe4fbd42025-04-02 06:29:42 +130056 * @quiet: Suppress all output from stdio
Simon Glass84c7fb32016-01-18 19:52:17 -070057 */
58struct vidconsole_priv {
59 struct stdio_dev sdev;
Simon Glass52c10c52016-01-14 18:10:37 -070060 int xcur_frac;
61 int ycur;
Simon Glass84c7fb32016-01-18 19:52:17 -070062 int rows;
63 int cols;
Simon Glass52c10c52016-01-14 18:10:37 -070064 int x_charsize;
65 int y_charsize;
66 int tab_width_frac;
67 int xsize_frac;
Simon Glassa74451d2016-01-14 18:10:39 -070068 int xstart_frac;
Simon Glassafee7432016-01-14 18:10:40 -070069 int last_ch;
Rob Clark06e7a0d2017-09-13 18:12:21 -040070 /*
71 * ANSI escape sequences are accumulated character by character,
72 * starting after the ESC char (0x1b) until the entire sequence
73 * is consumed at which point it is acted upon.
74 */
75 int escape;
76 int escape_len;
Heinrich Schuchardt9e933f12018-09-19 21:31:48 +020077 int row_saved;
78 int col_saved;
Rob Clark06e7a0d2017-09-13 18:12:21 -040079 char escape_buf[32];
Janne Grunau5548c362024-03-16 22:50:19 +010080 char utf8_buf[5];
Simon Glassbe4fbd42025-04-02 06:29:42 +130081 bool quiet;
Simon Glass84c7fb32016-01-18 19:52:17 -070082};
83
84/**
Simon Glass3b175ba2023-01-06 08:52:32 -060085 * struct vidfont_info - information about a font
86 *
87 * @name: Font name, e.g. nimbus_sans_l_regular
88 */
89struct vidfont_info {
90 const char *name;
91};
92
93/**
Simon Glassa73a8b82023-06-01 10:22:45 -060094 * struct vidconsole_colour - Holds colour information
95 *
96 * @colour_fg: Foreground colour (pixel value)
97 * @colour_bg: Background colour (pixel value)
98 */
99struct vidconsole_colour {
100 u32 colour_fg;
101 u32 colour_bg;
102};
103
104/**
Simon Glass5caf1252023-06-01 10:22:46 -0600105 * struct vidconsole_bbox - Bounding box of text
106 *
107 * This describes the bounding box of something, measured in pixels. The x0/y0
108 * pair is inclusive; the x1/y2 pair is exclusive, meaning that it is one pixel
109 * beyond the extent of the object
110 *
111 * @valid: Values are valid (bounding box is known)
112 * @x0: left x position, in pixels from left side
113 * @y0: top y position, in pixels from top
114 * @x1: right x position + 1
115 * @y1: botton y position + 1
116 */
117struct vidconsole_bbox {
118 bool valid;
119 int x0;
120 int y0;
121 int x1;
122 int y1;
123};
124
125/**
Simon Glass95bcad42025-04-02 06:29:36 +1300126 * vidconsole_mline - Holds information about a line of measured text
127 *
128 * @bbox: Bounding box of the line, assuming it starts at 0,0
129 * @start: String index of the first character in the line
130 * @len: Number of characters in the line
131 */
132struct vidconsole_mline {
133 struct vidconsole_bbox bbox;
134 int start;
135 int len;
136};
137
138/**
Simon Glass84c7fb32016-01-18 19:52:17 -0700139 * struct vidconsole_ops - Video console operations
140 *
141 * These operations work on either an absolute console position (measured
142 * in pixels) or a text row number (measured in rows, where each row consists
143 * of an entire line of text - typically 16 pixels).
144 */
145struct vidconsole_ops {
146 /**
147 * putc_xy() - write a single character to a position
148 *
149 * @dev: Device to write to
Simon Glass52c10c52016-01-14 18:10:37 -0700150 * @x_frac: Fractional pixel X position (0=left-most pixel) which
151 * is the X position multipled by VID_FRAC_DIV.
Simon Glass84c7fb32016-01-18 19:52:17 -0700152 * @y: Pixel Y position (0=top-most pixel)
Janne Grunau5548c362024-03-16 22:50:19 +0100153 * @cp: UTF-32 code point to write
Simon Glass52c10c52016-01-14 18:10:37 -0700154 * @return number of fractional pixels that the cursor should move,
155 * if all is OK, -EAGAIN if we ran out of space on this line, other -ve
156 * on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700157 */
Janne Grunau5548c362024-03-16 22:50:19 +0100158 int (*putc_xy)(struct udevice *dev, uint x_frac, uint y, int cp);
Simon Glass84c7fb32016-01-18 19:52:17 -0700159
160 /**
161 * move_rows() - Move text rows from one place to another
162 *
163 * @dev: Device to adjust
164 * @rowdst: Destination text row (0=top)
165 * @rowsrc: Source start text row
166 * @count: Number of text rows to move
167 * @return 0 if OK, -ve on error
168 */
169 int (*move_rows)(struct udevice *dev, uint rowdst, uint rowsrc,
170 uint count);
171
172 /**
173 * set_row() - Set the colour of a text row
174 *
175 * Every pixel contained within the text row is adjusted
176 *
177 * @dev: Device to adjust
178 * @row: Text row to adjust (0=top)
179 * @clr: Raw colour (pixel value) to write to each pixel
180 * @return 0 if OK, -ve on error
181 */
182 int (*set_row)(struct udevice *dev, uint row, int clr);
Simon Glassafee7432016-01-14 18:10:40 -0700183
184 /**
185 * entry_start() - Indicate that text entry is starting afresh
186 *
Simon Glass3b175ba2023-01-06 08:52:32 -0600187 * @dev: Device to adjust
188 * Returns: 0 on success, -ve on error
189 *
Simon Glassafee7432016-01-14 18:10:40 -0700190 * Consoles which use proportional fonts need to track the position of
191 * each character output so that backspace will return to the correct
192 * place. This method signals to the console driver that a new entry
193 * line is being start (e.g. the user pressed return to start a new
194 * command). The driver can use this signal to empty its list of
195 * positions.
196 */
197 int (*entry_start)(struct udevice *dev);
Simon Glass33bd3b62016-01-14 18:10:41 -0700198
199 /**
200 * backspace() - Handle erasing the last character
201 *
Simon Glass3b175ba2023-01-06 08:52:32 -0600202 * @dev: Device to adjust
203 * Returns: 0 on success, -ve on error
204 *
Simon Glass33bd3b62016-01-14 18:10:41 -0700205 * With proportional fonts the vidconsole uclass cannot itself erase
206 * the previous character. This optional method will be called when
207 * a backspace is needed. The driver should erase the previous
208 * character and update the cursor position (xcur_frac, ycur) to the
209 * start of the previous character.
210 *
211 * If not implement, default behaviour will work for fixed-width
212 * characters.
213 */
214 int (*backspace)(struct udevice *dev);
Simon Glass3b175ba2023-01-06 08:52:32 -0600215
216 /**
217 * get_font() - Obtain information about a font (optional)
218 *
219 * @dev: Device to check
220 * @seq: Font number to query (0=first, 1=second, etc.)
221 * @info: Returns font information on success
222 * Returns: 0 on success, -ENOENT if no such font
223 */
224 int (*get_font)(struct udevice *dev, int seq,
225 struct vidfont_info *info);
226
227 /**
Dzmitry Sankouski86c6a532023-03-07 13:21:15 +0300228 * get_font_size() - get the current font name and size
229 *
230 * @dev: vidconsole device
231 * @sizep: Place to put the font size (nominal height in pixels)
232 * Returns: Current font name
233 */
234 const char *(*get_font_size)(struct udevice *dev, uint *sizep);
235
236 /**
Simon Glass3b175ba2023-01-06 08:52:32 -0600237 * select_font() - Select a particular font by name / size
238 *
239 * @dev: Device to adjust
240 * @name: Font name to use (NULL to use default)
241 * @size: Font size to use (0 to use default)
242 * Returns: 0 on success, -ENOENT if no such font
243 */
244 int (*select_font)(struct udevice *dev, const char *name, uint size);
Simon Glass5caf1252023-06-01 10:22:46 -0600245
246 /**
Simon Glass95bcad42025-04-02 06:29:36 +1300247 * measure() - Measure the bounding box of some text
Simon Glass5caf1252023-06-01 10:22:46 -0600248 *
Simon Glass3c686e62025-04-02 06:29:38 +1300249 * The text can include newlines
250 *
Simon Glass95bcad42025-04-02 06:29:36 +1300251 * @dev: Console device to use
Simon Glass5caf1252023-06-01 10:22:46 -0600252 * @name: Font name to use (NULL to use default)
253 * @size: Font size to use (0 to use default)
254 * @text: Text to measure
Simon Glass3aa33582025-04-02 06:29:39 +1300255 * @limit: Width limit for each line, or -1 if none
Simon Glass5caf1252023-06-01 10:22:46 -0600256 * @bbox: Returns bounding box of text, assuming it is positioned
257 * at 0,0
Simon Glass95bcad42025-04-02 06:29:36 +1300258 * @lines: If non-NULL, this must be an alist of
259 * struct vidconsole_mline inited by caller. A separate
260 * record is added for each line of text
261 *
Simon Glass5caf1252023-06-01 10:22:46 -0600262 * Returns: 0 on success, -ENOENT if no such font
263 */
264 int (*measure)(struct udevice *dev, const char *name, uint size,
Simon Glass3aa33582025-04-02 06:29:39 +1300265 const char *text, int limit,
266 struct vidconsole_bbox *bbox, struct alist *lines);
Simon Glass8b82e592023-10-01 19:13:18 -0600267
268 /**
269 * nominal() - Measure the expected width of a line of text
270 *
271 * Uses an average font width and nominal height
272 *
273 * @dev: Console device to use
274 * @name: Font name, NULL for default
275 * @size: Font size, ignored if @name is NULL
276 * @num_chars: Number of characters to use
277 * @bbox: Returns nounding box of @num_chars characters
278 * Returns: 0 if OK, -ve on error
279 */
280 int (*nominal)(struct udevice *dev, const char *name, uint size,
281 uint num_chars, struct vidconsole_bbox *bbox);
Simon Glass34b5c252023-10-01 19:13:19 -0600282
283 /**
284 * entry_save() - Save any text-entry information for later use
285 *
286 * Saves text-entry context such as a list of positions for each
287 * character in the string.
288 *
289 * @dev: Console device to use
290 * @buf: Buffer to hold saved data
291 * Return: 0 if OK, -ENOMEM if out of memory
292 */
293 int (*entry_save)(struct udevice *dev, struct abuf *buf);
294
295 /**
296 * entry_restore() - Restore text-entry information for current use
297 *
298 * Restores text-entry context such as a list of positions for each
299 * character in the string.
300 *
301 * @dev: Console device to use
302 * @buf: Buffer containing data to restore
303 * Return: 0 if OK, -ve on error
304 */
305 int (*entry_restore)(struct udevice *dev, struct abuf *buf);
Simon Glass377f79aa2023-10-01 19:13:21 -0600306
307 /**
308 * set_cursor_visible() - Show or hide the cursor
309 *
310 * Shows or hides a cursor at the current position
311 *
312 * @dev: Console device to use
313 * @visible: true to show the cursor, false to hide it
314 * @x: X position in pixels
315 * @y: Y position in pixels
316 * @index: Character position (0 = at start)
317 * Return: 0 if OK, -ve on error
318 */
319 int (*set_cursor_visible)(struct udevice *dev, bool visible,
320 uint x, uint y, uint index);
Simon Glass84c7fb32016-01-18 19:52:17 -0700321};
322
323/* Get a pointer to the driver operations for a video console device */
324#define vidconsole_get_ops(dev) ((struct vidconsole_ops *)(dev)->driver->ops)
325
326/**
Simon Glass3b175ba2023-01-06 08:52:32 -0600327 * vidconsole_get_font() - Obtain information about a font
328 *
329 * @dev: Device to check
330 * @seq: Font number to query (0=first, 1=second, etc.)
331 * @info: Returns font information on success
332 * Returns: 0 on success, -ENOENT if no such font, -ENOSYS if there is no such
333 * method
334 */
335int vidconsole_get_font(struct udevice *dev, int seq,
336 struct vidfont_info *info);
337
338/**
339 * vidconsole_select_font() - Select a particular font by name / size
340 *
341 * @dev: Device to adjust
342 * @name: Font name to use (NULL to use default)
343 * @size: Font size to use (0 to use default)
344 */
345int vidconsole_select_font(struct udevice *dev, const char *name, uint size);
346
Simon Glass95bcad42025-04-02 06:29:36 +1300347/**
348 * vidconsole_measure() - Measure the bounding box of some text
349 *
Simon Glass3c686e62025-04-02 06:29:38 +1300350 * The text can include newlines
351 *
Simon Glass95bcad42025-04-02 06:29:36 +1300352 * @dev: Device to adjust
353 * @name: Font name to use (NULL to use default)
354 * @size: Font size to use (0 to use default)
355 * @text: Text to measure
Simon Glass3aa33582025-04-02 06:29:39 +1300356 * @limit: Width limit for each line, or -1 if none
Simon Glass95bcad42025-04-02 06:29:36 +1300357 * @bbox: Returns bounding box of text, assuming it is positioned
358 * at 0,0
359 * @lines: If non-NULL, this must be an alist of
360 * struct vidconsole_mline inited by caller. The list is emptied
361 * and then a separate record is added for each line of text
Simon Glass5caf1252023-06-01 10:22:46 -0600362 *
Simon Glass95bcad42025-04-02 06:29:36 +1300363 * Returns: 0 on success, -ENOENT if no such font
Simon Glass5caf1252023-06-01 10:22:46 -0600364 */
365int vidconsole_measure(struct udevice *dev, const char *name, uint size,
Simon Glass3aa33582025-04-02 06:29:39 +1300366 const char *text, int limit,
367 struct vidconsole_bbox *bbox, struct alist *lines);
Simon Glass3b175ba2023-01-06 08:52:32 -0600368/**
Simon Glass8b82e592023-10-01 19:13:18 -0600369 * vidconsole_nominal() - Measure the expected width of a line of text
370 *
371 * Uses an average font width and nominal height
372 *
373 * @dev: Console device to use
374 * @name: Font name, NULL for default
375 * @size: Font size, ignored if @name is NULL
376 * @num_chars: Number of characters to use
377 * @bbox: Returns nounding box of @num_chars characters
378 * Returns: 0 if OK, -ve on error
379 */
380int vidconsole_nominal(struct udevice *dev, const char *name, uint size,
381 uint num_chars, struct vidconsole_bbox *bbox);
382
383/**
Simon Glass34b5c252023-10-01 19:13:19 -0600384 * vidconsole_entry_save() - Save any text-entry information for later use
385 *
386 * Saves text-entry context such as a list of positions for each
387 * character in the string.
388 *
389 * @dev: Console device to use
390 * @buf: Buffer to hold saved data
391 * Return: 0 if OK, -ENOMEM if out of memory
392 */
393int vidconsole_entry_save(struct udevice *dev, struct abuf *buf);
394
395/**
396 * entry_restore() - Restore text-entry information for current use
397 *
398 * Restores text-entry context such as a list of positions for each
399 * character in the string.
400 *
401 * @dev: Console device to use
402 * @buf: Buffer containing data to restore
403 * Return: 0 if OK, -ve on error
404 */
405int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf);
406
407/**
Simon Glass377f79aa2023-10-01 19:13:21 -0600408 * vidconsole_set_cursor_visible() - Show or hide the cursor
409 *
410 * Shows or hides a cursor at the current position
411 *
412 * @dev: Console device to use
413 * @visible: true to show the cursor, false to hide it
414 * @x: X position in pixels
415 * @y: Y position in pixels
416 * @index: Character position (0 = at start)
417 * Return: 0 if OK, -ve on error
418 */
419int vidconsole_set_cursor_visible(struct udevice *dev, bool visible,
420 uint x, uint y, uint index);
421
422/**
Simon Glassa73a8b82023-06-01 10:22:45 -0600423 * vidconsole_push_colour() - Temporarily change the font colour
424 *
425 * @dev: Device to adjust
426 * @fg: Foreground colour to select
427 * @bg: Background colour to select
428 * @old: Place to store the current colour, so it can be restored
429 */
430void vidconsole_push_colour(struct udevice *dev, enum colour_idx fg,
431 enum colour_idx bg, struct vidconsole_colour *old);
432
433/**
434 * vidconsole_pop_colour() - Restore the original colour
435 *
436 * @dev: Device to adjust
437 * @old: Old colour to be restored
438 */
439void vidconsole_pop_colour(struct udevice *dev, struct vidconsole_colour *old);
440
441/**
Simon Glass84c7fb32016-01-18 19:52:17 -0700442 * vidconsole_putc_xy() - write a single character to a position
443 *
444 * @dev: Device to write to
Simon Glass52c10c52016-01-14 18:10:37 -0700445 * @x_frac: Fractional pixel X position (0=left-most pixel) which
446 * is the X position multipled by VID_FRAC_DIV.
Simon Glass84c7fb32016-01-18 19:52:17 -0700447 * @y: Pixel Y position (0=top-most pixel)
Janne Grunau5548c362024-03-16 22:50:19 +0100448 * @cp: UTF-32 code point to write
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100449 * Return: number of fractional pixels that the cursor should move,
Simon Glass52c10c52016-01-14 18:10:37 -0700450 * if all is OK, -EAGAIN if we ran out of space on this line, other -ve
451 * on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700452 */
Janne Grunau5548c362024-03-16 22:50:19 +0100453int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, int cp);
Simon Glass84c7fb32016-01-18 19:52:17 -0700454
455/**
456 * vidconsole_move_rows() - Move text rows from one place to another
457 *
458 * @dev: Device to adjust
459 * @rowdst: Destination text row (0=top)
460 * @rowsrc: Source start text row
461 * @count: Number of text rows to move
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100462 * Return: 0 if OK, -ve on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700463 */
464int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc,
465 uint count);
466
467/**
468 * vidconsole_set_row() - Set the colour of a text row
469 *
470 * Every pixel contained within the text row is adjusted
471 *
472 * @dev: Device to adjust
473 * @row: Text row to adjust (0=top)
474 * @clr: Raw colour (pixel value) to write to each pixel
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100475 * Return: 0 if OK, -ve on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700476 */
477int vidconsole_set_row(struct udevice *dev, uint row, int clr);
478
479/**
Simon Glass4446c4b2023-10-01 19:13:20 -0600480 * vidconsole_entry_start() - Set the start position of a vidconsole line
481 *
482 * Marks the current cursor position as the start of a line
483 *
484 * @dev: Device to adjust
485 */
486int vidconsole_entry_start(struct udevice *dev);
487
488/**
Simon Glass84c7fb32016-01-18 19:52:17 -0700489 * vidconsole_put_char() - Output a character to the current console position
490 *
491 * Outputs a character to the console and advances the cursor. This function
492 * handles wrapping to new lines and scrolling the console. Special
493 * characters are handled also: \n, \r, \b and \t.
494 *
495 * The device always starts with the cursor at position 0,0 (top left). It
496 * can be adjusted manually using vidconsole_position_cursor().
497 *
498 * @dev: Device to adjust
499 * @ch: Character to write
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100500 * Return: 0 if OK, -ve on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700501 */
502int vidconsole_put_char(struct udevice *dev, char ch);
503
504/**
Simon Glass6f5a8642025-04-02 06:29:40 +1300505 * vidconsole_put_stringn() - Output part of a string to the current console pos
506 *
507 * Outputs part of a string to the console and advances the cursor. This
508 * function handles wrapping to new lines and scrolling the console. Special
509 * characters are handled also: \n, \r, \b and \t.
510 *
511 * The device always starts with the cursor at position 0,0 (top left). It
512 * can be adjusted manually using vidconsole_position_cursor().
513 *
514 * @dev: Device to adjust
515 * @str: String to write
516 * @maxlen: Maximum chars to output, or -1 for all
517 * Return: 0 if OK, -ve on error
518 */
519int vidconsole_put_stringn(struct udevice *dev, const char *str, int maxlen);
520
521/**
Marek Vasuta89f9cb2019-05-17 20:22:31 +0200522 * vidconsole_put_string() - Output a string to the current console position
523 *
524 * Outputs a string to the console and advances the cursor. This function
525 * handles wrapping to new lines and scrolling the console. Special
526 * characters are handled also: \n, \r, \b and \t.
527 *
528 * The device always starts with the cursor at position 0,0 (top left). It
529 * can be adjusted manually using vidconsole_position_cursor().
530 *
531 * @dev: Device to adjust
532 * @str: String to write
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100533 * Return: 0 if OK, -ve on error
Marek Vasuta89f9cb2019-05-17 20:22:31 +0200534 */
535int vidconsole_put_string(struct udevice *dev, const char *str);
536
537/**
Simon Glass84c7fb32016-01-18 19:52:17 -0700538 * vidconsole_position_cursor() - Move the text cursor
539 *
540 * @dev: Device to adjust
541 * @col: New cursor text column
542 * @row: New cursor text row
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100543 * Return: 0 if OK, -ve on error
Simon Glass84c7fb32016-01-18 19:52:17 -0700544 */
545void vidconsole_position_cursor(struct udevice *dev, unsigned col,
546 unsigned row);
547
Simon Glassd622c5b2022-10-06 08:36:04 -0600548/**
Simon Glass90679c62023-03-10 12:47:21 -0800549 * vidconsole_clear_and_reset() - Clear the console and reset the cursor
550 *
551 * The cursor is placed at the start of the console
552 *
553 * @dev: vidconsole device to adjust
554 */
555int vidconsole_clear_and_reset(struct udevice *dev);
556
557/**
Simon Glassd622c5b2022-10-06 08:36:04 -0600558 * vidconsole_set_cursor_pos() - set cursor position
559 *
560 * The cursor is set to the new position and the start-of-line information is
561 * updated to the same position, so that a newline will return to @x
562 *
563 * @dev: video console device to update
564 * @x: x position from left in pixels
565 * @y: y position from top in pixels
566 */
567void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y);
568
Simon Glass981f00b2022-10-06 08:36:14 -0600569/**
570 * vidconsole_list_fonts() - List the available fonts
571 *
Simon Glass3b175ba2023-01-06 08:52:32 -0600572 * @dev: vidconsole device to check
Simon Glass981f00b2022-10-06 08:36:14 -0600573 *
Simon Glass3b175ba2023-01-06 08:52:32 -0600574 * This shows a list of fonts known by this vidconsole. The list is displayed on
575 * the console (not necessarily @dev but probably)
Simon Glass981f00b2022-10-06 08:36:14 -0600576 */
Simon Glass3b175ba2023-01-06 08:52:32 -0600577void vidconsole_list_fonts(struct udevice *dev);
Simon Glass981f00b2022-10-06 08:36:14 -0600578
Simon Glass9e972c32022-10-06 08:36:16 -0600579/**
Simon Glass3b175ba2023-01-06 08:52:32 -0600580 * vidconsole_get_font_size() - get the current font name and size
Simon Glass9e972c32022-10-06 08:36:16 -0600581 *
582 * @dev: vidconsole device
583 * @sizep: Place to put the font size (nominal height in pixels)
Dzmitry Sankouski86c6a532023-03-07 13:21:15 +0300584 * @name: pointer to font name, a placeholder for result
585 * Return: 0 if OK, -ENOSYS if not implemented in driver
Simon Glass9e972c32022-10-06 08:36:16 -0600586 */
Dzmitry Sankouski86c6a532023-03-07 13:21:15 +0300587int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep);
Simon Glass9e972c32022-10-06 08:36:16 -0600588
Simon Glassbe4fbd42025-04-02 06:29:42 +1300589/**
590 * vidconsole_set_quiet() - Select whether the console should output stdio
591 *
592 * @dev: vidconsole device
593 * @quiet: true to suppress stdout/stderr output, false to enable it
594 */
595void vidconsole_set_quiet(struct udevice *dev, bool quiet);
596
Heinrich Schuchardt290e1d82018-02-08 21:47:11 +0100597#endif