From f5e0ba1594e428954f2a1647b03564be1afaec4a Mon Sep 17 00:00:00 2001 From: Alexander Daichendt Date: Mon, 29 Jun 2026 20:42:23 +0200 Subject: [PATCH] make device `DrmDevice` in disable_crts --- src/backend/kms/device.rs | 6 +----- src/backend/kms/drm_helpers.rs | 16 ++++++---------- src/backend/kms/mod.rs | 9 +++------ 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/backend/kms/device.rs b/src/backend/kms/device.rs index c7a0a160..2b0e8f9d 100644 --- a/src/backend/kms/device.rs +++ b/src/backend/kms/device.rs @@ -96,7 +96,6 @@ pub struct Device { pub inner: InnerDevice, pub drm: GbmDrmOutputManager, - supports_atomic: bool, pub texture_formats: FormatSet, event_token: Option, pub socket: Option, @@ -711,7 +710,6 @@ impl Device { let (drm, notifier) = DrmDevice::new(fd.clone(), false) .with_context(|| format!("Failed to initialize drm device for: {}", path.display()))?; let dev_node = DrmNode::from_dev_id(dev)?; - let supports_atomic = drm.is_atomic(); let gbm = GbmDevice::new(fd) .with_context(|| format!("Failed to initialize GBM device for {}", path.display()))?; @@ -831,7 +829,6 @@ impl Device { active_clients, }, - supports_atomic, texture_formats, event_token: Some(token), socket, @@ -840,8 +837,7 @@ impl Device { pub fn enumerate_surfaces(&mut self) -> Result { // enumerate our outputs - let config = - drm_helpers::display_configuration(self.drm.device_mut(), self.supports_atomic)?; + let config = drm_helpers::display_configuration(self.drm.device_mut())?; let surfaces = self .inner diff --git a/src/backend/kms/drm_helpers.rs b/src/backend/kms/drm_helpers.rs index bc80b2b8..8629c9d7 100644 --- a/src/backend/kms/drm_helpers.rs +++ b/src/backend/kms/drm_helpers.rs @@ -3,6 +3,7 @@ use anyhow::{Context, Result, anyhow}; use libdisplay_info::{edid::DisplayDescriptorTag, info::Info}; use smithay::{ + backend::drm::DrmDevice, reexports::drm::control::{ AtomicCommitFlags, Device as ControlDevice, Mode, ModeFlags, PlaneType, ResourceHandle, atomic::AtomicModeReq, @@ -16,8 +17,7 @@ use smithay::{ use std::{collections::HashMap, ops::Range}; pub fn display_configuration( - device: &mut impl ControlDevice, - supports_atomic: bool, + device: &mut DrmDevice, ) -> Result>> { let res_handles = device.resource_handles()?; let connectors = res_handles.connectors(); @@ -73,7 +73,7 @@ pub fn display_configuration( } // And then cleanup - if supports_atomic { + if device.is_atomic() { let mut req = AtomicModeReq::new(); let plane_handles = device.plane_handles()?; @@ -105,24 +105,20 @@ pub fn display_configuration( let _ = device.set_cursor(*crtc, Option::<&DumbBuffer>::None); } } - disable_crtcs(device, supports_atomic, &cleanup)?; + disable_crtcs(device, &cleanup)?; Ok(map) } /// Disables the given CRTCs and detaches their connectors/planes. -pub fn disable_crtcs( - device: &mut impl ControlDevice, - supports_atomic: bool, - crtcs: &[crtc::Handle], -) -> Result<()> { +pub fn disable_crtcs(device: &mut DrmDevice, crtcs: &[crtc::Handle]) -> Result<()> { if crtcs.is_empty() { return Ok(()); } let res_handles = device.resource_handles()?; - if supports_atomic { + if device.is_atomic() { let mut req = AtomicModeReq::new(); for conn in res_handles diff --git a/src/backend/kms/mod.rs b/src/backend/kms/mod.rs index 07612790..13832da8 100644 --- a/src/backend/kms/mod.rs +++ b/src/backend/kms/mod.rs @@ -865,12 +865,9 @@ impl KmsGuard<'_> { } }); - let supports_atomic = device.drm.device().is_atomic(); - if let Err(err) = drm_helpers::disable_crtcs( - device.drm.device_mut(), - supports_atomic, - &disabled_crtcs, - ) { + if let Err(err) = + drm_helpers::disable_crtcs(device.drm.device_mut(), &disabled_crtcs) + { warn!("Failed to disable crtcs for disabled outputs: {err}"); } }