Trait drm::Device [−][src]
pub trait Device: AsRawFd { fn acquire_master_lock(&self) -> Result<(), SystemError> { ... } fn release_master_lock(&self) -> Result<(), SystemError> { ... } fn generate_auth_token(&self) -> Result<AuthToken, SystemError> { ... } fn authenticate_auth_token(
&self,
token: AuthToken
) -> Result<(), SystemError> { ... } fn set_client_capability(
&self,
cap: ClientCapability,
enable: bool
) -> Result<(), SystemError> { ... } fn get_bus_id(&self) -> Result<BusID, SystemError> { ... } fn authenticated(&self) -> Result<bool, SystemError> { ... } fn get_driver_capability(
&self,
cap: DriverCapability
) -> Result<u64, SystemError> { ... } fn get_driver(&self) -> Result<Driver, SystemError> { ... } }
This trait should be implemented by any object that acts as a DRM device. It is a prerequisite for using any DRM functionality.
This crate does not provide a concrete device object due to the various ways it can be implemented. The user of this crate is expected to implement it themselves and derive this trait as necessary. The example below demonstrates how to do this using a small wrapper.
Example
extern crate drm; use drm::Device; use std::fs::File; use std::fs::OpenOptions; use std::os::unix::io::RawFd; use std::os::unix::io::AsRawFd; #[derive(Debug)] /// A simple wrapper for a device node. struct Card(File); /// Implementing [`AsRawFd`] is a prerequisite to implementing the traits found /// in this crate. Here, we are just calling [`File::as_raw_fd()`] on the inner /// [`File`]. impl AsRawFd for Card { fn as_raw_fd(&self) -> RawFd { self.0.as_raw_fd() } } /// With [`AsRawFd`] implemented, we can now implement [`drm::Device`]. impl Device for Card {} impl Card { /// Simple helper method for opening a [`Card`]. fn open() -> Self { let mut options = OpenOptions::new(); options.read(true); options.write(true); // The normal location of the primary device node on Linux Card(options.open("/dev/dri/card0").unwrap()) } }
Provided methods
fn acquire_master_lock(&self) -> Result<(), SystemError>
[src]
Acquires the DRM Master lock for this process.
Notes
Acquiring the DRM Master is done automatically when the primary device node is opened. If you opened the primary device node and did not acquire the lock, another process likely has the lock.
This function is only available to processes with CAP_SYS_ADMIN privileges (usually as root)
fn release_master_lock(&self) -> Result<(), SystemError>
[src]
Releases the DRM Master lock for another process to use.
fn generate_auth_token(&self) -> Result<AuthToken, SystemError>
[src]
Consider opening a render node instead.
Generates an AuthToken
for this process.
fn authenticate_auth_token(&self, token: AuthToken) -> Result<(), SystemError>
[src]
Authenticates an AuthToken
from another process.
fn set_client_capability(
&self,
cap: ClientCapability,
enable: bool
) -> Result<(), SystemError>
[src]
&self,
cap: ClientCapability,
enable: bool
) -> Result<(), SystemError>
Requests the driver to expose or hide certain capabilities. See
ClientCapability
for more information.
fn get_bus_id(&self) -> Result<BusID, SystemError>
[src]
Gets the BusID
of this device.
fn authenticated(&self) -> Result<bool, SystemError>
[src]
Check to see if our AuthToken
has been authenticated
by the DRM Master
fn get_driver_capability(
&self,
cap: DriverCapability
) -> Result<u64, SystemError>
[src]
&self,
cap: DriverCapability
) -> Result<u64, SystemError>
Gets the value of a capability.
fn get_driver(&self) -> Result<Driver, SystemError>
[src]
Possible errors:
SystemError::MemoryFault
: Kernel could not copy fields into userspace