metal: implement VRR
This commit is contained in:
parent
cd09e57568
commit
2d7c13b0b4
35 changed files with 1320 additions and 91 deletions
|
|
@ -25,7 +25,7 @@ use {
|
|||
timer::Timer,
|
||||
video::{
|
||||
connector_type::{ConnectorType, CON_UNKNOWN},
|
||||
Connector, DrmDevice, GfxApi, Mode, Transform,
|
||||
Connector, DrmDevice, GfxApi, Mode, Transform, VrrMode,
|
||||
},
|
||||
Axis, Direction, ModifiedKeySym, PciId, Workspace,
|
||||
},
|
||||
|
|
@ -800,6 +800,14 @@ impl Client {
|
|||
(width, height)
|
||||
}
|
||||
|
||||
pub fn set_vrr_mode(&self, connector: Option<Connector>, mode: VrrMode) {
|
||||
self.send(&ClientMessage::SetVrrMode { connector, mode })
|
||||
}
|
||||
|
||||
pub fn set_vrr_cursor_hz(&self, connector: Option<Connector>, hz: f64) {
|
||||
self.send(&ClientMessage::SetVrrCursorHz { connector, hz })
|
||||
}
|
||||
|
||||
pub fn drm_devices(&self) -> Vec<DrmDevice> {
|
||||
let res = self.send_with_response(&ClientMessage::GetDrmDevices);
|
||||
get_response!(res, vec![], GetDrmDevices { devices });
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use {
|
|||
logging::LogLevel,
|
||||
theme::{colors::Colorable, sized::Resizable, Color},
|
||||
timer::Timer,
|
||||
video::{connector_type::ConnectorType, Connector, DrmDevice, GfxApi, Transform},
|
||||
video::{connector_type::ConnectorType, Connector, DrmDevice, GfxApi, Transform, VrrMode},
|
||||
Axis, Direction, PciId, Workspace,
|
||||
_private::{PollableId, WireMode},
|
||||
},
|
||||
|
|
@ -487,6 +487,14 @@ pub enum ClientMessage<'a> {
|
|||
seat: Seat,
|
||||
enabled: bool,
|
||||
},
|
||||
SetVrrMode {
|
||||
connector: Option<Connector>,
|
||||
mode: VrrMode,
|
||||
},
|
||||
SetVrrCursorHz {
|
||||
connector: Option<Connector>,
|
||||
hz: f64,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
|||
|
|
@ -248,6 +248,20 @@ impl Connector {
|
|||
}
|
||||
get!(String::new()).connector_get_serial_number(self)
|
||||
}
|
||||
|
||||
/// Sets the VRR mode.
|
||||
pub fn set_vrr_mode(self, mode: VrrMode) {
|
||||
get!().set_vrr_mode(Some(self), mode)
|
||||
}
|
||||
|
||||
/// Sets the VRR cursor refresh rate.
|
||||
///
|
||||
/// Limits the rate at which cursors are updated on screen when VRR is active.
|
||||
///
|
||||
/// Setting this to infinity disables the limiter.
|
||||
pub fn set_vrr_cursor_hz(self, hz: f64) {
|
||||
get!().set_vrr_cursor_hz(Some(self), hz)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns all available DRM devices.
|
||||
|
|
@ -531,3 +545,38 @@ pub enum Transform {
|
|||
/// Flip around the vertical axis, then rotate 270 degrees counter-clockwise.
|
||||
FlipRotate270,
|
||||
}
|
||||
|
||||
/// The VRR mode of a connector.
|
||||
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
|
||||
pub struct VrrMode(pub u32);
|
||||
|
||||
impl VrrMode {
|
||||
/// VRR is never enabled.
|
||||
pub const NEVER: Self = Self(0);
|
||||
/// VRR is always enabled.
|
||||
pub const ALWAYS: Self = Self(1);
|
||||
/// VRR is enabled when one or more applications are displayed fullscreen.
|
||||
pub const VARIANT_1: Self = Self(2);
|
||||
/// VRR is enabled when a single application is displayed fullscreen.
|
||||
pub const VARIANT_2: Self = Self(3);
|
||||
/// VRR is enabled when a single game or video is displayed fullscreen.
|
||||
pub const VARIANT_3: Self = Self(4);
|
||||
}
|
||||
|
||||
/// Sets the default VRR mode.
|
||||
///
|
||||
/// This setting can be overwritten on a per-connector basis with [Connector::set_vrr_mode].
|
||||
pub fn set_vrr_mode(mode: VrrMode) {
|
||||
get!().set_vrr_mode(None, mode)
|
||||
}
|
||||
|
||||
/// Sets the VRR cursor refresh rate.
|
||||
///
|
||||
/// Limits the rate at which cursors are updated on screen when VRR is active.
|
||||
///
|
||||
/// Setting this to infinity disables the limiter.
|
||||
///
|
||||
/// This setting can be overwritten on a per-connector basis with [Connector::set_vrr_cursor_hz].
|
||||
pub fn set_vrr_cursor_hz(hz: f64) {
|
||||
get!().set_vrr_cursor_hz(None, hz)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue