From 85744a8308338a8691f67b93448b2a26603f1420 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Thu, 14 Aug 2014 16:46:44 +0200 Subject: [PATCH] fb_drv: implement 'buffered' mode for OMAP4 Fixes #1228. --- .../os/src/drivers/framebuffer/omap4/main.cc | 89 +++++++++++++++---- .../src/drivers/framebuffer/omap4/target.mk | 2 +- 2 files changed, 72 insertions(+), 19 deletions(-) diff --git a/repos/os/src/drivers/framebuffer/omap4/main.cc b/repos/os/src/drivers/framebuffer/omap4/main.cc index fbcdac9b4..1ddb3da37 100644 --- a/repos/os/src/drivers/framebuffer/omap4/main.cc +++ b/repos/os/src/drivers/framebuffer/omap4/main.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -34,12 +35,21 @@ class Framebuffer::Session_component : public Genode::Rpc_object x2 || y1 > y2) return; + + int bypp = _mode.bytes_per_pixel(); + + /* copy pixels from back buffer to physical frame buffer */ + char *src = (char *)_bb_addr + bypp*(_mode.width()*y1 + x1), + *dst = (char *)_fb_addr + bypp*(_mode.width()*y1 + x1); + + blit(src, bypp*_mode.width(), dst, bypp*_mode.width(), + bypp*(x2 - x1 + 1), y2 - y1 + 1); + } + public: Session_component(Driver &driver, size_t width, size_t height, - Driver::Output output) - : - _width(width), - _height(height), - _format(Driver::FORMAT_RGB565), - _size(driver.buffer_size(width, height, _format)), - _ds(env()->ram_session()->alloc(_size, WRITE_COMBINED)), - _phys_base(Dataspace_client(_ds).phys_addr()) + Driver::Output output, bool buffered) + : _width(width), + _height(height), + _buffered(buffered), + _format(Driver::FORMAT_RGB565), + _size(driver.buffer_size(width, height, _format)), + _bb_ds(buffered ? Genode::env()->ram_session()->alloc(_size) + : Genode::Ram_dataspace_capability()), + _bb_addr(buffered ? (void*)Genode::env()->rm_session()->attach(_bb_ds) : 0), + _fb_ds(Genode::env()->ram_session()->alloc(_size, WRITE_COMBINED)), + _fb_addr((void*)Genode::env()->rm_session()->attach(_fb_ds)) { - if (!driver.init(width, height, _format, output, _phys_base)) { + if (!driver.init(width, height, _format, output, + Dataspace_client(_fb_ds).phys_addr())) { PERR("Could not initialize display"); struct Could_not_initialize_display : Exception { }; throw Could_not_initialize_display(); @@ -76,7 +111,10 @@ class Framebuffer::Session_component : public Genode::Rpc_objectxml_node().attribute(attr_name).has_value("yes"); } + catch (...) {} + return result; +} + + int main(int, char **) { using namespace Framebuffer; @@ -133,7 +185,8 @@ int main(int, char **) /* * Let the entry point serve the framebuffer session and root interfaces */ - static Session_component fb_session(driver, width, height, output); + static Session_component fb_session(driver, width, height, output, + config_attribute("buffered")); static Static_root fb_root(ep.manage(&fb_session)); /* diff --git a/repos/os/src/drivers/framebuffer/omap4/target.mk b/repos/os/src/drivers/framebuffer/omap4/target.mk index 820e84014..25e306b47 100644 --- a/repos/os/src/drivers/framebuffer/omap4/target.mk +++ b/repos/os/src/drivers/framebuffer/omap4/target.mk @@ -7,7 +7,7 @@ TARGET = fb_drv REQUIRES = omap4 SRC_CC = main.cc -LIBS = base config +LIBS = base blit config INC_DIR += $(PRG_DIR) vpath main.cc $(PRG_DIR)