Get ppfeaturemask from the kernel module info (#29)

* Switch to using the kernel module info for checking ppfeaturemask
This commit is contained in:
ilyazzz
2021-04-18 12:48:08 +03:00
committed by GitHub
parent 2f0843e1a7
commit 8c7a4ccdfd

View File

@@ -218,16 +218,28 @@ impl App {
}
{
let cmdline =
fs::read_to_string("/proc/cmdline").expect("Failed to read /proc/cmdline");
// It's overkill to both show and hide the frame, but it needs to be done in set_info because show_all overrides the default hidden state of the frame.
if !cmdline.contains("amdgpu.ppfeaturemask") {
log::info!("amdgpu.ppfeaturemask not detected, showing the warning");
self.root_stack.oc_page.warning_frame.show();
} else {
log::info!("overclocking support enabled, not showing the warning");
self.root_stack.oc_page.warning_frame.hide();
match fs::read_to_string("/sys/module/amdgpu/parameters/ppfeaturemask") {
Ok(ppfeaturemask) => {
const PP_OVERDRIVE_MASK: i32 = 0x4000;
let ppfeaturemask = ppfeaturemask.trim().strip_prefix("0x").unwrap();
log::trace!("ppfeaturemask {}", ppfeaturemask);
let ppfeaturemask: u64 =
u64::from_str_radix(ppfeaturemask, 16).expect("Invalid ppfeaturemask");
if (ppfeaturemask & PP_OVERDRIVE_MASK as u64) > 0 {
self.root_stack.oc_page.warning_frame.hide();
} else {
self.root_stack.oc_page.warning_frame.show();
}
}
Err(_) => {
log::info!("Failed to read feature mask! This is expected if your system doesn't have an AMD GPU.");
self.root_stack.oc_page.warning_frame.hide();
}
}
}