smithay::backend::drm

Struct DrmDevice

Source
pub struct DrmDevice<A: AsRawFd + 'static> { /* private fields */ }
Expand description

An open drm device

Implementations§

Source§

impl<A: AsRawFd + 'static> DrmDevice<A>

Source

pub fn new<L>(fd: A, disable_connectors: bool, logger: L) -> Result<Self, Error>
where A: AsRawFd + 'static, L: Into<Option<Logger>>,

Create a new DrmDevice from an open drm node

§Arguments
  • fd - Open drm node
  • disable_connectors - Setting this to true will initialize all connectors
    as disabled on device creation. smithay enables connectors, when attached
    to a surface, and disables them, when detached. Setting this to false
    requires usage of drm-rs to disable unused connectors to prevent them
    showing garbage, but will also prevent flickering of already turned on
    connectors (assuming you won’t change the resolution).
  • logger - Optional slog::Logger to be used by this device.
§Return

Returns an error if the file is no valid drm node or the device is not accessible.

Source

pub fn is_atomic(&self) -> bool

Returns if the underlying implementation uses atomic-modesetting or not.

Source

pub fn crtcs(&self) -> &[Handle]

Returns a list of crtcs for this device

Source

pub fn planes(&self, crtc: &Handle) -> Result<Planes, Error>

Returns a set of available planes for a given crtc

Source

pub fn create_surface( &self, crtc: Handle, mode: Mode, connectors: &[Handle], ) -> Result<DrmSurface<A>, Error>

Creates a new rendering surface.

§Arguments

Initialization of surfaces happens through the types provided by drm-rs.

  • crtcs represent scanout engines of the device pointing to one framebuffer.
    Their responsibility is to read the data of the framebuffer and export it into an “Encoder”.
    The number of crtc’s represent the number of independent output devices the hardware may handle.
  • mode describes the resolution and rate of images produced by the crtc and
    has to be compatible with the provided connectors.
  • connectors - List of connectors driven by the crtc. At least one(!) connector needs to be
    attached to a crtc in smithay.
Source

pub fn device_id(&self) -> dev_t

Returns the device_id of the underlying drm node

Trait Implementations§

Source§

impl<A: AsRawFd + 'static> Allocator<DumbBuffer<A>> for DrmDevice<A>

Source§

type Error = SystemError

Error type thrown if allocations fail
Source§

fn create_buffer( &mut self, width: u32, height: u32, fourcc: Fourcc, modifiers: &[Modifier], ) -> Result<DumbBuffer<A>, Self::Error>

Try to create a buffer with the given dimensions and pixel format
Source§

impl<A: AsRawFd + 'static> AsRawFd for DrmDevice<A>

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl<A: Debug + AsRawFd + 'static> Debug for DrmDevice<A>

Source§

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

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

impl<A: AsRawFd + 'static> Device for DrmDevice<A>

Source§

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

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

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

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

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

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

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

Authenticates an AuthToken from another process.
Source§

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

fn get_bus_id(&self) -> Result<BusID, SystemError>

Gets the BusID of this device.
Source§

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

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

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

Gets the value of a capability.
Source§

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

Possible errors: Read more
Source§

impl<A: AsRawFd + 'static> Device for DrmDevice<A>

Source§

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

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

fn plane_handles(&self) -> Result<PlaneResourceHandles, SystemError>

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

fn get_connector(&self, handle: Handle) -> Result<Info, SystemError>

Returns information about a specific connector
Source§

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

Returns information about a specific encoder
Source§

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

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<(), SystemError>

Set CRTC state
Source§

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

Returns information about a specific framebuffer
Source§

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

Add a new framebuffer
Source§

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

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

Mark parts of a framebuffer dirty
Source§

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

Destroy a framebuffer
Source§

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

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<(), SystemError>

Set plane state. Read more
Source§

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

Returns information about a specific property.
Source§

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

Sets a property for a specific resource.
Source§

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

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

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

Get a property blob’s data
Source§

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

Destroy a given property blob value
Source§

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

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

fn get_properties<T>(&self, handle: T) -> Result<PropertyValueSet, SystemError>
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<(), SystemError>

Receive the currently set gamma ramp of a crtc
Source§

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

Set a gamma ramp for the given crtc
Source§

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

Open a GEM buffer handle by name
Source§

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

Close a GEM buffer handle
Source§

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

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

Map the buffer for access
Source§

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

Free the memory resources of a dumb buffer
Source§

fn set_cursor<B>( &self, crtc: Handle, buffer: Option<&B>, ) -> Result<(), SystemError>
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<(), SystemError>
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<(), SystemError>

👎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<(), SystemError>

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

fn prime_fd_to_buffer(&self, fd: i32) -> Result<Handle, SystemError>

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

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

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

fn page_flip( &self, handle: Handle, framebuffer: Handle, flags: &[PageFlipFlags], target: Option<PageFlipTarget>, ) -> Result<(), SystemError>

Queue a page flip on the given crtc
Source§

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

Receive pending events
Source§

impl<A> EventSource for DrmDevice<A>
where A: AsRawFd + 'static,

Source§

type Event = DrmEvent

The type of events generated by your source.
Source§

type Metadata = ()

Some metadata of your event source Read more
Source§

type Ret = ()

The return type of the user callback Read more
Source§

fn process_events<F>( &mut self, _: Readiness, token: Token, callback: F, ) -> Result<PostAction>
where F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,

Process any relevant events Read more
Source§

fn register( &mut self, poll: &mut Poll, factory: &mut TokenFactory, ) -> Result<()>

Register yourself to this poll instance Read more
Source§

fn reregister( &mut self, poll: &mut Poll, factory: &mut TokenFactory, ) -> Result<()>

Re-register your file descriptors Read more
Source§

fn unregister(&mut self, poll: &mut Poll) -> Result<()>

Unregister your file descriptors Read more
Source§

impl<A: AsRawFd + 'static> Linkable<Signal> for DrmDevice<A>

Make this object listen for signals from given signaler

Auto Trait Implementations§

§

impl<A> !Freeze for DrmDevice<A>

§

impl<A> !RefUnwindSafe for DrmDevice<A>

§

impl<A> !Send for DrmDevice<A>

§

impl<A> !Sync for DrmDevice<A>

§

impl<A> Unpin for DrmDevice<A>

§

impl<A> !UnwindSafe for DrmDevice<A>

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<A> DevPath for A
where A: AsRawFd,

Source§

fn dev_path(&self) -> Option<PathBuf>

Returns the path of the open device if possible
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> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V