1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
use crate::*;
pub const GRBM_OFFSET: u32 = 0x2004;
pub const GRBM2_OFFSET: u32 = 0x2002;
pub const SRBM_OFFSET: u32 = 0x394;
pub const SRBM2_OFFSET: u32 = 0x393;
pub const SRBM3_OFFSET: u32 = 0x395;
pub const CP_STAT_OFFSET: u32 = 0x21A0;
// pub(crate) type DEVICE = bindings::amdgpu_device;
pub(crate) type DEVICE_HANDLE = bindings::amdgpu_device_handle;
// ref: https://gitlab.freedesktop.org/mesa/drm/-/blob/a81b9ab8f3fb6840b36f732c1dd25fe5e0d68d0a/amdgpu/amdgpu_device.c#L293
pub const DEFAULT_DEVICE_NAME: &str = "AMD Radeon Graphics";
mod device_handle;
pub use device_handle::*;
mod family;
pub use family::*;
mod vram;
pub use vram::*;
mod asic;
pub use asic::*;
mod chip_class;
pub use chip_class::*;
mod gpu_info;
pub use gpu_info::*;
#[cfg(feature = "std")]
mod metrics_table;
#[cfg(feature = "std")]
pub use metrics_table::*;
#[cfg(feature = "std")]
mod gpu_metrics;
#[cfg(feature = "std")]
pub use gpu_metrics::*;
#[cfg(feature = "std")]
mod throttle_status;
#[cfg(feature = "std")]
pub use throttle_status::*;
#[cfg(feature = "std")]
mod hwmon_temp;
#[cfg(feature = "std")]
pub use hwmon_temp::*;
#[cfg(feature = "std")]
mod power_cap;
#[cfg(feature = "std")]
pub use power_cap::*;
#[cfg(feature = "std")]
mod ip_discovery;
#[cfg(feature = "std")]
pub use ip_discovery::*;
#[cfg(feature = "std")]
pub(crate) fn parse_hwmon<T: std::str::FromStr, P: Into<std::path::PathBuf>>(path: P) -> Option<T> {
std::fs::read_to_string(path.into()).ok()
.and_then(|file| file.trim_end().parse::<T>().ok())
}
mod vbios;
mod video_caps;
mod hw_ip;
mod fw_version;
mod sensor_info;
pub mod VBIOS {
pub use super::vbios::*;
}
/// # Video Encode/Decode Capabilities
/// ## Examples
///
/// ```
/// use libdrm_amdgpu_sys::AMDGPU::{DeviceHandle, VIDEO_CAPS::*};
/// let (amdgpu_dev, drm_major, drm_minor) = {
/// use std::fs::File;
/// use std::os::fd::IntoRawFd;
///
/// let fd = File::open("/dev/dri/renderD128").unwrap();
///
/// DeviceHandle::init(fd.into_raw_fd()).unwrap()
/// };
/// for cap_type in [
/// amdgpu_dev.get_video_caps(CAP_TYPE::DECODE).unwrap(),
/// amdgpu_dev.get_video_caps(CAP_TYPE::ENCODE).unwrap(),
/// ] {
/// let codec_list = [
/// CODEC::MPEG2,
/// CODEC::MPEG4,
/// CODEC::VC1,
/// CODEC::MPEG4_AVC,
/// CODEC::HEVC,
/// CODEC::JPEG,
/// CODEC::VP9,
/// CODEC::AV1,
/// ];
///
/// for codec in &codec_list {
/// let cap = cap_type.get_codec_info(*codec);
/// println!("{cap:?}");
/// }
/// }
/// // or
/// if let Ok(dec_info) = amdgpu_dev.get_video_caps_info(CAP_TYPE::DECODE) {
/// println!("{dec_info:#?}");
/// }
/// if let Ok(enc_info) = amdgpu_dev.get_video_caps_info(CAP_TYPE::ENCODE) {
/// println!("{enc_info:#?}");
/// }
/// ```
pub mod VIDEO_CAPS {
pub use super::video_caps::*;
}
pub mod HW_IP {
pub use super::hw_ip::*;
}
pub mod FW_VERSION {
pub use super::fw_version::*;
}
pub mod SENSOR_INFO {
pub use super::sensor_info::*;
}