pub struct Device<T: AsRawFd + 'static> { /* private fields */ }Expand description
An open GBM device
Implementations
sourceimpl Device<FdWrapper>
impl Device<FdWrapper>
sourcepub unsafe fn new_from_fd(fd: RawFd) -> IoResult<Device<FdWrapper>>
pub unsafe fn new_from_fd(fd: RawFd) -> IoResult<Device<FdWrapper>>
Open a GBM device from a given unix file descriptor.
The 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.
Safety
The lifetime of the resulting device depends on the ownership of the file descriptor. Closing the file descriptor before dropping the Device will lead to undefined behavior.
sourceimpl<T: AsRawFd + 'static> Device<T>
impl<T: AsRawFd + 'static> Device<T>
sourcepub fn new(fd: T) -> IoResult<Device<T>>
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.
sourcepub fn backend_name(&self) -> &str
pub fn backend_name(&self) -> &str
Get the backend name
sourcepub fn is_format_supported(
&self,
format: Format,
usage: BufferObjectFlags
) -> bool
pub fn is_format_supported(
&self,
format: Format,
usage: BufferObjectFlags
) -> bool
Test if a format is supported for a given set of usage flags
sourcepub fn create_surface<U: 'static>(
&self,
width: u32,
height: u32,
format: Format,
usage: BufferObjectFlags
) -> IoResult<Surface<U>>
pub fn create_surface<U: 'static>(
&self,
width: u32,
height: u32,
format: Format,
usage: BufferObjectFlags
) -> IoResult<Surface<U>>
Allocate a new surface object
sourcepub fn create_surface_with_modifiers<U: 'static>(
&self,
width: u32,
height: u32,
format: Format,
modifiers: impl Iterator<Item = Modifier>
) -> IoResult<Surface<U>>
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
sourcepub fn create_surface_with_modifiers2<U: 'static>(
&self,
width: u32,
height: u32,
format: Format,
modifiers: impl Iterator<Item = Modifier>,
usage: BufferObjectFlags
) -> IoResult<Surface<U>>
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
sourcepub fn create_buffer_object<U: 'static>(
&self,
width: u32,
height: u32,
format: Format,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
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
sourcepub fn create_buffer_object_with_modifiers<U: 'static>(
&self,
width: u32,
height: u32,
format: Format,
modifiers: impl Iterator<Item = Modifier>
) -> IoResult<BufferObject<U>>
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
sourcepub 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>>
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
sourcepub fn import_buffer_object_from_wayland<U: 'static>(
&self,
buffer: &WlBuffer,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
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.
sourcepub unsafe fn import_buffer_object_from_egl<U: 'static>(
&self,
buffer: EGLImage,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
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.
sourcepub fn import_buffer_object_from_dma_buf<U: 'static>(
&self,
buffer: RawFd,
width: u32,
height: u32,
stride: u32,
format: Format,
usage: BufferObjectFlags
) -> IoResult<BufferObject<U>>
pub fn import_buffer_object_from_dma_buf<U: 'static>(
&self,
buffer: RawFd,
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.
sourcepub fn import_buffer_object_from_dma_buf_with_modifiers<U: 'static>(
&self,
len: u32,
buffers: [RawFd; 4],
width: u32,
height: u32,
format: Format,
usage: BufferObjectFlags,
strides: [i32; 4],
offsets: [i32; 4],
modifier: Modifier
) -> IoResult<BufferObject<U>>
pub fn import_buffer_object_from_dma_buf_with_modifiers<U: 'static>(
&self,
len: u32,
buffers: [RawFd; 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
sourceimpl<T: AsRawFd + 'static> AsRaw<gbm_device> for Device<T>
impl<T: AsRawFd + 'static> AsRaw<gbm_device> for Device<T>
sourcefn as_raw(&self) -> *const gbm_device
fn as_raw(&self) -> *const gbm_device
Receive a raw pointer representing this type.
sourceimpl<T: DrmDevice + AsRawFd + 'static> Device for Device<T>
impl<T: DrmDevice + AsRawFd + 'static> Device for Device<T>
sourcefn acquire_master_lock(&self) -> Result<(), SystemError>
fn acquire_master_lock(&self) -> Result<(), SystemError>
Acquires the DRM Master lock for this process. Read more
sourcefn release_master_lock(&self) -> Result<(), SystemError>
fn release_master_lock(&self) -> Result<(), SystemError>
Releases the DRM Master lock for another process to use.
sourcefn generate_auth_token(&self) -> Result<AuthToken, SystemError>
fn generate_auth_token(&self) -> Result<AuthToken, SystemError>
Consider opening a render node instead.
Generates an AuthToken for this process.
sourcefn authenticate_auth_token(&self, token: AuthToken) -> Result<(), SystemError>
fn authenticate_auth_token(&self, token: AuthToken) -> Result<(), SystemError>
Authenticates an AuthToken from another process.
sourcefn set_client_capability(
&self,
cap: ClientCapability,
enable: bool
) -> Result<(), SystemError>
fn set_client_capability(
&self,
cap: ClientCapability,
enable: bool
) -> Result<(), SystemError>
Requests the driver to expose or hide certain capabilities. See
ClientCapability for more information. Read more
sourcefn get_bus_id(&self) -> Result<OsString, SystemError>
fn get_bus_id(&self) -> Result<OsString, SystemError>
Gets the [BusID] of this device.
sourcefn authenticated(&self) -> Result<bool, SystemError>
fn authenticated(&self) -> Result<bool, SystemError>
sourcefn get_driver_capability(
&self,
cap: DriverCapability
) -> Result<u64, SystemError>
fn get_driver_capability(
&self,
cap: DriverCapability
) -> Result<u64, SystemError>
Gets the value of a capability.
sourcefn get_driver(&self) -> Result<Driver, SystemError>
fn get_driver(&self) -> Result<Driver, SystemError>
Possible errors: Read more
sourcefn wait_vblank(
&self,
target_sequence: VblankWaitTarget,
flags: VblankWaitFlags,
high_crtc: u32,
user_data: usize
) -> Result<VblankWaitReply, SystemError>
fn wait_vblank(
&self,
target_sequence: VblankWaitTarget,
flags: VblankWaitFlags,
high_crtc: u32,
user_data: usize
) -> Result<VblankWaitReply, SystemError>
Waits for a vblank.
sourceimpl<T: DrmControlDevice + AsRawFd + 'static> Device for Device<T>
impl<T: DrmControlDevice + AsRawFd + 'static> Device for Device<T>
sourcefn resource_handles(&self) -> Result<ResourceHandles, SystemError>
fn resource_handles(&self) -> Result<ResourceHandles, SystemError>
Gets the set of resource handles that this device currently controls
sourcefn plane_handles(&self) -> Result<Vec<Handle, Global>, SystemError>
fn plane_handles(&self) -> Result<Vec<Handle, Global>, SystemError>
Gets the set of plane handles that this device currently has
sourcefn get_connector(
&self,
handle: Handle,
force_probe: bool
) -> Result<Info, SystemError>
fn get_connector(
&self,
handle: Handle,
force_probe: bool
) -> Result<Info, SystemError>
Returns information about a specific connector
sourcefn get_encoder(&self, handle: Handle) -> Result<Info, SystemError>
fn get_encoder(&self, handle: Handle) -> Result<Info, SystemError>
Returns information about a specific encoder
sourcefn get_crtc(&self, handle: Handle) -> Result<Info, SystemError>
fn get_crtc(&self, handle: Handle) -> Result<Info, SystemError>
Returns information about a specific CRTC
sourcefn set_crtc(
&self,
handle: Handle,
framebuffer: Option<Handle>,
pos: (u32, u32),
conns: &[Handle],
mode: Option<Mode>
) -> Result<(), SystemError>
fn set_crtc(
&self,
handle: Handle,
framebuffer: Option<Handle>,
pos: (u32, u32),
conns: &[Handle],
mode: Option<Mode>
) -> Result<(), SystemError>
Set CRTC state
sourcefn get_framebuffer(&self, handle: Handle) -> Result<Info, SystemError>
fn get_framebuffer(&self, handle: Handle) -> Result<Info, SystemError>
Returns information about a specific framebuffer
sourcefn get_planar_framebuffer(
&self,
handle: Handle
) -> Result<PlanarInfo, SystemError>
fn get_planar_framebuffer(
&self,
handle: Handle
) -> Result<PlanarInfo, SystemError>
Returns information about a specific framebuffer (with modifiers)
sourcefn add_framebuffer<B>(
&self,
buffer: &B,
depth: u32,
bpp: u32
) -> Result<Handle, SystemError> where
B: Buffer + ?Sized,
fn add_framebuffer<B>(
&self,
buffer: &B,
depth: u32,
bpp: u32
) -> Result<Handle, SystemError> where
B: Buffer + ?Sized,
Add a new framebuffer
sourcefn add_planar_framebuffer<B>(
&self,
planar_buffer: &B,
modifiers: &[Option<DrmModifier>; 4],
flags: u32
) -> Result<Handle, SystemError> where
B: PlanarBuffer + ?Sized,
fn add_planar_framebuffer<B>(
&self,
planar_buffer: &B,
modifiers: &[Option<DrmModifier>; 4],
flags: u32
) -> Result<Handle, SystemError> where
B: PlanarBuffer + ?Sized,
Add framebuffer (with modifiers)
sourcefn dirty_framebuffer(
&self,
handle: Handle,
clips: &[drm_clip_rect]
) -> Result<(), SystemError>
fn dirty_framebuffer(
&self,
handle: Handle,
clips: &[drm_clip_rect]
) -> Result<(), SystemError>
Mark parts of a framebuffer dirty
sourcefn destroy_framebuffer(&self, handle: Handle) -> Result<(), SystemError>
fn destroy_framebuffer(&self, handle: Handle) -> Result<(), SystemError>
Destroy a framebuffer
sourcefn get_plane(&self, handle: Handle) -> Result<Info, SystemError>
fn get_plane(&self, handle: Handle) -> Result<Info, SystemError>
Returns information about a specific plane
sourcefn 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<(), SystemError>
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<(), SystemError>
Set plane state. Read more
sourcefn get_property(&self, handle: Handle) -> Result<Info, SystemError>
fn get_property(&self, handle: Handle) -> Result<Info, SystemError>
Returns information about a specific property.
sourcefn set_property<T>(
&self,
handle: T,
prop: Handle,
value: u64
) -> Result<(), SystemError> where
T: ResourceHandle,
fn set_property<T>(
&self,
handle: T,
prop: Handle,
value: u64
) -> Result<(), SystemError> where
T: ResourceHandle,
Sets a property for a specific resource.
sourcefn create_property_blob<T>(
&self,
data: &T
) -> Result<Value<'static>, SystemError>
fn create_property_blob<T>(
&self,
data: &T
) -> Result<Value<'static>, SystemError>
Create a property blob value from a given data blob
sourcefn get_property_blob(&self, blob: u64) -> Result<Vec<u8, Global>, SystemError>
fn get_property_blob(&self, blob: u64) -> Result<Vec<u8, Global>, SystemError>
Get a property blob’s data
sourcefn destroy_property_blob(&self, blob: u64) -> Result<(), SystemError>
fn destroy_property_blob(&self, blob: u64) -> Result<(), SystemError>
Destroy a given property blob value
sourcefn get_modes(&self, handle: Handle) -> Result<Vec<Mode, Global>, SystemError>
fn get_modes(&self, handle: Handle) -> Result<Vec<Mode, Global>, SystemError>
Returns the set of Modes that a particular connector supports.
sourcefn get_properties<T>(&self, handle: T) -> Result<PropertyValueSet, SystemError> where
T: ResourceHandle,
fn get_properties<T>(&self, handle: T) -> Result<PropertyValueSet, SystemError> where
T: ResourceHandle,
Gets a list of property handles and values for this resource.
sourcefn get_gamma(
&self,
crtc: Handle,
red: &mut [u16],
green: &mut [u16],
blue: &mut [u16]
) -> Result<(), SystemError>
fn get_gamma(
&self,
crtc: Handle,
red: &mut [u16],
green: &mut [u16],
blue: &mut [u16]
) -> Result<(), SystemError>
Receive the currently set gamma ramp of a crtc
sourcefn set_gamma(
&self,
crtc: Handle,
red: &[u16],
green: &[u16],
blue: &[u16]
) -> Result<(), SystemError>
fn set_gamma(
&self,
crtc: Handle,
red: &[u16],
green: &[u16],
blue: &[u16]
) -> Result<(), SystemError>
Set a gamma ramp for the given crtc
sourcefn open_buffer(&self, name: Name) -> Result<Handle, SystemError>
fn open_buffer(&self, name: Name) -> Result<Handle, SystemError>
Open a GEM buffer handle by name
sourcefn close_buffer(&self, handle: Handle) -> Result<(), SystemError>
fn close_buffer(&self, handle: Handle) -> Result<(), SystemError>
Close a GEM buffer handle
sourcefn create_dumb_buffer(
&self,
size: (u32, u32),
format: DrmFourcc,
bpp: u32
) -> Result<DumbBuffer, SystemError>
fn create_dumb_buffer(
&self,
size: (u32, u32),
format: DrmFourcc,
bpp: u32
) -> Result<DumbBuffer, SystemError>
Create a new dumb buffer with a given size and pixel format
sourcefn map_dumb_buffer(
&self,
buffer: &'a mut DumbBuffer
) -> Result<DumbMapping<'a>, SystemError>
fn map_dumb_buffer(
&self,
buffer: &'a mut DumbBuffer
) -> Result<DumbMapping<'a>, SystemError>
Map the buffer for access
sourcefn destroy_dumb_buffer(&self, buffer: DumbBuffer) -> Result<(), SystemError>
fn destroy_dumb_buffer(&self, buffer: DumbBuffer) -> Result<(), SystemError>
Free the memory resources of a dumb buffer
sourcefn set_cursor<B>(
&self,
crtc: Handle,
buffer: Option<&B>
) -> Result<(), SystemError> where
B: Buffer + ?Sized,
fn set_cursor<B>(
&self,
crtc: Handle,
buffer: Option<&B>
) -> Result<(), SystemError> where
B: Buffer + ?Sized,
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
sourcefn set_cursor2<B>(
&self,
crtc: Handle,
buffer: Option<&B>,
hotspot: (i32, i32)
) -> Result<(), SystemError> where
B: Buffer + ?Sized,
fn set_cursor2<B>(
&self,
crtc: Handle,
buffer: Option<&B>,
hotspot: (i32, i32)
) -> Result<(), SystemError> where
B: Buffer + ?Sized,
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
sourcefn move_cursor(&self, crtc: Handle, pos: (i32, i32)) -> Result<(), SystemError>
fn move_cursor(&self, crtc: Handle, pos: (i32, i32)) -> Result<(), SystemError>
Usage of deprecated ioctl move_cursor: use a cursor plane instead
Moves a set cursor on a given crtc
sourcefn atomic_commit(
&self,
flags: AtomicCommitFlags,
req: AtomicModeReq
) -> Result<(), SystemError>
fn atomic_commit(
&self,
flags: AtomicCommitFlags,
req: AtomicModeReq
) -> Result<(), SystemError>
Request an atomic commit with given flags and property-value pair for a list of objects.
sourcefn prime_fd_to_buffer(&self, fd: i32) -> Result<Handle, SystemError>
fn prime_fd_to_buffer(&self, fd: i32) -> Result<Handle, SystemError>
Convert a prime file descriptor to a GEM buffer handle
sourcefn buffer_to_prime_fd(
&self,
handle: Handle,
flags: u32
) -> Result<i32, SystemError>
fn buffer_to_prime_fd(
&self,
handle: Handle,
flags: u32
) -> Result<i32, SystemError>
Convert a prime file descriptor to a GEM buffer handle
sourcefn page_flip(
&self,
handle: Handle,
framebuffer: Handle,
flags: PageFlipFlags,
target_sequence: Option<PageFlipTarget>
) -> Result<(), SystemError>
fn page_flip(
&self,
handle: Handle,
framebuffer: Handle,
flags: PageFlipFlags,
target_sequence: Option<PageFlipTarget>
) -> Result<(), SystemError>
Queue a page flip on the given crtc
sourcefn receive_events(&self) -> Result<Events, SystemError>
fn receive_events(&self) -> Result<Events, SystemError>
Receive pending events
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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. Read more
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
fn as_any(&self) -> &(dyn Any + 'static)
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. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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. Read more