You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.6 KiB
67 lines
2.6 KiB
use intel_gpu_uapi::*;
|
|
use std::ffi::c_void;
|
|
use std::ffi::CStr;
|
|
use nix::{self};
|
|
|
|
#[test]
|
|
fn test_raw_drm_version() {
|
|
// TODO more robust render node detection
|
|
let fd = nix::fcntl::open("/dev/dri/renderD129", nix::fcntl::OFlag::O_RDWR | nix::fcntl::OFlag::O_CLOEXEC, nix::sys::stat::Mode::empty())
|
|
.expect("Failed to open /dev/dri/renderD129");
|
|
unsafe {
|
|
let name_vec = libc::malloc(128);
|
|
let date_vec = libc::malloc(128);
|
|
let desc_vec = libc::malloc(128);
|
|
|
|
let mut version = native::drm_version {
|
|
version_major: 0,
|
|
version_minor: 0,
|
|
version_patchlevel: 0,
|
|
name: name_vec as *mut i8,
|
|
date: date_vec as *mut i8,
|
|
desc: desc_vec as *mut i8,
|
|
name_len: 128,
|
|
date_len: 128,
|
|
desc_len: 128,
|
|
};
|
|
assert!(libc::ioctl(fd, native::DRM_IOCTL_VERSION, &mut version) == 0);
|
|
println!("version_major: {}, version_minor: {}, version_patchlevel: {}, name: {:?}, date: {:?}, desc: {:?}",
|
|
version.version_major,
|
|
version.version_minor,
|
|
version.version_patchlevel,
|
|
CStr::from_ptr(version.name),
|
|
CStr::from_ptr(version.date),
|
|
CStr::from_ptr(version.desc));
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_i915_raw_query() {
|
|
let fd = nix::fcntl::open("/dev/dri/renderD129", nix::fcntl::OFlag::O_RDWR | nix::fcntl::OFlag::O_CLOEXEC, nix::sys::stat::Mode::empty())
|
|
.expect("Failed to open /dev/dri/renderD129");
|
|
unsafe {
|
|
let mut query_item = native::drm_i915_query_item {
|
|
query_id: native::DRM_I915_QUERY_ENGINE_INFO as u64,
|
|
length: 0,
|
|
data_ptr: core::ptr::null_mut::<c_void>() as u64,
|
|
flags: 0,
|
|
};
|
|
let mut query = native::drm_i915_query {
|
|
items_ptr: (&mut query_item) as *mut native::drm_i915_query_item as u64,
|
|
num_items: 1,
|
|
flags: 0,
|
|
};
|
|
assert!(libc::ioctl(fd, native::DRM_IOCTL_I915_QUERY, &mut query) == 0);
|
|
let engine_info = libc::malloc(query_item.length as usize)
|
|
as *mut native::drm_i915_query_engine_info;
|
|
query_item.data_ptr = engine_info as u64;
|
|
assert!(libc::ioctl(fd, native::DRM_IOCTL_I915_QUERY, &mut query) == 0);
|
|
println!("engine_info: {:?}", *engine_info);
|
|
let engine_data = engine_info.as_mut().unwrap();
|
|
let engines = engine_data.engines.as_mut_slice(engine_data.num_engines as usize);
|
|
for engine in engines {
|
|
println!("engine: {:?}", engine);
|
|
}
|
|
}
|
|
}
|