Replace server/acpi_input with app/acpi_event

Fixes #3827
This commit is contained in:
Norman Feske 2020-08-13 12:06:55 +02:00
parent 19690193a4
commit 9e42a9ac7e
4 changed files with 53 additions and 69 deletions

View File

@ -12,12 +12,12 @@ if {
set build_components {
core init timer
drivers/input
server/acpi_input
server/dynamic_rom
server/event_filter
server/report_rom
server/event_dump
app/acpica
app/acpi_event
app/input_event_client
}
@ -96,11 +96,11 @@ append config {
</provides>
<config verbose="yes">
<policy label="platform_drv -> acpi_ready" report="acpica -> acpi_ready"/>
<policy label="acpi_input -> acpi_ac" report="acpica -> acpi_ac"/>
<policy label="acpi_input -> acpi_battery" report="acpica -> acpi_battery"/>
<policy label="acpi_input -> acpi_ec" report="acpica -> acpi_ec"/>
<policy label="acpi_input -> acpi_fixed" report="acpica -> acpi_fixed"/>
<policy label="acpi_input -> acpi_lid" report="acpica -> acpi_lid"/>
<policy label="acpi_event -> acpi_ac" report="acpica -> acpi_ac"/>
<policy label="acpi_event -> acpi_battery" report="acpica -> acpi_battery"/>
<policy label="acpi_event -> acpi_ec" report="acpica -> acpi_ec"/>
<policy label="acpi_event -> acpi_fixed" report="acpica -> acpi_fixed"/>
<policy label="acpi_event -> acpi_lid" report="acpica -> acpi_lid"/>
</config>
<route>
<any-service> <parent/> </any-service>
@ -183,20 +183,8 @@ append config {
</start>}
append config {
<start name="acpi" caps="90">
<start name="acpi_event">
<resource name="RAM" quantum="1M"/>
<binary name="input_event_client"/>
<config/>
<route>
<service name="Event"> <child name="event_filter" label="acpi"/> </service>
<service name="Input"> <child name="acpi_input"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
<start name="acpi_input">
<resource name="RAM" quantum="1M"/>
<provides><service name="Input"/></provides>
<config>
<!-- example mapping - adapt to your target notebook !!! -->
<!-- as="PRESS_RELEASE" is default if nothing specified -->
@ -211,11 +199,12 @@ append config {
<map acpi="battery" value="0" to_key="KEY_BATTERY"/>
</config>
<route>
<service name="ROM" label="acpi_ac"> <child name="acpi_state"/> </service>
<service name="ROM" label="acpi_ac"> <child name="acpi_state"/> </service>
<service name="ROM" label="acpi_battery"> <child name="acpi_state"/> </service>
<service name="ROM" label="acpi_ec"> <child name="acpi_state"/> </service>
<service name="ROM" label="acpi_fixed"> <child name="acpi_state"/> </service>
<service name="ROM" label="acpi_lid"> <child name="acpi_state"/> </service>
<service name="ROM" label="acpi_ec"> <child name="acpi_state"/> </service>
<service name="ROM" label="acpi_fixed"> <child name="acpi_state"/> </service>
<service name="ROM" label="acpi_lid"> <child name="acpi_state"/> </service>
<service name="Event"> <child name="event_filter" label="acpi"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>}
@ -237,7 +226,7 @@ set boot_modules {
report_rom
dynamic_rom
acpica
acpi_input
acpi_event
event_dump
input_event_client
}

View File

@ -16,23 +16,21 @@
#include <base/component.h>
#include <base/log.h>
#include <base/heap.h>
#include <base/attached_rom_dataspace.h>
#include <util/avl_tree.h>
/* os includes */
#include <input/component.h>
#include <input/root.h>
#include <base/attached_rom_dataspace.h>
#include <event_session/connection.h>
namespace Transform {
using Genode::Xml_node;
using Genode::String;
using namespace Genode;
struct Main;
class Keys;
};
class Transform::Keys : public Genode::Avl_node<Transform::Keys> {
class Transform::Keys : public Avl_node<Transform::Keys> {
public:
@ -46,8 +44,8 @@ class Transform::Keys : public Genode::Avl_node<Transform::Keys> {
bool _first = true;
Type _type;
static Genode::Avl_tree<Keys> _map_ec;
static Genode::Avl_tree<Keys> _map_special;
static Avl_tree<Keys> _map_ec;
static Avl_tree<Keys> _map_special;
Keys *_find_by_acpi_value(long acpi_value)
{
@ -65,7 +63,7 @@ class Transform::Keys : public Genode::Avl_node<Transform::Keys> {
bool higher(Keys *k) const { return k->_acpi_value > _acpi_value; }
Type const type() { return _type; }
Type type() const { return _type; }
unsigned long update_count(unsigned long acpi_count)
{
@ -120,25 +118,24 @@ struct Transform::Main {
ACPI_AC_ONLINE, ACPI_AC_OFFLINE, ACPI_BATTERY
};
Genode::Heap _heap;
Heap _heap;
Genode::Attached_rom_dataspace _config;
Genode::Attached_rom_dataspace _acpi_ac;
Genode::Attached_rom_dataspace _acpi_battery;
Genode::Attached_rom_dataspace _acpi_ec;
Genode::Attached_rom_dataspace _acpi_fixed;
Genode::Attached_rom_dataspace _acpi_lid;
Attached_rom_dataspace _config;
Attached_rom_dataspace _acpi_ac;
Attached_rom_dataspace _acpi_battery;
Attached_rom_dataspace _acpi_ec;
Attached_rom_dataspace _acpi_fixed;
Attached_rom_dataspace _acpi_lid;
Genode::Signal_handler<Main> _dispatch_acpi_ac;
Genode::Signal_handler<Main> _dispatch_acpi_battery;
Genode::Signal_handler<Main> _dispatch_acpi_ec;
Genode::Signal_handler<Main> _dispatch_acpi_fixed;
Genode::Signal_handler<Main> _dispatch_acpi_lid;
Signal_handler<Main> _dispatch_acpi_ac;
Signal_handler<Main> _dispatch_acpi_battery;
Signal_handler<Main> _dispatch_acpi_ec;
Signal_handler<Main> _dispatch_acpi_fixed;
Signal_handler<Main> _dispatch_acpi_lid;
Input::Session_component _session;
Input::Root_component _root;
Event::Connection _event;
Main(Genode::Env &env)
Main(Env &env)
:
_heap(env.ram(), env.rm()),
_config(env, "config"),
@ -152,18 +149,17 @@ struct Transform::Main {
_dispatch_acpi_ec(env.ep(), *this, &Main::check_acpi_ec),
_dispatch_acpi_fixed(env.ep(), *this, &Main::check_acpi_fixed),
_dispatch_acpi_lid(env.ep(), *this, &Main::check_acpi_lid),
_session(env, env.ram()),
_root(env.ep().rpc_ep(), _session)
_event(env)
{
Xml_node config(_config.local_addr<char>(), _config.size());
config.for_each_sub_node("map", [&] (Xml_node map_node) {
try {
long acpi_value = 0;
Genode::String<8> acpi_type;
Genode::String<8> acpi_value_string;
Genode::String<32> to_key;
String<8> acpi_type;
String<8> acpi_value_string;
String<32> to_key;
Genode::String<16> key_type("PRESS_RELEASE");
String<16> key_type("PRESS_RELEASE");
Keys::Type press_release = Keys::Type::PRESS_RELEASE;
map_node.attribute("acpi").value(acpi_type);
@ -257,8 +253,6 @@ struct Transform::Main {
_acpi_fixed.sigh(_dispatch_acpi_fixed);
_acpi_lid.sigh(_dispatch_acpi_lid);
env.parent().announce(env.ep().manage(_root));
/* check for initial valid ACPI data */
check_acpi_ac();
check_acpi_battery();
@ -299,16 +293,19 @@ struct Transform::Main {
void submit_input(Keys * key)
{
if (!key)
return;
_event.with_batch([&] (Event::Session_client::Batch &batch) {
if (key->type() == Keys::Type::PRESS_RELEASE ||
key->type() == Keys::Type::PRESS)
_session.submit(Input::Press{key->key_code()});
if (!key)
return;
if (key->type() == Keys::Type::PRESS_RELEASE ||
key->type() == Keys::Type::RELEASE)
_session.submit(Input::Release{key->key_code()});
if (key->type() == Keys::Type::PRESS_RELEASE ||
key->type() == Keys::Type::PRESS)
batch.submit(Input::Press{key->key_code()});
if (key->type() == Keys::Type::PRESS_RELEASE ||
key->type() == Keys::Type::RELEASE)
batch.submit(Input::Release{key->key_code()});
});
}
void check_acpi_fixed()

View File

@ -0,0 +1,3 @@
TARGET = acpi_event
SRC_CC = main.cc
LIBS = base

View File

@ -1,5 +0,0 @@
TARGET = acpi_input
SRC_CC = main.cc
LIBS = base
CC_CXX_WARN_STRICT =