pub struct Card { /* private fields */ }Expand description
An open DRM device.
Releases DRM master on drop, so a crash or a clean exit both hand the console back rather than leaving a black screen that needs a reboot.
Implementations§
Source§impl Card
impl Card
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, DrmError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, DrmError>
Opens a specific card node, such as /dev/dri/card0.
Sourcepub fn open_first() -> Result<Self, DrmError>
pub fn open_first() -> Result<Self, DrmError>
Opens the first card node that actually has a display output.
Nodes are tried in name order and skipped unless they report at least one connector, which filters out render-only devices.
Sourcepub fn from_fd(fd: OwnedFd) -> Self
pub fn from_fd(fd: OwnedFd) -> Self
Adopts a descriptor opened by somebody else.
This is how to coexist with libseat or a systemd unit that holds the
device rights, rather than demanding root.
Sourcepub fn path(&self) -> Option<&Path>
pub fn path(&self) -> Option<&Path>
The node this card was opened from, if it was opened by path.
Sourcepub fn has_display_output(&self) -> bool
pub fn has_display_output(&self) -> bool
Returns true if this device has connectors, rather than being a render
node.
Sourcepub fn become_master(&self) -> Result<(), DrmError>
pub fn become_master(&self) -> Result<(), DrmError>
Takes the DRM master lock, which is required to set a mode.
Fails if a compositor or another instance already holds it. See the crate documentation for the ways to have the right to it.
Sourcepub fn release_master(&self)
pub fn release_master(&self)
Gives the master lock back, restoring whatever had the console before.
Sourcepub fn connectors(&self) -> Result<(Vec<Handle>, Vec<ConnectorInfo>), DrmError>
pub fn connectors(&self) -> Result<(Vec<Handle>, Vec<ConnectorInfo>), DrmError>
Reads every connector, as handles and as plain data for crate::mode.
The two vectors are index-aligned: a crate::Selection::connector indexes
both.
Trait Implementations§
Source§impl AsFd for Card
impl AsFd for Card
Source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
Source§impl Device for Card
impl Device for Card
Source§fn acquire_master_lock(&self) -> Result<(), Error>
fn acquire_master_lock(&self) -> Result<(), Error>
Source§fn release_master_lock(&self) -> Result<(), Error>
fn release_master_lock(&self) -> Result<(), Error>
Source§fn generate_auth_token(&self) -> Result<AuthToken, Error>
fn generate_auth_token(&self) -> Result<AuthToken, Error>
Consider opening a render node instead.
AuthToken for this process.Source§fn authenticate_auth_token(&self, token: AuthToken) -> Result<(), Error>
fn authenticate_auth_token(&self, token: AuthToken) -> Result<(), Error>
AuthToken from another process.Source§fn set_client_capability(
&self,
cap: ClientCapability,
enable: bool,
) -> Result<(), Error>
fn set_client_capability( &self, cap: ClientCapability, enable: bool, ) -> Result<(), Error>
ClientCapability for more information.Source§fn authenticated(&self) -> Result<bool, Error>
fn authenticated(&self) -> Result<bool, Error>
AuthToken has been authenticated
by the DRM MasterSource§fn get_driver_capability(&self, cap: DriverCapability) -> Result<u64, Error>
fn get_driver_capability(&self, cap: DriverCapability) -> Result<u64, Error>
Source§fn wait_vblank(
&self,
target_sequence: VblankWaitTarget,
flags: VblankWaitFlags,
high_crtc: u32,
user_data: usize,
) -> Result<VblankWaitReply, Error>
fn wait_vblank( &self, target_sequence: VblankWaitTarget, flags: VblankWaitFlags, high_crtc: u32, user_data: usize, ) -> Result<VblankWaitReply, Error>
Source§impl Device for Card
impl Device for Card
Source§fn resource_handles(&self) -> Result<ResourceHandles, Error>
fn resource_handles(&self) -> Result<ResourceHandles, Error>
Source§fn plane_handles(&self) -> Result<Vec<Handle>, Error>
fn plane_handles(&self) -> Result<Vec<Handle>, Error>
Source§fn get_connector(
&self,
handle: Handle,
force_probe: bool,
) -> Result<Info, Error>
fn get_connector( &self, handle: Handle, force_probe: bool, ) -> Result<Info, Error>
Source§fn get_encoder(&self, handle: Handle) -> Result<Info, Error>
fn get_encoder(&self, handle: Handle) -> Result<Info, Error>
Source§fn get_crtc(&self, handle: Handle) -> Result<Info, Error>
fn get_crtc(&self, handle: Handle) -> Result<Info, Error>
Source§fn set_crtc(
&self,
handle: Handle,
framebuffer: Option<Handle>,
pos: (u32, u32),
conns: &[Handle],
mode: Option<Mode>,
) -> Result<(), Error>
fn set_crtc( &self, handle: Handle, framebuffer: Option<Handle>, pos: (u32, u32), conns: &[Handle], mode: Option<Mode>, ) -> Result<(), Error>
Source§fn get_framebuffer(&self, handle: Handle) -> Result<Info, Error>
fn get_framebuffer(&self, handle: Handle) -> Result<Info, Error>
Source§fn get_planar_framebuffer(
&self,
handle: Handle,
) -> Result<PlanarInfo, GetPlanarFramebufferError>
fn get_planar_framebuffer( &self, handle: Handle, ) -> Result<PlanarInfo, GetPlanarFramebufferError>
Source§fn add_framebuffer<B>(
&self,
buffer: &B,
depth: u32,
bpp: u32,
) -> Result<Handle, Error>
fn add_framebuffer<B>( &self, buffer: &B, depth: u32, bpp: u32, ) -> Result<Handle, Error>
Source§fn add_planar_framebuffer<B>(
&self,
planar_buffer: &B,
flags: FbCmd2Flags,
) -> Result<Handle, Error>where
B: PlanarBuffer + ?Sized,
fn add_planar_framebuffer<B>(
&self,
planar_buffer: &B,
flags: FbCmd2Flags,
) -> Result<Handle, Error>where
B: PlanarBuffer + ?Sized,
Source§fn dirty_framebuffer(
&self,
handle: Handle,
clips: &[ClipRect],
) -> Result<(), Error>
fn dirty_framebuffer( &self, handle: Handle, clips: &[ClipRect], ) -> Result<(), Error>
Source§fn get_plane(&self, handle: Handle) -> Result<Info, Error>
fn get_plane(&self, handle: Handle) -> Result<Info, Error>
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>
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>
Source§fn get_property(&self, handle: Handle) -> Result<Info, Error>
fn get_property(&self, handle: Handle) -> Result<Info, Error>
Source§fn set_property<T>(
&self,
handle: T,
prop: Handle,
value: u64,
) -> Result<(), Error>where
T: ResourceHandle,
fn set_property<T>(
&self,
handle: T,
prop: Handle,
value: u64,
) -> Result<(), Error>where
T: ResourceHandle,
Source§fn create_property_blob<T>(&self, data: &T) -> Result<Value<'static>, Error>where
T: ?Sized,
fn create_property_blob<T>(&self, data: &T) -> Result<Value<'static>, Error>where
T: ?Sized,
Source§fn destroy_property_blob(&self, blob: u64) -> Result<(), Error>
fn destroy_property_blob(&self, blob: u64) -> Result<(), Error>
Source§fn get_modes(&self, handle: Handle) -> Result<Vec<Mode>, Error>
fn get_modes(&self, handle: Handle) -> Result<Vec<Mode>, Error>
Modes that a particular connector supports.Source§fn get_properties<T>(&self, handle: T) -> Result<PropertyValueSet, Error>where
T: ResourceHandle,
fn get_properties<T>(&self, handle: T) -> Result<PropertyValueSet, Error>where
T: ResourceHandle,
Source§fn get_gamma(
&self,
crtc: Handle,
red: &mut [u16],
green: &mut [u16],
blue: &mut [u16],
) -> Result<(), Error>
fn get_gamma( &self, crtc: Handle, red: &mut [u16], green: &mut [u16], blue: &mut [u16], ) -> Result<(), Error>
Source§fn set_gamma(
&self,
crtc: Handle,
red: &[u16],
green: &[u16],
blue: &[u16],
) -> Result<(), Error>
fn set_gamma( &self, crtc: Handle, red: &[u16], green: &[u16], blue: &[u16], ) -> Result<(), Error>
Source§fn create_dumb_buffer(
&self,
size: (u32, u32),
format: DrmFourcc,
bpp: u32,
) -> Result<DumbBuffer, Error>
fn create_dumb_buffer( &self, size: (u32, u32), format: DrmFourcc, bpp: u32, ) -> Result<DumbBuffer, Error>
Source§fn map_dumb_buffer<'a>(
&self,
buffer: &'a mut DumbBuffer,
) -> Result<DumbMapping<'a>, Error>
fn map_dumb_buffer<'a>( &self, buffer: &'a mut DumbBuffer, ) -> Result<DumbMapping<'a>, Error>
Source§fn destroy_dumb_buffer(&self, buffer: DumbBuffer) -> Result<(), Error>
fn destroy_dumb_buffer(&self, buffer: DumbBuffer) -> Result<(), Error>
Source§fn set_cursor<B>(&self, crtc: Handle, buffer: Option<&B>) -> Result<(), Error>
fn set_cursor<B>(&self, crtc: Handle, buffer: Option<&B>) -> Result<(), Error>
Usage of deprecated ioctl set_cursor: use a cursor plane instead
Source§fn set_cursor2<B>(
&self,
crtc: Handle,
buffer: Option<&B>,
hotspot: (i32, i32),
) -> Result<(), Error>
fn set_cursor2<B>( &self, crtc: Handle, buffer: Option<&B>, hotspot: (i32, i32), ) -> Result<(), Error>
Usage of deprecated ioctl set_cursor2: use a cursor plane instead
Source§fn move_cursor(&self, crtc: Handle, pos: (i32, i32)) -> Result<(), Error>
fn move_cursor(&self, crtc: Handle, pos: (i32, i32)) -> Result<(), Error>
Usage of deprecated ioctl move_cursor: use a cursor plane instead
Source§fn atomic_commit(
&self,
flags: AtomicCommitFlags,
req: AtomicModeReq,
) -> Result<(), Error>
fn atomic_commit( &self, flags: AtomicCommitFlags, req: AtomicModeReq, ) -> Result<(), Error>
Source§fn prime_fd_to_buffer(&self, fd: BorrowedFd<'_>) -> Result<Handle, Error>
fn prime_fd_to_buffer(&self, fd: BorrowedFd<'_>) -> Result<Handle, Error>
Source§fn buffer_to_prime_fd(
&self,
handle: Handle,
flags: u32,
) -> Result<OwnedFd, Error>
fn buffer_to_prime_fd( &self, handle: Handle, flags: u32, ) -> Result<OwnedFd, Error>
Source§fn page_flip(
&self,
handle: Handle,
framebuffer: Handle,
flags: PageFlipFlags,
target_sequence: Option<PageFlipTarget>,
) -> Result<(), Error>
fn page_flip( &self, handle: Handle, framebuffer: Handle, flags: PageFlipFlags, target_sequence: Option<PageFlipTarget>, ) -> Result<(), Error>
Source§fn syncobj_to_fd(
&self,
handle: Handle,
export_sync_file: bool,
) -> Result<OwnedFd, Error>
fn syncobj_to_fd( &self, handle: Handle, export_sync_file: bool, ) -> Result<OwnedFd, Error>
Source§fn fd_to_syncobj(
&self,
fd: BorrowedFd<'_>,
import_sync_file: bool,
) -> Result<Handle, Error>
fn fd_to_syncobj( &self, fd: BorrowedFd<'_>, import_sync_file: bool, ) -> Result<Handle, Error>
Self::syncobj_to_fd back into a process-local handle.