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.
This commit is contained in:
Martin Whitaker 2022-04-11 21:46:49 +01:00
parent 84a54ca083
commit 9f92ecf761
1 changed files with 7 additions and 2 deletions

View File

@ -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;