output-configuration: Support cosmic-ext v2

This commit is contained in:
Victoria Brekenfeld 2024-11-18 21:30:02 +01:00 committed by Victoria Brekenfeld
parent 80965a61b9
commit 81b9fb179b
9 changed files with 120 additions and 25 deletions

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::{
config::{OutputConfig, OutputState},
config::{AdaptiveSync, OutputConfig, OutputState},
shell::Shell,
utils::prelude::*,
};
@ -664,6 +664,10 @@ fn populate_modes(
max_bpc,
scale,
transform,
// Try opportunistic VRR by default,
// if not supported this will be turned off on `resume`,
// when we have the `Surface` to actually check for support.
vrr: AdaptiveSync::Enabled,
..std::mem::take(&mut *output_config)
};

View file

@ -684,6 +684,9 @@ impl KmsState {
match surface.resume(drm_surface, gbm, cursor_size) {
Ok(_) => {
surface.output.set_adaptive_sync_support(
surface.adaptive_sync_support().ok(),
);
if surface.use_adaptive_sync(vrr)? {
surface.output.set_adaptive_sync(vrr);
} else {

View file

@ -405,6 +405,14 @@ impl Surface {
rx.recv().context("Surface thread died")?
}
pub fn adaptive_sync_support(&self) -> Result<VrrSupport> {
let (tx, rx) = std::sync::mpsc::sync_channel(1);
let _ = self
.thread_command
.send(ThreadCommand::AdaptiveSyncAvailable(tx));
rx.recv().context("Surface thread died")?
}
pub fn use_adaptive_sync(&mut self, vrr: AdaptiveSync) -> Result<bool> {
if vrr != AdaptiveSync::Disabled {
let (tx, rx) = std::sync::mpsc::sync_channel(1);