Skip to content

Commit

Permalink
platforms/atomic-kms: Release resources of disconnected outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
RAOF committed Oct 25, 2024
1 parent 75910a6 commit 130bb1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/platforms/atomic-kms/server/kms/atomic_kms_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,13 @@ bool mga::AtomicKMSOutput::has_crtc_mismatch()
void mga::AtomicKMSOutput::clear_crtc()
{
auto conf = configuration.lock();
try
{
ensure_crtc(*conf);
}
catch (...)
if (!conf->current_crtc)
{
/*
* In order to actually clear the output, we need to have a crtc
* connected to the output/connector so that we can disconnect
* it. However, not being able to get a crtc is OK, since it means
* that the output cannot be displaying anything anyway.
* it. However, if we don't have a current CRTC then we're obviously
* not displaying anything anyway.
*/
return;
}
Expand Down
15 changes: 13 additions & 2 deletions src/platforms/atomic-kms/server/kms/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ void mga::Display::clear_connected_unused_outputs()
{
current_display_configuration.for_each_output([&](DisplayConfigurationOutput const& conf_output)
{
auto kms_output = current_display_configuration.get_output_for(conf_output.id);

/*
* An output may be unused either because it's explicitly not used
* (DisplayConfigurationOutput::used) or because its power mode is
Expand All @@ -270,12 +272,21 @@ void mga::Display::clear_connected_unused_outputs()
if (conf_output.connected &&
(!conf_output.used || (conf_output.power_mode != mir_power_mode_on)))
{
auto kms_output = current_display_configuration.get_output_for(conf_output.id);

kms_output->clear_crtc();
kms_output->set_power_mode(conf_output.power_mode);
kms_output->set_gamma(conf_output.gamma);
}
/*
* If the output is no longer connected, we may still have associated resources
* with it.
*
* Clear those resources.
*/
if (!conf_output.connected)
{
// clear_crtc() is a no-op if there isn't an existing CRTC & we can't find one.
kms_output->clear_crtc();
}
});
}

Expand Down

0 comments on commit 130bb1b

Please sign in to comment.