Allow device auto detection to tell steam deck driver the specific model
This commit is contained in:
parent
0ee30eebe6
commit
85a9fc8f7e
11 changed files with 74 additions and 47 deletions
|
@ -6,8 +6,8 @@ use super::RangeLimit;
|
|||
pub enum BatteryLimitType {
|
||||
#[serde(rename = "GabeBoy", alias = "SteamDeck")]
|
||||
SteamDeck,
|
||||
#[serde(rename = "GabeBoyAdvance", alias = "SteamDeckAdvance")]
|
||||
SteamDeckAdvance,
|
||||
#[serde(rename = "GabeBoySP", alias = "SteamDeckOLED")]
|
||||
SteamDeckOLED,
|
||||
Generic,
|
||||
Unknown,
|
||||
DevMode,
|
||||
|
@ -25,7 +25,7 @@ pub struct GenericBatteryLimit {
|
|||
impl GenericBatteryLimit {
|
||||
pub fn default_for(t: BatteryLimitType) -> Self {
|
||||
match t {
|
||||
BatteryLimitType::SteamDeck | BatteryLimitType::SteamDeckAdvance => Self::default_steam_deck(),
|
||||
BatteryLimitType::SteamDeck | BatteryLimitType::SteamDeckOLED => Self::default_steam_deck(),
|
||||
BatteryLimitType::DevMode => Self::default_dev_mode(),
|
||||
_t => Self::default(),
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ use super::RangeLimit;
|
|||
pub enum CpuLimitType {
|
||||
#[serde(rename = "GabeBoy", alias = "SteamDeck")]
|
||||
SteamDeck,
|
||||
#[serde(rename = "GabeBoyAdvance", alias = "SteamDeckAdvance")]
|
||||
SteamDeckAdvance,
|
||||
#[serde(rename = "GabeBoySP", alias = "SteamDeckOLED")]
|
||||
SteamDeckOLED,
|
||||
Generic,
|
||||
GenericAMD,
|
||||
Unknown,
|
||||
|
@ -25,7 +25,7 @@ pub struct GenericCpusLimit {
|
|||
impl GenericCpusLimit {
|
||||
pub fn default_for(t: CpuLimitType) -> Self {
|
||||
match t {
|
||||
CpuLimitType::SteamDeck | CpuLimitType::SteamDeckAdvance => {
|
||||
CpuLimitType::SteamDeck | CpuLimitType::SteamDeckOLED => {
|
||||
Self {
|
||||
cpus: [(); 8].iter().enumerate().map(|(i, _)| GenericCpuLimit::default_for(&t, i)).collect(),
|
||||
global_governors: true,
|
||||
|
@ -96,7 +96,7 @@ pub struct GenericCpuLimit {
|
|||
impl GenericCpuLimit {
|
||||
pub fn default_for(t: &CpuLimitType, _index: usize) -> Self {
|
||||
match t {
|
||||
CpuLimitType::SteamDeck | CpuLimitType::SteamDeckAdvance => Self::default_steam_deck(),
|
||||
CpuLimitType::SteamDeck | CpuLimitType::SteamDeckOLED => Self::default_steam_deck(),
|
||||
CpuLimitType::DevMode => Self {
|
||||
clock_min: Some(RangeLimit { min: Some(100), max: Some(5000) }),
|
||||
clock_max: Some(RangeLimit { min: Some(100), max: Some(4800) }),
|
||||
|
|
|
@ -6,8 +6,6 @@ use super::RangeLimit;
|
|||
pub enum GpuLimitType {
|
||||
#[serde(rename = "GabeBoy", alias = "SteamDeck")]
|
||||
SteamDeck,
|
||||
#[serde(rename = "GabeBoyAdvance", alias = "SteamDeckAdvance")]
|
||||
SteamDeckAdvance,
|
||||
#[serde(rename = "GabeBoySP", alias = "SteamDeckOLED")]
|
||||
SteamDeckOLED,
|
||||
Generic,
|
||||
|
@ -40,7 +38,7 @@ pub struct GenericGpuLimit {
|
|||
impl GenericGpuLimit {
|
||||
pub fn default_for(t: GpuLimitType) -> Self {
|
||||
match t {
|
||||
GpuLimitType::SteamDeck | GpuLimitType::SteamDeckAdvance => Self::default_steam_deck(),
|
||||
GpuLimitType::SteamDeck => Self::default_steam_deck(),
|
||||
GpuLimitType::SteamDeckOLED => Self::default_steam_deck_oled(),
|
||||
GpuLimitType::DevMode => Self::default_dev_mode(),
|
||||
_t => Self::default(),
|
||||
|
|
|
@ -337,7 +337,7 @@ fn main() -> Result<(), ()> {
|
|||
#[cfg(debug_assertions)]
|
||||
std::thread::spawn(|| {
|
||||
utility::ioperm_power_ec();
|
||||
settings::steam_deck::util::flash_led();
|
||||
settings::steam_deck::flash_led();
|
||||
});
|
||||
|
||||
if let Err(e) = loaded_settings.on_set() {
|
||||
|
|
|
@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize};
|
|||
pub enum DriverJson {
|
||||
#[serde(rename = "steam-deck", alias = "gabe-boy")]
|
||||
SteamDeck,
|
||||
#[serde(rename = "steam-deck-oc", alias = "gabe-boy-advance")]
|
||||
SteamDeckAdvance,
|
||||
#[serde(rename = "steam-deck-oled", alias = "gabe-boy-sp")]
|
||||
SteamDeckOLED,
|
||||
#[serde(rename = "generic")]
|
||||
Generic,
|
||||
#[serde(rename = "generic-amd")]
|
||||
|
|
|
@ -156,14 +156,14 @@ pub fn auto_detect0(
|
|||
settings.cpus.clone(),
|
||||
settings.version,
|
||||
relevant_limits.cpu.limits,
|
||||
))
|
||||
).variant(super::super::steam_deck::Model::LCD))
|
||||
}
|
||||
CpuLimitType::SteamDeckAdvance => {
|
||||
CpuLimitType::SteamDeckOLED => {
|
||||
Box::new(crate::settings::steam_deck::Cpus::from_json_and_limits(
|
||||
settings.cpus.clone(),
|
||||
settings.version,
|
||||
relevant_limits.cpu.limits,
|
||||
))
|
||||
).variant(super::super::steam_deck::Model::OLED))
|
||||
}
|
||||
CpuLimitType::Generic => Box::new(crate::settings::generic::Cpus::<
|
||||
crate::settings::generic::Cpu,
|
||||
|
@ -201,21 +201,14 @@ pub fn auto_detect0(
|
|||
settings.gpu.clone(),
|
||||
settings.version,
|
||||
relevant_limits.gpu.limits,
|
||||
))
|
||||
}
|
||||
GpuLimitType::SteamDeckAdvance => {
|
||||
Box::new(crate::settings::steam_deck::Gpu::from_json_and_limits(
|
||||
settings.gpu.clone(),
|
||||
settings.version,
|
||||
relevant_limits.gpu.limits,
|
||||
))
|
||||
).variant(super::super::steam_deck::Model::LCD))
|
||||
}
|
||||
GpuLimitType::SteamDeckOLED => {
|
||||
Box::new(crate::settings::steam_deck::Gpu::from_json_and_limits(
|
||||
settings.gpu.clone(),
|
||||
settings.version,
|
||||
relevant_limits.gpu.limits,
|
||||
))
|
||||
).variant(super::super::steam_deck::Model::OLED))
|
||||
}
|
||||
GpuLimitType::Generic => {
|
||||
Box::new(crate::settings::generic::Gpu::from_json_and_limits(
|
||||
|
@ -252,14 +245,14 @@ pub fn auto_detect0(
|
|||
settings.battery.clone(),
|
||||
settings.version,
|
||||
relevant_limits.battery.limits,
|
||||
))
|
||||
).variant(super::super::steam_deck::Model::LCD))
|
||||
}
|
||||
BatteryLimitType::SteamDeckAdvance => {
|
||||
BatteryLimitType::SteamDeckOLED => {
|
||||
Box::new(crate::settings::steam_deck::Battery::from_json_and_limits(
|
||||
settings.battery.clone(),
|
||||
settings.version,
|
||||
relevant_limits.battery.limits,
|
||||
))
|
||||
).variant(super::super::steam_deck::Model::OLED))
|
||||
}
|
||||
BatteryLimitType::Generic => Box::new(
|
||||
crate::settings::generic::Battery::from_json_and_limits(
|
||||
|
@ -293,10 +286,10 @@ pub fn auto_detect0(
|
|||
} else {
|
||||
let cpu_driver: Box<dyn TCpus> = match relevant_limits.cpu.provider {
|
||||
CpuLimitType::SteamDeck => {
|
||||
Box::new(crate::settings::steam_deck::Cpus::from_limits(relevant_limits.cpu.limits))
|
||||
Box::new(crate::settings::steam_deck::Cpus::from_limits(relevant_limits.cpu.limits).variant(super::super::steam_deck::Model::LCD))
|
||||
}
|
||||
CpuLimitType::SteamDeckAdvance => {
|
||||
Box::new(crate::settings::steam_deck::Cpus::from_limits(relevant_limits.cpu.limits))
|
||||
CpuLimitType::SteamDeckOLED => {
|
||||
Box::new(crate::settings::steam_deck::Cpus::from_limits(relevant_limits.cpu.limits).variant(super::super::steam_deck::Model::OLED))
|
||||
}
|
||||
CpuLimitType::Generic => {
|
||||
Box::new(crate::settings::generic::Cpus::<
|
||||
|
@ -315,13 +308,10 @@ pub fn auto_detect0(
|
|||
};
|
||||
let gpu_driver: Box<dyn TGpu> = match relevant_limits.gpu.provider {
|
||||
GpuLimitType::SteamDeck => {
|
||||
Box::new(crate::settings::steam_deck::Gpu::from_limits(relevant_limits.gpu.limits))
|
||||
}
|
||||
GpuLimitType::SteamDeckAdvance => {
|
||||
Box::new(crate::settings::steam_deck::Gpu::from_limits(relevant_limits.gpu.limits))
|
||||
Box::new(crate::settings::steam_deck::Gpu::from_limits(relevant_limits.gpu.limits).variant(super::super::steam_deck::Model::LCD))
|
||||
}
|
||||
GpuLimitType::SteamDeckOLED => {
|
||||
Box::new(crate::settings::steam_deck::Gpu::from_limits(relevant_limits.gpu.limits))
|
||||
Box::new(crate::settings::steam_deck::Gpu::from_limits(relevant_limits.gpu.limits).variant(super::super::steam_deck::Model::OLED))
|
||||
}
|
||||
GpuLimitType::Generic => {
|
||||
Box::new(crate::settings::generic::Gpu::from_limits(relevant_limits.gpu.limits))
|
||||
|
@ -338,10 +328,10 @@ pub fn auto_detect0(
|
|||
};
|
||||
let battery_driver: Box<dyn TBattery> = match relevant_limits.battery.provider {
|
||||
BatteryLimitType::SteamDeck => {
|
||||
Box::new(crate::settings::steam_deck::Battery::from_limits(relevant_limits.battery.limits))
|
||||
Box::new(crate::settings::steam_deck::Battery::from_limits(relevant_limits.battery.limits).variant(super::super::steam_deck::Model::LCD))
|
||||
}
|
||||
BatteryLimitType::SteamDeckAdvance => {
|
||||
Box::new(crate::settings::steam_deck::Battery::from_limits(relevant_limits.battery.limits))
|
||||
BatteryLimitType::SteamDeckOLED => {
|
||||
Box::new(crate::settings::steam_deck::Battery::from_limits(relevant_limits.battery.limits).variant(super::super::steam_deck::Model::OLED))
|
||||
}
|
||||
BatteryLimitType::Generic => {
|
||||
Box::new(crate::settings::generic::Battery::from_limits(relevant_limits.battery.limits))
|
||||
|
|
|
@ -29,7 +29,7 @@ impl Driver {
|
|||
#[inline]
|
||||
pub fn maybe_do_button() {
|
||||
match super::auto_detect_provider() {
|
||||
DriverJson::SteamDeck | DriverJson::SteamDeckAdvance => {
|
||||
DriverJson::SteamDeck | DriverJson::SteamDeckOLED => {
|
||||
crate::settings::steam_deck::flash_led();
|
||||
}
|
||||
DriverJson::Generic | DriverJson::GenericAMD => {
|
||||
|
|
|
@ -23,6 +23,7 @@ pub struct Battery {
|
|||
sysfs_bat: PowerSupplyPath,
|
||||
sysfs_hwmon: Arc<HwMonPath>,
|
||||
bat_ec: Arc<Mutex<UnnamedPowerEC>>,
|
||||
variant: super::Model,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -542,6 +543,11 @@ impl Battery {
|
|||
self.events.clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn variant(mut self, model: super::Model) -> Self {
|
||||
self.variant = model;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<BatteryJson> for Battery {
|
||||
|
@ -579,6 +585,7 @@ impl ProviderBuilder<BatteryJson, GenericBatteryLimit> for Battery {
|
|||
sysfs_bat: Self::find_battery_sysfs(None::<&'static str>),
|
||||
sysfs_hwmon: hwmon_sys,
|
||||
bat_ec: ec,
|
||||
variant: super::Model::LCD,
|
||||
}.remove_charge_limit_instructions(),
|
||||
_ => Self {
|
||||
charge_rate: persistent.charge_rate,
|
||||
|
@ -597,6 +604,7 @@ impl ProviderBuilder<BatteryJson, GenericBatteryLimit> for Battery {
|
|||
sysfs_bat: Self::find_battery_sysfs(None::<&'static str>),
|
||||
sysfs_hwmon: hwmon_sys,
|
||||
bat_ec: ec,
|
||||
variant: super::Model::LCD,
|
||||
}.remove_charge_limit_instructions(),
|
||||
}
|
||||
}
|
||||
|
@ -612,6 +620,7 @@ impl ProviderBuilder<BatteryJson, GenericBatteryLimit> for Battery {
|
|||
sysfs_bat: Self::find_battery_sysfs(None::<&'static str>),
|
||||
sysfs_hwmon: Arc::new(Self::find_hwmon_sysfs(None::<&'static str>)),
|
||||
bat_ec: Arc::new(Mutex::new(UnnamedPowerEC::new())),
|
||||
variant: super::Model::LCD,
|
||||
}.remove_charge_limit_instructions()
|
||||
}
|
||||
}
|
||||
|
@ -806,6 +815,9 @@ impl TBattery for Battery {
|
|||
}
|
||||
|
||||
fn provider(&self) -> crate::persist::DriverJson {
|
||||
crate::persist::DriverJson::SteamDeck
|
||||
match self.variant {
|
||||
super::Model::LCD => crate::persist::DriverJson::SteamDeck,
|
||||
super::Model::OLED => crate::persist::DriverJson::SteamDeckOLED,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ pub struct Cpus {
|
|||
pub smt: bool,
|
||||
pub smt_capable: bool,
|
||||
pub(super) limits: GenericCpusLimit,
|
||||
variant: super::Model,
|
||||
}
|
||||
|
||||
impl OnSet for Cpus {
|
||||
|
@ -100,6 +101,11 @@ impl Cpus {
|
|||
Err(_) => (false, false),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn variant(mut self, model: super::Model) -> Self {
|
||||
self.variant = model;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl ProviderBuilder<Vec<CpuJson>, GenericCpusLimit> for Cpus {
|
||||
|
@ -144,6 +150,7 @@ impl ProviderBuilder<Vec<CpuJson>, GenericCpusLimit> for Cpus {
|
|||
smt: smt_guess,
|
||||
smt_capable: can_smt,
|
||||
limits: limits,
|
||||
variant: super::Model::LCD,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,6 +175,7 @@ impl ProviderBuilder<Vec<CpuJson>, GenericCpusLimit> for Cpus {
|
|||
smt: true,
|
||||
smt_capable: can_smt,
|
||||
limits: limits,
|
||||
variant: super::Model::LCD,
|
||||
}
|
||||
} else {
|
||||
Self {
|
||||
|
@ -175,6 +183,7 @@ impl ProviderBuilder<Vec<CpuJson>, GenericCpusLimit> for Cpus {
|
|||
smt: false,
|
||||
smt_capable: false,
|
||||
limits: limits,
|
||||
variant: super::Model::LCD,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +227,10 @@ impl TCpus for Cpus {
|
|||
}
|
||||
|
||||
fn provider(&self) -> crate::persist::DriverJson {
|
||||
crate::persist::DriverJson::SteamDeck
|
||||
match self.variant {
|
||||
super::Model::LCD => crate::persist::DriverJson::SteamDeck,
|
||||
super::Model::OLED => crate::persist::DriverJson::SteamDeckOLED,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ pub struct Gpu {
|
|||
limits: GenericGpuLimit,
|
||||
state: crate::state::steam_deck::Gpu,
|
||||
sysfs_card: BasicEntityPath,
|
||||
sysfs_hwmon: HwMonPath
|
||||
sysfs_hwmon: HwMonPath,
|
||||
variant: super::Model,
|
||||
}
|
||||
|
||||
// same as CPU
|
||||
|
@ -346,6 +347,11 @@ impl Gpu {
|
|||
self.memory_clock = Some(mem_clock.clamp(self.limits.memory_clock.and_then(|lim| lim.min).unwrap_or(MIN_MEMORY_CLOCK), self.limits.memory_clock.and_then(|lim| lim.max).unwrap_or(MAX_MEMORY_CLOCK)));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn variant(mut self, model: super::Model) -> Self {
|
||||
self.variant = model;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<GpuJson> for Gpu {
|
||||
|
@ -375,6 +381,7 @@ impl ProviderBuilder<GpuJson, GenericGpuLimit> for Gpu {
|
|||
state: crate::state::steam_deck::Gpu::default(),
|
||||
sysfs_card: Self::find_card_sysfs(persistent.root.clone()),
|
||||
sysfs_hwmon: Self::find_hwmon_sysfs(persistent.root),
|
||||
variant: super::Model::LCD,
|
||||
},
|
||||
_ => Self {
|
||||
fast_ppt: persistent.fast_ppt,
|
||||
|
@ -385,6 +392,7 @@ impl ProviderBuilder<GpuJson, GenericGpuLimit> for Gpu {
|
|||
state: crate::state::steam_deck::Gpu::default(),
|
||||
sysfs_card: Self::find_card_sysfs(persistent.root.clone()),
|
||||
sysfs_hwmon: Self::find_hwmon_sysfs(persistent.root),
|
||||
variant: super::Model::LCD,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -399,6 +407,7 @@ impl ProviderBuilder<GpuJson, GenericGpuLimit> for Gpu {
|
|||
state: crate::state::steam_deck::Gpu::default(),
|
||||
sysfs_card: Self::find_card_sysfs(None::<&'static str>),
|
||||
sysfs_hwmon: Self::find_hwmon_sysfs(None::<&'static str>),
|
||||
variant: super::Model::LCD,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +494,10 @@ impl TGpu for Gpu {
|
|||
}
|
||||
|
||||
fn provider(&self) -> crate::persist::DriverJson {
|
||||
crate::persist::DriverJson::SteamDeck
|
||||
match self.variant {
|
||||
super::Model::LCD => crate::persist::DriverJson::SteamDeck,
|
||||
super::Model::OLED => crate::persist::DriverJson::SteamDeckOLED,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,6 @@ mod battery;
|
|||
mod cpu;
|
||||
mod gpu;
|
||||
mod power_dpm_force;
|
||||
#[cfg(debug_assertions)]
|
||||
pub mod util;
|
||||
#[cfg(not(debug_assertions))]
|
||||
mod util;
|
||||
|
||||
pub use battery::Battery;
|
||||
|
@ -12,6 +9,12 @@ pub use cpu::Cpus;
|
|||
pub use gpu::Gpu;
|
||||
pub(self) use power_dpm_force::{POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT, DPM_FORCE_LIMITS_ATTRIBUTE};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Model {
|
||||
LCD,
|
||||
OLED,
|
||||
}
|
||||
|
||||
pub use util::flash_led;
|
||||
|
||||
fn _impl_checker() {
|
||||
|
|
Loading…
Reference in a new issue