Skip to content

Commit

Permalink
platforms/atomic-kms: Release resources for disconnected outputs.
Browse files Browse the repository at this point in the history
Otherwise we *can* be in a position where hardware resources are bound to
a disconnected output, preventing them being used if a display is plugged
in to a different connector.
  • Loading branch information
RAOF committed Nov 7, 2024
1 parent 3aae8bb commit 5efbaef
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/platforms/atomic-kms/server/kms/atomic_kms_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,24 @@ void mga::AtomicKMSOutput::reset()
{
conf->connector = resources.connector(conf->connector->connector_id);
conf->connector_props = std::make_unique<mgk::ObjectProperties>(drm_fd_, conf->connector);

if (conf->current_crtc && (conf->connector->connection != DRM_MODE_CONNECTED))
{
AtomicUpdate update;
update.add_property(*conf->connector_props, "CRTC_ID", 0);
update.add_property(*conf->crtc_props, "ACTIVE", 0);
update.add_property(*conf->crtc_props, "MODE_ID", 0);
update.add_property(*conf->plane_props, "FB_ID", 0);
update.add_property(*conf->plane_props, "CRTC_ID", 0);

if (auto err = drmModeAtomicCommit(drm_fd(), update, DRM_MODE_ATOMIC_ALLOW_MODESET, nullptr))
{
mir::log_warning("Failed release resources for disconnected output: %s (%i)", strerror(-err), -err);
}

conf->crtc_props = nullptr;
conf->plane_props = nullptr;
}
}
catch (std::exception const& e)
{
Expand Down

0 comments on commit 5efbaef

Please sign in to comment.