1
0
Fork 0
forked from wry/wry

implement wlr-gamma-control-unstable-v1

This commit is contained in:
khyperia 2026-01-24 20:26:51 +01:00 committed by Julian Orth
parent 11b3f08514
commit b1db715a90
26 changed files with 475 additions and 21 deletions

View file

@ -37,7 +37,7 @@ use {
hash::Hash,
rc::Rc,
},
uapi::{OwnedFd, c},
uapi::{OwnedFd, Packed, Pod, c},
};
pub mod transaction;
@ -165,6 +165,9 @@ pub trait Connector: Any {
self.kernel_id(),
))
}
fn gamma_lut_size(&self) -> Option<u32> {
None
}
}
#[derive(Debug)]
@ -611,6 +614,42 @@ impl BackendColorSpace {
}
}
// 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,
@ -629,4 +668,5 @@ pub struct BackendConnectorState {
pub format: &'static Format,
pub color_space: BackendColorSpace,
pub eotf: BackendEotfs,
pub gamma_lut: Option<Rc<BackendGammaLut>>,
}