make device DrmDevice in disable_crts

This commit is contained in:
Alexander Daichendt 2026-06-29 20:42:23 +02:00 committed by Victoria Brekenfeld
parent a9f2427c00
commit f5e0ba1594
3 changed files with 10 additions and 21 deletions

View file

@ -96,7 +96,6 @@ pub struct Device {
pub inner: InnerDevice,
pub drm: GbmDrmOutputManager,
supports_atomic: bool,
pub texture_formats: FormatSet,
event_token: Option<RegistrationToken>,
pub socket: Option<Socket>,
@ -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<OutputChanges> {
// 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

View file

@ -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<HashMap<connector::Handle, Option<crtc::Handle>>> {
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

View file

@ -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}");
}
}