wayland: implement wp-drm-lease-v1
This commit is contained in:
parent
e92c92bf49
commit
abbc847144
27 changed files with 797 additions and 19 deletions
|
|
@ -40,8 +40,8 @@ use crate::{
|
|||
video::{
|
||||
dmabuf::DmaBuf,
|
||||
drm::sys::{
|
||||
drm_format_modifier, drm_format_modifier_blob, get_version, revoke_lease,
|
||||
DRM_CAP_CURSOR_HEIGHT, DRM_CAP_CURSOR_WIDTH, FORMAT_BLOB_CURRENT,
|
||||
auth_magic, drm_format_modifier, drm_format_modifier_blob, drop_master, get_version,
|
||||
revoke_lease, DRM_CAP_CURSOR_HEIGHT, DRM_CAP_CURSOR_WIDTH, FORMAT_BLOB_CURRENT,
|
||||
},
|
||||
Modifier, INVALID_MODIFIER,
|
||||
},
|
||||
|
|
@ -139,6 +139,8 @@ pub enum DrmError {
|
|||
ImportSyncFile(#[source] OsError),
|
||||
#[error("Could not create a lease")]
|
||||
CreateLease(#[source] OsError),
|
||||
#[error("Could not drop DRM master")]
|
||||
DropMaster(#[source] OsError),
|
||||
}
|
||||
|
||||
fn render_node_name(fd: c::c_int) -> Result<Ustring, DrmError> {
|
||||
|
|
@ -175,7 +177,6 @@ pub struct Drm {
|
|||
}
|
||||
|
||||
impl Drm {
|
||||
#[cfg_attr(not(feature = "it"), allow(dead_code))]
|
||||
pub fn open_existing(fd: Rc<OwnedFd>) -> Self {
|
||||
Self { fd }
|
||||
}
|
||||
|
|
@ -213,6 +214,14 @@ impl Drm {
|
|||
pub fn version(&self) -> Result<DrmVersion, DrmError> {
|
||||
get_version(self.fd.raw()).map_err(DrmError::Version)
|
||||
}
|
||||
|
||||
pub fn drop_master(&self) -> Result<(), DrmError> {
|
||||
drop_master(self.fd.raw()).map_err(DrmError::DropMaster)
|
||||
}
|
||||
|
||||
pub fn is_master(&self) -> bool {
|
||||
auth_magic(self.fd.raw(), 0) != Err(OsError(c::EACCES))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct InFormat {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ pub unsafe fn ioctl<T>(fd: c::c_int, request: c::c_ulong, t: &mut T) -> Result<c
|
|||
|
||||
pub const DRM_IOCTL_BASE: u64 = b'd' as u64;
|
||||
|
||||
pub const fn drm_io(nr: u64) -> u64 {
|
||||
uapi::_IO(DRM_IOCTL_BASE, nr)
|
||||
}
|
||||
|
||||
pub const fn drm_iow<T>(nr: u64) -> u64 {
|
||||
uapi::_IOW::<T>(DRM_IOCTL_BASE, nr)
|
||||
}
|
||||
|
|
@ -1369,3 +1373,28 @@ pub fn sync_ioc_merge(left: c::c_int, right: c::c_int) -> Result<OwnedFd, OsErro
|
|||
}
|
||||
Ok(OwnedFd::new(res.fence))
|
||||
}
|
||||
|
||||
const DRM_IOCTL_DROP_MASTER: u64 = drm_io(0x1f);
|
||||
|
||||
pub fn drop_master(fd: c::c_int) -> Result<(), OsError> {
|
||||
let mut res = 0u8;
|
||||
unsafe {
|
||||
ioctl(fd, DRM_IOCTL_DROP_MASTER, &mut res)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
const DRM_IOCTL_AUTH_MAGIC: u64 = drm_iow::<drm_auth>(0x11);
|
||||
|
||||
#[repr(C)]
|
||||
struct drm_auth {
|
||||
magic: c::c_uint,
|
||||
}
|
||||
|
||||
pub fn auth_magic(fd: c::c_int, magic: c::c_uint) -> Result<(), OsError> {
|
||||
let mut res = drm_auth { magic };
|
||||
unsafe {
|
||||
ioctl(fd, DRM_IOCTL_AUTH_MAGIC, &mut res)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue