implement wlr-gamma-control-unstable-v1
This commit is contained in:
parent
11b3f08514
commit
b1db715a90
26 changed files with 475 additions and 21 deletions
|
|
@ -2,7 +2,8 @@ use {
|
|||
crate::{
|
||||
allocator::BufferObject,
|
||||
backend::{
|
||||
BackendColorSpace, BackendConnectorState, BackendEotfs, Connector, ConnectorEvent,
|
||||
BackendColorSpace, BackendConnectorState, BackendEotfs, BackendGammaLut, Connector,
|
||||
ConnectorEvent,
|
||||
transaction::{
|
||||
BackendAppliedConnectorTransaction, BackendConnectorTransaction,
|
||||
BackendConnectorTransactionError, BackendPreparedConnectorTransaction,
|
||||
|
|
@ -57,6 +58,9 @@ pub struct DrmCrtcState {
|
|||
pub mode_blob: Option<Rc<PropBlob>>,
|
||||
pub vrr_enabled: bool,
|
||||
pub assigned_connector: DrmConnector,
|
||||
pub gamma_lut: Option<Rc<BackendGammaLut>>,
|
||||
pub gamma_lut_blob_id: DrmBlob,
|
||||
pub gamma_lut_blob: Option<Rc<PropBlob>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug)]
|
||||
|
|
@ -420,6 +424,22 @@ impl MetalDeviceTransaction {
|
|||
crtc.new.mode_blob = Some(Rc::new(blob));
|
||||
mode.clone()
|
||||
};
|
||||
if crtc.new.gamma_lut != state.gamma_lut {
|
||||
if let Some(gamma_lut) = &state.gamma_lut {
|
||||
let blob = slf
|
||||
.dev
|
||||
.dev
|
||||
.master
|
||||
.create_blob(&gamma_lut.gamma_lut as &[_])
|
||||
.map_err(BackendConnectorTransactionError::CreateGammaLutBlob)?;
|
||||
crtc.new.gamma_lut_blob_id = blob.id();
|
||||
crtc.new.gamma_lut_blob = Some(Rc::new(blob));
|
||||
} else {
|
||||
crtc.new.gamma_lut_blob_id = DrmBlob::NONE;
|
||||
crtc.new.gamma_lut_blob = None;
|
||||
}
|
||||
crtc.new.gamma_lut = state.gamma_lut.clone();
|
||||
}
|
||||
for plane_id in [&mut crtc_planes.primary, &mut crtc_planes.cursor] {
|
||||
if plane_id.is_none() {
|
||||
continue;
|
||||
|
|
@ -841,6 +861,12 @@ impl MetalDeviceTransactionWithDrmState {
|
|||
log_change!(o, n, mode_blob_id);
|
||||
c.change(crtc.obj.mode_id, n.mode_blob_id);
|
||||
}
|
||||
if let Some(gamma_lut) = crtc.obj.gamma_lut
|
||||
&& n.gamma_lut_blob_id != o.gamma_lut_blob_id
|
||||
{
|
||||
log_change!(o, n, gamma_lut_blob_id);
|
||||
c.change(gamma_lut, n.gamma_lut_blob_id);
|
||||
}
|
||||
reset_default_properties!(
|
||||
c,
|
||||
&*crtc.obj.untyped_properties.borrow(),
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ use {
|
|||
async_engine::{Phase, SpawnedFuture},
|
||||
backend::{
|
||||
BackendColorSpace, BackendConnectorState, BackendDrmDevice, BackendDrmLease,
|
||||
BackendDrmLessee, BackendEotfs, BackendEvent, BackendLuminance, CONCAP_CONNECTOR,
|
||||
CONCAP_MODE_SETTING, CONCAP_PHYSICAL_DISPLAY, Connector, ConnectorCaps, ConnectorEvent,
|
||||
ConnectorId, ConnectorKernelId, DrmDeviceId, HardwareCursor, HardwareCursorUpdate,
|
||||
Mode, MonitorInfo,
|
||||
BackendDrmLessee, BackendEotfs, BackendEvent, BackendGammaLut, BackendGammaLutElement,
|
||||
BackendLuminance, CONCAP_CONNECTOR, CONCAP_MODE_SETTING, CONCAP_PHYSICAL_DISPLAY,
|
||||
Connector, ConnectorCaps, ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId,
|
||||
HardwareCursor, HardwareCursorUpdate, Mode, MonitorInfo,
|
||||
transaction::{
|
||||
BackendConnectorTransaction, BackendConnectorTransactionError,
|
||||
BackendConnectorTransactionType, BackendConnectorTransactionTypeDyn,
|
||||
|
|
@ -905,6 +905,10 @@ impl Connector for MetalConnector {
|
|||
) -> Result<Box<dyn BackendConnectorTransaction>, BackendConnectorTransactionError> {
|
||||
self.create_transaction().map(|v| Box::new(v) as _)
|
||||
}
|
||||
|
||||
fn gamma_lut_size(&self) -> Option<u32> {
|
||||
self.crtc.get().and_then(|crtc| crtc.gamma_lut_size)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MetalCrtc {
|
||||
|
|
@ -925,6 +929,8 @@ pub struct MetalCrtc {
|
|||
pub mode_id: DrmProperty,
|
||||
pub vrr_enabled: DrmProperty,
|
||||
pub out_fence_ptr: DrmProperty,
|
||||
pub gamma_lut: Option<DrmProperty>,
|
||||
pub gamma_lut_size: Option<u32>,
|
||||
pub drm_state: RefCell<DrmCrtcState>,
|
||||
|
||||
pub sequence: Cell<u64>,
|
||||
|
|
@ -1327,6 +1333,7 @@ fn create_connector_display_data(
|
|||
format: XRGB8888,
|
||||
color_space: Default::default(),
|
||||
eotf: Default::default(),
|
||||
gamma_lut: Default::default(),
|
||||
}),
|
||||
});
|
||||
dev.backend
|
||||
|
|
@ -1499,7 +1506,6 @@ fn create_crtc(
|
|||
("AMD_CRTC_REGAMMA_TF", DefaultValue::Enum("Default")),
|
||||
("CTM", DefaultValue::Fixed(0)),
|
||||
("DEGAMMA_LUT", DefaultValue::Fixed(0)),
|
||||
("GAMMA_LUT", DefaultValue::Fixed(0)),
|
||||
("OUT_FENCE_PTR", DefaultValue::Fixed(0)),
|
||||
],
|
||||
);
|
||||
|
|
@ -1507,6 +1513,14 @@ fn create_crtc(
|
|||
let mode_id = props.get("MODE_ID")?.map(|v| DrmBlob(v as u32));
|
||||
let vrr_enabled = props.get("VRR_ENABLED")?.map(|v| v == 1);
|
||||
let out_fence_ptr = props.get("OUT_FENCE_PTR")?;
|
||||
let gamma_lut = props
|
||||
.get("GAMMA_LUT")
|
||||
.ok()
|
||||
.map(|v| v.map(|v| DrmBlob(v as u32)));
|
||||
let mut gamma_lut_size = None;
|
||||
if gamma_lut.is_some() {
|
||||
gamma_lut_size = props.get("GAMMA_LUT_SIZE").ok().map(|v| v.value as u32);
|
||||
}
|
||||
let mut mode = None;
|
||||
if mode_id.value.is_some() {
|
||||
match master.getblob::<drm_mode_modeinfo>(mode_id.value) {
|
||||
|
|
@ -1523,6 +1537,9 @@ fn create_crtc(
|
|||
mode_blob: None,
|
||||
vrr_enabled: vrr_enabled.value,
|
||||
assigned_connector: DrmConnector::NONE,
|
||||
gamma_lut: None,
|
||||
gamma_lut_blob_id: gamma_lut.map_or(DrmBlob::NONE, |v| v.value),
|
||||
gamma_lut_blob: None,
|
||||
};
|
||||
Ok(MetalCrtc {
|
||||
id: crtc,
|
||||
|
|
@ -1539,6 +1556,8 @@ fn create_crtc(
|
|||
mode_id: mode_id.id,
|
||||
vrr_enabled: vrr_enabled.id,
|
||||
out_fence_ptr: out_fence_ptr.id,
|
||||
gamma_lut: gamma_lut.map(|v| v.id),
|
||||
gamma_lut_size,
|
||||
sequence: Cell::new(0),
|
||||
have_queued_sequence: Cell::new(false),
|
||||
needs_vblank_emulation: Cell::new(false),
|
||||
|
|
@ -2187,6 +2206,25 @@ impl MetalCrtc {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(gamma_lut) = self.gamma_lut {
|
||||
let id = DrmBlob(get(props, gamma_lut)? as _);
|
||||
let old = state.gamma_lut_blob_id;
|
||||
state.gamma_lut_blob_id = id;
|
||||
if old != id {
|
||||
state.gamma_lut = None;
|
||||
state.gamma_lut_blob = None;
|
||||
if id.is_some() {
|
||||
match master.getblob_vec::<BackendGammaLutElement>(id) {
|
||||
Ok(b) => {
|
||||
state.gamma_lut = Some(Rc::new(BackendGammaLut::new(b)));
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Could not fetch gamma_lut: {}", ErrorFmt(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -493,6 +493,7 @@ impl XBackend {
|
|||
format: FORMAT,
|
||||
color_space: Default::default(),
|
||||
eotf: Default::default(),
|
||||
gamma_lut: Default::default(),
|
||||
};
|
||||
let output = Rc::new(XOutput {
|
||||
id: self.state.connector_ids.next(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue