From 77875f71c65bd895fe9caab2d9fc75298a4352a8 Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Sun, 26 Apr 2020 13:51:21 +0200 Subject: [PATCH] fallback: add disable_connectors to `FallbackDevice` initialization --- src/backend/drm/common/fallback.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/backend/drm/common/fallback.rs b/src/backend/drm/common/fallback.rs index 69679a9..eebb38b 100644 --- a/src/backend/drm/common/fallback.rs +++ b/src/backend/drm/common/fallback.rs @@ -150,19 +150,35 @@ pub enum FallbackSurface { impl FallbackDevice, LegacyDrmDevice> { /// Try to initialize an [`AtomicDrmDevice`](::backend::drm:;atomic::AtomicDrmDevice) /// and fall back to a [`LegacyDrmDevice`] if atomic-modesetting is not supported. - pub fn new(fd: A, logger: L) -> Result + /// + /// # Arguments + /// + /// - `fd` - Open drm node (needs to be clonable to be passed to multiple initializers) + /// - `disable_connectors` - Setting this to true will initialize all connectors \ + /// as disabled on device creation. smithay enables connectors, when attached \ + /// to a surface, and disables them, when detached. Setting this to `false` \ + /// requires usage of `drm-rs` to disable unused connectors to prevent them \ + /// showing garbage, but will also prevent flickering of already turned on \ + /// connectors (assuming you won't change the resolution). + /// - `logger` - Optional [`slog::Logger`] to be used by the resulting device. + /// + /// # Return + /// + /// Returns an error, if both devices fail to initialize due to `fd` being no valid + /// drm node or the device being not accessible. + pub fn new(fd: A, disable_connectors: bool, logger: L) -> Result where L: Into>, { let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_drm_fallback")); info!(log, "Trying to initialize AtomicDrmDevice"); - match AtomicDrmDevice::new(fd.clone(), log.clone()) { + match AtomicDrmDevice::new(fd.clone(), disable_connectors, log.clone()) { Ok(dev) => Ok(FallbackDevice::Preference(dev)), Err(err) => { error!(log, "Failed to initialize preferred AtomicDrmDevice: {}", err); info!(log, "Falling back to fallback LegacyyDrmDevice"); - Ok(FallbackDevice::Fallback(LegacyDrmDevice::new(fd, log)?)) + Ok(FallbackDevice::Fallback(LegacyDrmDevice::new(fd, disable_connectors, log)?)) } } }