parent
5abca43688
commit
85744a8308
|
@ -17,6 +17,7 @@
|
||||||
#include <dataspace/client.h>
|
#include <dataspace/client.h>
|
||||||
#include <base/printf.h>
|
#include <base/printf.h>
|
||||||
#include <base/sleep.h>
|
#include <base/sleep.h>
|
||||||
|
#include <blit/blit.h>
|
||||||
#include <os/config.h>
|
#include <os/config.h>
|
||||||
#include <os/static_root.h>
|
#include <os/static_root.h>
|
||||||
|
|
||||||
|
@ -34,12 +35,21 @@ class Framebuffer::Session_component : public Genode::Rpc_object<Framebuffer::Se
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
size_t _width;
|
size_t _width;
|
||||||
size_t _height;
|
size_t _height;
|
||||||
Driver::Format _format;
|
bool _buffered;
|
||||||
size_t _size;
|
Mode _mode;
|
||||||
Dataspace_capability _ds;
|
Driver::Format _format;
|
||||||
addr_t _phys_base;
|
size_t _size;
|
||||||
|
|
||||||
|
/* dataspace uses a back buffer (if '_buffered' is true) */
|
||||||
|
Genode::Dataspace_capability _bb_ds;
|
||||||
|
void *_bb_addr;
|
||||||
|
|
||||||
|
/* dataspace of physical frame buffer */
|
||||||
|
Genode::Dataspace_capability _fb_ds;
|
||||||
|
void *_fb_addr;
|
||||||
|
|
||||||
Signal_context_capability _sync_sigh;
|
Signal_context_capability _sync_sigh;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,19 +63,44 @@ class Framebuffer::Session_component : public Genode::Rpc_object<Framebuffer::Se
|
||||||
return Mode::INVALID;
|
return Mode::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _refresh_buffered(int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
Mode _mode = mode();
|
||||||
|
|
||||||
|
/* clip specified coordinates against screen boundaries */
|
||||||
|
int x2 = min(x + w - 1, (int)_mode.width() - 1),
|
||||||
|
y2 = min(y + h - 1, (int)_mode.height() - 1);
|
||||||
|
int x1 = max(x, 0),
|
||||||
|
y1 = max(y, 0);
|
||||||
|
if (x1 > 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:
|
public:
|
||||||
|
|
||||||
Session_component(Driver &driver, size_t width, size_t height,
|
Session_component(Driver &driver, size_t width, size_t height,
|
||||||
Driver::Output output)
|
Driver::Output output, bool buffered)
|
||||||
:
|
: _width(width),
|
||||||
_width(width),
|
_height(height),
|
||||||
_height(height),
|
_buffered(buffered),
|
||||||
_format(Driver::FORMAT_RGB565),
|
_format(Driver::FORMAT_RGB565),
|
||||||
_size(driver.buffer_size(width, height, _format)),
|
_size(driver.buffer_size(width, height, _format)),
|
||||||
_ds(env()->ram_session()->alloc(_size, WRITE_COMBINED)),
|
_bb_ds(buffered ? Genode::env()->ram_session()->alloc(_size)
|
||||||
_phys_base(Dataspace_client(_ds).phys_addr())
|
: 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");
|
PERR("Could not initialize display");
|
||||||
struct Could_not_initialize_display : Exception { };
|
struct Could_not_initialize_display : Exception { };
|
||||||
throw Could_not_initialize_display();
|
throw Could_not_initialize_display();
|
||||||
|
@ -76,7 +111,10 @@ class Framebuffer::Session_component : public Genode::Rpc_object<Framebuffer::Se
|
||||||
** Framebuffer::Session interface **
|
** Framebuffer::Session interface **
|
||||||
************************************/
|
************************************/
|
||||||
|
|
||||||
Dataspace_capability dataspace() override { return _ds; }
|
Dataspace_capability dataspace() override
|
||||||
|
{
|
||||||
|
return _buffered ? _bb_ds : _fb_ds;
|
||||||
|
}
|
||||||
|
|
||||||
Mode mode() const override
|
Mode mode() const override
|
||||||
{
|
{
|
||||||
|
@ -92,14 +130,28 @@ class Framebuffer::Session_component : public Genode::Rpc_object<Framebuffer::Se
|
||||||
_sync_sigh = sigh;
|
_sync_sigh = sigh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh(int, int, int, int) override
|
void refresh(int x, int y, int w, int h) override
|
||||||
{
|
{
|
||||||
|
if (_buffered)
|
||||||
|
_refresh_buffered(x, y, w, h);
|
||||||
|
|
||||||
if (_sync_sigh.valid())
|
if (_sync_sigh.valid())
|
||||||
Signal_transmitter(_sync_sigh).submit();
|
Signal_transmitter(_sync_sigh).submit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static bool config_attribute(const char *attr_name)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
try {
|
||||||
|
result =
|
||||||
|
Genode::config()->xml_node().attribute(attr_name).has_value("yes"); }
|
||||||
|
catch (...) {}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int, char **)
|
int main(int, char **)
|
||||||
{
|
{
|
||||||
using namespace Framebuffer;
|
using namespace Framebuffer;
|
||||||
|
@ -133,7 +185,8 @@ int main(int, char **)
|
||||||
/*
|
/*
|
||||||
* Let the entry point serve the framebuffer session and root interfaces
|
* 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<Framebuffer::Session> fb_root(ep.manage(&fb_session));
|
static Static_root<Framebuffer::Session> fb_root(ep.manage(&fb_session));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
TARGET = fb_drv
|
TARGET = fb_drv
|
||||||
REQUIRES = omap4
|
REQUIRES = omap4
|
||||||
SRC_CC = main.cc
|
SRC_CC = main.cc
|
||||||
LIBS = base config
|
LIBS = base blit config
|
||||||
INC_DIR += $(PRG_DIR)
|
INC_DIR += $(PRG_DIR)
|
||||||
|
|
||||||
vpath main.cc $(PRG_DIR)
|
vpath main.cc $(PRG_DIR)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user