Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015 Google, Inc |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef __video_console_h |
| 7 | #define __video_console_h |
| 8 | |
Heinrich Schuchardt | 5c30fbb | 2018-02-08 21:47:11 +0100 | [diff] [blame] | 9 | #include <video.h> |
| 10 | |
Simon Glass | 2d7c268 | 2020-07-02 21:12:18 -0600 | [diff] [blame] | 11 | struct video_priv; |
| 12 | |
Simon Glass | f266178 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 13 | #define VID_FRAC_DIV 256 |
| 14 | |
| 15 | #define VID_TO_PIXEL(x) ((x) / VID_FRAC_DIV) |
| 16 | #define VID_TO_POS(x) ((x) * VID_FRAC_DIV) |
| 17 | |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 18 | /** |
| 19 | * struct vidconsole_priv - uclass-private data about a console device |
| 20 | * |
Simon Glass | f266178 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 21 | * Drivers must set up @rows, @cols, @x_charsize, @y_charsize in their probe() |
| 22 | * method. Drivers may set up @xstart_frac if desired. |
| 23 | * |
Heinrich Schuchardt | 662f381 | 2018-09-19 21:31:48 +0200 | [diff] [blame] | 24 | * @sdev: stdio device, acting as an output sink |
| 25 | * @xcur_frac: Current X position, in fractional units (VID_TO_POS(x)) |
| 26 | * @ycur: Current Y position in pixels (0=top) |
| 27 | * @rows: Number of text rows |
| 28 | * @cols: Number of text columns |
| 29 | * @x_charsize: Character width in pixels |
| 30 | * @y_charsize: Character height in pixels |
Simon Glass | f266178 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 31 | * @tab_width_frac: Tab width in fractional units |
Heinrich Schuchardt | 662f381 | 2018-09-19 21:31:48 +0200 | [diff] [blame] | 32 | * @xsize_frac: Width of the display in fractional units |
Simon Glass | c5b77d0 | 2016-01-14 18:10:39 -0700 | [diff] [blame] | 33 | * @xstart_frac: Left margin for the text console in fractional units |
Heinrich Schuchardt | 662f381 | 2018-09-19 21:31:48 +0200 | [diff] [blame] | 34 | * @last_ch: Last character written to the text console on this line |
| 35 | * @escape: TRUE if currently accumulating an ANSI escape sequence |
| 36 | * @escape_len: Length of accumulated escape sequence so far |
| 37 | * @col_saved: Saved X position, in fractional units (VID_TO_POS(x)) |
| 38 | * @row_saved: Saved Y position in pixels (0=top) |
| 39 | * @escape_buf: Buffer to accumulate escape sequence |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 40 | */ |
| 41 | struct vidconsole_priv { |
| 42 | struct stdio_dev sdev; |
Simon Glass | f266178 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 43 | int xcur_frac; |
| 44 | int ycur; |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 45 | int rows; |
| 46 | int cols; |
Simon Glass | f266178 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 47 | int x_charsize; |
| 48 | int y_charsize; |
| 49 | int tab_width_frac; |
| 50 | int xsize_frac; |
Simon Glass | c5b77d0 | 2016-01-14 18:10:39 -0700 | [diff] [blame] | 51 | int xstart_frac; |
Simon Glass | 58c733a | 2016-01-14 18:10:40 -0700 | [diff] [blame] | 52 | int last_ch; |
Rob Clark | a085aa1 | 2017-09-13 18:12:21 -0400 | [diff] [blame] | 53 | /* |
| 54 | * ANSI escape sequences are accumulated character by character, |
| 55 | * starting after the ESC char (0x1b) until the entire sequence |
| 56 | * is consumed at which point it is acted upon. |
| 57 | */ |
| 58 | int escape; |
| 59 | int escape_len; |
Heinrich Schuchardt | 662f381 | 2018-09-19 21:31:48 +0200 | [diff] [blame] | 60 | int row_saved; |
| 61 | int col_saved; |
Rob Clark | a085aa1 | 2017-09-13 18:12:21 -0400 | [diff] [blame] | 62 | char escape_buf[32]; |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | /** |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 66 | * struct vidfont_info - information about a font |
| 67 | * |
| 68 | * @name: Font name, e.g. nimbus_sans_l_regular |
| 69 | */ |
| 70 | struct vidfont_info { |
| 71 | const char *name; |
| 72 | }; |
| 73 | |
| 74 | /** |
Simon Glass | 648a499 | 2023-06-01 10:22:45 -0600 | [diff] [blame] | 75 | * struct vidconsole_colour - Holds colour information |
| 76 | * |
| 77 | * @colour_fg: Foreground colour (pixel value) |
| 78 | * @colour_bg: Background colour (pixel value) |
| 79 | */ |
| 80 | struct vidconsole_colour { |
| 81 | u32 colour_fg; |
| 82 | u32 colour_bg; |
| 83 | }; |
| 84 | |
| 85 | /** |
Simon Glass | b828ed7 | 2023-06-01 10:22:46 -0600 | [diff] [blame] | 86 | * struct vidconsole_bbox - Bounding box of text |
| 87 | * |
| 88 | * This describes the bounding box of something, measured in pixels. The x0/y0 |
| 89 | * pair is inclusive; the x1/y2 pair is exclusive, meaning that it is one pixel |
| 90 | * beyond the extent of the object |
| 91 | * |
| 92 | * @valid: Values are valid (bounding box is known) |
| 93 | * @x0: left x position, in pixels from left side |
| 94 | * @y0: top y position, in pixels from top |
| 95 | * @x1: right x position + 1 |
| 96 | * @y1: botton y position + 1 |
| 97 | */ |
| 98 | struct vidconsole_bbox { |
| 99 | bool valid; |
| 100 | int x0; |
| 101 | int y0; |
| 102 | int x1; |
| 103 | int y1; |
| 104 | }; |
| 105 | |
| 106 | /** |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 107 | * struct vidconsole_ops - Video console operations |
| 108 | * |
| 109 | * These operations work on either an absolute console position (measured |
| 110 | * in pixels) or a text row number (measured in rows, where each row consists |
| 111 | * of an entire line of text - typically 16 pixels). |
| 112 | */ |
| 113 | struct vidconsole_ops { |
| 114 | /** |
| 115 | * putc_xy() - write a single character to a position |
| 116 | * |
| 117 | * @dev: Device to write to |
Simon Glass | f266178 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 118 | * @x_frac: Fractional pixel X position (0=left-most pixel) which |
| 119 | * is the X position multipled by VID_FRAC_DIV. |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 120 | * @y: Pixel Y position (0=top-most pixel) |
| 121 | * @ch: Character to write |
Simon Glass | f266178 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 122 | * @return number of fractional pixels that the cursor should move, |
| 123 | * if all is OK, -EAGAIN if we ran out of space on this line, other -ve |
| 124 | * on error |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 125 | */ |
Simon Glass | f266178 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 126 | int (*putc_xy)(struct udevice *dev, uint x_frac, uint y, char ch); |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * move_rows() - Move text rows from one place to another |
| 130 | * |
| 131 | * @dev: Device to adjust |
| 132 | * @rowdst: Destination text row (0=top) |
| 133 | * @rowsrc: Source start text row |
| 134 | * @count: Number of text rows to move |
| 135 | * @return 0 if OK, -ve on error |
| 136 | */ |
| 137 | int (*move_rows)(struct udevice *dev, uint rowdst, uint rowsrc, |
| 138 | uint count); |
| 139 | |
| 140 | /** |
| 141 | * set_row() - Set the colour of a text row |
| 142 | * |
| 143 | * Every pixel contained within the text row is adjusted |
| 144 | * |
| 145 | * @dev: Device to adjust |
| 146 | * @row: Text row to adjust (0=top) |
| 147 | * @clr: Raw colour (pixel value) to write to each pixel |
| 148 | * @return 0 if OK, -ve on error |
| 149 | */ |
| 150 | int (*set_row)(struct udevice *dev, uint row, int clr); |
Simon Glass | 58c733a | 2016-01-14 18:10:40 -0700 | [diff] [blame] | 151 | |
| 152 | /** |
| 153 | * entry_start() - Indicate that text entry is starting afresh |
| 154 | * |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 155 | * @dev: Device to adjust |
| 156 | * Returns: 0 on success, -ve on error |
| 157 | * |
Simon Glass | 58c733a | 2016-01-14 18:10:40 -0700 | [diff] [blame] | 158 | * Consoles which use proportional fonts need to track the position of |
| 159 | * each character output so that backspace will return to the correct |
| 160 | * place. This method signals to the console driver that a new entry |
| 161 | * line is being start (e.g. the user pressed return to start a new |
| 162 | * command). The driver can use this signal to empty its list of |
| 163 | * positions. |
| 164 | */ |
| 165 | int (*entry_start)(struct udevice *dev); |
Simon Glass | 7b9f7e4 | 2016-01-14 18:10:41 -0700 | [diff] [blame] | 166 | |
| 167 | /** |
| 168 | * backspace() - Handle erasing the last character |
| 169 | * |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 170 | * @dev: Device to adjust |
| 171 | * Returns: 0 on success, -ve on error |
| 172 | * |
Simon Glass | 7b9f7e4 | 2016-01-14 18:10:41 -0700 | [diff] [blame] | 173 | * With proportional fonts the vidconsole uclass cannot itself erase |
| 174 | * the previous character. This optional method will be called when |
| 175 | * a backspace is needed. The driver should erase the previous |
| 176 | * character and update the cursor position (xcur_frac, ycur) to the |
| 177 | * start of the previous character. |
| 178 | * |
| 179 | * If not implement, default behaviour will work for fixed-width |
| 180 | * characters. |
| 181 | */ |
| 182 | int (*backspace)(struct udevice *dev); |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 183 | |
| 184 | /** |
| 185 | * get_font() - Obtain information about a font (optional) |
| 186 | * |
| 187 | * @dev: Device to check |
| 188 | * @seq: Font number to query (0=first, 1=second, etc.) |
| 189 | * @info: Returns font information on success |
| 190 | * Returns: 0 on success, -ENOENT if no such font |
| 191 | */ |
| 192 | int (*get_font)(struct udevice *dev, int seq, |
| 193 | struct vidfont_info *info); |
| 194 | |
| 195 | /** |
Dzmitry Sankouski | 4f6e348 | 2023-03-07 13:21:15 +0300 | [diff] [blame] | 196 | * get_font_size() - get the current font name and size |
| 197 | * |
| 198 | * @dev: vidconsole device |
| 199 | * @sizep: Place to put the font size (nominal height in pixels) |
| 200 | * Returns: Current font name |
| 201 | */ |
| 202 | const char *(*get_font_size)(struct udevice *dev, uint *sizep); |
| 203 | |
| 204 | /** |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 205 | * select_font() - Select a particular font by name / size |
| 206 | * |
| 207 | * @dev: Device to adjust |
| 208 | * @name: Font name to use (NULL to use default) |
| 209 | * @size: Font size to use (0 to use default) |
| 210 | * Returns: 0 on success, -ENOENT if no such font |
| 211 | */ |
| 212 | int (*select_font)(struct udevice *dev, const char *name, uint size); |
Simon Glass | b828ed7 | 2023-06-01 10:22:46 -0600 | [diff] [blame] | 213 | |
| 214 | /** |
| 215 | * measure() - Measure the bounds of some text |
| 216 | * |
| 217 | * @dev: Device to adjust |
| 218 | * @name: Font name to use (NULL to use default) |
| 219 | * @size: Font size to use (0 to use default) |
| 220 | * @text: Text to measure |
| 221 | * @bbox: Returns bounding box of text, assuming it is positioned |
| 222 | * at 0,0 |
| 223 | * Returns: 0 on success, -ENOENT if no such font |
| 224 | */ |
| 225 | int (*measure)(struct udevice *dev, const char *name, uint size, |
| 226 | const char *text, struct vidconsole_bbox *bbox); |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 227 | }; |
| 228 | |
| 229 | /* Get a pointer to the driver operations for a video console device */ |
| 230 | #define vidconsole_get_ops(dev) ((struct vidconsole_ops *)(dev)->driver->ops) |
| 231 | |
| 232 | /** |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 233 | * vidconsole_get_font() - Obtain information about a font |
| 234 | * |
| 235 | * @dev: Device to check |
| 236 | * @seq: Font number to query (0=first, 1=second, etc.) |
| 237 | * @info: Returns font information on success |
| 238 | * Returns: 0 on success, -ENOENT if no such font, -ENOSYS if there is no such |
| 239 | * method |
| 240 | */ |
| 241 | int vidconsole_get_font(struct udevice *dev, int seq, |
| 242 | struct vidfont_info *info); |
| 243 | |
| 244 | /** |
| 245 | * vidconsole_select_font() - Select a particular font by name / size |
| 246 | * |
| 247 | * @dev: Device to adjust |
| 248 | * @name: Font name to use (NULL to use default) |
| 249 | * @size: Font size to use (0 to use default) |
| 250 | */ |
| 251 | int vidconsole_select_font(struct udevice *dev, const char *name, uint size); |
| 252 | |
Simon Glass | b828ed7 | 2023-06-01 10:22:46 -0600 | [diff] [blame] | 253 | /* |
| 254 | * vidconsole_measure() - Measuring the bounding box of some text |
| 255 | * |
| 256 | * @dev: Console device to use |
| 257 | * @name: Font name, NULL for default |
| 258 | * @size: Font size, ignored if @name is NULL |
| 259 | * @text: Text to measure |
| 260 | * @bbox: Returns nounding box of text |
| 261 | * Returns: 0 if OK, -ve on error |
| 262 | */ |
| 263 | int vidconsole_measure(struct udevice *dev, const char *name, uint size, |
| 264 | const char *text, struct vidconsole_bbox *bbox); |
| 265 | |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 266 | /** |
Simon Glass | 648a499 | 2023-06-01 10:22:45 -0600 | [diff] [blame] | 267 | * vidconsole_push_colour() - Temporarily change the font colour |
| 268 | * |
| 269 | * @dev: Device to adjust |
| 270 | * @fg: Foreground colour to select |
| 271 | * @bg: Background colour to select |
| 272 | * @old: Place to store the current colour, so it can be restored |
| 273 | */ |
| 274 | void vidconsole_push_colour(struct udevice *dev, enum colour_idx fg, |
| 275 | enum colour_idx bg, struct vidconsole_colour *old); |
| 276 | |
| 277 | /** |
| 278 | * vidconsole_pop_colour() - Restore the original colour |
| 279 | * |
| 280 | * @dev: Device to adjust |
| 281 | * @old: Old colour to be restored |
| 282 | */ |
| 283 | void vidconsole_pop_colour(struct udevice *dev, struct vidconsole_colour *old); |
| 284 | |
| 285 | /** |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 286 | * vidconsole_putc_xy() - write a single character to a position |
| 287 | * |
| 288 | * @dev: Device to write to |
Simon Glass | f266178 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 289 | * @x_frac: Fractional pixel X position (0=left-most pixel) which |
| 290 | * is the X position multipled by VID_FRAC_DIV. |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 291 | * @y: Pixel Y position (0=top-most pixel) |
| 292 | * @ch: Character to write |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 293 | * Return: number of fractional pixels that the cursor should move, |
Simon Glass | f266178 | 2016-01-14 18:10:37 -0700 | [diff] [blame] | 294 | * if all is OK, -EAGAIN if we ran out of space on this line, other -ve |
| 295 | * on error |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 296 | */ |
| 297 | int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch); |
| 298 | |
| 299 | /** |
| 300 | * vidconsole_move_rows() - Move text rows from one place to another |
| 301 | * |
| 302 | * @dev: Device to adjust |
| 303 | * @rowdst: Destination text row (0=top) |
| 304 | * @rowsrc: Source start text row |
| 305 | * @count: Number of text rows to move |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 306 | * Return: 0 if OK, -ve on error |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 307 | */ |
| 308 | int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc, |
| 309 | uint count); |
| 310 | |
| 311 | /** |
| 312 | * vidconsole_set_row() - Set the colour of a text row |
| 313 | * |
| 314 | * Every pixel contained within the text row is adjusted |
| 315 | * |
| 316 | * @dev: Device to adjust |
| 317 | * @row: Text row to adjust (0=top) |
| 318 | * @clr: Raw colour (pixel value) to write to each pixel |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 319 | * Return: 0 if OK, -ve on error |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 320 | */ |
| 321 | int vidconsole_set_row(struct udevice *dev, uint row, int clr); |
| 322 | |
| 323 | /** |
| 324 | * vidconsole_put_char() - Output a character to the current console position |
| 325 | * |
| 326 | * Outputs a character to the console and advances the cursor. This function |
| 327 | * handles wrapping to new lines and scrolling the console. Special |
| 328 | * characters are handled also: \n, \r, \b and \t. |
| 329 | * |
| 330 | * The device always starts with the cursor at position 0,0 (top left). It |
| 331 | * can be adjusted manually using vidconsole_position_cursor(). |
| 332 | * |
| 333 | * @dev: Device to adjust |
| 334 | * @ch: Character to write |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 335 | * Return: 0 if OK, -ve on error |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 336 | */ |
| 337 | int vidconsole_put_char(struct udevice *dev, char ch); |
| 338 | |
| 339 | /** |
Marek Vasut | e63168a | 2019-05-17 20:22:31 +0200 | [diff] [blame] | 340 | * vidconsole_put_string() - Output a string to the current console position |
| 341 | * |
| 342 | * Outputs a string to the console and advances the cursor. This function |
| 343 | * handles wrapping to new lines and scrolling the console. Special |
| 344 | * characters are handled also: \n, \r, \b and \t. |
| 345 | * |
| 346 | * The device always starts with the cursor at position 0,0 (top left). It |
| 347 | * can be adjusted manually using vidconsole_position_cursor(). |
| 348 | * |
| 349 | * @dev: Device to adjust |
| 350 | * @str: String to write |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 351 | * Return: 0 if OK, -ve on error |
Marek Vasut | e63168a | 2019-05-17 20:22:31 +0200 | [diff] [blame] | 352 | */ |
| 353 | int vidconsole_put_string(struct udevice *dev, const char *str); |
| 354 | |
| 355 | /** |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 356 | * vidconsole_position_cursor() - Move the text cursor |
| 357 | * |
| 358 | * @dev: Device to adjust |
| 359 | * @col: New cursor text column |
| 360 | * @row: New cursor text row |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 361 | * Return: 0 if OK, -ve on error |
Simon Glass | 8351076 | 2016-01-18 19:52:17 -0700 | [diff] [blame] | 362 | */ |
| 363 | void vidconsole_position_cursor(struct udevice *dev, unsigned col, |
| 364 | unsigned row); |
| 365 | |
Simon Glass | 6b6dc0d | 2022-10-06 08:36:04 -0600 | [diff] [blame] | 366 | /** |
Simon Glass | a76b60f | 2023-03-10 12:47:21 -0800 | [diff] [blame] | 367 | * vidconsole_clear_and_reset() - Clear the console and reset the cursor |
| 368 | * |
| 369 | * The cursor is placed at the start of the console |
| 370 | * |
| 371 | * @dev: vidconsole device to adjust |
| 372 | */ |
| 373 | int vidconsole_clear_and_reset(struct udevice *dev); |
| 374 | |
| 375 | /** |
Simon Glass | 6b6dc0d | 2022-10-06 08:36:04 -0600 | [diff] [blame] | 376 | * vidconsole_set_cursor_pos() - set cursor position |
| 377 | * |
| 378 | * The cursor is set to the new position and the start-of-line information is |
| 379 | * updated to the same position, so that a newline will return to @x |
| 380 | * |
| 381 | * @dev: video console device to update |
| 382 | * @x: x position from left in pixels |
| 383 | * @y: y position from top in pixels |
| 384 | */ |
| 385 | void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y); |
| 386 | |
Simon Glass | 57a847c | 2022-10-06 08:36:14 -0600 | [diff] [blame] | 387 | /** |
| 388 | * vidconsole_list_fonts() - List the available fonts |
| 389 | * |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 390 | * @dev: vidconsole device to check |
Simon Glass | 57a847c | 2022-10-06 08:36:14 -0600 | [diff] [blame] | 391 | * |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 392 | * This shows a list of fonts known by this vidconsole. The list is displayed on |
| 393 | * the console (not necessarily @dev but probably) |
Simon Glass | 57a847c | 2022-10-06 08:36:14 -0600 | [diff] [blame] | 394 | */ |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 395 | void vidconsole_list_fonts(struct udevice *dev); |
Simon Glass | 57a847c | 2022-10-06 08:36:14 -0600 | [diff] [blame] | 396 | |
Simon Glass | 430e167 | 2022-10-06 08:36:16 -0600 | [diff] [blame] | 397 | /** |
Simon Glass | 0e38bd8 | 2023-01-06 08:52:32 -0600 | [diff] [blame] | 398 | * vidconsole_get_font_size() - get the current font name and size |
Simon Glass | 430e167 | 2022-10-06 08:36:16 -0600 | [diff] [blame] | 399 | * |
| 400 | * @dev: vidconsole device |
| 401 | * @sizep: Place to put the font size (nominal height in pixels) |
Dzmitry Sankouski | 4f6e348 | 2023-03-07 13:21:15 +0300 | [diff] [blame] | 402 | * @name: pointer to font name, a placeholder for result |
| 403 | * Return: 0 if OK, -ENOSYS if not implemented in driver |
Simon Glass | 430e167 | 2022-10-06 08:36:16 -0600 | [diff] [blame] | 404 | */ |
Dzmitry Sankouski | 4f6e348 | 2023-03-07 13:21:15 +0300 | [diff] [blame] | 405 | int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep); |
Simon Glass | 430e167 | 2022-10-06 08:36:16 -0600 | [diff] [blame] | 406 | |
Simon Glass | 8c0b5d2 | 2020-07-02 21:12:23 -0600 | [diff] [blame] | 407 | #ifdef CONFIG_VIDEO_COPY |
| 408 | /** |
| 409 | * vidconsole_sync_copy() - Sync back to the copy framebuffer |
| 410 | * |
| 411 | * This ensures that the copy framebuffer has the same data as the framebuffer |
| 412 | * for a particular region. It should be called after the framebuffer is updated |
| 413 | * |
| 414 | * @from and @to can be in either order. The region between them is synced. |
| 415 | * |
| 416 | * @dev: Vidconsole device being updated |
| 417 | * @from: Start/end address within the framebuffer (->fb) |
| 418 | * @to: Other address within the frame buffer |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 419 | * Return: 0 if OK, -EFAULT if the start address is before the start of the |
Simon Glass | 8c0b5d2 | 2020-07-02 21:12:23 -0600 | [diff] [blame] | 420 | * frame buffer start |
| 421 | */ |
| 422 | int vidconsole_sync_copy(struct udevice *dev, void *from, void *to); |
| 423 | |
| 424 | /** |
| 425 | * vidconsole_memmove() - Perform a memmove() within the frame buffer |
| 426 | * |
| 427 | * This handles a memmove(), e.g. for scrolling. It also updates the copy |
| 428 | * framebuffer. |
| 429 | * |
| 430 | * @dev: Vidconsole device being updated |
| 431 | * @dst: Destination address within the framebuffer (->fb) |
| 432 | * @src: Source address within the framebuffer (->fb) |
| 433 | * @size: Number of bytes to transfer |
Heinrich Schuchardt | 185f812 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 434 | * Return: 0 if OK, -EFAULT if the start address is before the start of the |
Simon Glass | 8c0b5d2 | 2020-07-02 21:12:23 -0600 | [diff] [blame] | 435 | * frame buffer start |
| 436 | */ |
| 437 | int vidconsole_memmove(struct udevice *dev, void *dst, const void *src, |
| 438 | int size); |
| 439 | #else |
Dzmitry Sankouski | 3154725 | 2023-03-07 13:21:11 +0300 | [diff] [blame] | 440 | |
| 441 | #include <string.h> |
| 442 | |
Simon Glass | 8c0b5d2 | 2020-07-02 21:12:23 -0600 | [diff] [blame] | 443 | static inline int vidconsole_sync_copy(struct udevice *dev, void *from, |
| 444 | void *to) |
| 445 | { |
| 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | static inline int vidconsole_memmove(struct udevice *dev, void *dst, |
| 450 | const void *src, int size) |
| 451 | { |
| 452 | memmove(dst, src, size); |
| 453 | |
| 454 | return 0; |
| 455 | } |
| 456 | |
| 457 | #endif |
| 458 | |
Heinrich Schuchardt | 5c30fbb | 2018-02-08 21:47:11 +0100 | [diff] [blame] | 459 | #endif |