2013-10-09 12:50:35 +02:00
|
|
|
/*
|
|
|
|
* \brief Framebuffer driver for Exynos5 HDMI
|
|
|
|
* \author Martin Stein
|
|
|
|
* \date 2013-08-09
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Genode Labs GmbH
|
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <framebuffer_session/framebuffer_session.h>
|
|
|
|
#include <cap_session/connection.h>
|
2015-01-29 14:11:14 +01:00
|
|
|
#include <timer_session/connection.h>
|
2013-10-09 12:50:35 +02:00
|
|
|
#include <dataspace/client.h>
|
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
|
|
|
#include <base/log.h>
|
2013-10-09 12:50:35 +02:00
|
|
|
#include <base/sleep.h>
|
|
|
|
#include <os/config.h>
|
|
|
|
#include <os/static_root.h>
|
2015-04-14 13:56:26 +02:00
|
|
|
#include <os/server.h>
|
|
|
|
|
|
|
|
/* local includes */
|
|
|
|
#include <driver.h>
|
2013-10-09 12:50:35 +02:00
|
|
|
|
|
|
|
namespace Framebuffer
|
|
|
|
{
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Framebuffer session backend
|
|
|
|
*/
|
|
|
|
class Session_component;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Framebuffer::Session_component
|
|
|
|
:
|
|
|
|
public Genode::Rpc_object<Framebuffer::Session>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2014-04-29 15:32:09 +02:00
|
|
|
size_t _width;
|
|
|
|
size_t _height;
|
|
|
|
Driver::Format _format;
|
|
|
|
size_t _size;
|
|
|
|
Dataspace_capability _ds;
|
|
|
|
addr_t _phys_base;
|
2015-01-29 14:11:14 +01:00
|
|
|
Timer::Connection _timer;
|
2013-10-09 12:50:35 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* \param driver driver backend that communicates with hardware
|
|
|
|
* \param width width of framebuffer in pixel
|
|
|
|
* \param height height of framebuffer in pixel
|
|
|
|
* \param output targeted output device
|
|
|
|
*/
|
|
|
|
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)),
|
2014-06-19 16:37:31 +02:00
|
|
|
_ds(env()->ram_session()->alloc(_size, WRITE_COMBINED)),
|
2013-10-09 12:50:35 +02:00
|
|
|
_phys_base(Dataspace_client(_ds).phys_addr())
|
|
|
|
{
|
|
|
|
if (driver.init_drv(width, height, _format, output, _phys_base)) {
|
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");
|
2013-10-09 12:50:35 +02:00
|
|
|
struct Could_not_initialize_display : Exception { };
|
|
|
|
throw Could_not_initialize_display();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************
|
|
|
|
** Framebuffer::Session interface **
|
|
|
|
************************************/
|
|
|
|
|
2014-04-29 15:32:09 +02:00
|
|
|
Dataspace_capability dataspace() override { return _ds; }
|
2013-10-09 12:50:35 +02:00
|
|
|
|
2014-04-29 15:32:09 +02:00
|
|
|
Mode mode() const override
|
2013-10-09 12:50:35 +02:00
|
|
|
{
|
|
|
|
return Mode(_width, _height, _convert_format(_format));
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:32:09 +02:00
|
|
|
void mode_sigh(Genode::Signal_context_capability) override { }
|
2013-10-09 12:50:35 +02:00
|
|
|
|
2014-04-29 15:32:09 +02:00
|
|
|
void sync_sigh(Genode::Signal_context_capability sigh) override
|
|
|
|
{
|
2015-01-29 14:11:14 +01:00
|
|
|
_timer.sigh(sigh);
|
|
|
|
_timer.trigger_periodic(10*1000);
|
2014-04-29 15:32:09 +02:00
|
|
|
}
|
|
|
|
|
2015-01-29 14:11:14 +01:00
|
|
|
void refresh(int, int, int, int) override { }
|
2013-10-09 12:50:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-04-14 13:56:26 +02:00
|
|
|
struct Main
|
2013-10-09 12:50:35 +02:00
|
|
|
{
|
2015-04-14 13:56:26 +02:00
|
|
|
Server::Entrypoint &ep;
|
|
|
|
Framebuffer::Driver driver;
|
|
|
|
|
|
|
|
Main(Server::Entrypoint &ep)
|
|
|
|
: ep(ep), driver()
|
|
|
|
{
|
|
|
|
using namespace Framebuffer;
|
|
|
|
|
|
|
|
/* default config */
|
|
|
|
size_t width = 1920;
|
|
|
|
size_t height = 1080;
|
|
|
|
Driver::Output output = Driver::OUTPUT_HDMI;
|
|
|
|
|
|
|
|
/* try to read custom user config */
|
|
|
|
try {
|
|
|
|
char out[5] = { 0 };
|
|
|
|
Genode::Xml_node config_node = Genode::config()->xml_node();
|
|
|
|
config_node.attribute("width").value(&width);
|
|
|
|
config_node.attribute("height").value(&height);
|
|
|
|
config_node.attribute("output").value(out, sizeof(out));
|
|
|
|
if (!Genode::strcmp(out, "LCD")) {
|
|
|
|
output = Driver::OUTPUT_LCD;
|
|
|
|
}
|
2013-10-09 12:50:35 +02:00
|
|
|
}
|
2015-04-14 13:56:26 +02:00
|
|
|
catch (...) {
|
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
|
|
|
log("using default configuration: HDMI@", width, "x", height);
|
2015-04-14 13:56:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* let entrypoint serve the framebuffer session and root interfaces */
|
|
|
|
static Session_component fb_session(driver, width, height, output);
|
|
|
|
static Static_root<Framebuffer::Session> fb_root(ep.manage(fb_session));
|
|
|
|
|
|
|
|
/* announce service and relax */
|
|
|
|
env()->parent()->announce(ep.manage(fb_root));
|
2013-10-09 12:50:35 +02:00
|
|
|
}
|
2015-04-14 13:56:26 +02:00
|
|
|
};
|
|
|
|
|
2013-10-09 12:50:35 +02:00
|
|
|
|
2015-04-14 13:56:26 +02:00
|
|
|
/************
|
|
|
|
** Server **
|
|
|
|
************/
|
|
|
|
|
|
|
|
namespace Server {
|
2016-11-28 15:13:14 +01:00
|
|
|
char const *name() { return "fb_drv_ep"; }
|
|
|
|
size_t stack_size() { return 16*1024*sizeof(long); }
|
|
|
|
void construct(Entrypoint &ep) { static Main server(ep); }
|
2015-04-14 13:56:26 +02:00
|
|
|
}
|