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.

70 lines
2.8 KiB

use intel_gpu::*;
3 weeks ago
use std::ffi::c_void;
use std::ffi::CStr;
use nix::{self};
#[test]
fn test_raw_drm_version() {
3 weeks ago
// 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");
3 weeks ago
unsafe {
let name_vec = libc::malloc(128);
libc::memset(name_vec, 0, 128);
3 weeks ago
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);
3 weeks ago
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,
3 weeks ago
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/renderD128", nix::fcntl::OFlag::O_RDWR | nix::fcntl::OFlag::O_CLOEXEC, nix::sys::stat::Mode::empty())
.expect("Failed to open /dev/dri/renderD128");
3 weeks ago
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);
3 weeks ago
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);
3 weeks ago
}
}
}