2 * Copyright (c) 2015 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
7 #ifndef __video_console_h
8 #define __video_console_h
11 * struct vidconsole_priv - uclass-private data about a console device
13 * @sdev: stdio device, acting as an output sink
14 * @curr_col: Current text column (0=left)
15 * @curr_row: Current row (0=top)
16 * @rows: Number of text rows
17 * @cols: Number of text columns
19 struct vidconsole_priv {
20 struct stdio_dev sdev;
28 * struct vidconsole_ops - Video console operations
30 * These operations work on either an absolute console position (measured
31 * in pixels) or a text row number (measured in rows, where each row consists
32 * of an entire line of text - typically 16 pixels).
34 struct vidconsole_ops {
36 * putc_xy() - write a single character to a position
38 * @dev: Device to write to
39 * @x: Pixel X position (0=left-most pixel)
40 * @y: Pixel Y position (0=top-most pixel)
41 * @ch: Character to write
42 * @return 0 if OK, -ve on error
44 int (*putc_xy)(struct udevice *dev, uint x, uint y, char ch);
47 * move_rows() - Move text rows from one place to another
49 * @dev: Device to adjust
50 * @rowdst: Destination text row (0=top)
51 * @rowsrc: Source start text row
52 * @count: Number of text rows to move
53 * @return 0 if OK, -ve on error
55 int (*move_rows)(struct udevice *dev, uint rowdst, uint rowsrc,
59 * set_row() - Set the colour of a text row
61 * Every pixel contained within the text row is adjusted
63 * @dev: Device to adjust
64 * @row: Text row to adjust (0=top)
65 * @clr: Raw colour (pixel value) to write to each pixel
66 * @return 0 if OK, -ve on error
68 int (*set_row)(struct udevice *dev, uint row, int clr);
71 /* Get a pointer to the driver operations for a video console device */
72 #define vidconsole_get_ops(dev) ((struct vidconsole_ops *)(dev)->driver->ops)
75 * vidconsole_putc_xy() - write a single character to a position
77 * @dev: Device to write to
78 * @x: Pixel X position (0=left-most pixel)
79 * @y: Pixel Y position (0=top-most pixel)
80 * @ch: Character to write
81 * @return 0 if OK, -ve on error
83 int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch);
86 * vidconsole_move_rows() - Move text rows from one place to another
88 * @dev: Device to adjust
89 * @rowdst: Destination text row (0=top)
90 * @rowsrc: Source start text row
91 * @count: Number of text rows to move
92 * @return 0 if OK, -ve on error
94 int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc,
98 * vidconsole_set_row() - Set the colour of a text row
100 * Every pixel contained within the text row is adjusted
102 * @dev: Device to adjust
103 * @row: Text row to adjust (0=top)
104 * @clr: Raw colour (pixel value) to write to each pixel
105 * @return 0 if OK, -ve on error
107 int vidconsole_set_row(struct udevice *dev, uint row, int clr);
110 * vidconsole_put_char() - Output a character to the current console position
112 * Outputs a character to the console and advances the cursor. This function
113 * handles wrapping to new lines and scrolling the console. Special
114 * characters are handled also: \n, \r, \b and \t.
116 * The device always starts with the cursor at position 0,0 (top left). It
117 * can be adjusted manually using vidconsole_position_cursor().
119 * @dev: Device to adjust
120 * @ch: Character to write
121 * @return 0 if OK, -ve on error
123 int vidconsole_put_char(struct udevice *dev, char ch);
126 * vidconsole_position_cursor() - Move the text cursor
128 * @dev: Device to adjust
129 * @col: New cursor text column
130 * @row: New cursor text row
131 * @return 0 if OK, -ve on error
133 void vidconsole_position_cursor(struct udevice *dev, unsigned col,