kms: Adaptive VRR support

This commit is contained in:
Victoria Brekenfeld 2024-11-18 19:47:59 +01:00 committed by Victoria Brekenfeld
parent d72bf54628
commit 80965a61b9
7 changed files with 146 additions and 87 deletions

View file

@ -349,40 +349,6 @@ pub fn calculate_refresh_rate(mode: Mode) -> u32 {
refresh as u32
}
pub fn supports_vrr(dev: &impl ControlDevice, conn: connector::Handle) -> Result<bool> {
get_property_val(dev, conn, "vrr_capable").map(|(val_type, val)| {
match val_type.convert_value(val) {
property::Value::UnsignedRange(res) => res == 1,
property::Value::Boolean(res) => res,
_ => false,
}
})
}
pub fn set_vrr(
dev: &impl ControlDevice,
crtc: crtc::Handle,
conn: connector::Handle,
vrr: bool,
) -> Result<bool> {
if supports_vrr(dev, conn)? {
dev.set_property(
conn,
get_prop(dev, crtc, "VRR_ENABLED")?,
property::Value::UnsignedRange(if vrr { 1 } else { 0 }).into(),
)
.map_err(Into::<anyhow::Error>::into)
.and_then(|_| get_property_val(dev, crtc, "VRR_ENABLED"))
.map(|(val_type, val)| match val_type.convert_value(val) {
property::Value::UnsignedRange(vrr) => vrr == 1,
property::Value::Boolean(vrr) => vrr,
_ => false,
})
} else {
Ok(false)
}
}
pub fn get_max_bpc(
dev: &impl ControlDevice,
conn: connector::Handle,