|
|
|
use intel_gpu::*;
|
|
|
|
use std::ffi::c_void;
|
|
|
|
use nix::{self};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_raw_drm_version() {
|
|
|
|
// TODO more robust render node detection
|
|
|
|
let fd = nix::fcntl::open("/dev/dri/renderD128", nix::fcntl::OFlag::O_RDWR | nix::fcntl::OFlag::O_CLOEXEC, nix::sys::stat::Mode::empty())
|
|
|
|
.expect("Failed to open /dev/dri/renderD128");
|
|
|
|
unsafe {
|
|
|
|
let name_vec = libc::malloc(128);
|
|
|
|
libc::memset(name_vec, 0, 128);
|
|
|
|
let date_vec = libc::malloc(128);
|
|
|
|
libc::memset(date_vec, 0, 128);
|
|
|
|
let mut desc_vec = vec![0; 128];
|
|
|
|
//libc::memset(desc_vec, 0, 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_ptr() as *mut i8,
|
|
|
|
name_len: 128,
|
|
|
|
date_len: 128,
|
|
|
|
desc_len: 128,
|
|
|
|
};
|
|
|
|
assert!(libc::ioctl(fd, native::DRM_IOCTL_VERSION, &mut version) == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_i915_raw_query() {
|
|
|
|
let fd = nix::fcntl::open("/dev/dri/renderD128", nix::fcntl::OFlag::O_RDWR | nix::fcntl::OFlag::O_CLOEXEC, nix::sys::stat::Mode::empty())
|
|
|
|
.expect("Failed to open /dev/dri/renderD128");
|
|
|
|
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;
|
|
|
|
libc::memset(engine_info as *mut c_void, 0, query_item.length as usize);
|
|
|
|
query_item.data_ptr = engine_info as u64;
|
|
|
|
assert!(libc::ioctl(fd, native::DRM_IOCTL_I915_QUERY, &mut query) == 0);
|
|
|
|
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 {
|
|
|
|
assert!(engine.engine.engine_class != uapi::i915::EngineClass::Invalid as u16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|