Add EdidProduct, as user data for kms Outputs
This is the same as `libdisplay_info::edid::VendorProduct`, but with implementations for `Serialize`, `Eq`, etc.
This commit is contained in:
parent
2fe5897db0
commit
e74eafce2c
3 changed files with 39 additions and 4 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::render::{output_elements, CursorMode, GlMultiRenderer, CLEAR_COLOR},
|
backend::render::{output_elements, CursorMode, GlMultiRenderer, CLEAR_COLOR},
|
||||||
config::{AdaptiveSync, OutputConfig, OutputState, ScreenFilter},
|
config::{AdaptiveSync, EdidProduct, OutputConfig, OutputState, ScreenFilter},
|
||||||
shell::Shell,
|
shell::Shell,
|
||||||
utils::prelude::*,
|
utils::prelude::*,
|
||||||
wayland::protocols::screencopy::Frame as ScreencopyFrame,
|
wayland::protocols::screencopy::Frame as ScreencopyFrame,
|
||||||
|
|
@ -743,7 +743,7 @@ fn create_output_for_conn(drm: &mut DrmDevice, conn: connector::Handle) -> Resul
|
||||||
.ok();
|
.ok();
|
||||||
let (phys_w, phys_h) = conn_info.size().unwrap_or((0, 0));
|
let (phys_w, phys_h) = conn_info.size().unwrap_or((0, 0));
|
||||||
|
|
||||||
Ok(Output::new(
|
let output = Output::new(
|
||||||
interface,
|
interface,
|
||||||
PhysicalProperties {
|
PhysicalProperties {
|
||||||
size: (phys_w as i32, phys_h as i32).into(),
|
size: (phys_w as i32, phys_h as i32).into(),
|
||||||
|
|
@ -764,7 +764,13 @@ fn create_output_for_conn(drm: &mut DrmDevice, conn: connector::Handle) -> Resul
|
||||||
.and_then(|info| info.model())
|
.and_then(|info| info.model())
|
||||||
.unwrap_or_else(|| String::from("Unknown")),
|
.unwrap_or_else(|| String::from("Unknown")),
|
||||||
},
|
},
|
||||||
))
|
);
|
||||||
|
if let Some(edid) = edid_info.as_ref().and_then(|x| x.edid()) {
|
||||||
|
output
|
||||||
|
.user_data()
|
||||||
|
.insert_if_missing(|| EdidProduct::from(edid.vendor_product()));
|
||||||
|
}
|
||||||
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn populate_modes(
|
fn populate_modes(
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,29 @@ impl From<Output> for OutputInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub struct EdidProduct {
|
||||||
|
pub manufacturer: [char; 3],
|
||||||
|
pub product: u16,
|
||||||
|
pub serial: Option<u32>,
|
||||||
|
pub manufacture_week: i32,
|
||||||
|
pub manufacture_year: i32,
|
||||||
|
pub model_year: Option<i32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<libdisplay_info::edid::VendorProduct> for EdidProduct {
|
||||||
|
fn from(vp: libdisplay_info::edid::VendorProduct) -> Self {
|
||||||
|
Self {
|
||||||
|
manufacturer: vp.manufacturer,
|
||||||
|
product: vp.product,
|
||||||
|
serial: vp.serial,
|
||||||
|
manufacture_week: vp.manufacture_week,
|
||||||
|
manufacture_year: vp.manufacture_year,
|
||||||
|
model_year: vp.model_year,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Deserialize, Serialize)]
|
#[derive(Default, Debug, Deserialize, Serialize)]
|
||||||
pub struct NumlockStateConfig {
|
pub struct NumlockStateConfig {
|
||||||
pub last_state: bool,
|
pub last_state: bool,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ pub use crate::shell::{SeatExt, Shell, Workspace};
|
||||||
pub use crate::state::{Common, State};
|
pub use crate::state::{Common, State};
|
||||||
pub use crate::wayland::handlers::xdg_shell::popup::update_reactive_popups;
|
pub use crate::wayland::handlers::xdg_shell::popup::update_reactive_popups;
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{AdaptiveSync, OutputConfig, OutputState},
|
config::{AdaptiveSync, EdidProduct, OutputConfig, OutputState},
|
||||||
shell::zoom::OutputZoomState,
|
shell::zoom::OutputZoomState,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -35,6 +35,8 @@ pub trait OutputExt {
|
||||||
fn is_enabled(&self) -> bool;
|
fn is_enabled(&self) -> bool;
|
||||||
fn config(&self) -> Ref<'_, OutputConfig>;
|
fn config(&self) -> Ref<'_, OutputConfig>;
|
||||||
fn config_mut(&self) -> RefMut<'_, OutputConfig>;
|
fn config_mut(&self) -> RefMut<'_, OutputConfig>;
|
||||||
|
|
||||||
|
fn edid(&self) -> Option<&EdidProduct>;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Vrr(AtomicU8);
|
struct Vrr(AtomicU8);
|
||||||
|
|
@ -158,4 +160,8 @@ impl OutputExt for Output {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn edid(&self) -> Option<&EdidProduct> {
|
||||||
|
self.user_data().get()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue