drmkit_display/lib.rs
1// SPDX-FileCopyrightText: (c) 2026 Joel Winarske
2// SPDX-License-Identifier: MIT
3
4//! Display characterization and color handling.
5//!
6//! What a connected display can do, and what has to happen to pixels before
7//! they reach it. Two halves that mostly do not talk to each other.
8//!
9//! # Finding the display
10//!
11//! - [`ScanoutTarget`] — the connected output and the CRTC and primary plane
12//! that drive it, which is the pair everything downstream needs and the one
13//! thing `crtcs().first()` reliably gets wrong on real hardware.
14//! - [`query_connector_modes`] — what each connector offers, with
15//! [`Probe`] deciding whether to ask the sink or trust the cache.
16//! - [`ConnectorCapabilities`] and [`CrtcCapabilities`] — the properties this
17//! pipe actually exposes, so a caller writes what the driver has rather than
18//! what the spec allows.
19//! - `HotplugMonitor` — the kernel's own uevent stream, behind the `hotplug`
20//! feature.
21//! - [`DriverProfile`] — device capabilities, probed and never inferred from
22//! the driver's name.
23//!
24//! # Getting the pixels right
25//!
26//! - [`ToneMapper`] — SDR to HDR and back, over a [`ToneMapCurve`]. Color
27//! maths has too many plausible readings for a paper derivation to be worth
28//! much, so its answers are diffed against the reference's own, vector by
29//! vector.
30//! - [`CrtcColorPipeline`] — the CRTC's degamma, CTM and gamma stages. Each
31//! refuses on its own rather than the pipeline refusing whole, because
32//! partial pipelines are the common case: of 4,129 CRTCs surveyed, 848 have
33//! no color stage at all and three more shapes sit between that and the
34//! full three.
35//! - [`HdrSourceMetadata`] and [`HdrMetadataCache`] — the CTA-861.3 blob a
36//! sink needs to switch into HDR, and the cache that stops it being rewritten
37//! every frame. Its green/blue/red primary ordering and tail padding are both
38//! invisible on screen and both change the bytes, so this is diffed against
39//! the reference too, over twelve vectors.
40//! - `edid` — what the sink says about itself, behind the `edid` feature.
41//!
42//! # Features
43//!
44//! `edid` is off by default: `libdisplay-info-sys` links a system library, and
45//! the cross lanes have no sysroot for it. Everything else here — the tone
46//! mapper and color curves that downstream crates want — builds without it.
47
48mod capabilities;
49
50#[cfg(feature = "hotplug")]
51mod hotplug;
52mod pipeline;
53pub mod scanout;
54
55pub mod color;
56pub mod curves;
57#[cfg(feature = "edid")]
58pub mod edid;
59pub mod hdr;
60pub mod hdr_cache;
61mod modes;
62mod profile;
63mod tone_mapper;
64
65#[cfg(test)]
66mod hdr_tests;
67#[cfg(test)]
68mod tests;
69
70pub use capabilities::{BroadcastRgb, Colorspace, ConnectorCapabilities, CrtcCapabilities, MaxBpc};
71pub use curves::{ColorCtm, ColorLut};
72pub use hdr::{
73 HdrBlob, HdrMetadataBlob, HdrSourceMetadata, TransferFunction, hdr_metadata_hash,
74 serialize_hdr_metadata,
75};
76pub use hdr_cache::HdrMetadataCache;
77#[cfg(feature = "hotplug")]
78pub use hotplug::{HotplugEvent, HotplugMonitor, Source};
79pub use modes::{ConnectorModes, Probe, query_connector_modes};
80pub use pipeline::{CrtcColorPipeline, PipelineError, Stage};
81pub use profile::{
82 DriverProfile, PanelSelfRefresh, PrimeCaps, connector_type_self_refreshes, decode_prime_caps,
83};
84pub use scanout::{
85 CrtcChoice, ScanoutError, ScanoutTarget, crtc_for_connector, primary_plane_for_crtc, rank,
86 rank_pick,
87};
88pub use tone_mapper::{Direction, LUT_SIZE, ToneMapCurve, ToneMapper};