metal: add support for render-only devices
This commit is contained in:
parent
17e434ba34
commit
3d60cfc5dc
3 changed files with 78 additions and 57 deletions
|
|
@ -26,7 +26,8 @@ use {
|
|||
get_version, mode_addfb2, mode_atomic, mode_create_blob, mode_destroy_blob,
|
||||
mode_get_resources, mode_getconnector, mode_getencoder, mode_getplane,
|
||||
mode_getplaneresources, mode_getprobblob, mode_getproperty, mode_obj_getproperties,
|
||||
mode_rmfb, prime_fd_to_handle, queue_sequence, revoke_lease, set_client_cap,
|
||||
mode_rmfb, mode_supports_get_resources, prime_fd_to_handle, queue_sequence,
|
||||
revoke_lease, set_client_cap,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -339,6 +340,10 @@ impl DrmMaster {
|
|||
mode_get_resources(self.raw())
|
||||
}
|
||||
|
||||
pub fn supports_get_resources(&self) -> Result<bool, DrmError> {
|
||||
mode_supports_get_resources(self.raw())
|
||||
}
|
||||
|
||||
pub fn get_cap(&self, cap: u64) -> Result<u64, OsError> {
|
||||
get_cap(self.raw(), cap)
|
||||
}
|
||||
|
|
@ -751,12 +756,12 @@ drm_obj!(DrmFb, DRM_MODE_OBJECT_FB);
|
|||
drm_obj!(DrmBlob, DRM_MODE_OBJECT_BLOB);
|
||||
drm_obj!(DrmPlane, DRM_MODE_OBJECT_PLANE);
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct DrmCardResources {
|
||||
pub min_width: u32,
|
||||
pub max_width: u32,
|
||||
pub min_height: u32,
|
||||
pub max_height: u32,
|
||||
pub _min_width: u32,
|
||||
pub _max_width: u32,
|
||||
pub _min_height: u32,
|
||||
pub _max_height: u32,
|
||||
pub _fbs: Vec<DrmFb>,
|
||||
pub crtcs: Vec<DrmCrtc>,
|
||||
pub connectors: Vec<DrmConnector>,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,11 @@ use {
|
|||
ffi::CString,
|
||||
io::{BufRead, BufReader},
|
||||
},
|
||||
uapi::{OwnedFd, Pod, Ustring, c, pod_zeroed},
|
||||
uapi::{
|
||||
OwnedFd, Pod, Ustring,
|
||||
c::{self, c_int},
|
||||
pod_zeroed,
|
||||
},
|
||||
};
|
||||
|
||||
pub unsafe fn ioctl<T>(fd: c::c_int, request: c::c_ulong, t: &mut T) -> Result<c::c_int, OsError> {
|
||||
|
|
@ -546,10 +550,10 @@ pub fn mode_get_resources(fd: c::c_int) -> Result<DrmCardResources, DrmError> {
|
|||
}
|
||||
|
||||
Ok(DrmCardResources {
|
||||
min_width: res.min_width,
|
||||
max_width: res.max_width,
|
||||
min_height: res.min_height,
|
||||
max_height: res.max_height,
|
||||
_min_width: res.min_width,
|
||||
_max_width: res.max_width,
|
||||
_min_height: res.min_height,
|
||||
_max_height: res.max_height,
|
||||
_fbs: fbs,
|
||||
crtcs,
|
||||
connectors,
|
||||
|
|
@ -557,6 +561,16 @@ pub fn mode_get_resources(fd: c::c_int) -> Result<DrmCardResources, DrmError> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn mode_supports_get_resources(fd: c_int) -> Result<bool, DrmError> {
|
||||
let mut res = drm_mode_card_res::default();
|
||||
let res = unsafe { ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &mut res) };
|
||||
match res {
|
||||
Ok(_) => Ok(true),
|
||||
Err(e) if e.0 == c::EOPNOTSUPP => Ok(false),
|
||||
Err(e) => Err(DrmError::GetResources(e)),
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct drm_mode_get_plane_res {
|
||||
plane_id_ptr: u64,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue