From f2ef77b866c2ddd8d7cc3a50d069eaae270ec6ea Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Sat, 2 Mar 2024 13:29:56 +0100 Subject: [PATCH] Better logic to handle availability of tdp limiters --- app/AutoTDP/AutoTDPService.cs | 5 +++-- app/AutoTDP/AutoTDPUI.cs | 9 +++++---- app/AutoTDP/PowerLimiter/ASUSACPIPowerLimiter.cs | 5 +++++ app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs | 5 +++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/AutoTDP/AutoTDPService.cs b/app/AutoTDP/AutoTDPService.cs index 753c97a9..18c22b70 100644 --- a/app/AutoTDP/AutoTDPService.cs +++ b/app/AutoTDP/AutoTDPService.cs @@ -82,13 +82,14 @@ namespace GHelper.AutoTDP int availableFS = 0; int availablePL = 0; + //Requires RTSS to be installed if (RTSSFramerateSource.IsAvailable()) availableFS++; //Intel MSR Limiter is available on Intel only - if (!RyzenControl.IsAMD()) availablePL++; + if (IntelMSRPowerLimiter.IsAvailable()) availablePL++; //ASUS ACPI Power limiter is available - if (AppConfig.IsASUS()) availablePL++; + if (ASUSACPIPowerLimiter.IsAvailable()) availablePL++; return availablePL > 0 && availableFS > 0; } diff --git a/app/AutoTDP/AutoTDPUI.cs b/app/AutoTDP/AutoTDPUI.cs index 525cb299..9d8096e4 100644 --- a/app/AutoTDP/AutoTDPUI.cs +++ b/app/AutoTDP/AutoTDPUI.cs @@ -1,4 +1,5 @@ using GHelper.AutoTDP.FramerateSource; +using GHelper.AutoTDP.PowerLimiter; using GHelper.UI; using Ryzen; @@ -123,7 +124,7 @@ namespace GHelper.AutoTDP { checkBoxEnabled.Checked = AppConfig.Get("auto_tdp_enabled", 0) == 1; - if (!RyzenControl.IsAMD()) + if (IntelMSRPowerLimiter.IsAvailable()) comboBoxLimiter.Items.Add("Intel MSR Power Limiter"); @@ -134,14 +135,14 @@ namespace GHelper.AutoTDP if (comboBoxLimiter.Items.Count > 0 && limiter is null) comboBoxLimiter.SelectedIndex = 0; - if (!RyzenControl.IsAMD() && limiter is not null && limiter.Equals("intel_msr")) + if (IntelMSRPowerLimiter.IsAvailable() && limiter is not null && limiter.Equals("intel_msr")) { comboBoxLimiter.SelectedIndex = 0; } - if (limiter is not null && limiter.Equals("asus_acpi")) + if (limiter is not null && limiter.Equals("asus_acpi") && ASUSACPIPowerLimiter.IsAvailable()) { - comboBoxLimiter.SelectedIndex = !RyzenControl.IsAMD() ? 1 : 0; + comboBoxLimiter.SelectedIndex = IntelMSRPowerLimiter.IsAvailable() ? 1 : 0; } diff --git a/app/AutoTDP/PowerLimiter/ASUSACPIPowerLimiter.cs b/app/AutoTDP/PowerLimiter/ASUSACPIPowerLimiter.cs index 6697c0e1..6cea04c5 100644 --- a/app/AutoTDP/PowerLimiter/ASUSACPIPowerLimiter.cs +++ b/app/AutoTDP/PowerLimiter/ASUSACPIPowerLimiter.cs @@ -17,6 +17,11 @@ namespace GHelper.AutoTDP.PowerLimiter } + public static bool IsAvailable() + { + return AppConfig.IsASUS(); + } + public void SavePowerLimits() { DefaultA0 = Program.acpi.DeviceGet(AsusACPI.PPT_APUA0); diff --git a/app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs b/app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs index 5a3cf24e..0a0a04aa 100644 --- a/app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs +++ b/app/AutoTDP/PowerLimiter/IntelMSRPowerLimiter.cs @@ -27,6 +27,11 @@ namespace GHelper.AutoTDP.PowerLimiter ReadPowerUnit(); } + public static bool IsAvailable() + { + return !RyzenControl.IsAMD(); + } + public void SavePowerLimits() { DefaultEax = 0;