mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-23 12:14:32 +08:00
video: Avoid starting a new line to close to the bottom
When starting a new text line, an assumption is made that the current vertical position is a multiple of the character height. When this is not true, characters can be written after the end of the framebuffer. This can causes crashes and strange errors from QEMU. Adjust the scrolling check when processing a newline character, to avoid any problems. Add some comments to make things a little clearer. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
52c19173df
commit
18a85cf7b5
@ -94,7 +94,9 @@ static void vidconsole_newline(struct udevice *dev)
|
||||
priv->ycur += priv->y_charsize;
|
||||
|
||||
/* Check if we need to scroll the terminal */
|
||||
if ((priv->ycur + priv->y_charsize) / priv->y_charsize > priv->rows) {
|
||||
if (vid_priv->rot % 2 ?
|
||||
priv->ycur + priv->x_charsize > vid_priv->xsize :
|
||||
priv->ycur + priv->y_charsize > vid_priv->ysize) {
|
||||
vidconsole_move_rows(dev, 0, rows, priv->rows - rows);
|
||||
for (i = 0; i < rows; i++)
|
||||
vidconsole_set_row(dev, priv->rows - i - 1,
|
||||
|
@ -78,7 +78,8 @@ enum video_format {
|
||||
*
|
||||
* @xsize: Number of pixel columns (e.g. 1366)
|
||||
* @ysize: Number of pixels rows (e.g.. 768)
|
||||
* @rot: Display rotation (0=none, 1=90 degrees clockwise, etc.)
|
||||
* @rot: Display rotation (0=none, 1=90 degrees clockwise, etc.). THis
|
||||
* does not affect @xsize and @ysize
|
||||
* @bpix: Encoded bits per pixel (enum video_log2_bpp)
|
||||
* @format: Pixel format (enum video_format)
|
||||
* @vidconsole_drv_name: Driver to use for the text console, NULL to
|
||||
|
@ -27,6 +27,14 @@ enum {
|
||||
* Drivers must set up @rows, @cols, @x_charsize, @y_charsize in their probe()
|
||||
* method. Drivers may set up @xstart_frac if desired.
|
||||
*
|
||||
* Note that these values relate to the rotated console, so that an 80x25
|
||||
* console which is rotated 90 degrees will have rows=80 and cols=25
|
||||
*
|
||||
* The xcur_frac and ycur values refer to the unrotated coordinates, that is
|
||||
* xcur_frac always advances with each character, even if its limit might be
|
||||
* vid_priv->ysize instead of vid_priv->xsize if the console is rotated 90 or
|
||||
* 270 degrees.
|
||||
*
|
||||
* @sdev: stdio device, acting as an output sink
|
||||
* @xcur_frac: Current X position, in fractional units (VID_TO_POS(x))
|
||||
* @ycur: Current Y position in pixels (0=top)
|
||||
|
Loading…
Reference in New Issue
Block a user