output: move connector state into type crate
This commit is contained in:
parent
be1511a7be
commit
03f35d7944
4 changed files with 207 additions and 143 deletions
151
src/backend.rs
151
src/backend.rs
|
|
@ -5,31 +5,31 @@ use {
|
|||
BackendConnectorTransaction, BackendConnectorTransactionError,
|
||||
BackendConnectorTransactionType, BackendConnectorTransactionTypeDyn,
|
||||
},
|
||||
cmm::cmm_primaries::Primaries,
|
||||
drm_feedback::DrmFeedback,
|
||||
fixed::Fixed,
|
||||
format::Format,
|
||||
gfx_api::{FdSync, GfxApi, GfxFramebuffer},
|
||||
video::drm::{
|
||||
ConnectorType, DRM_MODE_COLORIMETRY_BT2020_RGB, DRM_MODE_COLORIMETRY_DEFAULT,
|
||||
DrmConnector, DrmError, DrmVersion, HDMI_EOTF_SMPTE_ST2084,
|
||||
HDMI_EOTF_TRADITIONAL_GAMMA_SDR,
|
||||
},
|
||||
video::drm::{ConnectorType, DrmConnector, DrmError, DrmVersion},
|
||||
},
|
||||
jay_config::input::SwitchEvent,
|
||||
linearize::Linearize,
|
||||
std::{
|
||||
any::Any,
|
||||
error::Error,
|
||||
fmt::{Debug, Display, Formatter},
|
||||
rc::Rc,
|
||||
},
|
||||
uapi::{OwnedFd, Packed, Pod, c},
|
||||
uapi::{OwnedFd, c},
|
||||
};
|
||||
|
||||
pub mod transaction;
|
||||
|
||||
pub use jay_output_types::{ConnectorId, ConnectorIds, DrmDeviceId, DrmDeviceIds, Mode, OutputId};
|
||||
pub use jay_output_types::{
|
||||
BackendColorSpace, BackendConnectorState, BackendConnectorStateSerial,
|
||||
BackendConnectorStateSerials, BackendEotfs, BackendGammaLut, BackendGammaLutElement,
|
||||
BackendLuminance, CONCAP_CONNECTOR, CONCAP_MODE_SETTING, CONCAP_PHYSICAL_DISPLAY,
|
||||
ConnectorCaps, ConnectorId, ConnectorIds, DrmDeviceId, DrmDeviceIds, Mode, MonitorInfo,
|
||||
OutputId,
|
||||
};
|
||||
|
||||
pub use jay_input_types::{
|
||||
AXIS_120, AxisSource, ButtonState, InputDeviceAccelProfile, InputDeviceCapability,
|
||||
|
|
@ -64,22 +64,6 @@ pub trait Backend: Any {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct MonitorInfo {
|
||||
pub modes: Option<Vec<Mode>>,
|
||||
pub output_id: Rc<OutputId>,
|
||||
pub width_mm: i32,
|
||||
pub height_mm: i32,
|
||||
pub non_desktop: bool,
|
||||
pub non_desktop_effective: bool,
|
||||
pub vrr_capable: bool,
|
||||
pub eotfs: Vec<BackendEotfs>,
|
||||
pub color_spaces: Vec<BackendColorSpace>,
|
||||
pub primaries: Primaries,
|
||||
pub luminance: Option<BackendLuminance>,
|
||||
pub state: BackendConnectorState,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct ConnectorKernelId {
|
||||
pub ty: ConnectorType,
|
||||
|
|
@ -92,13 +76,6 @@ impl Display for ConnectorKernelId {
|
|||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
ConnectorCaps: u32;
|
||||
CONCAP_CONNECTOR,
|
||||
CONCAP_MODE_SETTING,
|
||||
CONCAP_PHYSICAL_DISPLAY,
|
||||
}
|
||||
|
||||
pub trait Connector: Any {
|
||||
fn id(&self) -> ConnectorId;
|
||||
fn kernel_id(&self) -> ConnectorKernelId;
|
||||
|
|
@ -457,113 +434,3 @@ pub trait BackendDrmLease {
|
|||
pub trait BackendDrmLessee {
|
||||
fn created(&self, lease: Rc<dyn BackendDrmLease>);
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default, Linearize)]
|
||||
pub enum BackendEotfs {
|
||||
#[default]
|
||||
Default,
|
||||
Pq,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default, Linearize)]
|
||||
pub enum BackendColorSpace {
|
||||
#[default]
|
||||
Default,
|
||||
Bt2020,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct BackendLuminance {
|
||||
pub min: f64,
|
||||
pub max: f64,
|
||||
pub max_fall: f64,
|
||||
}
|
||||
|
||||
impl BackendEotfs {
|
||||
pub fn to_drm(self) -> u8 {
|
||||
match self {
|
||||
BackendEotfs::Default => HDMI_EOTF_TRADITIONAL_GAMMA_SDR,
|
||||
BackendEotfs::Pq => HDMI_EOTF_SMPTE_ST2084,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn name(self) -> &'static str {
|
||||
match self {
|
||||
BackendEotfs::Default => "default",
|
||||
BackendEotfs::Pq => "pq",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BackendColorSpace {
|
||||
pub fn to_drm(self) -> u64 {
|
||||
match self {
|
||||
BackendColorSpace::Default => DRM_MODE_COLORIMETRY_DEFAULT,
|
||||
BackendColorSpace::Bt2020 => DRM_MODE_COLORIMETRY_BT2020_RGB,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn name(self) -> &'static str {
|
||||
match self {
|
||||
BackendColorSpace::Default => "default",
|
||||
BackendColorSpace::Bt2020 => "bt2020",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// kernel: struct drm_color_lut
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)]
|
||||
#[repr(C)]
|
||||
pub struct BackendGammaLutElement {
|
||||
pub red: u16,
|
||||
pub green: u16,
|
||||
pub blue: u16,
|
||||
pub reserved: u16,
|
||||
}
|
||||
|
||||
unsafe impl Pod for BackendGammaLutElement {}
|
||||
unsafe impl Packed for BackendGammaLutElement {}
|
||||
|
||||
#[derive(Debug, Eq)]
|
||||
pub struct BackendGammaLut {
|
||||
id: [u8; 32],
|
||||
pub gamma_lut: Vec<BackendGammaLutElement>,
|
||||
}
|
||||
|
||||
impl BackendGammaLut {
|
||||
pub fn new(mut gamma_lut: Vec<BackendGammaLutElement>) -> Self {
|
||||
for element in &mut gamma_lut {
|
||||
element.reserved = 0;
|
||||
}
|
||||
let gamma_lut_bytes = uapi::as_bytes(&gamma_lut as &[_]);
|
||||
let id = *blake3::hash(gamma_lut_bytes).as_bytes();
|
||||
Self { id, gamma_lut }
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for BackendGammaLut {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.id == other.id
|
||||
}
|
||||
}
|
||||
|
||||
linear_ids!(
|
||||
BackendConnectorStateSerials,
|
||||
BackendConnectorStateSerial,
|
||||
u64
|
||||
);
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct BackendConnectorState {
|
||||
pub serial: BackendConnectorStateSerial,
|
||||
pub enabled: bool,
|
||||
pub active: bool,
|
||||
pub mode: Mode,
|
||||
pub non_desktop_override: Option<bool>,
|
||||
pub vrr: bool,
|
||||
pub tearing: bool,
|
||||
pub format: &'static Format,
|
||||
pub color_space: BackendColorSpace,
|
||||
pub eotf: BackendEotfs,
|
||||
pub gamma_lut: Option<Rc<BackendGammaLut>>,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue