Skip to main content

Device

Struct Device 

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

An open DRM device.

Port of drm::Device from src/core/device.{hpp,cpp}.

Implements the drm crate’s Device and control::Device traits, so every KMS operation those traits provide is available directly. drmkit wraps rather than re-binds (DR-2); the methods here are the ones the C++ adds on top or gives a different contract.

Implementations§

Source§

impl Device

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open a DRM device node and verify the kernel agrees it is one.

Sets DRM master if possible. Failing to become master is not an error: a client running under a compositor never will be, and the C++ ignores the result for the same reason.

§Errors
Source

pub const fn from_owned_fd(fd: OwnedFd) -> Self

Take ownership of an already-open DRM descriptor.

The descriptor is closed when the device is dropped. This has no C++ counterpart: Device::from_fd there is always non-owning, because C++ cannot express the transfer in a type.

Source

pub const unsafe fn from_borrowed_fd(fd: RawFd) -> Self

Wrap a descriptor owned by someone else.

The returned device does not close fd on drop; the caller — for instance a seat session holding a revocable libseat descriptor — keeps that responsibility. Resume flows replace the device wholesale with a freshly built one, exactly as the C++ move-assigns a new from_fd.

§Safety

fd must be a valid descriptor that stays open for the whole life of the returned Device and of everything derived from it. This cannot be checked: the borrow has no lifetime to tie it to, which is precisely why the safe Device::from_owned_fd exists and should be preferred.

Source

pub fn raw_fd(&self) -> RawFd

The raw descriptor, for interop with code that needs one.

Borrowed, never transferred.

Source

pub const fn owns_fd(&self) -> bool

Whether this device will close its descriptor on drop.

Source

pub fn enable_universal_planes(&self) -> Result<()>

Enable the universal-planes client capability.

Without it the kernel hides primary and cursor planes from plane_handles, and the allocator sees only overlays.

§Errors

CoreError::Io if the driver rejects the capability.

Source

pub fn enable_atomic(&self) -> Result<()>

Enable the atomic client capability.

§Errors

CoreError::Io if the driver does not support atomic modesetting.

Source

pub fn set_client_cap(&self, cap: ClientCapability, enable: bool) -> Result<()>

Set an arbitrary client capability.

§Errors

CoreError::Io if the driver rejects it.

Source

pub fn set_master(&self) -> Result<()>

Become DRM master.

§Errors

CoreError::Io with EBUSY if another client already holds it, or CoreError::NotMaster if the caller lacks the privilege to take it.

Source

pub fn drop_master(&self) -> Result<()>

Release DRM master.

§Errors

CoreError::Io if the ioctl fails.

Source

pub fn property_blob(&self, blob_id: u64) -> Result<Vec<u8>>

Read an immutable blob property’s payload.

This is the seam drmkit-fmt is built around: the IN_FORMATS blob is fetched here and parsed by FormatTable::from_blob, which keeps the format crate device-free and no_std.

§Errors

CoreError::Io if the blob id is unknown to the kernel.

Source§

impl Device

Source

pub fn create_property_blob<T: ?Sized>( &self, data: &T, ) -> Result<PropertyBlob<'_>>

Stage data as a kernel property blob.

The blob borrows the device, so it cannot outlive the descriptor that has to free it.

§Errors

CoreError if the kernel refuses to create the blob.

Trait Implementations§

Source§

impl AsFd for Device

Source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
Source§

impl Debug for Device

Source§

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

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

impl Device for Device

Source§

fn acquire_master_lock(&self) -> Result<(), Error>

Acquires the DRM Master lock for this process. Read more
Source§

fn release_master_lock(&self) -> Result<(), Error>

Releases the DRM Master lock for another process to use.
Source§

fn generate_auth_token(&self) -> Result<AuthToken, Error>

👎Deprecated:

Consider opening a render node instead.

Generates an AuthToken for this process.
Source§

fn authenticate_auth_token(&self, token: AuthToken) -> Result<(), Error>

Authenticates an AuthToken from another process.
Source§

fn set_client_capability( &self, cap: ClientCapability, enable: bool, ) -> Result<(), Error>

Requests the driver to expose or hide certain capabilities. See ClientCapability for more information.
Source§

fn get_bus_id(&self) -> Result<OsString, Error>

Gets the bus ID of this device.
Source§

fn authenticated(&self) -> Result<bool, Error>

Check to see if our AuthToken has been authenticated by the DRM Master
Source§

fn get_driver_capability(&self, cap: DriverCapability) -> Result<u64, Error>

Gets the value of a capability.
Source§

fn get_driver(&self) -> Result<Driver, Error>

Possible errors: Read more
Source§

fn wait_vblank( &self, target_sequence: VblankWaitTarget, flags: VblankWaitFlags, high_crtc: u32, user_data: usize, ) -> Result<VblankWaitReply, Error>

Waits for a vblank.
Source§

impl Device for Device

Source§

fn resource_handles(&self) -> Result<ResourceHandles, Error>

Gets the set of resource handles that this device currently controls
Source§

fn plane_handles(&self) -> Result<Vec<Handle>, Error>

Gets the set of plane handles that this device currently has
Source§

fn get_connector( &self, handle: Handle, force_probe: bool, ) -> Result<Info, Error>

Returns information about a specific connector Read more
Source§

fn get_encoder(&self, handle: Handle) -> Result<Info, Error>

Returns information about a specific encoder
Source§

fn get_crtc(&self, handle: Handle) -> Result<Info, Error>

Returns information about a specific CRTC
Source§

fn set_crtc( &self, handle: Handle, framebuffer: Option<Handle>, pos: (u32, u32), conns: &[Handle], mode: Option<Mode>, ) -> Result<(), Error>

Set CRTC state
Source§

fn get_framebuffer(&self, handle: Handle) -> Result<Info, Error>

Returns information about a specific framebuffer
Source§

fn get_planar_framebuffer( &self, handle: Handle, ) -> Result<PlanarInfo, GetPlanarFramebufferError>

Returns information about a specific framebuffer (with modifiers)
Source§

fn add_framebuffer<B>( &self, buffer: &B, depth: u32, bpp: u32, ) -> Result<Handle, Error>
where B: Buffer + ?Sized,

Add a new framebuffer
Source§

fn add_planar_framebuffer<B>( &self, planar_buffer: &B, flags: FbCmd2Flags, ) -> Result<Handle, Error>
where B: PlanarBuffer + ?Sized,

Add framebuffer (with modifiers)
Source§

fn dirty_framebuffer( &self, handle: Handle, clips: &[ClipRect], ) -> Result<(), Error>

Mark parts of a framebuffer dirty
Source§

fn destroy_framebuffer(&self, handle: Handle) -> Result<(), Error>

Destroy a framebuffer
Source§

fn get_plane(&self, handle: Handle) -> Result<Info, Error>

Returns information about a specific plane
Source§

fn set_plane( &self, handle: Handle, crtc: Handle, framebuffer: Option<Handle>, flags: u32, crtc_rect: (i32, i32, u32, u32), src_rect: (u32, u32, u32, u32), ) -> Result<(), Error>

Set plane state. Read more
Source§

fn get_property(&self, handle: Handle) -> Result<Info, Error>

Returns information about a specific property.
Source§

fn set_property<T>( &self, handle: T, prop: Handle, value: u64, ) -> Result<(), Error>
where T: ResourceHandle,

Sets a property for a specific resource.
Source§

fn create_property_blob<T>(&self, data: &T) -> Result<Value<'static>, Error>
where T: ?Sized,

Create a property blob value from a given data blob
Source§

fn get_property_blob(&self, blob: u64) -> Result<Vec<u8>, Error>

Get a property blob’s data
Source§

fn destroy_property_blob(&self, blob: u64) -> Result<(), Error>

Destroy a given property blob value
Source§

fn get_modes(&self, handle: Handle) -> Result<Vec<Mode>, Error>

Returns the set of Modes that a particular connector supports.
Source§

fn get_properties<T>(&self, handle: T) -> Result<PropertyValueSet, Error>
where T: ResourceHandle,

Gets a list of property handles and values for this resource.
Source§

fn get_gamma( &self, crtc: Handle, red: &mut [u16], green: &mut [u16], blue: &mut [u16], ) -> Result<(), Error>

Receive the currently set gamma ramp of a crtc
Source§

fn set_gamma( &self, crtc: Handle, red: &[u16], green: &[u16], blue: &[u16], ) -> Result<(), Error>

Set a gamma ramp for the given crtc
Source§

fn open_buffer(&self, name: Name) -> Result<Handle, Error>

Open a GEM buffer handle by name
Source§

fn close_buffer(&self, handle: Handle) -> Result<(), Error>

Close a GEM buffer handle
Source§

fn create_dumb_buffer( &self, size: (u32, u32), format: DrmFourcc, bpp: u32, ) -> Result<DumbBuffer, Error>

Create a new dumb buffer with a given size and pixel format
Source§

fn map_dumb_buffer<'a>( &self, buffer: &'a mut DumbBuffer, ) -> Result<DumbMapping<'a>, Error>

Map the buffer for access
Source§

fn destroy_dumb_buffer(&self, buffer: DumbBuffer) -> Result<(), Error>

Free the memory resources of a dumb buffer
Source§

fn set_cursor<B>(&self, crtc: Handle, buffer: Option<&B>) -> Result<(), Error>
where B: Buffer + ?Sized,

👎Deprecated:

Usage of deprecated ioctl set_cursor: use a cursor plane instead

Sets a hardware-cursor on the given crtc with the image of a given buffer Read more
Source§

fn set_cursor2<B>( &self, crtc: Handle, buffer: Option<&B>, hotspot: (i32, i32), ) -> Result<(), Error>
where B: Buffer + ?Sized,

👎Deprecated:

Usage of deprecated ioctl set_cursor2: use a cursor plane instead

Sets a hardware-cursor on the given crtc with the image of a given buffer and a hotspot marking the click point of the cursor. Read more
Source§

fn move_cursor(&self, crtc: Handle, pos: (i32, i32)) -> Result<(), Error>

👎Deprecated:

Usage of deprecated ioctl move_cursor: use a cursor plane instead

Moves a set cursor on a given crtc
Source§

fn atomic_commit( &self, flags: AtomicCommitFlags, req: AtomicModeReq, ) -> Result<(), Error>

Request an atomic commit with given flags and property-value pair for a list of objects.
Source§

fn prime_fd_to_buffer(&self, fd: BorrowedFd<'_>) -> Result<Handle, Error>

Convert a prime file descriptor to a GEM buffer handle
Source§

fn buffer_to_prime_fd( &self, handle: Handle, flags: u32, ) -> Result<OwnedFd, Error>

Convert a GEM buffer handle to a prime file descriptor
Source§

fn page_flip( &self, handle: Handle, framebuffer: Handle, flags: PageFlipFlags, target_sequence: Option<PageFlipTarget>, ) -> Result<(), Error>

Queue a page flip on the given crtc
Source§

fn create_syncobj(&self, signalled: bool) -> Result<Handle, Error>

Creates a syncobj.
Source§

fn destroy_syncobj(&self, handle: Handle) -> Result<(), Error>

Destroys a syncobj.
Source§

fn syncobj_to_fd( &self, handle: Handle, export_sync_file: bool, ) -> Result<OwnedFd, Error>

Exports a syncobj as an inter-process file descriptor or as a poll()-able sync file.
Source§

fn fd_to_syncobj( &self, fd: BorrowedFd<'_>, import_sync_file: bool, ) -> Result<Handle, Error>

Imports a file descriptor exported by Self::syncobj_to_fd back into a process-local handle.
Source§

fn syncobj_wait( &self, handles: &[Handle], timeout_nsec: i64, wait_all: bool, wait_for_submit: bool, ) -> Result<u32, Error>

Waits for one or more syncobjs to become signalled.
Source§

fn syncobj_reset(&self, handles: &[Handle]) -> Result<(), Error>

Resets (un-signals) one or more syncobjs.
Source§

fn syncobj_signal(&self, handles: &[Handle]) -> Result<(), Error>

Signals one or more syncobjs.
Source§

fn syncobj_timeline_wait( &self, handles: &[Handle], points: &[u64], timeout_nsec: i64, wait_all: bool, wait_for_submit: bool, wait_available: bool, ) -> Result<u32, Error>

Waits for one or more specific timeline syncobj points.
Source§

fn syncobj_timeline_query( &self, handles: &[Handle], points: &mut [u64], last_submitted: bool, ) -> Result<(), Error>

Queries for state of one or more timeline syncobjs.
Source§

fn syncobj_timeline_transfer( &self, src_handle: Handle, dst_handle: Handle, src_point: u64, dst_point: u64, ) -> Result<(), Error>

Transfers one timeline syncobj point to another.
Source§

fn syncobj_timeline_signal( &self, handles: &[Handle], points: &[u64], ) -> Result<(), Error>

Signals one or more specific timeline syncobj points.
Source§

fn syncobj_eventfd( &self, handle: Handle, point: u64, eventfd: BorrowedFd<'_>, wait_available: bool, ) -> Result<(), Error>

Register an eventfd to be signalled by a syncobj.
Source§

fn create_lease( &self, objects: &[NonZero<u32>], flags: u32, ) -> Result<(NonZero<u32>, OwnedFd), Error>

Create a drm lease
Source§

fn list_lessees(&self) -> Result<Vec<NonZero<u32>>, Error>

List active lessees
Source§

fn revoke_lease(&self, lessee_id: NonZero<u32>) -> Result<(), Error>

Revoke a previously issued drm lease
Source§

fn receive_events(&self) -> Result<Events, Error>
where Self: Sized,

Receive pending events

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> 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, 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.