Skip to main content

TestCommitter

Trait TestCommitter 

Source
pub trait TestCommitter {
    // Required method
    fn test_assignment(
        &mut self,
        assignment: &[(u32, LayerRef<'_>)],
    ) -> Result<(), TestFailure>;

    // Provided methods
    fn set_extra_plane(&mut self, plane_id: u32, layer: Layer) { ... }
    fn clear_extra_plane(&mut self) { ... }
    fn lit_planes(&mut self, crtc_id: u32) -> Option<Vec<u32>> { ... }
}
Expand description

Validates tentative plane assignments.

§Why this is a trait

The C++ allocator holds a Device and issues TEST_ONLY commits itself. Doing the same here would make drmkit-planes depend on drmkit-core and give up being device-free — and the plan wants this crate no_std-adjacent (§5).

Handing the commit back to the caller keeps the split clean: the allocator decides what to try, the scene knows how to ask the kernel, and the property-name-to-id resolution stays next to the PropertyStore that owns it. It also makes the whole search testable against a fake, which is how the suite reaches its coverage with no hardware.

Required Methods§

Source

fn test_assignment( &mut self, assignment: &[(u32, LayerRef<'_>)], ) -> Result<(), TestFailure>

Validate an assignment with a TEST_ONLY commit.

assignment is (plane_id, layer) pairs. An implementation is expected to disable every other CRTC-compatible plane in the same request: without that, the test inherits stale state from the previously committed plane and reports a spurious rejection when a layer migrates between planes on one CRTC.

§Errors

TestFailure::Rejected for an ordinary kernel rejection, or TestFailure::NotMaster when DRM master was lost.

Provided Methods§

Source

fn set_extra_plane(&mut self, plane_id: u32, layer: Layer)

Arm one more plane in every test, alongside the assignment.

The composition canvas lands on a plane the assignment never names, so without this the search validates a frame one plane smaller than the one that gets committed. Where the hardware lights fewer planes than it advertises, that difference is a frame the kernel refuses – and a refused frame shows nothing at all. Telling the committer about the canvas makes the search account for it, so it drops a layer into the composition instead of proposing something uncommittable.

The plane is excluded from the test’s disable pass for as long as it is set. Call TestCommitter::clear_extra_plane afterwards.

Defaults to doing nothing, which is right for a committer that accepts everything or one that is not talking to a device.

Source

fn clear_extra_plane(&mut self)

Stop arming the plane set by TestCommitter::set_extra_plane.

Source

fn lit_planes(&mut self, crtc_id: u32) -> Option<Vec<u32>>

The planes the kernel has lit on crtc_id right now, whoever lit them; None when the committer cannot tell.

A scene asks this while it does not yet know what the kernel holds – before its first commit lands, after a rebind or a resume – so the frame can turn off a plane another client left armed, as every test already does. None, the default, makes the scene turn off every plane it does not use instead, which is right but writes more.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§