Skip to main content

Crate drmkit

Crate drmkit 

Source
Expand description

Umbrella crate for drmkit, a layered Linux DRM/KMS display framework — modesetting, plane allocation, scene composition, and scanout.

drmkit is a behavioral-parity Rust port of drm-cxx.

§Using it

Every member crate is a module here, behind a feature of the same name: drmkit::scene is drmkit-scene, drmkit::core is drmkit-core. The default features are the path from a card to a committed scene — core, modeset, dumb, fmt, planes and scene — and full adds every other crate.

[dependencies]
drmkit = { version = "0.1", features = ["cursor", "capture"] }

None of those links a system library. The parts that do are features of their own, so a build machine is never asked for one nobody wanted:

FeatureTurns onLinks
edidEDID parsing in displaylibdisplay-info
hotplugthe hotplug watch in displaylibudev
libinputinput devices in inputlibinput, libudev
xkbkeymaps and key resolution in inputxkbcommon
libseatthe seat backend in sessionlibseat

A member crate’s other features — JPEG in drmkit-capture, the tracing sink in drmkit-log, the device half of drmkit-present — are turned on by naming that crate alongside this one; Cargo unifies the two.

§Status

Phases 0–4 of the porting plan are met. Of phase 5, the v0.1.0-minimal ship gate, what remains is the smoke run on RK3588 and VisionFive 2 boards; the 0.1 releases ship ahead of it. A scene can bring up a display, allocate planes for a layer stack, commit a frame, composite what it cannot place, and release buffers on the right vblank; EDID, color management, cursor and capture are in. So are the present spine, cross-output orchestration, GBM surface sources and client-side decorations.

Not yet here: the GL compositor, the GL and Vulkan scanout producers, EGL streams, the V4L2, GStreamer and nvbufsurface sources, and the Vulkan display surface. Of the 108 test files drm-cxx v5.0.0 has, 75 are ported, 14 partial and 3 not applicable; the 16 still pending each wait on hardware or a library this tree does not have — a GPU render node, the vgem, vivid or vicodec modules, or NVIDIA silicon. TEST_PARITY.md records which, per file.

§The crates

Roughly bottom-up. A consumer driving a display needs -core, -modeset and one of the buffer crates; everything above that is optional.

CrateWhat it is for
drmkit-coreDevice handles, cached properties, atomic requests. Everything else sits on this.
drmkit-modesetChoosing a mode, and dispatching page-flip events.
drmkit-dumbGPU-free CPU-mappable scanout buffers.
drmkit-gbmGBM allocation, for when the GPU renders.
drmkit-fmtFormats and modifiers: what a plane will actually scan out.
drmkit-planesThe plane registry and the allocator that assigns layers to planes.
drmkit-sceneA layer stack, lowered to a frame and committed; composition for what will not fit.
drmkit-scene-sourcesWhere a layer’s pixels come from: dumb buffers, imported DMA-BUFs.
drmkit-scene-gbmA layer fed by a GBM surface — the swap chain a GL or Vulkan producer renders into.
drmkit-scene-setMirrored layers across several scenes, and how many commits a frame across them costs.
drmkit-presentThe scanout spine: buffer rings, modifier negotiation, frame pacing, and a backend that drives them.
drmkit-csdClient-side decorations: title bars, shadows, and getting them onto a plane.
drmkit-displayEDID, driver capabilities, color pipelines and tone mapping.
drmkit-cursorCursor themes, and getting one onto a plane.
drmkit-captureReading back what a CRTC is scanning out.
drmkit-syncsync_file fences, for explicit synchronization.
drmkit-sessionHolding devices across a VT switch.
drmkit-inputlibinput devices and xkb key resolution.
drmkit-logDiagnostics: a process-wide level and an installable sink.
drmkit-timeA swappable presentation clock, so pacing is testable.

§The contracts

Six timing and lifetime rules are load-bearing across the crates, and each is stated once in INVARIANTS.md and cross-referenced from the items that carry it. They are the parts a caller can get wrong without any type complaining — releasing a buffer a commit ago, tearing down while a flip is outstanding — so the doc comment on the item that owns each one is worth reading before using it.

Follow https://github.com/jwinarske/drmkit for the porting plan, the per-phase scope, and what each divergence from the reference turned out to be.

Modules§

capturecapture
Read back what a CRTC is scanning out, and write it to a file.
corecore
Core DRM/KMS device access for drmkit.
csdcsd
Client-side window decorations.
cursorcursor
Cursor themes, and the cursors in them.
displaydisplay
Display characterization and color handling.
dumbdumb
DRM dumb buffers: GPU-free, CPU-mappable scanout surfaces.
fmtfmt
Format-modifier and hardware-compression support for drmkit’s plane allocator.
gbmgbm
GBM buffer allocation.
inputinput
Keyboard, pointer and touch input.
loglog
drmkit’s library-wide diagnostic surface.
modesetmodeset
Mode selection and page-flip dispatch for drmkit.
planesplanes
Display-plane capabilities, the layer model, and the plane allocator.
presentpresent
The present spine: getting rendered frames onto a display, repeatedly.
scenescene
Scene composition for drmkit.
scene_gbmscene-gbm
A scene source backed by a GBM surface.
scene_setscene-set
Several scenes, one frame.
scene_sourcesscene-sources
Tier-1 buffer sources for drmkit scenes.
sessionsession
Holding devices across a VT switch.
syncsync
sync_file fences for explicit synchronization.
timetime
drmkit’s library-wide monotonic clock abstraction.

Constants§

UPSTREAM_BASELINE
The upstream drm-cxx revision this port targets.