From e55618d07a62dc64f1b4cf236f23c59dacf17e30 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Mon, 1 Jul 2024 09:36:52 -0400 Subject: 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 --- firmware/target/hosted/lcd-linuxfb.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/firmware/target/hosted/lcd-linuxfb.c b/firmware/target/hosted/lcd-linuxfb.c index 14c8c30f89..5dda5cf1cc 100644 --- a/firmware/target/hosted/lcd-linuxfb.c +++ b/firmware/target/hosted/lcd-linuxfb.c @@ -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 -- cgit v1.2.3