mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
Update readme, slash configs
This commit is contained in:
@@ -10,7 +10,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
usb_node = Some(node);
|
||||
println!("Looked for keyboard controller 0x{}: Found", id);
|
||||
}
|
||||
Err(err) => println!("Looked for keyboard controller: {err}"),
|
||||
Err(err) => println!("Looked for keyboard controller: {err}")
|
||||
}
|
||||
|
||||
if usb_node.is_none() {
|
||||
@@ -24,7 +24,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
];
|
||||
|
||||
let x_stable = 2107;
|
||||
@@ -72,7 +72,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
];
|
||||
node.write_bytes(&packet)?;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
];
|
||||
node.write_bytes(&packet)?;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
usb_node = Some(node);
|
||||
println!("Looked for keyboard controller 0x{}: Found", id);
|
||||
}
|
||||
Err(err) => println!("Looked for keyboard controller: {err}"),
|
||||
Err(err) => println!("Looked for keyboard controller: {err}")
|
||||
}
|
||||
|
||||
if usb_node.is_none() {
|
||||
@@ -23,19 +23,33 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// node.write_bytes(&[0x5a, 0xd1, 0x0a, 0x01])?; // TODO: need to CHECK
|
||||
println!("Set mouse mode for 10 seconds");
|
||||
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x03])?;
|
||||
node.write_bytes(&[0x5a, 0xd1, 0x0f, 0x20])?;
|
||||
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x00])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x03
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x0f, 0x20
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x00
|
||||
])?;
|
||||
sleep(Duration::from_secs(10));
|
||||
|
||||
println!("Set wasd mode for 10 seconds");
|
||||
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x02])?;
|
||||
node.write_bytes(&[0x5a, 0xd1, 0x0f, 0x20])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x02
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x0f, 0x20
|
||||
])?;
|
||||
sleep(Duration::from_secs(10));
|
||||
|
||||
println!("Set back to gamepad mode");
|
||||
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x01])?;
|
||||
node.write_bytes(&[0x5a, 0xd1, 0x0f, 0x20])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x01
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x0f, 0x20
|
||||
])?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
usb_node = Some(node);
|
||||
println!("Looked for keyboard controller 0x{}: Found", id);
|
||||
}
|
||||
Err(err) => println!("Looked for keyboard controller: {err}"),
|
||||
Err(err) => println!("Looked for keyboard controller: {err}")
|
||||
}
|
||||
|
||||
if usb_node.is_none() {
|
||||
@@ -21,9 +21,15 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// node.write_bytes(&[0x5a, 0xd1, 0x0a, 0x01])?; // TODO: need to CHECK
|
||||
println!("Set mouse mode for 10 seconds");
|
||||
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x03])?;
|
||||
node.write_bytes(&[0x5a, 0xd1, 0x0f, 0x20])?;
|
||||
node.write_bytes(&[0x5a, 0xd1, 0x01, 0x01, 0x00])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x03
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x0f, 0x20
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x00
|
||||
])?;
|
||||
// sleep(Duration::from_secs(10));
|
||||
|
||||
// println!("Set wasd mode for 10 seconds");
|
||||
|
||||
@@ -18,7 +18,7 @@ const ATTR_EPP: &str = "cpufreq/energy_performance_preference";
|
||||
/// which can drastically alter CPU performance.
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
|
||||
pub struct CPUControl {
|
||||
paths: Vec<PathBuf>,
|
||||
paths: Vec<PathBuf>
|
||||
}
|
||||
|
||||
impl CPUControl {
|
||||
@@ -54,7 +54,7 @@ impl CPUControl {
|
||||
}
|
||||
match device.attribute_value(ATTR_GOVERNOR) {
|
||||
Some(g) => info!("{ATTR_GOVERNOR}: {g:?}"),
|
||||
None => return Err(PlatformError::CPU(format!("{ATTR_GOVERNOR} not found"))),
|
||||
None => return Err(PlatformError::CPU(format!("{ATTR_GOVERNOR} not found")))
|
||||
}
|
||||
match device.attribute_value(ATTR_AVAILABLE_EPP) {
|
||||
Some(g) => info!("{ATTR_AVAILABLE_EPP}: {g:?}"),
|
||||
@@ -66,7 +66,7 @@ impl CPUControl {
|
||||
}
|
||||
match device.attribute_value(ATTR_EPP) {
|
||||
Some(g) => info!("{ATTR_EPP}: {g:?}"),
|
||||
None => return Err(PlatformError::CPU(format!("{ATTR_EPP} not found"))),
|
||||
None => return Err(PlatformError::CPU(format!("{ATTR_EPP} not found")))
|
||||
}
|
||||
supported = true;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ impl CPUControl {
|
||||
}
|
||||
if cpu.paths.is_empty() {
|
||||
return Err(PlatformError::MissingFunction(
|
||||
"asus-nb-wmi not found".into(),
|
||||
"asus-nb-wmi not found".into()
|
||||
));
|
||||
}
|
||||
Ok(cpu)
|
||||
@@ -154,7 +154,7 @@ impl CPUControl {
|
||||
pub enum CPUGovernor {
|
||||
Performance = 0,
|
||||
Powersave = 1,
|
||||
BadValue = 2,
|
||||
BadValue = 2
|
||||
}
|
||||
|
||||
impl From<&str> for CPUGovernor {
|
||||
@@ -162,7 +162,7 @@ impl From<&str> for CPUGovernor {
|
||||
match s {
|
||||
"performance" => Self::Performance,
|
||||
"powersave" => Self::Powersave,
|
||||
_ => Self::BadValue,
|
||||
_ => Self::BadValue
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ impl From<CPUGovernor> for String {
|
||||
match g {
|
||||
CPUGovernor::Performance => "performance".to_string(),
|
||||
CPUGovernor::Powersave => "powersave".to_string(),
|
||||
CPUGovernor::BadValue => "bad_value".to_string(),
|
||||
CPUGovernor::BadValue => "bad_value".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ pub enum CPUEPP {
|
||||
Performance = 1,
|
||||
BalancePerformance = 2,
|
||||
BalancePower = 3,
|
||||
Power = 4,
|
||||
Power = 4
|
||||
}
|
||||
|
||||
impl From<ThrottlePolicy> for CPUEPP {
|
||||
@@ -206,7 +206,7 @@ impl From<ThrottlePolicy> for CPUEPP {
|
||||
match value {
|
||||
ThrottlePolicy::Balanced => CPUEPP::BalancePerformance,
|
||||
ThrottlePolicy::Performance => CPUEPP::Performance,
|
||||
ThrottlePolicy::Quiet => CPUEPP::Power,
|
||||
ThrottlePolicy::Quiet => CPUEPP::Power
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ impl From<&str> for CPUEPP {
|
||||
"balance_performance" => Self::BalancePerformance,
|
||||
"balance_power" => Self::BalancePower,
|
||||
"power" => Self::Power,
|
||||
_ => Self::Default,
|
||||
_ => Self::Default
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,7 +231,7 @@ impl From<CPUEPP> for String {
|
||||
CPUEPP::Performance => "performance".to_string(),
|
||||
CPUEPP::BalancePerformance => "balance_performance".to_string(),
|
||||
CPUEPP::BalancePower => "balance_power".to_string(),
|
||||
CPUEPP::Power => "power".to_string(),
|
||||
CPUEPP::Power => "power".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,7 +244,7 @@ impl From<i32> for CPUEPP {
|
||||
2 => Self::BalancePerformance,
|
||||
3 => Self::BalancePower,
|
||||
4 => Self::Power,
|
||||
_ => Self::Default,
|
||||
_ => Self::Default
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,21 +265,18 @@ mod tests {
|
||||
fn check_cpu() {
|
||||
let cpu = CPUControl::new().unwrap();
|
||||
assert_eq!(cpu.get_governor().unwrap(), CPUGovernor::Powersave);
|
||||
assert_eq!(
|
||||
cpu.get_available_governors().unwrap(),
|
||||
vec![CPUGovernor::Performance, CPUGovernor::Powersave]
|
||||
);
|
||||
assert_eq!(cpu.get_available_governors().unwrap(), vec![
|
||||
CPUGovernor::Performance,
|
||||
CPUGovernor::Powersave
|
||||
]);
|
||||
|
||||
assert_eq!(cpu.get_epp().unwrap(), CPUEPP::BalancePower);
|
||||
assert_eq!(
|
||||
cpu.get_available_epp().unwrap(),
|
||||
vec![
|
||||
CPUEPP::Default,
|
||||
CPUEPP::Performance,
|
||||
CPUEPP::BalancePerformance,
|
||||
CPUEPP::BalancePower,
|
||||
CPUEPP::Power,
|
||||
]
|
||||
);
|
||||
assert_eq!(cpu.get_available_epp().unwrap(), vec![
|
||||
CPUEPP::Default,
|
||||
CPUEPP::Performance,
|
||||
CPUEPP::BalancePerformance,
|
||||
CPUEPP::BalancePower,
|
||||
CPUEPP::Power,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ pub enum PlatformError {
|
||||
InvalidValue,
|
||||
NoAuraKeyboard,
|
||||
NoAuraNode,
|
||||
CPU(String),
|
||||
CPU(String)
|
||||
}
|
||||
|
||||
impl fmt::Display for PlatformError {
|
||||
@@ -52,7 +52,7 @@ impl fmt::Display for PlatformError {
|
||||
PlatformError::IoPath(path, detail) => write!(f, "{} {}", path, detail),
|
||||
PlatformError::NoAuraKeyboard => write!(f, "No supported Aura keyboard"),
|
||||
PlatformError::NoAuraNode => write!(f, "No Aura keyboard node found"),
|
||||
PlatformError::CPU(s) => write!(f, "CPU control: {s}"),
|
||||
PlatformError::CPU(s) => write!(f, "CPU control: {s}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ impl From<PlatformError> for FdoErr {
|
||||
log::error!("PlatformError: got: {error}");
|
||||
match error {
|
||||
PlatformError::NotSupported => FdoErr::NotSupported("".to_owned()),
|
||||
_ => FdoErr::Failed(format!("Failed with {error}")),
|
||||
_ => FdoErr::Failed(format!("Failed with {error}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ pub enum AttrValue {
|
||||
EnumInt(Vec<i32>),
|
||||
EnumStr(Vec<String>),
|
||||
#[default]
|
||||
None,
|
||||
None
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
@@ -49,7 +49,7 @@ pub struct Attribute {
|
||||
min_value: AttrValue,
|
||||
max_value: AttrValue,
|
||||
scalar_increment: AttrValue,
|
||||
base_path: PathBuf,
|
||||
base_path: PathBuf
|
||||
}
|
||||
|
||||
impl Attribute {
|
||||
@@ -71,7 +71,7 @@ impl Attribute {
|
||||
Ok(AttrValue::String(val))
|
||||
}
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
Err(e) => Err(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ impl Attribute {
|
||||
let value_str = match new_value {
|
||||
AttrValue::Integer(val) => val.to_string(),
|
||||
AttrValue::String(val) => val,
|
||||
_ => return Err(PlatformError::InvalidValue),
|
||||
_ => return Err(PlatformError::InvalidValue)
|
||||
};
|
||||
|
||||
let mut file = OpenOptions::new().write(true).open(&path)?;
|
||||
@@ -114,7 +114,7 @@ impl Attribute {
|
||||
/// change, if they do then it is possibly a driver issue - although this is
|
||||
/// subject to `firmware_attributes` class changes in kernel.
|
||||
fn read_base_values(
|
||||
base_path: &Path,
|
||||
base_path: &Path
|
||||
) -> (AttrValue, AttrValue, AttrValue, AttrValue, AttrValue) {
|
||||
let default_value = match read_string(&base_path.join("default_value")) {
|
||||
Ok(val) => {
|
||||
@@ -124,7 +124,7 @@ impl Attribute {
|
||||
AttrValue::String(val)
|
||||
}
|
||||
}
|
||||
Err(_) => AttrValue::None,
|
||||
Err(_) => AttrValue::None
|
||||
};
|
||||
|
||||
let possible_values = match read_string(&base_path.join("possible_values")) {
|
||||
@@ -137,7 +137,7 @@ impl Attribute {
|
||||
AttrValue::EnumStr(val.split(';').map(|s| s.to_string()).collect())
|
||||
}
|
||||
}
|
||||
Err(_) => AttrValue::None,
|
||||
Err(_) => AttrValue::None
|
||||
};
|
||||
|
||||
let min_value = read_i32(&base_path.join("min_value"))
|
||||
@@ -154,17 +154,13 @@ impl Attribute {
|
||||
.unwrap_or_default();
|
||||
|
||||
(
|
||||
default_value,
|
||||
possible_values,
|
||||
min_value,
|
||||
max_value,
|
||||
scalar_increment,
|
||||
default_value, possible_values, min_value, max_value, scalar_increment
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FirmwareAttributes {
|
||||
attrs: Vec<Attribute>,
|
||||
attrs: Vec<Attribute>
|
||||
}
|
||||
|
||||
#[allow(clippy::new_without_default)]
|
||||
@@ -191,7 +187,7 @@ impl FirmwareAttributes {
|
||||
min_value,
|
||||
max_value,
|
||||
scalar_increment,
|
||||
base_path,
|
||||
base_path
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -226,28 +222,10 @@ macro_rules! define_attribute_getters {
|
||||
}
|
||||
|
||||
define_attribute_getters!(
|
||||
apu_mem,
|
||||
cores_performance,
|
||||
cores_efficiency,
|
||||
ppt_pl1_spl,
|
||||
ppt_pl2_sppt,
|
||||
ppt_apu_sppt,
|
||||
ppt_platform_sppt,
|
||||
ppt_fppt,
|
||||
nv_dynamic_boost,
|
||||
nv_temp_target,
|
||||
dgpu_base_tgp,
|
||||
dgpu_tgp,
|
||||
charge_mode,
|
||||
boot_sound,
|
||||
mcu_powersave,
|
||||
panel_od,
|
||||
panel_hd_mode,
|
||||
egpu_connected,
|
||||
egpu_enable,
|
||||
dgpu_disable,
|
||||
gpu_mux_mode,
|
||||
mini_led_mode
|
||||
apu_mem, cores_performance, cores_efficiency, ppt_pl1_spl, ppt_pl2_sppt, ppt_apu_sppt,
|
||||
ppt_platform_sppt, ppt_fppt, nv_dynamic_boost, nv_temp_target, dgpu_base_tgp, dgpu_tgp,
|
||||
charge_mode, boot_sound, mcu_powersave, panel_od, panel_hd_mode, egpu_connected, egpu_enable,
|
||||
dgpu_disable, gpu_mux_mode, mini_led_mode
|
||||
);
|
||||
|
||||
/// CamelCase names of the properties. Intended for use with DBUS
|
||||
@@ -278,7 +256,7 @@ pub enum FirmwareAttribute {
|
||||
GpuMuxMode = 20,
|
||||
MiniLedMode = 21,
|
||||
PendingReboot = 22,
|
||||
None = 23,
|
||||
None = 23
|
||||
}
|
||||
|
||||
impl From<&str> for FirmwareAttribute {
|
||||
@@ -307,7 +285,7 @@ impl From<&str> for FirmwareAttribute {
|
||||
"gpu_mux_mode" => Self::GpuMuxMode,
|
||||
"mini_led_mode" => Self::MiniLedMode,
|
||||
"pending_reboot" => Self::PendingReboot,
|
||||
_ => panic!("Invalid firmware attribute: {}", s),
|
||||
_ => panic!("Invalid firmware attribute: {}", s)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -338,7 +316,7 @@ impl From<FirmwareAttribute> for &str {
|
||||
FirmwareAttribute::GpuMuxMode => "gpu_mux_mode",
|
||||
FirmwareAttribute::MiniLedMode => "mini_led_mode",
|
||||
FirmwareAttribute::PendingReboot => "pending_reboot",
|
||||
FirmwareAttribute::None => "none",
|
||||
FirmwareAttribute::None => "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ pub struct HidRaw {
|
||||
prod_id: String,
|
||||
_device_bcd: u32,
|
||||
/// Retaining a handle to the file for the duration of `HidRaw`
|
||||
file: RefCell<File>,
|
||||
file: RefCell<File>
|
||||
}
|
||||
|
||||
impl HidRaw {
|
||||
@@ -66,7 +66,7 @@ impl HidRaw {
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.parse()
|
||||
.unwrap_or_default(),
|
||||
.unwrap_or_default()
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -98,13 +98,13 @@ impl HidRaw {
|
||||
.unwrap_or_default()
|
||||
.to_string_lossy()
|
||||
.parse()
|
||||
.unwrap_or_default(),
|
||||
.unwrap_or_default()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(PlatformError::MissingFunction(
|
||||
"hidraw dev no dev path".to_string(),
|
||||
"hidraw dev no dev path".to_string()
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::{attr_u8, has_attr, set_attr_u8_array, to_device};
|
||||
/// for Aura keyboards
|
||||
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Clone)]
|
||||
pub struct KeyboardBacklight {
|
||||
path: PathBuf,
|
||||
path: PathBuf
|
||||
}
|
||||
|
||||
impl KeyboardBacklight {
|
||||
@@ -51,12 +51,12 @@ impl KeyboardBacklight {
|
||||
if sys.contains("kbd_backlight") || sys.contains("ally:rgb:gamepad") {
|
||||
info!("Found keyboard LED controls at {:?}", device.sysname());
|
||||
return Ok(Self {
|
||||
path: device.syspath().to_owned(),
|
||||
path: device.syspath().to_owned()
|
||||
});
|
||||
}
|
||||
}
|
||||
Err(PlatformError::MissingFunction(
|
||||
"KeyboardLed:new(), asus::kbd_backlight not found".into(),
|
||||
"KeyboardLed:new(), asus::kbd_backlight not found".into()
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,9 @@ pub fn write_attr_string(device: &mut Device, attr: &str, value: &str) -> Result
|
||||
mod tests {
|
||||
#[test]
|
||||
fn check() {
|
||||
let data = [1, 2, 3, 4, 5];
|
||||
let data = [
|
||||
1, 2, 3, 4, 5
|
||||
];
|
||||
let mut tmp = String::new();
|
||||
for n in data {
|
||||
tmp.push_str(&n.to_string());
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::{attr_bool, attr_string, attr_u8, to_device};
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
|
||||
pub struct RogPlatform {
|
||||
path: PathBuf,
|
||||
pp_path: PathBuf,
|
||||
pp_path: PathBuf
|
||||
}
|
||||
|
||||
impl RogPlatform {
|
||||
@@ -127,11 +127,11 @@ impl RogPlatform {
|
||||
info!("Found platform support at {:?}", device.sysname());
|
||||
return Ok(Self {
|
||||
path: device.syspath().to_owned(),
|
||||
pp_path: PathBuf::from_str("/sys/firmware/acpi").unwrap(),
|
||||
pp_path: PathBuf::from_str("/sys/firmware/acpi").unwrap()
|
||||
});
|
||||
}
|
||||
Err(PlatformError::MissingFunction(
|
||||
"asus-nb-wmi not found".into(),
|
||||
"asus-nb-wmi not found".into()
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ impl Default for RogPlatform {
|
||||
unsafe {
|
||||
Self {
|
||||
path: PathBuf::from_str("/this_shouldNeVErr_exisid").unwrap_unchecked(),
|
||||
pp_path: PathBuf::from_str("/this_shouldNeVErr_exisid").unwrap_unchecked(),
|
||||
pp_path: PathBuf::from_str("/this_shouldNeVErr_exisid").unwrap_unchecked()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ pub enum GpuMode {
|
||||
Ultimate = 4,
|
||||
#[default]
|
||||
Error = 254,
|
||||
NotSupported = 255,
|
||||
NotSupported = 255
|
||||
}
|
||||
|
||||
impl From<u8> for GpuMode {
|
||||
@@ -171,7 +171,7 @@ impl From<u8> for GpuMode {
|
||||
3 => GpuMode::Vfio,
|
||||
4 => GpuMode::Ultimate,
|
||||
5 => GpuMode::Error,
|
||||
_ => GpuMode::NotSupported,
|
||||
_ => GpuMode::NotSupported
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,7 +238,7 @@ impl Display for GpuMode {
|
||||
GpuMode::Vfio => write!(f, "VFIO"),
|
||||
GpuMode::Ultimate => write!(f, "Ultimate"),
|
||||
GpuMode::Error => write!(f, "Error"),
|
||||
GpuMode::NotSupported => write!(f, "Not Supported"),
|
||||
GpuMode::NotSupported => write!(f, "Not Supported")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ pub enum ThrottlePolicy {
|
||||
#[default]
|
||||
Balanced = 0,
|
||||
Performance = 1,
|
||||
Quiet = 2,
|
||||
Quiet = 2
|
||||
}
|
||||
|
||||
impl ThrottlePolicy {
|
||||
@@ -274,12 +274,16 @@ impl ThrottlePolicy {
|
||||
match self {
|
||||
Self::Balanced => Self::Performance,
|
||||
Self::Performance => Self::Quiet,
|
||||
Self::Quiet => Self::Balanced,
|
||||
Self::Quiet => Self::Balanced
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn list() -> [Self; 3] {
|
||||
[Self::Balanced, Self::Performance, Self::Quiet]
|
||||
[
|
||||
Self::Balanced,
|
||||
Self::Performance,
|
||||
Self::Quiet
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +312,7 @@ impl From<ThrottlePolicy> for u8 {
|
||||
match p {
|
||||
ThrottlePolicy::Balanced => 0,
|
||||
ThrottlePolicy::Performance => 1,
|
||||
ThrottlePolicy::Quiet => 2,
|
||||
ThrottlePolicy::Quiet => 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,7 +328,7 @@ impl From<ThrottlePolicy> for &str {
|
||||
match profile {
|
||||
ThrottlePolicy::Balanced => "balanced",
|
||||
ThrottlePolicy::Performance => "performance",
|
||||
ThrottlePolicy::Quiet => "quiet",
|
||||
ThrottlePolicy::Quiet => "quiet"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -337,7 +341,7 @@ impl std::str::FromStr for ThrottlePolicy {
|
||||
"balanced" => Ok(ThrottlePolicy::Balanced),
|
||||
"performance" => Ok(ThrottlePolicy::Performance),
|
||||
"quiet" => Ok(ThrottlePolicy::Quiet),
|
||||
_ => Err(PlatformError::NotSupported),
|
||||
_ => Err(PlatformError::NotSupported)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,5 +371,5 @@ pub enum Properties {
|
||||
PptApuSppt,
|
||||
PptPlatformSppt,
|
||||
NvDynamicBoost,
|
||||
NvTempTarget,
|
||||
NvTempTarget
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use crate::{attr_u8, to_device};
|
||||
pub struct AsusPower {
|
||||
mains: PathBuf,
|
||||
battery: PathBuf,
|
||||
usb: Option<PathBuf>,
|
||||
usb: Option<PathBuf>
|
||||
}
|
||||
|
||||
impl AsusPower {
|
||||
@@ -97,12 +97,12 @@ impl AsusPower {
|
||||
return Ok(Self {
|
||||
mains,
|
||||
battery,
|
||||
usb,
|
||||
usb
|
||||
});
|
||||
}
|
||||
|
||||
Err(PlatformError::MissingFunction(
|
||||
"Did not find a battery".to_owned(),
|
||||
"Did not find a battery".to_owned()
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ impl USBRaw {
|
||||
}
|
||||
|
||||
fn get_dev_handle(
|
||||
device: &Device<rusb::GlobalContext>,
|
||||
device: &Device<rusb::GlobalContext>
|
||||
) -> Result<DeviceHandle<rusb::GlobalContext>> {
|
||||
// We don't expect this ID to ever change
|
||||
let device = device.open()?;
|
||||
@@ -42,7 +42,7 @@ impl USBRaw {
|
||||
0x35e, // value
|
||||
0x00, // index
|
||||
message,
|
||||
Duration::from_millis(200),
|
||||
Duration::from_millis(200)
|
||||
)
|
||||
.map_err(PlatformError::USB)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user