make device DrmDevice in disable_crts
This commit is contained in:
parent
a9f2427c00
commit
f5e0ba1594
3 changed files with 10 additions and 21 deletions
|
|
@ -96,7 +96,6 @@ pub struct Device {
|
||||||
pub inner: InnerDevice,
|
pub inner: InnerDevice,
|
||||||
pub drm: GbmDrmOutputManager,
|
pub drm: GbmDrmOutputManager,
|
||||||
|
|
||||||
supports_atomic: bool,
|
|
||||||
pub texture_formats: FormatSet,
|
pub texture_formats: FormatSet,
|
||||||
event_token: Option<RegistrationToken>,
|
event_token: Option<RegistrationToken>,
|
||||||
pub socket: Option<Socket>,
|
pub socket: Option<Socket>,
|
||||||
|
|
@ -711,7 +710,6 @@ impl Device {
|
||||||
let (drm, notifier) = DrmDevice::new(fd.clone(), false)
|
let (drm, notifier) = DrmDevice::new(fd.clone(), false)
|
||||||
.with_context(|| format!("Failed to initialize drm device for: {}", path.display()))?;
|
.with_context(|| format!("Failed to initialize drm device for: {}", path.display()))?;
|
||||||
let dev_node = DrmNode::from_dev_id(dev)?;
|
let dev_node = DrmNode::from_dev_id(dev)?;
|
||||||
let supports_atomic = drm.is_atomic();
|
|
||||||
|
|
||||||
let gbm = GbmDevice::new(fd)
|
let gbm = GbmDevice::new(fd)
|
||||||
.with_context(|| format!("Failed to initialize GBM device for {}", path.display()))?;
|
.with_context(|| format!("Failed to initialize GBM device for {}", path.display()))?;
|
||||||
|
|
@ -831,7 +829,6 @@ impl Device {
|
||||||
active_clients,
|
active_clients,
|
||||||
},
|
},
|
||||||
|
|
||||||
supports_atomic,
|
|
||||||
texture_formats,
|
texture_formats,
|
||||||
event_token: Some(token),
|
event_token: Some(token),
|
||||||
socket,
|
socket,
|
||||||
|
|
@ -840,8 +837,7 @@ impl Device {
|
||||||
|
|
||||||
pub fn enumerate_surfaces(&mut self) -> Result<OutputChanges> {
|
pub fn enumerate_surfaces(&mut self) -> Result<OutputChanges> {
|
||||||
// enumerate our outputs
|
// enumerate our outputs
|
||||||
let config =
|
let config = drm_helpers::display_configuration(self.drm.device_mut())?;
|
||||||
drm_helpers::display_configuration(self.drm.device_mut(), self.supports_atomic)?;
|
|
||||||
|
|
||||||
let surfaces = self
|
let surfaces = self
|
||||||
.inner
|
.inner
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
use anyhow::{Context, Result, anyhow};
|
use anyhow::{Context, Result, anyhow};
|
||||||
use libdisplay_info::{edid::DisplayDescriptorTag, info::Info};
|
use libdisplay_info::{edid::DisplayDescriptorTag, info::Info};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
|
backend::drm::DrmDevice,
|
||||||
reexports::drm::control::{
|
reexports::drm::control::{
|
||||||
AtomicCommitFlags, Device as ControlDevice, Mode, ModeFlags, PlaneType, ResourceHandle,
|
AtomicCommitFlags, Device as ControlDevice, Mode, ModeFlags, PlaneType, ResourceHandle,
|
||||||
atomic::AtomicModeReq,
|
atomic::AtomicModeReq,
|
||||||
|
|
@ -16,8 +17,7 @@ use smithay::{
|
||||||
use std::{collections::HashMap, ops::Range};
|
use std::{collections::HashMap, ops::Range};
|
||||||
|
|
||||||
pub fn display_configuration(
|
pub fn display_configuration(
|
||||||
device: &mut impl ControlDevice,
|
device: &mut DrmDevice,
|
||||||
supports_atomic: bool,
|
|
||||||
) -> Result<HashMap<connector::Handle, Option<crtc::Handle>>> {
|
) -> Result<HashMap<connector::Handle, Option<crtc::Handle>>> {
|
||||||
let res_handles = device.resource_handles()?;
|
let res_handles = device.resource_handles()?;
|
||||||
let connectors = res_handles.connectors();
|
let connectors = res_handles.connectors();
|
||||||
|
|
@ -73,7 +73,7 @@ pub fn display_configuration(
|
||||||
}
|
}
|
||||||
|
|
||||||
// And then cleanup
|
// And then cleanup
|
||||||
if supports_atomic {
|
if device.is_atomic() {
|
||||||
let mut req = AtomicModeReq::new();
|
let mut req = AtomicModeReq::new();
|
||||||
let plane_handles = device.plane_handles()?;
|
let plane_handles = device.plane_handles()?;
|
||||||
|
|
||||||
|
|
@ -105,24 +105,20 @@ pub fn display_configuration(
|
||||||
let _ = device.set_cursor(*crtc, Option::<&DumbBuffer>::None);
|
let _ = device.set_cursor(*crtc, Option::<&DumbBuffer>::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
disable_crtcs(device, supports_atomic, &cleanup)?;
|
disable_crtcs(device, &cleanup)?;
|
||||||
|
|
||||||
Ok(map)
|
Ok(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disables the given CRTCs and detaches their connectors/planes.
|
/// Disables the given CRTCs and detaches their connectors/planes.
|
||||||
pub fn disable_crtcs(
|
pub fn disable_crtcs(device: &mut DrmDevice, crtcs: &[crtc::Handle]) -> Result<()> {
|
||||||
device: &mut impl ControlDevice,
|
|
||||||
supports_atomic: bool,
|
|
||||||
crtcs: &[crtc::Handle],
|
|
||||||
) -> Result<()> {
|
|
||||||
if crtcs.is_empty() {
|
if crtcs.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let res_handles = device.resource_handles()?;
|
let res_handles = device.resource_handles()?;
|
||||||
|
|
||||||
if supports_atomic {
|
if device.is_atomic() {
|
||||||
let mut req = AtomicModeReq::new();
|
let mut req = AtomicModeReq::new();
|
||||||
|
|
||||||
for conn in res_handles
|
for conn in res_handles
|
||||||
|
|
|
||||||
|
|
@ -865,12 +865,9 @@ impl KmsGuard<'_> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let supports_atomic = device.drm.device().is_atomic();
|
if let Err(err) =
|
||||||
if let Err(err) = drm_helpers::disable_crtcs(
|
drm_helpers::disable_crtcs(device.drm.device_mut(), &disabled_crtcs)
|
||||||
device.drm.device_mut(),
|
{
|
||||||
supports_atomic,
|
|
||||||
&disabled_crtcs,
|
|
||||||
) {
|
|
||||||
warn!("Failed to disable crtcs for disabled outputs: {err}");
|
warn!("Failed to disable crtcs for disabled outputs: {err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue