Hi Petr,

On 2026-10-02T21:19:31, Petr Hodina via B4 Relay
<[email protected]> wrote:
> 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.
>
> Step per scanline by line_length instead matching the glyph renderer.
>
> Signed-off-by: Petr Hodina <[email protected]>
>
> drivers/video/console_normal.c | 16 +++++++++-------
>  drivers/video/console_rotate.c | 16 +++++++++-------
>  2 files changed, 18 insertions(+), 14 deletions(-)

> diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
> @@ -29,11 +28,14 @@ static int console_set_row(struct udevice *dev, uint row, 
> int clr)
> +     for (j = 0; j < fontdata->height; j++) {
> +             dst = line;
> +             for (i = 0; i < vid_priv->xsize; i++)
> +                     fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes);
> +             line += vid_priv->line_length;
> +     }

The old loop writes height * xsize pixels contiguously, so with a
padded stride it runs into the padding and stops short of the last
scanlines of the row.

BTW video_fill_part() already does a stride-aware fill and calls
video_damage(), so this could become something like:

    return video_fill_part(dev->parent, 0, row * fontdata->height,
                           vid_priv->xsize,
                           (row + 1) * fontdata->height, clr);

That avoids open-coding the same loop here and in console_set_row_2().
It returns -ENOSYS for an unsupported bpix, so the
check_bpix_support() call could go too. What do you think? I am OK
with the patch as it is, if you prefer.

> diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c
> @@ -112,18 +112,20 @@ static int console_set_row_2(struct udevice *dev, uint 
> row, int clr)
> +     void *start, *line, *dst;
> +     int i, j;
>       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;

Since you are changing this, start is no longer needed. You could
assign to line directly, as console_set_row() does.

Reviewed-by: Simon Glass <[email protected]>

Regards,
Simon

Reply via email to