pub use card::*;
pub use error::*;
use serde::{Deserialize, Serialize};
pub use temp_input::*;
mod card;
mod error;
#[cfg(feature = "gui-helper")]
pub mod hw_mon;
pub mod lock_file;
pub mod pidfile;
mod temp_input;
pub mod utils;
pub static CONFIG_DIR: &str = "/etc/amdfand";
pub static ROOT_DIR: &str = "/sys/class/drm";
pub static HW_MON_DIR: &str = "hwmon";
pub static PULSE_WIDTH_MODULATION_MIN: &str = "pwm1_min";
pub static PULSE_WIDTH_MODULATION_MAX: &str = "pwm1_max";
pub static PULSE_WIDTH_MODULATION: &str = "pwm1";
pub static PULSE_WIDTH_MODULATION_MODE: &str = "pwm1_enable";
pub static PULSE_WIDTH_MODULATION_MANUAL: &str = "1";
pub static PULSE_WIDTH_MODULATION_AUTO: &str = "2";
static mut RELOAD_CONFIG: bool = false;
extern "C" fn sig_reload(_n: i32) {
unsafe {
RELOAD_CONFIG = true;
};
}
pub fn listen_unix_signal() {
use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal};
unsafe {
let handler: SigHandler = SigHandler::Handler(sig_reload);
let action = SigAction::new(handler, SaFlags::SA_NOCLDWAIT, SigSet::empty());
sigaction(Signal::SIGHUP, &action).expect("Failed to mount action handler");
};
}
#[inline(always)]
pub fn is_reload_required() -> bool {
unsafe { RELOAD_CONFIG }
}
#[inline(always)]
pub fn config_reloaded() {
unsafe {
RELOAD_CONFIG = false;
}
}
pub type Result<T> = std::result::Result<T, AmdGpuError>;
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
pub enum LogLevel {
Off,
Error,
Warn,
Info,
Debug,
Trace,
}
impl LogLevel {
pub fn as_str(&self) -> &str {
match self {
LogLevel::Off => "OFF",
LogLevel::Error => "ERROR",
LogLevel::Warn => "WARN",
LogLevel::Info => "INFO",
LogLevel::Debug => "DEBUG",
LogLevel::Trace => "TRACE",
}
}
}