Skip to content

Commit bebd7c5

Browse files
committed
kms: Cleanup now that output_elements won't panic for uninitialized outputs
1 parent db13eea commit bebd7c5

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

src/backend/kms/device.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ use smithay::{
1818
Format, Fourcc,
1919
},
2020
drm::{
21-
compositor::FrameFlags, output::DrmOutputManager, DrmDevice, DrmDeviceFd, DrmEvent,
22-
DrmNode,
21+
compositor::{FrameError, FrameFlags},
22+
output::DrmOutputManager,
23+
DrmDevice, DrmDeviceFd, DrmEvent, DrmNode,
2324
},
2425
egl::{context::ContextPriority, EGLContext, EGLDevice, EGLDisplay},
2526
session::Session,
@@ -620,24 +621,18 @@ impl Device {
620621
renderer: &mut GlMultiRenderer,
621622
clock: &Clock<Monotonic>,
622623
shell: &Arc<RwLock<Shell>>,
623-
startup_done: bool,
624624
) -> Result<()> {
625625
for surface in self.surfaces.values_mut() {
626626
surface.allow_frame_flags(flag, flags);
627627
}
628628

629629
if !flag {
630630
let now = clock.now();
631-
632-
let mut output_map = self
631+
let output_map = self
633632
.surfaces
634633
.iter()
635-
.filter(|(_, s)| s.is_active())
636634
.map(|(crtc, surface)| (*crtc, surface.output.clone()))
637635
.collect::<HashMap<_, _>>();
638-
if !startup_done {
639-
output_map.clear();
640-
}
641636

642637
self.drm.with_compositors::<Result<()>>(|map| {
643638
for (crtc, compositor) in map.iter() {
@@ -662,7 +657,11 @@ impl Device {
662657
CLEAR_COLOR,
663658
FrameFlags::empty(),
664659
)?;
665-
compositor.commit_frame()?;
660+
if let Err(err) = compositor.commit_frame() {
661+
if !matches!(err, FrameError::EmptyFrame) {
662+
return Err(err.into());
663+
}
664+
}
666665
}
667666

668667
Ok(())
@@ -685,7 +684,6 @@ impl Device {
685684
renderer,
686685
clock,
687686
shell,
688-
true,
689687
)
690688
}
691689

@@ -695,15 +693,13 @@ impl Device {
695693
renderer: &mut GlMultiRenderer,
696694
clock: &Clock<Monotonic>,
697695
shell: &Arc<RwLock<Shell>>,
698-
startup_done: bool,
699696
) -> Result<()> {
700697
self.allow_frame_flags(
701698
flag,
702699
FrameFlags::ALLOW_PRIMARY_PLANE_SCANOUT_ANY,
703700
renderer,
704701
clock,
705702
shell,
706-
startup_done,
707703
)?;
708704

709705
self.drm.with_compositors(|comps| {

src/backend/kms/mod.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ use std::{
4444
borrow::BorrowMut,
4545
collections::{HashMap, HashSet},
4646
path::Path,
47-
sync::{
48-
atomic::{AtomicBool, Ordering},
49-
Arc, RwLock,
50-
},
47+
sync::{atomic::AtomicBool, Arc, RwLock},
5148
};
5249

5350
mod device;
@@ -649,19 +646,14 @@ impl KmsState {
649646
.context("Failed to enable devices")?;
650647
}
651648

652-
let startup_done = startup_done.load(Ordering::SeqCst);
653649
let mut all_outputs = Vec::new();
654650
for device in self.drm_devices.values_mut() {
655651
let now = clock.now();
656-
let mut output_map = device
652+
let output_map = device
657653
.surfaces
658654
.iter()
659-
.filter(|(_, s)| s.is_active())
660655
.map(|(crtc, surface)| (*crtc, surface.output.clone()))
661656
.collect::<HashMap<_, _>>();
662-
if !startup_done {
663-
output_map.clear();
664-
}
665657

666658
// configure primary scanout allowance
667659
if !device.surfaces.is_empty() {
@@ -675,13 +667,12 @@ impl KmsState {
675667
device
676668
.surfaces
677669
.values()
678-
.filter(|s| s.output.is_enabled())
670+
.filter(|s| s.output.is_enabled() && s.output.mirroring().is_none())
679671
.count()
680672
<= 1,
681673
&mut renderer,
682674
clock,
683675
&shell,
684-
startup_done,
685676
)
686677
.context("Failed to switch primary-plane scanout flags")?;
687678
}

0 commit comments

Comments
 (0)