Show warning if ppfeaturemask is not enabled

This commit is contained in:
Ilya Zlobintsev
2021-02-13 16:16:22 +02:00
parent 96829320a9
commit 565f46ed17
3 changed files with 62 additions and 6 deletions

View File

@@ -4,10 +4,13 @@ mod root_stack;
extern crate gtk;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use std::{
fs,
sync::atomic::{AtomicU32, Ordering},
};
use apply_revealer::ApplyRevealer;
use daemon::daemon_connection::DaemonConnection;
@@ -208,6 +211,20 @@ impl App {
Err(_) => self.root_stack.thermals_page.hide_fan_controls(),
}
{
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();
}
}
self.apply_revealer.hide();
}

View File

@@ -1,6 +1,7 @@
mod clocks_frame;
mod power_profile_frame;
mod stats_grid;
mod warning_frame;
use clocks_frame::ClocksSettings;
use daemon::gpu_controller::{ClocksTable, GpuStats, PowerProfile};
@@ -8,6 +9,7 @@ use gtk::*;
use power_profile_frame::PowerProfileFrame;
use stats_grid::StatsGrid;
use warning_frame::WarningFrame;
use self::clocks_frame::ClocksFrame;
@@ -17,11 +19,16 @@ pub struct OcPage {
stats_grid: StatsGrid,
power_profile_frame: PowerProfileFrame,
clocks_frame: ClocksFrame,
pub warning_frame: WarningFrame,
}
impl OcPage {
pub fn new() -> Self {
let container = Box::new(Orientation::Vertical, 5);
let warning_frame = WarningFrame::new();
container.pack_start(&warning_frame.container, false, true, 5);
let stats_grid = StatsGrid::new();
@@ -40,21 +47,20 @@ impl OcPage {
stats_grid,
power_profile_frame,
clocks_frame,
warning_frame,
}
}
pub fn set_stats(&self, stats: &GpuStats) {
self.stats_grid.set_stats(stats);
}
pub fn connect_clocks_reset<F: Fn() + 'static + Clone>(&self, f: F) {
self.clocks_frame.connect_clocks_reset(move || {
f();
});
}
pub fn connect_settings_changed<F: Fn() + 'static + Clone>(&self, f: F) {
{
let f = f.clone();
@@ -85,7 +91,6 @@ impl OcPage {
true => Some(self.power_profile_frame.get_selected_power_profile()),
false => None,
}
}
pub fn set_clocks(&self, clocks_table: &Option<ClocksTable>) {
@@ -94,7 +99,7 @@ impl OcPage {
None => self.clocks_frame.hide(),
}
}
pub fn get_clocks(&self) -> Option<ClocksSettings> {
match self.clocks_frame.get_visibility() {
true => Some(self.clocks_frame.get_settings()),

View File

@@ -0,0 +1,34 @@
use std::fs;
use gtk::*;
#[derive(Clone)]
pub struct WarningFrame {
pub container: Frame,
}
impl WarningFrame {
pub fn new() -> Self {
let container = Frame::new(Some("Overclocking information"));
container.set_label_align(0.3, 0.5);
let warning_label = Label::new(None);
warning_label.set_line_wrap(true);
warning_label.set_markup("Overclocking support is not enabled! To enable overclocking support, you need to add <b>amdgpu.ppfeaturemask=0xffffffff</b> to your kernel boot options. Look for the documentation of your distro.");
warning_label.set_selectable(true);
container.add(&warning_label);
Self { container }
}
pub fn show(&self) {
self.container.set_visible(true);
}
pub fn hide(&self) {
self.container.set_visible(false);
}
}