mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-05 06:00:30 -04:00
Kill UnsupportedFeature
This commit is contained in:
parent
ffebee0930
commit
452690adee
4 changed files with 16 additions and 59 deletions
|
@ -26,7 +26,6 @@ pub enum HardwareVariant {
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum HardwareCurrentlySupported {
|
pub enum HardwareCurrentlySupported {
|
||||||
UnsupportedFeature = 0,
|
|
||||||
Unsupported = 1,
|
Unsupported = 1,
|
||||||
Supported = 2,
|
Supported = 2,
|
||||||
}
|
}
|
||||||
|
@ -46,9 +45,6 @@ impl TryFrom<u32> for HardwareCurrentlySupported {
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
||||||
match v {
|
match v {
|
||||||
x if x == HardwareCurrentlySupported::UnsupportedFeature as u32 => {
|
|
||||||
Ok(HardwareCurrentlySupported::UnsupportedFeature)
|
|
||||||
}
|
|
||||||
x if x == HardwareCurrentlySupported::Unsupported as u32 => {
|
x if x == HardwareCurrentlySupported::Unsupported as u32 => {
|
||||||
Ok(HardwareCurrentlySupported::Unsupported)
|
Ok(HardwareCurrentlySupported::Unsupported)
|
||||||
}
|
}
|
||||||
|
@ -63,7 +59,6 @@ impl TryFrom<u32> for HardwareCurrentlySupported {
|
||||||
impl fmt::Display for HardwareCurrentlySupported {
|
impl fmt::Display for HardwareCurrentlySupported {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
HardwareCurrentlySupported::UnsupportedFeature => write!(f, "Unsupported feature"),
|
|
||||||
HardwareCurrentlySupported::Unsupported => write!(f, "Unsupported"),
|
HardwareCurrentlySupported::Unsupported => write!(f, "Unsupported"),
|
||||||
HardwareCurrentlySupported::Supported => write!(f, "Supported"),
|
HardwareCurrentlySupported::Supported => write!(f, "Supported"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use tokio::fs::File;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
use zbus::{interface, zvariant::Fd};
|
use zbus::{interface, zvariant::Fd};
|
||||||
|
|
||||||
use crate::hardware::{check_support, variant, HardwareCurrentlySupported, HardwareVariant};
|
use crate::hardware::{check_support, variant, HardwareVariant};
|
||||||
use crate::power::{
|
use crate::power::{
|
||||||
get_gpu_performance_level, set_gpu_clocks, set_gpu_performance_level, set_tdp_limit,
|
get_gpu_performance_level, set_gpu_clocks, set_gpu_performance_level, set_tdp_limit,
|
||||||
GPUPerformanceLevel,
|
GPUPerformanceLevel,
|
||||||
|
@ -30,7 +30,6 @@ enum PrepareFactoryReset {
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
enum FanControl {
|
enum FanControl {
|
||||||
UnsupportedFeature = 0,
|
|
||||||
BIOS = 1,
|
BIOS = 1,
|
||||||
OS = 2,
|
OS = 2,
|
||||||
}
|
}
|
||||||
|
@ -39,7 +38,6 @@ impl TryFrom<u32> for FanControl {
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
||||||
match v {
|
match v {
|
||||||
x if x == FanControl::UnsupportedFeature as u32 => Ok(FanControl::UnsupportedFeature),
|
|
||||||
x if x == FanControl::BIOS as u32 => Ok(FanControl::BIOS),
|
x if x == FanControl::BIOS as u32 => Ok(FanControl::BIOS),
|
||||||
x if x == FanControl::OS as u32 => Ok(FanControl::BIOS),
|
x if x == FanControl::OS as u32 => Ok(FanControl::BIOS),
|
||||||
_ => Err("No enum match for value {v}"),
|
_ => Err("No enum match for value {v}"),
|
||||||
|
@ -50,7 +48,6 @@ impl TryFrom<u32> for FanControl {
|
||||||
impl fmt::Display for FanControl {
|
impl fmt::Display for FanControl {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
FanControl::UnsupportedFeature => write!(f, "Unsupported feature"),
|
|
||||||
FanControl::BIOS => write!(f, "BIOS"),
|
FanControl::BIOS => write!(f, "BIOS"),
|
||||||
FanControl::OS => write!(f, "OS"),
|
FanControl::OS => write!(f, "OS"),
|
||||||
}
|
}
|
||||||
|
@ -94,8 +91,8 @@ impl SteamOSManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
fn wifi_power_management_state(&self) -> u32 {
|
fn wifi_power_management_state(&self) -> zbus::fdo::Result<u32> {
|
||||||
WifiPowerManagement::UnsupportedFeature as u32 // TODO
|
Err(zbus::fdo::Error::UnknownProperty(String::from("This property can't currently be read")))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
|
@ -107,12 +104,6 @@ impl SteamOSManager {
|
||||||
let state = match state {
|
let state = match state {
|
||||||
WifiPowerManagement::Disabled => "off",
|
WifiPowerManagement::Disabled => "off",
|
||||||
WifiPowerManagement::Enabled => "on",
|
WifiPowerManagement::Enabled => "on",
|
||||||
WifiPowerManagement::UnsupportedFeature => {
|
|
||||||
return Err(zbus::fdo::Error::InvalidArgs(String::from(
|
|
||||||
"Can't set state to unsupported",
|
|
||||||
))
|
|
||||||
.into())
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
run_script(
|
run_script(
|
||||||
|
@ -125,8 +116,8 @@ impl SteamOSManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
fn fan_control_state(&self) -> u32 {
|
fn fan_control_state(&self) -> zbus::fdo::Result<u32> {
|
||||||
FanControl::UnsupportedFeature as u32 // TODO
|
Err(zbus::fdo::Error::UnknownProperty(String::from("This property can't currently be read")))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
|
@ -138,12 +129,6 @@ impl SteamOSManager {
|
||||||
let state = match state {
|
let state = match state {
|
||||||
FanControl::OS => "stop",
|
FanControl::OS => "stop",
|
||||||
FanControl::BIOS => "start",
|
FanControl::BIOS => "start",
|
||||||
FanControl::UnsupportedFeature => {
|
|
||||||
return Err(zbus::fdo::Error::InvalidArgs(String::from(
|
|
||||||
"Can't set state to unsupported",
|
|
||||||
))
|
|
||||||
.into())
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Run what steamos-polkit-helpers/jupiter-fan-control does
|
// Run what steamos-polkit-helpers/jupiter-fan-control does
|
||||||
|
@ -157,10 +142,10 @@ impl SteamOSManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
async fn hardware_currently_supported(&self) -> u32 {
|
async fn hardware_currently_supported(&self) -> zbus::fdo::Result<u32> {
|
||||||
match check_support().await {
|
match check_support().await {
|
||||||
Ok(res) => res as u32,
|
Ok(res) => Ok(res as u32),
|
||||||
Err(_) => HardwareCurrentlySupported::UnsupportedFeature as u32,
|
Err(e) => Err(anyhow_to_zbus_fdo(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,10 +231,10 @@ impl SteamOSManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
async fn gpu_performance_level(&self) -> u32 {
|
async fn gpu_performance_level(&self) -> zbus::fdo::Result<u32> {
|
||||||
match get_gpu_performance_level().await {
|
match get_gpu_performance_level().await {
|
||||||
Ok(level) => level as u32,
|
Ok(level) => Ok(level as u32),
|
||||||
Err(_) => GPUPerformanceLevel::UnsupportedFeature as u32,
|
Err(e) => Err(anyhow_to_zbus_fdo(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,9 +273,6 @@ impl SteamOSManager {
|
||||||
// Return false on error
|
// Return false on error
|
||||||
|
|
||||||
let wanted_mode = match WifiDebugMode::try_from(mode) {
|
let wanted_mode = match WifiDebugMode::try_from(mode) {
|
||||||
Ok(WifiDebugMode::UnsupportedFeature) => {
|
|
||||||
return Err(zbus::fdo::Error::InvalidArgs(String::from("Invalid mode")))
|
|
||||||
}
|
|
||||||
Ok(mode) => mode,
|
Ok(mode) => mode,
|
||||||
Err(e) => return Err(zbus::fdo::Error::InvalidArgs(e.to_string())),
|
Err(e) => return Err(zbus::fdo::Error::InvalidArgs(e.to_string())),
|
||||||
};
|
};
|
||||||
|
|
16
src/power.rs
16
src/power.rs
|
@ -22,7 +22,6 @@ const GPU_CLOCKS_PATH: &str = "/sys/class/drm/card0/device/pp_od_clk_voltage";
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum GPUPerformanceLevel {
|
pub enum GPUPerformanceLevel {
|
||||||
UnsupportedFeature = 0,
|
|
||||||
Auto = 1,
|
Auto = 1,
|
||||||
Low = 2,
|
Low = 2,
|
||||||
High = 3,
|
High = 3,
|
||||||
|
@ -34,9 +33,6 @@ impl TryFrom<u32> for GPUPerformanceLevel {
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
||||||
match v {
|
match v {
|
||||||
x if x == GPUPerformanceLevel::UnsupportedFeature as u32 => {
|
|
||||||
Ok(GPUPerformanceLevel::UnsupportedFeature)
|
|
||||||
}
|
|
||||||
x if x == GPUPerformanceLevel::Auto as u32 => Ok(GPUPerformanceLevel::Auto),
|
x if x == GPUPerformanceLevel::Auto as u32 => Ok(GPUPerformanceLevel::Auto),
|
||||||
x if x == GPUPerformanceLevel::Low as u32 => Ok(GPUPerformanceLevel::Low),
|
x if x == GPUPerformanceLevel::Low as u32 => Ok(GPUPerformanceLevel::Low),
|
||||||
x if x == GPUPerformanceLevel::High as u32 => Ok(GPUPerformanceLevel::High),
|
x if x == GPUPerformanceLevel::High as u32 => Ok(GPUPerformanceLevel::High),
|
||||||
|
@ -63,17 +59,15 @@ impl FromStr for GPUPerformanceLevel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryInto<String> for GPUPerformanceLevel {
|
impl ToString for GPUPerformanceLevel {
|
||||||
type Error = Error;
|
fn to_string(&self) -> String {
|
||||||
fn try_into(self) -> Result<String, Self::Error> {
|
String::from(match self {
|
||||||
Ok(String::from(match self {
|
|
||||||
GPUPerformanceLevel::Auto => "auto",
|
GPUPerformanceLevel::Auto => "auto",
|
||||||
GPUPerformanceLevel::Low => "low",
|
GPUPerformanceLevel::Low => "low",
|
||||||
GPUPerformanceLevel::High => "high",
|
GPUPerformanceLevel::High => "high",
|
||||||
GPUPerformanceLevel::Manual => "manual",
|
GPUPerformanceLevel::Manual => "manual",
|
||||||
GPUPerformanceLevel::ProfilePeak => "peak_performance",
|
GPUPerformanceLevel::ProfilePeak => "peak_performance",
|
||||||
GPUPerformanceLevel::UnsupportedFeature => bail!("No valid string representation"),
|
})
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +84,7 @@ pub async fn set_gpu_performance_level(level: GPUPerformanceLevel) -> Result<()>
|
||||||
.await
|
.await
|
||||||
.inspect_err(|message| error!("Error opening sysfs file for writing: {message}"))?;
|
.inspect_err(|message| error!("Error opening sysfs file for writing: {message}"))?;
|
||||||
|
|
||||||
let level: String = level.try_into()?;
|
let level: String = level.to_string();
|
||||||
|
|
||||||
myfile
|
myfile
|
||||||
.write_all(level.as_bytes())
|
.write_all(level.as_bytes())
|
||||||
|
|
14
src/wifi.rs
14
src/wifi.rs
|
@ -29,7 +29,6 @@ const MIN_BUFFER_SIZE: u32 = 100;
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum WifiDebugMode {
|
pub enum WifiDebugMode {
|
||||||
UnsupportedFeature = 0,
|
|
||||||
Off = 1,
|
Off = 1,
|
||||||
On = 2,
|
On = 2,
|
||||||
}
|
}
|
||||||
|
@ -37,7 +36,6 @@ pub enum WifiDebugMode {
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum WifiPowerManagement {
|
pub enum WifiPowerManagement {
|
||||||
UnsupportedFeature = 0,
|
|
||||||
Disabled = 1,
|
Disabled = 1,
|
||||||
Enabled = 2,
|
Enabled = 2,
|
||||||
}
|
}
|
||||||
|
@ -46,9 +44,6 @@ impl TryFrom<u32> for WifiDebugMode {
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
||||||
match v {
|
match v {
|
||||||
x if x == WifiDebugMode::UnsupportedFeature as u32 => {
|
|
||||||
Ok(WifiDebugMode::UnsupportedFeature)
|
|
||||||
}
|
|
||||||
x if x == WifiDebugMode::Off as u32 => Ok(WifiDebugMode::Off),
|
x if x == WifiDebugMode::Off as u32 => Ok(WifiDebugMode::Off),
|
||||||
x if x == WifiDebugMode::On as u32 => Ok(WifiDebugMode::On),
|
x if x == WifiDebugMode::On as u32 => Ok(WifiDebugMode::On),
|
||||||
_ => Err("No enum match for value {v}"),
|
_ => Err("No enum match for value {v}"),
|
||||||
|
@ -59,7 +54,6 @@ impl TryFrom<u32> for WifiDebugMode {
|
||||||
impl fmt::Display for WifiDebugMode {
|
impl fmt::Display for WifiDebugMode {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
WifiDebugMode::UnsupportedFeature => write!(f, "Unsupported feature"),
|
|
||||||
WifiDebugMode::Off => write!(f, "Off"),
|
WifiDebugMode::Off => write!(f, "Off"),
|
||||||
WifiDebugMode::On => write!(f, "On"),
|
WifiDebugMode::On => write!(f, "On"),
|
||||||
}
|
}
|
||||||
|
@ -70,9 +64,6 @@ impl TryFrom<u32> for WifiPowerManagement {
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
||||||
match v {
|
match v {
|
||||||
x if x == WifiPowerManagement::UnsupportedFeature as u32 => {
|
|
||||||
Ok(WifiPowerManagement::UnsupportedFeature)
|
|
||||||
}
|
|
||||||
x if x == WifiPowerManagement::Disabled as u32 => Ok(WifiPowerManagement::Disabled),
|
x if x == WifiPowerManagement::Disabled as u32 => Ok(WifiPowerManagement::Disabled),
|
||||||
x if x == WifiPowerManagement::Enabled as u32 => Ok(WifiPowerManagement::Enabled),
|
x if x == WifiPowerManagement::Enabled as u32 => Ok(WifiPowerManagement::Enabled),
|
||||||
_ => Err("No enum match for value {v}"),
|
_ => Err("No enum match for value {v}"),
|
||||||
|
@ -83,7 +74,6 @@ impl TryFrom<u32> for WifiPowerManagement {
|
||||||
impl fmt::Display for WifiPowerManagement {
|
impl fmt::Display for WifiPowerManagement {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
WifiPowerManagement::UnsupportedFeature => write!(f, "Unsupported feature"),
|
|
||||||
WifiPowerManagement::Disabled => write!(f, "Disabled"),
|
WifiPowerManagement::Disabled => write!(f, "Disabled"),
|
||||||
WifiPowerManagement::Enabled => write!(f, "Enabled"),
|
WifiPowerManagement::Enabled => write!(f, "Enabled"),
|
||||||
}
|
}
|
||||||
|
@ -188,10 +178,6 @@ pub async fn set_wifi_debug_mode(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mode => {
|
|
||||||
// Invalid mode requested, more coming later, but add this catch-all for now
|
|
||||||
bail!("Invalid wifi debug mode {mode} requested");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue