Skip to main content

Card

Struct Card 

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

An open DRM device.

Releases DRM master on drop, so a crash or a clean exit both hand the console back rather than leaving a black screen that needs a reboot.

Implementations§

Source§

impl Card

Source

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

Opens a specific card node, such as /dev/dri/card0.

Source

pub fn open_first() -> Result<Self, DrmError>

Opens the first card node that actually has a display output.

Nodes are tried in name order and skipped unless they report at least one connector, which filters out render-only devices.

Source

pub fn from_fd(fd: OwnedFd) -> Self

Adopts a descriptor opened by somebody else.

This is how to coexist with libseat or a systemd unit that holds the device rights, rather than demanding root.

Source

pub fn path(&self) -> Option<&Path>

The node this card was opened from, if it was opened by path.

Source

pub fn has_display_output(&self) -> bool

Returns true if this device has connectors, rather than being a render node.

Source

pub fn become_master(&self) -> Result<(), DrmError>

Takes the DRM master lock, which is required to set a mode.

Fails if a compositor or another instance already holds it. See the crate documentation for the ways to have the right to it.

Source

pub fn release_master(&self)

Gives the master lock back, restoring whatever had the console before.

Source

pub fn is_master(&self) -> bool

Returns true if this process currently holds DRM master.

Source

pub fn connectors(&self) -> Result<(Vec<Handle>, Vec<ConnectorInfo>), DrmError>

Reads every connector, as handles and as plain data for crate::mode.

The two vectors are index-aligned: a crate::Selection::connector indexes both.

Source

pub fn crtc_for(&self, connector: Handle) -> Result<Handle, DrmError>

Finds a CRTC that can drive connector.

Prefers the one already routed to it, so taking over from the console does not reshuffle the pipeline for no reason.

Trait Implementations§

Source§

impl AsFd for Card

Source§

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

Borrows the file descriptor. Read more
Source§

impl Debug for Card

Source§

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

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

impl Device for Card

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 Card

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
Source§

impl Drop for Card

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Freeze for Card

§

impl !RefUnwindSafe for Card

§

impl !Sync for Card

§

impl Send for Card

§

impl Unpin for Card

§

impl UnsafeUnpin for Card

§

impl UnwindSafe for Card

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.