Struct Device

Source
pub struct Device<T: AsFd> { /* private fields */ }
Expand description

An open GBM device

Implementations§

Source§

impl<T: AsFd> Device<T>

Source

pub fn new(fd: T) -> IoResult<Device<T>>

Open a GBM device from a given open DRM device.

The underlying file descriptor passed in is used by the backend to communicate with platform for allocating the memory. For allocations using DRI this would be the file descriptor returned when opening a device such as /dev/dri/card0.

Source

pub fn backend_name(&self) -> &str

Get the backend name

Source

pub fn is_format_supported( &self, format: Format, usage: BufferObjectFlags, ) -> bool

Test if a format is supported for a given set of usage flags

Source

pub fn format_modifier_plane_count( &self, format: Format, modifier: Modifier, ) -> Option<u32>

Get the required number of planes for a given format and modifier

Some combination (e.g. when using a Modifier::Invalid) might not have a defined/fixed number of planes. In these cases the function might return Option::None.

Source

pub fn create_surface<U: 'static>( &self, width: u32, height: u32, format: Format, usage: BufferObjectFlags, ) -> IoResult<Surface<U>>

Allocate a new surface object

Source

pub fn create_surface_with_modifiers<U: 'static>( &self, width: u32, height: u32, format: Format, modifiers: impl Iterator<Item = Modifier>, ) -> IoResult<Surface<U>>

Allocate a new surface object with explicit modifiers

Source

pub fn create_surface_with_modifiers2<U: 'static>( &self, width: u32, height: u32, format: Format, modifiers: impl Iterator<Item = Modifier>, usage: BufferObjectFlags, ) -> IoResult<Surface<U>>

Allocate a new surface object with explicit modifiers and flags

Source

pub fn create_buffer_object<U: 'static>( &self, width: u32, height: u32, format: Format, usage: BufferObjectFlags, ) -> IoResult<BufferObject<U>>

Allocate a buffer object for the given dimensions

Source

pub fn create_buffer_object_with_modifiers<U: 'static>( &self, width: u32, height: u32, format: Format, modifiers: impl Iterator<Item = Modifier>, ) -> IoResult<BufferObject<U>>

Allocate a buffer object for the given dimensions with explicit modifiers

Source

pub fn create_buffer_object_with_modifiers2<U: 'static>( &self, width: u32, height: u32, format: Format, modifiers: impl Iterator<Item = Modifier>, usage: BufferObjectFlags, ) -> IoResult<BufferObject<U>>

Allocate a buffer object for the given dimensions with explicit modifiers and flags

Source

pub fn import_buffer_object_from_wayland<U: 'static>( &self, buffer: &WlBuffer, usage: BufferObjectFlags, ) -> IoResult<BufferObject<U>>

Create a GBM buffer object from a wayland buffer

This function imports a foreign [WlBuffer] object and creates a new GBM buffer object for it. This enables using the foreign object with a display API such as KMS.

The GBM bo shares the underlying pixels but its life-time is independent of the foreign object.

Source

pub fn import_buffer_object_from_dma_buf<U: 'static>( &self, buffer: BorrowedFd<'_>, width: u32, height: u32, stride: u32, format: Format, usage: BufferObjectFlags, ) -> IoResult<BufferObject<U>>

Create a GBM buffer object from a dma buffer

This function imports a foreign dma buffer from an open file descriptor and creates a new GBM buffer object for it. This enables using the foreign object with a display API such as KMS.

The GBM bo shares the underlying pixels but its life-time is independent of the foreign object.

Source

pub fn import_buffer_object_from_dma_buf_with_modifiers<U: 'static>( &self, len: u32, buffers: [Option<BorrowedFd<'_>>; 4], width: u32, height: u32, format: Format, usage: BufferObjectFlags, strides: [i32; 4], offsets: [i32; 4], modifier: Modifier, ) -> IoResult<BufferObject<U>>

Create a GBM buffer object from a dma buffer with explicit modifiers

This function imports a foreign dma buffer from an open file descriptor and creates a new GBM buffer object for it. This enables using the foreign object with a display API such as KMS.

The GBM bo shares the underlying pixels but its life-time is independent of the foreign object.

Trait Implementations§

Source§

impl<T: AsFd> AsFd for Device<T>

Source§

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

Borrows the file descriptor. Read more
Source§

impl<T: AsFd> AsRaw<gbm_device> for Device<T>

Source§

fn as_raw(&self) -> *const gbm_device

Receive a raw pointer representing this type.
Source§

impl<T: AsFd + Clone> Clone for Device<T>

Source§

fn clone(&self) -> Device<T>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: AsFd> Debug for Device<T>

Source§

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

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

impl<T: AsFd> Deref for Device<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: AsFd> DerefMut for Device<T>

Source§

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

Mutably dereferences the value.
Source§

impl<T: DrmDevice + AsFd> Device for Device<T>

§

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

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

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

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

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

👎Deprecated: Consider opening a render node instead.
Generates an [AuthToken] for this process.
§

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

Authenticates an [AuthToken] from another process.
§

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

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

Gets the bus ID of this device.
§

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

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

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

Gets the value of a capability.
§

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

Possible errors: Read more
§

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

Waits for a vblank.
Source§

impl<T: DrmControlDevice + AsFd> Device for Device<T>

§

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

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

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

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

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

Returns information about a specific connector Read more
§

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

Returns information about a specific encoder
§

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

Returns information about a specific CRTC
§

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

Set CRTC state
§

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

Returns information about a specific framebuffer
§

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

Returns information about a specific framebuffer (with modifiers)
§

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

Add a new framebuffer
§

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

Add framebuffer (with modifiers)
§

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

Mark parts of a framebuffer dirty
§

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

Destroy a framebuffer
§

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

Returns information about a specific plane
§

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
§

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

Returns information about a specific property.
§

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

Sets a property for a specific resource.
§

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

Create a property blob value from a given data blob
§

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

Get a property blob’s data
§

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

Destroy a given property blob value
§

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

Returns the set of [Mode]s that a particular connector supports.
§

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

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

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
§

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

Set a gamma ramp for the given crtc
§

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

Open a GEM buffer handle by name
§

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

Close a GEM buffer handle
§

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
§

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

Map the buffer for access
§

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

Free the memory resources of a dumb buffer
§

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
§

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
§

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
§

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

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

Convert a prime file descriptor to a GEM buffer handle
§

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

Convert a GEM buffer handle to a prime file descriptor
§

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

Queue a page flip on the given crtc
§

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

Creates a syncobj.
§

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

Destroys a syncobj.
§

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

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

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

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

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

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

Signals one or more syncobjs.
§

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

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

Queries for state of one or more timeline syncobjs.
§

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

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

Signals one or more specific timeline syncobj points.
§

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

Register an eventfd to be signalled by a syncobj.
§

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

Create a drm lease
§

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

List active lessees
§

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

Revoke a previously issued drm lease
§

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

Receive pending events

Auto Trait Implementations§

§

impl<T> Freeze for Device<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for Device<T>

§

impl<T> Send for Device<T>
where T: Send,

§

impl<T> Sync for Device<T>
where T: Sync,

§

impl<T> Unpin for Device<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Device<T>

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.