Expand description
Display-plane capabilities, the layer model, and the plane allocator.
Port of src/planes/ from drm-cxx @ dc2915b.
Three pieces, bottom-up:
PlaneCapabilitiesandPlaneRegistry— what each plane on a device can do: which CRTCs it feeds, which formats and modifiers it scans out, whether it rotates, where its zpos may sit. Built from a device behind thedevicefeature, or from fixtures a caller supplies, which is what lets the allocator be tested against hardware nobody has.Layer— one thing to put on screen, as a bag of KMS properties plus the hints that inform placement.Allocator— which layer goes on which plane.
§Why placement is a search
Nothing in the kernel’s uAPI answers “can these layers be scanned out
together”. IN_FORMATS prunes, possible_crtcs prunes, and neither
settles it: bandwidth limits, scaler counts and per-driver rules decide the
rest and are not advertised anywhere. The only oracle is an atomic
TEST_ONLY commit, which costs an ioctl.
So the allocator proposes and the kernel disposes, and the whole design is
about proposing well enough that few proposals are needed. It seeds with a
maximum bipartite matching, orders candidates by a score, backtracks by
dropping the layer it can most afford to composite, and spends at most
Allocator::DEFAULT_MAX_TEST_COMMITS test commits per search before
settling for what it has. Layers that do not overlap are solved
independently, so a busy corner of the screen does not make the rest of it
expensive.
Two caches keep the steady state near zero ioctls: a warm start that re-validates last frame’s assignment, and the fast path below.
§Invariant 4
Layer::property_hash isolates content from placement: a frame that
changes only content on already-placed layers reuses the cached plane
assignment and skips the redundant TEST_ONLY commit.
The C++ can only document which properties are which. Here the split is
PropTag::class, an exhaustive match, so a property added without a
classification does not compile — the misclassification the invariant warns
about cannot reach a running system.
Structs§
- Allocation
- The result of one allocation pass.
- Allocator
- Assigns layers to display planes.
- Always
Accept - A committer that accepts everything. For tests that care about which assignment the search proposes rather than how it narrows one down.
- Bipartite
Matching - A reusable Hopcroft–Karp matcher.
- Blend
Mode Values - Driver-assigned enum integers for a property’s named values.
- Color
Encoding Values - Driver-assigned enum integers for
COLOR_ENCODING. - Color
Pipeline - Per-plane color pipeline support (pre-blend CMS).
- Color
Range Values - Driver-assigned enum integers for
COLOR_RANGE. - Diagnostics
- What one allocation pass did.
- Layer
- One layer the scene wants on screen.
- LayerId
- Stable identity for a layer across frames.
- Layer
Ref - One layer offered to the allocator.
- Output
- The layers destined for one CRTC, in presentation order.
- Plane
Assignment - Plane-to-layer assignment.
- Plane
Capabilities - Everything the allocator needs to know about one plane.
- Plane
Registry - Every display plane the device exposes.
- Property
Snapshot - A snapshot of a layer’s property state, for diffing against the last commit.
- Rect
- An axis-aligned rectangle in CRTC pixels.
- Score
Context - Everything
score_pairneeds that is not the plane or the layer. - Stack
Entry - One armed plane in a frame’s stack.
- Test
Cache - Memoized test-commit verdicts, keyed by
(plane, property_hash).
Enums§
- Color
Encoding - Plane
COLOR_ENCODING: the YCbCr-to-RGB matrix applied when scanning out a YUV format. Ignored by the kernel for RGB. - Color
Range - Plane
COLOR_RANGE: whether 8-bit YCbCr is full-range (0..255) or limited-range (16..235 luma, 16..240 chroma). - Content
Type - What a layer is showing, for placement priority.
- Plane
Type - The kernel’s plane type.
- Prop
Class - What a property describes, for the FB-only fast path.
- PropTag
- Property tags a layer recognizes.
- Test
Failure - Why a test commit was rejected.
Constants§
- NUM_
PROPS - Number of distinct property tags.
- WARM_
STABILITY_ BONUS - The bonus for keeping a layer on the plane it held last frame.
Traits§
- Test
Committer - Validates tentative plane assignments.
Functions§
- bandwidth_
class_ bonus - Power-aware placement bonus for a buffer’s bandwidth class.
- cost_
bias - Bounded tiebreak by a layer’s per-frame scanout byte cost.
- effective_
zpos - Where a layer requesting
layer_zposstacks onplane: the fixed slot, else the layer’s own written zpos.Nonewhen neither is known. - keep_
priority - Keep-or-drop ordering under plane pressure.
- layer_
priority - Content-class placement priority.
- layers_
intersect - Whether two layers overlap on the CRTC.
- multirect_
pairing_ ok - Whether a plane whose multirect parent is
parentmay be placed, given the planes already in use: a plain plane always, a virtual one only once its parent is in use.in_use(id)reports whether a plane id is taken. - parse_
blend_ stage_ limit - How many planes a CRTC can stack, from its
capabilitiesblob, orNonewhen the blob does not say. - parse_
multirect_ parent - The parent plane id from a
capabilitiesblob’s text, orNonewhen the blob does not mark the plane as a multirect rectangle, or the value is garbage. - plane_
statically_ compatible - Whether a plane could possibly scan out a layer.
- rects_
intersect - Whether two destination rectangles overlap.
- rescale_
alpha - Map a 16-bit layer alpha onto the range a plane advertises.
- score_
pair - Score a candidate placement. Higher is more preferred.
- split_
independent_ groups - Partition layer indices into spatially independent groups.
- stack_
zpos - Number the armed planes’ zpos densely, in requested order.
- stacked_
zpos - The zpos to write on each armed plane, as
(plane_id, value). - stacked_
zpos_ beneath stacked_zposwithbeneathstacked under the planes requesting the same zpos: the composition canvas in the slotAllocator::canvas_zposgives it.- stacking_
consistent - Whether layer A (zpos
za) onpaand layer B (zposzb) onpbstack in the order their zpos values request. - stacks_
by_ plane_ id - Whether the planes on
crtc_indexstack by plane id: no non-cursor plane exposeszpos. - zpos_
fixed - Whether the plane’s zpos is a single fixed slot that cannot be written.