Struct gbm::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 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 unsafe fn import_buffer_object_from_egl<U: 'static>( &self, buffer: EGLImage, usage: BufferObjectFlags ) -> IoResult<BufferObject<U>>

Create a GBM buffer object from an egl buffer

This function imports a foreign EGLImage 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.

§Safety

The given EGLImage is a raw pointer. Passing null or an invalid EGLImage will cause undefined behavior.

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>

§

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: DrmControlDevice + AsFd> Device for Device<T>

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>

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<T: DrmDevice + AsFd> Device for Device<T>

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.

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>

§

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> Downcast for T
where T: Any,

source§

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

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

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

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

§

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

§

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

§

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.