For odd rotations (rot=1 and rot=3) the console rows advance along the
physical X axis by the font height (priv->y_charsize): console_move_rows()
and console_set_row() treat a row as fontdata->height physical columns.

But the scroll condition in vidconsole_newline() compared the cursor
position against the font *width* (priv->x_charsize):

    priv->ycur + priv->x_charsize > vid_priv->xsize

The condition is only met at the bottom boundary when
(xsize % font_height) < font_width. With CONFIG_VIDEO_FONT_16X32 on a
1200x1920 panel used with rot=3, xsize % 32 == 16 == font_width, so the
condition is never true at the boundary: the console fills the visible
rows and then keeps drawing past the right screen edge, corrupting the
following scanout line (and past the framebuffer allocation on the last
scanout line), with no visible scrolling.

Use priv->y_charsize in the odd-rotation branch, matching the even-
rotation branch which already correctly compares against the character
height. With this the cursor wraps back to row 0 and scrolling advances
by one row per newline as expected.

Fixes: 18a85cf7b5da ("video: Avoid starting a new line to close to the bottom")
Signed-off-by: Valentin Haudiquet <[email protected]>
---

Tested on a Kukui-Krane Lenovo IdeaPad Duet ARM Chromebook (rot=3 panel), 
while experimenting with getting U-Boot to run on that platform. 

 drivers/video/vidconsole-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/vidconsole-uclass.c 
b/drivers/video/vidconsole-uclass.c
index f1b2d61bd8f..008c8b70e08 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -95,7 +95,7 @@ static void vidconsole_newline(struct udevice *dev)
 
        /* Check if we need to scroll the terminal */
        if (vid_priv->rot % 2 ?
-           priv->ycur + priv->x_charsize > vid_priv->xsize :
+           priv->ycur + priv->y_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++)
-- 
2.53.0

Reply via email to