mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-13 01:41:59 -04:00
hardware: Move DeviceConfig and allow for auto-matching based on file contents
This commit is contained in:
parent
ee9d2332aa
commit
dd9b000e4b
10 changed files with 375 additions and 263 deletions
422
src/hardware.rs
422
src/hardware.rs
|
@ -7,19 +7,33 @@
|
|||
|
||||
use anyhow::{bail, ensure, Result};
|
||||
use num_enum::TryFromPrimitive;
|
||||
use serde::de::Error;
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use std::num::NonZeroU32;
|
||||
use std::str::FromStr;
|
||||
use strum::{Display, EnumString};
|
||||
use tokio::fs;
|
||||
use strum::{Display, EnumString, VariantNames};
|
||||
use tokio::fs::{read_dir, read_to_string};
|
||||
#[cfg(not(test))]
|
||||
use tokio::sync::OnceCell;
|
||||
use tracing::error;
|
||||
use zbus::Connection;
|
||||
|
||||
use crate::path;
|
||||
use crate::platform::{platform_config, ServiceConfig};
|
||||
use crate::power::TdpLimitingMethod;
|
||||
use crate::process::{run_script, script_exit_code};
|
||||
use crate::systemd::SystemdUnit;
|
||||
|
||||
#[cfg(not(test))]
|
||||
static DEVICE_CONFIG: OnceCell<Option<DeviceConfig>> = OnceCell::const_new();
|
||||
|
||||
const SYS_VENDOR_PATH: &str = "/sys/class/dmi/id/sys_vendor";
|
||||
const BOARD_NAME_PATH: &str = "/sys/class/dmi/id/board_name";
|
||||
const PRODUCT_NAME_PATH: &str = "/sys/class/dmi/id/product_name";
|
||||
#[cfg(not(test))]
|
||||
const DEVICE_CONFIG_PATH: &str = "/usr/share/steamos-manager/devices";
|
||||
#[cfg(test)]
|
||||
const DEVICE_CONFIG_PATH: &str = "data/devices";
|
||||
|
||||
#[derive(Display, EnumString, PartialEq, Debug, Default, Copy, Clone)]
|
||||
#[strum(serialize_all = "snake_case", ascii_case_insensitive)]
|
||||
|
@ -30,19 +44,6 @@ pub(crate) enum SteamDeckVariant {
|
|||
Galileo,
|
||||
}
|
||||
|
||||
#[derive(Display, EnumString, PartialEq, Debug, Default, Copy, Clone)]
|
||||
#[strum(serialize_all = "snake_case", ascii_case_insensitive)]
|
||||
pub(crate) enum DeviceType {
|
||||
#[default]
|
||||
Unknown,
|
||||
SteamDeck,
|
||||
LegionGo,
|
||||
LegionGoS,
|
||||
RogAlly,
|
||||
RogAllyX,
|
||||
ZotacGamingZone,
|
||||
}
|
||||
|
||||
#[derive(Display, EnumString, PartialEq, Debug, Copy, Clone, TryFromPrimitive)]
|
||||
#[strum(ascii_case_insensitive)]
|
||||
#[repr(u32)]
|
||||
|
@ -62,36 +63,174 @@ pub enum FactoryResetKind {
|
|||
All = 3,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Deserialize, Debug)]
|
||||
#[serde(default)]
|
||||
pub(crate) struct DeviceConfig {
|
||||
pub device: Vec<DeviceMatch>,
|
||||
pub tdp_limit: Option<TdpLimitConfig>,
|
||||
pub gpu_clocks: Option<RangeConfig<u32>>,
|
||||
pub battery_charge_limit: Option<BatteryChargeLimitConfig>,
|
||||
pub performance_profile: Option<PerformanceProfileConfig>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Debug)]
|
||||
pub(crate) struct BatteryChargeLimitConfig {
|
||||
pub suggested_minimum_limit: Option<i32>,
|
||||
pub hwmon_name: String,
|
||||
pub attribute: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Debug)]
|
||||
pub(crate) struct DeviceMatch {
|
||||
pub dmi: Option<DmiMatch>,
|
||||
pub device: String,
|
||||
pub variant: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Debug)]
|
||||
pub(crate) struct DmiMatch {
|
||||
pub sys_vendor: String,
|
||||
pub board_name: Option<String>,
|
||||
pub product_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Debug)]
|
||||
pub(crate) struct FirmwareAttributeConfig {
|
||||
pub attribute: String,
|
||||
pub performance_profile: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Debug)]
|
||||
pub(crate) struct PerformanceProfileConfig {
|
||||
pub suggested_default: String,
|
||||
pub platform_profile_name: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Debug)]
|
||||
pub(crate) struct RangeConfig<T: Clone> {
|
||||
pub min: T,
|
||||
pub max: T,
|
||||
}
|
||||
|
||||
impl<T> Copy for RangeConfig<T> where T: Copy {}
|
||||
|
||||
impl<T: Clone> RangeConfig<T> {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn new(min: T, max: T) -> RangeConfig<T> {
|
||||
RangeConfig { min, max }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Debug)]
|
||||
pub(crate) struct TdpLimitConfig {
|
||||
#[serde(deserialize_with = "de_tdp_limiter_method")]
|
||||
pub method: TdpLimitingMethod,
|
||||
pub range: Option<RangeConfig<u32>>,
|
||||
pub download_mode_limit: Option<NonZeroU32>,
|
||||
pub firmware_attribute: Option<FirmwareAttributeConfig>,
|
||||
}
|
||||
|
||||
impl DeviceConfig {
|
||||
pub(crate) async fn device_match(&self) -> Result<Option<&'_ DeviceMatch>> {
|
||||
let sys_vendor = read_to_string(path(SYS_VENDOR_PATH)).await?;
|
||||
let sys_vendor = sys_vendor.trim_end();
|
||||
let board_name = read_to_string(path(BOARD_NAME_PATH)).await?;
|
||||
let board_name = board_name.trim_end();
|
||||
let product_name = read_to_string(path(PRODUCT_NAME_PATH)).await?;
|
||||
let product_name = product_name.trim_end();
|
||||
|
||||
for device in self.device.iter() {
|
||||
if let Some(dmi) = &device.dmi {
|
||||
if dmi.sys_vendor != sys_vendor {
|
||||
continue;
|
||||
}
|
||||
if Some(board_name) == dmi.board_name.as_deref() {
|
||||
return Ok(Some(device));
|
||||
}
|
||||
if Some(product_name) == dmi.product_name.as_deref() {
|
||||
return Ok(Some(device));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
async fn load() -> Result<Option<DeviceConfig>> {
|
||||
let mut dir = read_dir(DEVICE_CONFIG_PATH).await?;
|
||||
while let Some(config) = dir.next_entry().await? {
|
||||
let path = config.path();
|
||||
if let Some(ext) = path.extension() {
|
||||
if ext != "toml" {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
let config = match read_to_string(&path).await {
|
||||
Ok(config) => config,
|
||||
Err(e) => {
|
||||
error!("Failed to read config file {}: {e}", path.display());
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let config: DeviceConfig = match toml::from_str(config.as_ref()) {
|
||||
Ok(config) => config,
|
||||
Err(e) => {
|
||||
error!("Failed to parse config file {}: {e}", path.display());
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if config.device_match().await?.is_some() {
|
||||
return Ok(Some(config));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn de_tdp_limiter_method<'de, D>(deserializer: D) -> Result<TdpLimitingMethod, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
D::Error: Error,
|
||||
{
|
||||
let string = String::deserialize(deserializer)?;
|
||||
TdpLimitingMethod::try_from(string.as_str())
|
||||
.map_err(|_| D::Error::unknown_variant(string.as_str(), TdpLimitingMethod::VARIANTS))
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
pub(crate) async fn device_config() -> Result<&'static Option<DeviceConfig>> {
|
||||
DEVICE_CONFIG.get_or_try_init(DeviceConfig::load).await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) async fn device_config() -> Result<Option<DeviceConfig>> {
|
||||
let test = crate::testing::current();
|
||||
let config = test.device_config.borrow().clone();
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
pub(crate) async fn steam_deck_variant() -> Result<SteamDeckVariant> {
|
||||
let sys_vendor = fs::read_to_string(path(SYS_VENDOR_PATH)).await?;
|
||||
let sys_vendor = read_to_string(path(SYS_VENDOR_PATH)).await?;
|
||||
if sys_vendor.trim_end() != "Valve" {
|
||||
return Ok(SteamDeckVariant::Unknown);
|
||||
}
|
||||
let board_name = fs::read_to_string(path(BOARD_NAME_PATH)).await?;
|
||||
let board_name = read_to_string(path(BOARD_NAME_PATH)).await?;
|
||||
Ok(SteamDeckVariant::from_str(board_name.trim_end()).unwrap_or_default())
|
||||
}
|
||||
|
||||
pub(crate) async fn device_type() -> Result<DeviceType> {
|
||||
pub(crate) async fn device_type() -> Result<String> {
|
||||
Ok(device_variant().await?.0)
|
||||
}
|
||||
|
||||
pub(crate) async fn device_variant() -> Result<(DeviceType, String)> {
|
||||
let sys_vendor = fs::read_to_string(path(SYS_VENDOR_PATH)).await?;
|
||||
let product_name = fs::read_to_string(path(PRODUCT_NAME_PATH)).await?;
|
||||
let product_name = product_name.trim_end();
|
||||
let board_name = fs::read_to_string(path(BOARD_NAME_PATH)).await?;
|
||||
let board_name = board_name.trim_end();
|
||||
Ok(match (sys_vendor.trim_end(), product_name, board_name) {
|
||||
("ASUSTeK COMPUTER INC.", _, "RC71L") => (DeviceType::RogAlly, board_name.to_string()),
|
||||
("ASUSTeK COMPUTER INC.", _, "RC72LA") => (DeviceType::RogAllyX, board_name.to_string()),
|
||||
("LENOVO", "83E1", _) => (DeviceType::LegionGo, product_name.to_string()),
|
||||
("LENOVO", "83L3" | "83N6" | "83Q2" | "83Q3", _) => {
|
||||
(DeviceType::LegionGoS, product_name.to_string())
|
||||
}
|
||||
("Valve", _, "Jupiter" | "Galileo") => (DeviceType::SteamDeck, board_name.to_string()),
|
||||
("ZOTAC", _, "G0A1W" | "G1A1W") => (DeviceType::ZotacGamingZone, board_name.to_string()),
|
||||
_ => (DeviceType::Unknown, String::from("unknown")),
|
||||
})
|
||||
pub(crate) async fn device_variant() -> Result<(String, String)> {
|
||||
let Some(device) = device_config().await? else {
|
||||
return Ok((String::from("unknown"), String::from("unknown")));
|
||||
};
|
||||
let Some(device) = device.device_match().await? else {
|
||||
return Ok((String::from("unknown"), String::from("unknown")));
|
||||
};
|
||||
Ok((device.device.to_string(), device.variant.to_string()))
|
||||
}
|
||||
|
||||
pub(crate) struct FanControl {
|
||||
|
@ -173,238 +312,237 @@ pub mod test {
|
|||
use zbus::zvariant::{ObjectPath, OwnedObjectPath};
|
||||
|
||||
pub(crate) async fn fake_model(model: SteamDeckVariant) -> Result<()> {
|
||||
create_dir_all(crate::path("/sys/class/dmi/id")).await?;
|
||||
create_dir_all(path("/sys/class/dmi/id")).await?;
|
||||
match model {
|
||||
SteamDeckVariant::Unknown => write(crate::path(SYS_VENDOR_PATH), "LENOVO\n").await?,
|
||||
SteamDeckVariant::Unknown => {
|
||||
write(path(SYS_VENDOR_PATH), "LENOVO\n").await?;
|
||||
write(path(BOARD_NAME_PATH), "INVALID\n").await?;
|
||||
write(path(PRODUCT_NAME_PATH), "INVALID\n").await?;
|
||||
}
|
||||
SteamDeckVariant::Jupiter => {
|
||||
write(crate::path(SYS_VENDOR_PATH), "Valve\n").await?;
|
||||
write(crate::path(BOARD_NAME_PATH), "Jupiter\n").await?;
|
||||
write(crate::path(PRODUCT_NAME_PATH), "Jupiter\n").await?;
|
||||
write(path(SYS_VENDOR_PATH), "Valve\n").await?;
|
||||
write(path(BOARD_NAME_PATH), "Jupiter\n").await?;
|
||||
write(path(PRODUCT_NAME_PATH), "Jupiter\n").await?;
|
||||
}
|
||||
SteamDeckVariant::Galileo => {
|
||||
write(crate::path(SYS_VENDOR_PATH), "Valve\n").await?;
|
||||
write(crate::path(BOARD_NAME_PATH), "Galileo\n").await?;
|
||||
write(crate::path(PRODUCT_NAME_PATH), "Galileo\n").await?;
|
||||
write(path(SYS_VENDOR_PATH), "Valve\n").await?;
|
||||
write(path(BOARD_NAME_PATH), "Galileo\n").await?;
|
||||
write(path(PRODUCT_NAME_PATH), "Galileo\n").await?;
|
||||
}
|
||||
}
|
||||
testing::current()
|
||||
.device_config
|
||||
.replace(DeviceConfig::load().await?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn setup_board(
|
||||
sys_vendor: &str,
|
||||
board_name: &str,
|
||||
product_name: &str,
|
||||
) -> Result<testing::TestHandle> {
|
||||
let h = testing::start();
|
||||
|
||||
create_dir_all(path("/sys/class/dmi/id")).await?;
|
||||
write(path(SYS_VENDOR_PATH), sys_vendor).await?;
|
||||
write(path(BOARD_NAME_PATH), board_name).await?;
|
||||
write(path(PRODUCT_NAME_PATH), product_name).await?;
|
||||
h.test.device_config.replace(DeviceConfig::load().await?);
|
||||
Ok(h)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn board_lookup() {
|
||||
let _h = testing::start();
|
||||
|
||||
create_dir_all(crate::path("/sys/class/dmi/id"))
|
||||
async fn board_lookup_invalid() {
|
||||
let _h = setup_board("ASUSTeK COMPUTER INC.\n", "INVALID\n", "INVALID\n")
|
||||
.await
|
||||
.expect("create_dir_all");
|
||||
assert!(steam_deck_variant().await.is_err());
|
||||
assert!(device_variant().await.is_err());
|
||||
|
||||
write(crate::path(SYS_VENDOR_PATH), "ASUSTeK COMPUTER INC.\n")
|
||||
.await
|
||||
.expect("write");
|
||||
write(crate::path(BOARD_NAME_PATH), "INVALID\n")
|
||||
.await
|
||||
.expect("write");
|
||||
write(crate::path(PRODUCT_NAME_PATH), "INVALID\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::Unknown, String::from("unknown"))
|
||||
(String::from("unknown"), String::from("unknown"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(BOARD_NAME_PATH), "RC71L\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_rog_ally() {
|
||||
let _h = setup_board("ASUSTeK COMPUTER INC.\n", "RC71L\n", "INVALID\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::RogAlly, String::from("RC71L"))
|
||||
(String::from("rog_ally"), String::from("RC71L"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(BOARD_NAME_PATH), "RC72LA\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_rog_ally_x() {
|
||||
let _h = setup_board("ASUSTeK COMPUTER INC.\n", "RC72LA\n", "INVALID\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::RogAllyX, String::from("RC72LA"))
|
||||
(String::from("rog_ally_x"), String::from("RC72LA"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(SYS_VENDOR_PATH), "LENOVO\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_legion_go() {
|
||||
let _h = setup_board("LENOVO\n", "INVALID\n", "83E1\n")
|
||||
.await
|
||||
.expect("write");
|
||||
write(crate::path(BOARD_NAME_PATH), "INVALID\n")
|
||||
.await
|
||||
.expect("write");
|
||||
write(crate::path(PRODUCT_NAME_PATH), "INVALID\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::Unknown, String::from("unknown"))
|
||||
(String::from("legion_go"), String::from("83E1"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(PRODUCT_NAME_PATH), "83E1\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_legion_go_s_83l3() {
|
||||
let _h = setup_board("LENOVO\n", "INVALID\n", "83L3\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::LegionGo, String::from("83E1"))
|
||||
(String::from("legion_go_s"), String::from("83L3"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(PRODUCT_NAME_PATH), "83L3\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_legion_go_s_83n6() {
|
||||
let _h = setup_board("LENOVO\n", "INVALID\n", "83N6\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::LegionGoS, String::from("83L3"))
|
||||
(String::from("legion_go_s"), String::from("83N6"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(PRODUCT_NAME_PATH), "83N6\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_legion_go_s_83q2() {
|
||||
let _h = setup_board("LENOVO\n", "INVALID\n", "83Q2\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::LegionGoS, String::from("83N6"))
|
||||
(String::from("legion_go_s"), String::from("83Q2"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(PRODUCT_NAME_PATH), "83Q2\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_legion_go_s_83q3() {
|
||||
let _h = setup_board("LENOVO\n", "INVALID\n", "83Q3\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::LegionGoS, String::from("83Q2"))
|
||||
(String::from("legion_go_s"), String::from("83Q3"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(PRODUCT_NAME_PATH), "83Q3\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_steam_deck_jupiter() {
|
||||
let _h = setup_board("Valve\n", "Jupiter\n", "Jupiter\n")
|
||||
.await
|
||||
.expect("write");
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::LegionGoS, String::from("83Q3"))
|
||||
);
|
||||
|
||||
write(crate::path(SYS_VENDOR_PATH), "Valve\n")
|
||||
.await
|
||||
.expect("write");
|
||||
write(crate::path(BOARD_NAME_PATH), "Jupiter\n")
|
||||
.await
|
||||
.expect("write");
|
||||
write(crate::path(PRODUCT_NAME_PATH), "Jupiter\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Jupiter
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::SteamDeck, String::from("Jupiter"))
|
||||
(String::from("steam_deck"), String::from("Jupiter"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(BOARD_NAME_PATH), "Galileo\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_steam_deck_galileo() {
|
||||
let _h = setup_board("Valve\n", "Galileo\n", "Galileo\n")
|
||||
.await
|
||||
.expect("write");
|
||||
write(crate::path(PRODUCT_NAME_PATH), "Galileo\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Galileo
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::SteamDeck, String::from("Galileo"))
|
||||
(String::from("steam_deck"), String::from("Galileo"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(BOARD_NAME_PATH), "Neptune\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_invalid_valve() {
|
||||
let _h = setup_board("Valve\n", "Neptune\n", "Neptune\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::Unknown, String::from("unknown"))
|
||||
(String::from("unknown"), String::from("unknown"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(SYS_VENDOR_PATH), "ZOTAC\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_zotac_gaming_zone_g0a1w() {
|
||||
let _h = setup_board("ZOTAC\n", "G0A1W\n", "INVALID\n")
|
||||
.await
|
||||
.expect("write");
|
||||
write(crate::path(BOARD_NAME_PATH), "INVALID\n")
|
||||
.await
|
||||
.expect("write");
|
||||
write(crate::path(PRODUCT_NAME_PATH), "INVALID\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::Unknown, String::from("unknown"))
|
||||
(String::from("zotac_gaming_zone"), String::from("G0A1W"))
|
||||
);
|
||||
}
|
||||
|
||||
write(crate::path(BOARD_NAME_PATH), "G0A1W\n")
|
||||
#[tokio::test]
|
||||
async fn board_lookup_zotac_gaming_zone_g1a1w() {
|
||||
let _h = setup_board("ZOTAC\n", "G1A1W\n", "INVALID\n")
|
||||
.await
|
||||
.expect("write");
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::ZotacGamingZone, String::from("G0A1W"))
|
||||
);
|
||||
|
||||
write(crate::path(BOARD_NAME_PATH), "G1A1W\n")
|
||||
.await
|
||||
.expect("write");
|
||||
assert_eq!(
|
||||
steam_deck_variant().await.unwrap(),
|
||||
SteamDeckVariant::Unknown
|
||||
);
|
||||
assert_eq!(
|
||||
device_variant().await.unwrap(),
|
||||
(DeviceType::ZotacGamingZone, String::from("G1A1W"))
|
||||
(String::from("zotac_gaming_zone"), String::from("G1A1W"))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue