hosted: Minor corrections to the linux framebuffer driver.

* Query variable info _before_ mmaping the framebuffer
 * Sanity-check the resolution/bitdepth, and if it doens't match
   try to set it to what we want.

This is functionally a no-op.

Change-Id: I087ff81775d8f63bf7846b7fef19f6fc36c1cc84
This commit is contained in:
Solomon Peachy 2024-07-01 09:36:52 -04:00
parent 5f26f21ab2
commit e55618d07a

View file

@ -59,14 +59,21 @@ void lcd_init_device(void)
panicf("Cannot read framebuffer fixed information");
}
#if 0
/* check resolution and framebuffer size */
if(vinfo.xres != LCD_WIDTH || vinfo.yres != LCD_HEIGHT || vinfo.bits_per_pixel != LCD_DEPTH)
if(ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0)
{
panicf("Unexpected framebuffer resolution: %dx%dx%d\n", vinfo.xres,
vinfo.yres, vinfo.bits_per_pixel);
panicf("Cannot read framebuffer variable information");
}
/* Make sure we match our desired bitdepth */
if (vinfo.bits_per_pixel != LCD_DEPTH || vinfo.xres != LCD_WIDTH || vinfo.yres != LCD_HEIGHT) {
vinfo.bits_per_pixel = LCD_DEPTH;
vinfo.xres = LCD_WIDTH;
vinfo.yres = LCD_HEIGHT;
if (ioctl(fd, FBIOPUT_VSCREENINFO, &vinfo)) {
panicf("Cannot set framebuffer to %dx%dx%d",
vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);
}
}
#endif
/* Note: we use a framebuffer size of width*height*bbp. We cannot trust the
* values returned by the driver for line_length */
@ -77,11 +84,6 @@ void lcd_init_device(void)
panicf("Cannot map framebuffer");
}
if(ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0)
{
panicf("Cannot read framebuffer variable information");
}
memset(framebuffer, 0, finfo.smem_len);
#ifdef HAVE_LCD_ENABLE