From 0b09cc8cf6e794a5a9a69bb740f7fd842d40cb34 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 1 Nov 2017 20:29:49 +0100 Subject: [PATCH] driver_manager: improve fb-driver selection This is a follup-up commit for "driver_manager: add fb_boot_drv support". It refines the heuristics for selecting the most suitable framebuffer driver be prevent boot_fb_drv from being preferred over the VESA driver when running in Qemu. --- repos/gems/src/app/driver_manager/main.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/repos/gems/src/app/driver_manager/main.cc b/repos/gems/src/app/driver_manager/main.cc index f0e36eceb..dfa1fabfb 100644 --- a/repos/gems/src/app/driver_manager/main.cc +++ b/repos/gems/src/app/driver_manager/main.cc @@ -163,20 +163,25 @@ struct Driver_manager::Boot_fb_driver : Device_driver struct Mode { - unsigned _width = 0, _height = 0, _bpp = 0; + enum { TYPE_RGB_COLOR = 1 }; + + unsigned _pitch = 0, _height = 0; Mode() { } Mode(Xml_node node) : - _width (node.attribute_value("width", 0U)), - _height(node.attribute_value("height", 0U)), - _bpp (node.attribute_value("bpp", 0U)) - { } + _pitch(node.attribute_value("pitch", 0U)), + _height(node.attribute_value("height", 0U)) + { + /* check for unsupported type */ + if (node.attribute_value("type", 0U) != TYPE_RGB_COLOR) + _pitch = _height = 0; + } - size_t num_bytes() const { return _width * _height * _bpp/8 + 512*1024; } + size_t num_bytes() const { return _pitch * _height + 512*1024; } - bool valid() const { return _width*_height*_bpp != 0; } + bool valid() const { return _pitch * _height != 0; } }; Boot_fb_driver(Mode const mode) : _ram_quota(Ram_quota{mode.num_bytes()}) { }