2012-06-15 17:28:31 +02:00
|
|
|
/*
|
|
|
|
* \brief Frame-buffer driver for the OMAP4430 display-subsystem (HDMI)
|
|
|
|
* \author Norman Feske
|
2012-06-21 11:32:14 +02:00
|
|
|
* \date 2012-06-21
|
2012-06-15 17:28:31 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2012-2017 Genode Labs GmbH
|
2012-06-15 17:28:31 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2012-06-15 17:28:31 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
2017-01-03 14:11:15 +01:00
|
|
|
#include <base/attached_rom_dataspace.h>
|
|
|
|
#include <base/component.h>
|
|
|
|
#include <base/log.h>
|
2012-06-15 17:28:31 +02:00
|
|
|
#include <framebuffer_session/framebuffer_session.h>
|
|
|
|
#include <dataspace/client.h>
|
2014-08-14 16:46:44 +02:00
|
|
|
#include <blit/blit.h>
|
2012-10-05 17:12:20 +02:00
|
|
|
#include <os/static_root.h>
|
2017-01-03 14:11:15 +01:00
|
|
|
#include <timer_session/connection.h>
|
2012-06-15 17:28:31 +02:00
|
|
|
|
|
|
|
/* local includes */
|
2012-06-21 11:32:14 +02:00
|
|
|
#include <driver.h>
|
2012-06-15 17:28:31 +02:00
|
|
|
|
|
|
|
|
2012-06-21 11:32:14 +02:00
|
|
|
namespace Framebuffer {
|
|
|
|
using namespace Genode;
|
|
|
|
class Session_component;
|
|
|
|
};
|
2012-06-15 17:28:31 +02:00
|
|
|
|
|
|
|
|
2012-06-21 11:32:14 +02:00
|
|
|
class Framebuffer::Session_component : public Genode::Rpc_object<Framebuffer::Session>
|
|
|
|
{
|
|
|
|
private:
|
2012-06-15 17:28:31 +02:00
|
|
|
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 15:42:15 +01:00
|
|
|
/*
|
|
|
|
* Noncopyable
|
|
|
|
*/
|
|
|
|
Session_component(Session_component const &);
|
|
|
|
Session_component &operator = (Session_component const &);
|
|
|
|
|
2014-08-14 16:46:44 +02:00
|
|
|
size_t _width;
|
|
|
|
size_t _height;
|
|
|
|
bool _buffered;
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 15:42:15 +01:00
|
|
|
Mode _mode { };
|
2014-08-14 16:46:44 +02:00
|
|
|
Driver::Format _format;
|
|
|
|
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;
|
|
|
|
|
Follow practices suggested by "Effective C++"
The patch adjust the code of the base, base-<kernel>, and os repository.
To adapt existing components to fix violations of the best practices
suggested by "Effective C++" as reported by the -Weffc++ compiler
argument. The changes follow the patterns outlined below:
* A class with virtual functions can no longer publicly inherit base
classed without a vtable. The inherited object may either be moved
to a member variable, or inherited privately. The latter would be
used for classes that inherit 'List::Element' or 'Avl_node'. In order
to enable the 'List' and 'Avl_tree' to access the meta data, the
'List' must become a friend.
* Instead of adding a virtual destructor to abstract base classes,
we inherit the new 'Interface' class, which contains a virtual
destructor. This way, single-line abstract base classes can stay
as compact as they are now. The 'Interface' utility resides in
base/include/util/interface.h.
* With the new warnings enabled, all member variables must be explicitly
initialized. Basic types may be initialized with '='. All other types
are initialized with braces '{ ... }' or as class initializers. If
basic types and non-basic types appear in a row, it is nice to only
use the brace syntax (also for basic types) and align the braces.
* If a class contains pointers as members, it must now also provide a
copy constructor and assignment operator. In the most cases, one
would make them private, effectively disallowing the objects to be
copied. Unfortunately, this warning cannot be fixed be inheriting
our existing 'Noncopyable' class (the compiler fails to detect that
the inheriting class cannot be copied and still gives the error).
For now, we have to manually add declarations for both the copy
constructor and assignment operator as private class members. Those
declarations should be prepended with a comment like this:
/*
* Noncopyable
*/
Thread(Thread const &);
Thread &operator = (Thread const &);
In the future, we should revisit these places and try to replace
the pointers with references. In the presence of at least one
reference member, the compiler would no longer implicitly generate
a copy constructor. So we could remove the manual declaration.
Issue #465
2017-12-21 15:42:15 +01:00
|
|
|
Signal_context_capability _sync_sigh { };
|
2012-06-15 17:28:31 +02:00
|
|
|
|
2017-01-03 14:11:15 +01:00
|
|
|
Timer::Connection _timer;
|
|
|
|
|
2012-06-21 11:32:14 +02:00
|
|
|
/**
|
|
|
|
* Convert Driver::Format to Framebuffer::Mode::Format
|
|
|
|
*/
|
|
|
|
static Mode::Format _convert_format(Driver::Format driver_format)
|
|
|
|
{
|
|
|
|
switch (driver_format) {
|
|
|
|
case Driver::FORMAT_RGB565: return Mode::RGB565;
|
|
|
|
}
|
|
|
|
return Mode::INVALID;
|
|
|
|
}
|
2012-06-15 17:28:31 +02:00
|
|
|
|
2014-08-14 16:46:44 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-06-21 11:32:14 +02:00
|
|
|
public:
|
2012-06-15 17:28:31 +02:00
|
|
|
|
2017-01-03 14:11:15 +01:00
|
|
|
Session_component(Genode::Env &env, Driver &driver, size_t width, size_t height,
|
2014-08-14 16:46:44 +02:00
|
|
|
Driver::Output output, bool buffered)
|
|
|
|
: _width(width),
|
|
|
|
_height(height),
|
|
|
|
_buffered(buffered),
|
|
|
|
_format(Driver::FORMAT_RGB565),
|
|
|
|
_size(driver.buffer_size(width, height, _format)),
|
2017-01-03 14:11:15 +01:00
|
|
|
_bb_ds(buffered ? env.ram().alloc(_size)
|
2014-08-14 16:46:44 +02:00
|
|
|
: Genode::Ram_dataspace_capability()),
|
2017-01-03 14:11:15 +01:00
|
|
|
_bb_addr(buffered ? (void*)env.rm().attach(_bb_ds) : 0),
|
|
|
|
_fb_ds(env.ram().alloc(_size, WRITE_COMBINED)),
|
|
|
|
_fb_addr((void*)env.rm().attach(_fb_ds)),
|
|
|
|
_timer(env)
|
2012-06-21 11:32:14 +02:00
|
|
|
{
|
2014-08-14 16:46:44 +02:00
|
|
|
if (!driver.init(width, height, _format, output,
|
|
|
|
Dataspace_client(_fb_ds).phys_addr())) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
error("Could not initialize display");
|
2012-06-21 11:32:14 +02:00
|
|
|
struct Could_not_initialize_display : Exception { };
|
|
|
|
throw Could_not_initialize_display();
|
|
|
|
}
|
2017-01-03 14:11:15 +01:00
|
|
|
|
|
|
|
Genode::log("using ", width, "x", height,
|
|
|
|
output == Driver::OUTPUT_HDMI ? " HDMI" : " LCD");
|
2012-06-21 11:32:14 +02:00
|
|
|
}
|
2012-06-15 17:28:31 +02:00
|
|
|
|
2012-06-21 11:32:14 +02:00
|
|
|
/************************************
|
|
|
|
** Framebuffer::Session interface **
|
|
|
|
************************************/
|
2012-06-15 17:28:31 +02:00
|
|
|
|
2014-08-14 16:46:44 +02:00
|
|
|
Dataspace_capability dataspace() override
|
|
|
|
{
|
|
|
|
return _buffered ? _bb_ds : _fb_ds;
|
|
|
|
}
|
2012-06-15 17:28:31 +02:00
|
|
|
|
2014-04-29 15:32:09 +02:00
|
|
|
Mode mode() const override
|
2012-06-21 11:32:14 +02:00
|
|
|
{
|
2013-05-11 06:51:26 +02:00
|
|
|
return Mode(_width,
|
|
|
|
_height,
|
2012-06-21 11:32:14 +02:00
|
|
|
_convert_format(_format));
|
|
|
|
}
|
2012-06-15 17:28:31 +02:00
|
|
|
|
2014-04-29 15:32:09 +02:00
|
|
|
void mode_sigh(Genode::Signal_context_capability) override { }
|
2012-06-15 17:28:31 +02:00
|
|
|
|
2014-04-29 15:32:09 +02:00
|
|
|
void sync_sigh(Genode::Signal_context_capability sigh) override
|
|
|
|
{
|
|
|
|
_sync_sigh = sigh;
|
2017-01-03 14:11:15 +01:00
|
|
|
|
|
|
|
_timer.sigh(_sync_sigh);
|
|
|
|
_timer.trigger_periodic(10*1000);
|
2014-04-29 15:32:09 +02:00
|
|
|
}
|
|
|
|
|
2014-08-14 16:46:44 +02:00
|
|
|
void refresh(int x, int y, int w, int h) override
|
2014-04-29 15:32:09 +02:00
|
|
|
{
|
2014-08-14 16:46:44 +02:00
|
|
|
if (_buffered)
|
|
|
|
_refresh_buffered(x, y, w, h);
|
|
|
|
|
2014-04-29 15:32:09 +02:00
|
|
|
if (_sync_sigh.valid())
|
|
|
|
Signal_transmitter(_sync_sigh).submit();
|
|
|
|
}
|
2012-06-21 11:32:14 +02:00
|
|
|
};
|
2012-06-15 17:28:31 +02:00
|
|
|
|
|
|
|
|
2017-01-03 14:11:15 +01:00
|
|
|
template <typename T>
|
|
|
|
static T config_attribute(Genode::Xml_node node, char const *attr_name, T const &default_value)
|
2014-08-14 16:46:44 +02:00
|
|
|
{
|
2017-01-03 14:11:15 +01:00
|
|
|
return node.attribute_value(attr_name, default_value);
|
2014-08-14 16:46:44 +02:00
|
|
|
}
|
|
|
|
|
2017-01-03 14:11:15 +01:00
|
|
|
static Framebuffer::Driver::Output config_output(Genode::Xml_node node,
|
|
|
|
Framebuffer::Driver::Output default_value)
|
2012-06-21 11:32:14 +02:00
|
|
|
{
|
2017-01-03 14:11:15 +01:00
|
|
|
Framebuffer::Driver::Output value = default_value;
|
2012-06-15 17:28:31 +02:00
|
|
|
|
2013-05-11 06:51:26 +02:00
|
|
|
try {
|
2017-01-03 14:11:15 +01:00
|
|
|
Genode::String<8> output;
|
|
|
|
node.attribute("output").value(&output);
|
2013-05-11 06:51:26 +02:00
|
|
|
|
2017-01-03 14:11:15 +01:00
|
|
|
if (output == "LCD") { value = Framebuffer::Driver::OUTPUT_LCD; }
|
|
|
|
} catch (...) { }
|
|
|
|
|
|
|
|
return value;
|
2012-06-15 17:28:31 +02:00
|
|
|
}
|
|
|
|
|
2017-01-03 14:11:15 +01:00
|
|
|
|
|
|
|
struct Main
|
|
|
|
{
|
|
|
|
Genode::Env &_env;
|
|
|
|
Genode::Entrypoint &_ep;
|
|
|
|
|
|
|
|
Genode::Attached_rom_dataspace _config { _env, "config" };
|
|
|
|
|
|
|
|
Framebuffer::Driver _driver { _env };
|
|
|
|
|
|
|
|
Framebuffer::Session_component _fb_session { _env, _driver,
|
|
|
|
config_attribute(_config.xml(), "width", 1024u),
|
|
|
|
config_attribute(_config.xml(), "height", 768u),
|
|
|
|
config_output(_config.xml(), Framebuffer::Driver::OUTPUT_HDMI),
|
|
|
|
config_attribute(_config.xml(), "buffered", false),
|
|
|
|
};
|
|
|
|
|
|
|
|
Genode::Static_root<Framebuffer::Session> _fb_root { _ep.manage(_fb_session) };
|
|
|
|
|
|
|
|
Main(Genode::Env &env) : _env(env), _ep(_env.ep())
|
|
|
|
{
|
|
|
|
/* announce service */
|
|
|
|
_env.parent().announce(_ep.manage(_fb_root));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void Component::construct(Genode::Env &env) { static Main main(env); }
|