Skip to contentSkip to conversation

video: console: clear rows stride-aware in set_row

PATCH In review Petr Hodina 3 participants 3 messages Oct 4 – Oct 22 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 video: console: clear rows stride-aware in set_row

console_set_row() and console_set_row_2() clear a row with a single contiguous fill assuming line_length == xsize * pbytes. A stride-padded framebuffer inherited from a prior boot stage (e.g. via simple-framebuffer) breaks that assumption leaving stale pixels after scroll.

Use video_fill_part() which already steps per scanline by line_length.

---
Found while testing the scrollback viewer against a stride-padded splash framebuffer inherited via simple-framebuffer.

console_set_row() and console_set_row_2() clear rows assuming
line_length == xsize * pbytes. Fix them to step per scanline by
line_length instead.
---
Changes in v2:
- Switch to video_fill_part() which already handles stride
- Link to v1: https://patch.msgid.link/20261002-b4-framebuffer-stride-fix-v1-1-4a8498416b01@protonmail.com

To: [email protected]
Cc: Anatolij Gustschin <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Petr Hodina <[email protected]>

---
 drivers/video/console_normal.c | 26 +++-----------------------
 drivers/video/console_rotate.c | 23 ++++-------------------
 2 files changed, 7 insertions(+), 42 deletions(-)
drivers/video/console_normal.c +3 -23
index 07db613ac53..9a3d08aad02 100644
@@ -18,30 +18,10 @@ static int console_set_row(struct udevice *dev, uint row, int clr)
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 	struct console_simple_priv *priv = dev_get_priv(dev);
 	struct video_fontdata *fontdata = priv->fontdata;
-	void *line, *dst, *end;
-	int pixels = fontdata->height * vid_priv->xsize;
-	int ret;
-	int i;
-	int pbytes;
 
-	ret = check_bpix_support(vid_priv->bpix);
-	if (ret)
-		return ret;
-
-	line = vid_priv->fb + row * fontdata->height * vid_priv->line_length;
-	dst = line;
-	pbytes = VNBYTES(vid_priv->bpix);
-	for (i = 0; i < pixels; i++)
-		fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes);
-	end = dst;
-
-	video_damage(dev->parent,
-		     0,
-		     fontdata->height * row,
-		     vid_priv->xsize,
-		     fontdata->height);
-
-	return 0;
+	return video_fill_part(dev->parent, 0, row * fontdata->height,
+				vid_priv->xsize,
+				(row + 1) * fontdata->height, clr);
 }
 
 static int console_move_rows(struct udevice *dev, uint rowdst,
drivers/video/console_rotate.c +4 -19
index 886b25dcfaf..6feacd43b6c 100644
@@ -112,26 +112,11 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 	struct console_simple_priv *priv = dev_get_priv(dev);
 	struct video_fontdata *fontdata = priv->fontdata;
-	void *start, *line, *dst, *end;
-	int pixels = fontdata->height * vid_priv->xsize;
-	int i;
-	int pbytes = VNBYTES(vid_priv->bpix);
-
-	start = vid_priv->fb + vid_priv->ysize * vid_priv->line_length -
-		(row + 1) * fontdata->height * vid_priv->line_length;
-	line = start;
-	dst = line;
-	for (i = 0; i < pixels; i++)
-		fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes);
-	end = dst;
 
-	video_damage(dev->parent,
-		     0,
-		     vid_priv->ysize - (row + 1) * fontdata->height,
-		     vid_priv->xsize,
-		     fontdata->height);
-
-	return 0;
+	return video_fill_part(dev->parent, 0,
+				vid_priv->ysize - (row + 1) * fontdata->height,
+				vid_priv->xsize,
+				vid_priv->ysize - row * fontdata->height, clr);
 }
 
 static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc,

---
base-commit: ece349ade2973e220f524ce59e59711cc919263f
change-id: 20261002-b4-framebuffer-stride-fix-67c1d7d981e9

Best regards,

Signature · 1 line
Petr Hodina <[email protected]>
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · On 2026-10-04T19:47:24, Petr Hodina via B4 Relay…

video: console: clear rows stride-aware in set_row

console_set_row() and console_set_row_2() clear a row with a single contiguous fill assuming line_length == xsize * pbytes. A stride-padded framebuffer inherited from a prior boot stage (e.g. via simple-framebuffer) breaks that assumption leaving stale pixels after scroll.

Quoted 8 lines

Use video_fill_part() which already steps per scanline by line_length.

drivers/video/console_normal.c | 26 +++-----------------------

 drivers/video/console_rotate.c | 23 ++++-------------------
 2 files changed, 7 insertions(+), 42 deletions(-)
#2 lore raw
In reply to Petr Hodina
Quoted 10 lines · Petr Hodina

console_set_row() and console_set_row_2() clear a row with a single contiguous fill assuming line_length == xsize * pbytes. A stride-padded framebuffer inherited from a prior boot stage (e.g. via simple-framebuffer) breaks that assumption leaving stale pixels after scroll.

Use video_fill_part() which already steps per scanline by line_length.

[...]

Applied to u-boot/main, thanks!

[1/1] video: console: clear rows stride-aware in set_row

      commit: e16958bc076d842df20c8ea96d9fbec479e54459
Signature · 1 line
Tom