From 274a733e1a0395948ec73eb82e279add8b6637dc Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 22 Apr 2024 16:39:01 +0200 Subject: [PATCH] sculpt: support blanking system state The blanking state is evaluated by the intel_fb driver, which will switch off all connectors. When done, the intel_fb driver will exit and the sculpt_manager will continue with the next step, stopping all drivers. Issue #5180 --- repos/gems/src/app/sculpt_manager/driver/fb.h | 3 +- repos/gems/src/app/sculpt_manager/main.cc | 31 ++++++++++++++----- .../app/sculpt_manager/model/system_state.h | 4 ++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/repos/gems/src/app/sculpt_manager/driver/fb.h b/repos/gems/src/app/sculpt_manager/driver/fb.h index 688a678744..e8e64f12ec 100644 --- a/repos/gems/src/app/sculpt_manager/driver/fb.h +++ b/repos/gems/src/app/sculpt_manager/driver/fb.h @@ -65,7 +65,8 @@ struct Sculpt::Fb_driver : private Noncopyable gen_named_node(xml, "child", "intel_gpu"); }); gen_capture_route(xml); gen_parent_rom_route(xml, "pc_intel_fb_drv"); - gen_parent_rom_route(xml, "config", "config -> fb_drv"); + gen_parent_rom_route(xml, "config", "config -> managed/fb_drv"); + gen_parent_rom_route(xml, "system", "config -> managed/system"); gen_parent_rom_route(xml, "intel_opregion", "report -> drivers/intel_opregion"); gen_parent_route(xml); gen_common_routes(xml); diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index 5d3cad48e0..bff2f573b1 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -175,13 +175,8 @@ struct Sculpt::Main : Input_event_handler, */ void trigger_suspend() override { - _system_state.state = System_state::DRIVERS_STOPPING; + _system_state.state = System_state::BLANKING; _broadcast_system_state(); - - _driver_options.suspending = true; - _drivers.update_options(_driver_options); - - generate_runtime_config(); } /** @@ -1563,9 +1558,13 @@ struct Sculpt::Main : Input_event_handler, Managed_config
_fb_drv_config { _env, "config", "fb_drv", *this, &Main::_handle_fb_drv_config }; - void _handle_fb_drv_config(Xml_node const &) + void _handle_fb_drv_config(Xml_node const &node) { - _fb_drv_config.try_generate_manually_managed(); + _fb_drv_config.generate([&] (Xml_generator &xml) { + xml.attribute("system", "yes"); + copy_attributes(xml, node); + node.for_each_sub_node([&] (Xml_node const &sub_node) { + copy_node(xml, sub_node, { 5 }); }); }); } void _update_window_layout(Xml_node const &, Xml_node const &); @@ -1650,6 +1649,7 @@ struct Sculpt::Main : Input_event_handler, _gui.input()->sigh(_input_handler); _gui.mode_sigh(_gui_mode_handler); _handle_gui_mode(); + _fb_drv_config.trigger_update(); /* * Generate initial configurations @@ -2198,6 +2198,21 @@ void Sculpt::Main::_handle_runtime_state(Xml_node const &state) } } + { + Child_exit_state exit_state(state, "intel_fb"); + + if (exit_state.exited && _system_state.state == System_state::BLANKING) { + + _system_state.state = System_state::DRIVERS_STOPPING; + _broadcast_system_state(); + + _driver_options.suspending = true; + _drivers.update_options(_driver_options); + + reconfigure_runtime = true; + } + } + /* upgrade RAM and cap quota on demand */ state.for_each_sub_node("child", [&] (Xml_node child) { diff --git a/repos/gems/src/app/sculpt_manager/model/system_state.h b/repos/gems/src/app/sculpt_manager/model/system_state.h index c2a6df3a6d..eb64e31882 100644 --- a/repos/gems/src/app/sculpt_manager/model/system_state.h +++ b/repos/gems/src/app/sculpt_manager/model/system_state.h @@ -23,7 +23,7 @@ struct Sculpt::System_state : private Noncopyable { enum State { RUNNING, - DRIVERS_STOPPING, ACPI_SUSPENDING, SUSPENDED, ACPI_RESUMING, + BLANKING, DRIVERS_STOPPING, ACPI_SUSPENDING, SUSPENDED, ACPI_RESUMING, POWERED_OFF, RESET }; @@ -33,6 +33,7 @@ struct Sculpt::System_state : private Noncopyable { auto value = node.attribute_value("state", String<64>()); + if (value == "blanking") return State::BLANKING; if (value == "driver_stop") return State::DRIVERS_STOPPING; if (value == "s3_prepare") return State::ACPI_SUSPENDING; if (value == "suspend") return State::SUSPENDED; @@ -47,6 +48,7 @@ struct Sculpt::System_state : private Noncopyable { switch (state) { case RUNNING: break; + case BLANKING: return "blanking"; case DRIVERS_STOPPING: return "driver_stop"; case ACPI_SUSPENDING: return "s3_prepare"; case SUSPENDED: return "suspend";