Skip to main content

AtomicRequest

Struct AtomicRequest 

Source
pub struct AtomicRequest { /* private fields */ }
Expand description

An atomic modeset request under construction.

§Deviation: no libdrm request object

The C++ allocates a drmModeAtomicReq up front and appends to it, so its valid() reports whether that allocation succeeded. Here the request is a plain vector of PropertyWrites and the drm crate’s AtomicModeReq is built at commit time. There is no allocation to fail, so there is no valid() — construction is infallible.

Implementations§

Source§

impl AtomicRequest

Source

pub const fn new() -> Self

An empty request.

Source

pub fn with_capacity(capacity: usize) -> Self

An empty request with room for capacity writes.

Source

pub fn add_property( &mut self, object_id: u32, property_id: u32, value: u64, ) -> Result<()>

Append a property write.

Order is preserved and duplicates are kept: the kernel applies writes in order, so a later write to the same property wins, and collapsing them here would change what a replayed trace means.

§Errors

CoreError::Io with EINVAL if either id is zero. libdrm’s drmModeAtomicAddProperty rejects a zero id the same way, and rejecting at insertion is what keeps the commit path total: DRM resource handles are non-zero by construction, so a zero id has no representation to build a request from and could only be dropped silently — a commit going out one property short, which is far worse than an error here.

Note that non-zero ids are not checked against real kernel objects. libdrm does not either; that check happens at commit time.

Source

pub fn writes(&self) -> &[PropertyWrite]

The accumulated writes, in submission order.

See PropertyWrite for why this exists rather than a raw request pointer.

Source

pub fn len(&self) -> usize

How many writes are queued.

Source

pub fn is_empty(&self) -> bool

Whether nothing is queued.

Source

pub fn clear(&mut self)

Drop every queued write, keeping the allocation for the next frame.

Source

pub fn test(&self, device: &Device, flags: AtomicCommitFlags) -> Result<()>

Validate the request without applying it (DRM_MODE_ATOMIC_TEST_ONLY).

PAGE_FLIP_EVENT is masked out of flags. The kernel rejects TEST_ONLY | PAGE_FLIP_EVENT with EINVAL — a test applies nothing to hardware, so there is no flip to queue an event on — and callers routinely forward the same flags they would pass to commit. The allocator replays caller flags for its internal test commits, so masking here beats making every caller remember.

§Errors

CoreError::NotMaster if the caller lost DRM master, otherwise CoreError::Io with the kernel’s rejection reason.

Source

pub fn commit(&self, device: &Device, flags: AtomicCommitFlags) -> Result<()>

Apply the request.

§Errors

CoreError::NotMaster if the caller is not DRM master — the one failure a scene suspends on (invariant 2) — otherwise CoreError::Io.

Source

pub fn dump(&self, device: &Device, why: &str)

Log every write this request carries, property ids resolved to names.

A rejected atomic request says only that the kernel disliked something, and nothing in the error names which property. No-op unless DRM_ATOMIC_DEBUG or DRM_ALLOC_DEBUG is set – upstream’s switches, so one variable works on both implementations – and then routed through log_channel!, since the variable is already the opt-in. why labels the dump.

test and commit call it themselves on a rejection other than CoreError::NotMaster, and on the first request accepted after one: a rejected request beside an accepted one is what shows the difference, where a rejection alone is read as whatever looks suspicious. Upstream wires the same two dumps into its allocator and scene; here every request goes through these two methods, so wiring them once covers the allocator, the present backend and the cursor alike.

Trait Implementations§

Source§

impl Clone for AtomicRequest

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AtomicRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AtomicRequest

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.