mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-23 09:15:36 +00:00
committed by
Christian Helmuth
parent
80104f5192
commit
eb62d9cc04
@ -20,6 +20,7 @@
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <util/xml_generator.h>
|
||||
#include <util/xml_node.h>
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
@ -31,19 +32,32 @@ struct Framebuffer_controller
|
||||
Heap heap;
|
||||
Allocator_avl fs_alloc;
|
||||
File_system::Connection fs;
|
||||
Timer::Connection timer;
|
||||
Signal_handler<Framebuffer_controller> timer_handler;
|
||||
|
||||
void update_connector_config(Xml_generator & xml, Xml_node & node);
|
||||
void update_fb_config(Xml_node & report);
|
||||
void report_changed();
|
||||
void handle_timer();
|
||||
|
||||
Framebuffer_controller(Env &env)
|
||||
: rom(env, "connectors"),
|
||||
rom_sigh(env.ep(), *this, &Framebuffer_controller::report_changed),
|
||||
heap(env.ram(), env.rm()),
|
||||
fs_alloc(&heap),
|
||||
fs(env, fs_alloc, "", "/", true, 128*1024)
|
||||
fs(env, fs_alloc, "", "/", true, 128*1024),
|
||||
timer(env),
|
||||
timer_handler(env.ep(), *this, &Framebuffer_controller::handle_timer)
|
||||
{
|
||||
Attached_rom_dataspace config(env, "config");
|
||||
unsigned long const period_ms = config.xml().attribute_value("artifical_update_ms", 0UL);
|
||||
|
||||
rom.sigh(rom_sigh);
|
||||
|
||||
if (period_ms) {
|
||||
timer.sigh(timer_handler);
|
||||
timer.trigger_periodic(period_ms * 1000 /* in us */);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -59,20 +73,25 @@ void Framebuffer_controller::update_connector_config(Xml_generator & xml,
|
||||
bool connected = node.attribute_value("connected", false);
|
||||
xml.attribute("enabled", connected ? "true" : "false");
|
||||
|
||||
unsigned long width = 0, height = 0;
|
||||
unsigned long width = 0, height = 0, hz = 0;
|
||||
node.for_each_sub_node("mode", [&] (Xml_node &mode) {
|
||||
unsigned long w, h;
|
||||
unsigned long w, h, z;
|
||||
w = mode.attribute_value<unsigned long>("width", 0);
|
||||
h = mode.attribute_value<unsigned long>("height", 0);
|
||||
if (w > width) {
|
||||
z = mode.attribute_value<unsigned long>("hz", 0);
|
||||
if (w >= width) {
|
||||
width = w;
|
||||
height = h;
|
||||
if (z > hz)
|
||||
hz = z;
|
||||
}
|
||||
});
|
||||
|
||||
if (width && height) {
|
||||
xml.attribute("width", width);
|
||||
xml.attribute("height", height);
|
||||
xml.attribute("hz", hz);
|
||||
xml.attribute("brightness", 73);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -84,6 +103,7 @@ void Framebuffer_controller::update_fb_config(Xml_node & report)
|
||||
static char buf[4096];
|
||||
|
||||
Xml_generator xml(buf, sizeof(buf), "config", [&] {
|
||||
// xml.attribute("poll", "5000");
|
||||
xml.node("report", [&] {
|
||||
xml.attribute("connectors", "yes");
|
||||
});
|
||||
@ -115,6 +135,17 @@ void Framebuffer_controller::report_changed()
|
||||
}
|
||||
|
||||
|
||||
void Framebuffer_controller::handle_timer()
|
||||
{
|
||||
if (!rom.is_valid())
|
||||
return;
|
||||
|
||||
/* artificial update */
|
||||
Xml_node report(rom.local_addr<char>(), rom.size());
|
||||
update_fb_config(report);
|
||||
}
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env)
|
||||
{
|
||||
log("--- Framebuffer controller ---\n");
|
||||
|
Reference in New Issue
Block a user