drmkit_core/lib.rs
1// SPDX-FileCopyrightText: (c) 2026 Joel Winarske
2// SPDX-License-Identifier: MIT
3
4//! Core DRM/KMS device access for drmkit.
5//!
6//! Port of `src/core/` plus `src/modeset/atomic.{hpp,cpp}` from drm-cxx @
7//! `dc2915b`.
8//!
9//! The main pieces:
10//!
11//! - [`Device`] — an open DRM node, owning or borrowing its descriptor.
12//! - [`PropertyStore`] — a per-object property cache, so building a frame's
13//! atomic request is hash-map lookups rather than an ioctl per property.
14//! - [`AtomicRequest`] — accumulated property writes, testable and committable.
15//!
16//! # Relationship to the `drm` crate
17//!
18//! Per DR-2 drmkit **wraps** the Smithay `drm` crate and never re-binds the
19//! ioctls. [`Device`] implements [`drm::Device`] and [`drm::control::Device`],
20//! so the whole KMS surface those traits expose is available directly. What
21//! this crate adds is the parts the C++ gives a different contract: descriptor
22//! ownership, the property cache, and the atomic request's export seam.
23//!
24//! # Example
25//!
26//! ```no_run
27//! use drmkit_core::{AtomicRequest, Device, ObjectType, PropertyStore};
28//! use drm::control::AtomicCommitFlags;
29//!
30//! let device = Device::open("/dev/dri/card0")?;
31//! device.enable_universal_planes()?;
32//! device.enable_atomic()?;
33//!
34//! let mut props = PropertyStore::new();
35//! props.cache_properties(&device, 31, ObjectType::Plane)?;
36//!
37//! let mut request = AtomicRequest::new();
38//! request.add_property(31, props.property_id(31, "FB_ID")?, 42)?;
39//!
40//! request.test(&device, AtomicCommitFlags::empty())?;
41//! # Ok::<(), drmkit_core::CoreError>(())
42//! ```
43
44mod atomic;
45mod device;
46mod error;
47mod property;
48mod vblank;
49
50pub use atomic::{AtomicRequest, PropertyWrite, commit_with_out_fence};
51pub use device::{Device, PropertyBlob, framebuffer_modifier, supports_framebuffer_modifiers};
52pub use error::{CoreError, Result};
53pub use property::{ObjectType, PropertyInfo, PropertyStore};
54pub use vblank::{crtc_sequence, event_pending};
55
56// Re-exported so consumers need not depend on `drm` directly for the types
57// that appear in this crate's signatures.
58pub use drm::ClientCapability;
59pub use drm::control::AtomicCommitFlags;
60pub use drm::control::Mode;
61
62#[cfg(test)]
63mod tests;