From 9f92ecf761a190c162a7f55e1525e4e070a6605b Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Mon, 11 Apr 2022 21:46:49 +0100 Subject: [PATCH] Fix the remapping of the screen frame buffer. The size of the region to be mapped is determined by the buffer stride, not the pixel width. --- system/screen.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/system/screen.c b/system/screen.c index 4dda81a..93b2b76 100644 --- a/system/screen.c +++ b/system/screen.c @@ -195,11 +195,16 @@ void screen_init(void) // Clip the framebuffer size to make sure we can map it into the 0.5GB device region. // This will produce a garbled display, but that's better than nothing. - if (lfb_width > 8192) lfb_width = 8192; + if (lfb_stride > 32768) { + lfb_stride = 32768; + if (lfb_width > (lfb_stride / lfb_bytes_per_pixel)) { + lfb_width = (lfb_stride / lfb_bytes_per_pixel); + } + } if (lfb_height > 8192) lfb_height = 8192; // The above clipping should guarantee the mapping never fails. - lfb_base = map_region(lfb_base, lfb_height * lfb_width * lfb_bytes_per_pixel, false); + lfb_base = map_region(lfb_base, lfb_height * lfb_stride, false); // Blank the whole framebuffer. int pixels_per_word = sizeof(uint32_t) / lfb_bytes_per_pixel;