diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 2f6dd90e..85842ccf 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -436,7 +436,7 @@ public static bool IsAnimeMatrix() { return ContainsModel("GA401") || ContainsModel("GA402") || ContainsModel("GU604V"); } - + public static bool IsSlash() { return ContainsModel("GA403") || ContainsModel("GU605") || ContainsModel("GA605"); @@ -723,5 +723,9 @@ public static bool IsAutoStatusLed() return Is("auto_status_led"); } + public static void SetEPP(int value) + { + PowerNative.SetEPP(value); + } } diff --git a/app/Fans.Designer.cs b/app/Fans.Designer.cs index c1ad6565..79f82ba3 100644 --- a/app/Fans.Designer.cs +++ b/app/Fans.Designer.cs @@ -60,6 +60,7 @@ private void InitializeComponent() checkApplyFans = new RCheckBox(); buttonReset = new RButton(); comboBoost = new RComboBox(); + sliderEPP = new TrackBar(); panelSliders = new Panel(); panelAdvanced = new Panel(); panelAdvancedAlways = new Panel(); @@ -113,6 +114,15 @@ private void InitializeComponent() panelBoostTitle = new Panel(); pictureBoost = new PictureBox(); labelBoost = new Label(); + if (AppConfig.IsAlly()) + { + panelEPP = new Panel(); + panelEPPTitle = new Panel(); + labelEPP = new Label(); + labelEPPSliderLeft = new Label(); + labelEPPSliderRight = new Label(); + pictureEPP = new PictureBox(); + } panelPowerMode = new Panel(); comboPowerMode = new RComboBox(); panelPowerModeTItle = new Panel(); @@ -189,6 +199,17 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)pictureBoxCPU).BeginInit(); panelBoost.SuspendLayout(); panelBoostTitle.SuspendLayout(); + + if (AppConfig.IsAlly()) + { + ((System.ComponentModel.ISupportInitialize)pictureEPP).BeginInit(); + panelEPP.SuspendLayout(); + panelEPPTitle.SuspendLayout(); + labelEPP.SuspendLayout(); + labelEPPSliderLeft.SuspendLayout(); + labelEPPSliderRight.SuspendLayout(); + } + ((System.ComponentModel.ISupportInitialize)pictureBoost).BeginInit(); panelPowerMode.SuspendLayout(); panelPowerModeTItle.SuspendLayout(); @@ -508,6 +529,25 @@ private void InitializeComponent() comboBoost.Name = "comboBoost"; comboBoost.Size = new Size(329, 40); comboBoost.TabIndex = 42; + + if (AppConfig.IsAlly()) + { + // + // sliderEPP + // + sliderEPP.Location = new Point(6, 48); + sliderEPP.Margin = new Padding(4, 2, 4, 2); + sliderEPP.Maximum = 100; + sliderEPP.Minimum = 0; + sliderEPP.Name = "sliderEPP"; + sliderEPP.Size = new Size(508, 90); + sliderEPP.TabIndex = 10; + sliderEPP.TickFrequency = 10; + sliderEPP.SmallChange = 10; + sliderEPP.LargeChange = 10; + sliderEPP.TickStyle = TickStyle.TopLeft; + } + // // panelSliders // @@ -864,6 +904,8 @@ private void InitializeComponent() panelPower.Controls.Add(panelSlow); panelPower.Controls.Add(panelTotal); panelPower.Controls.Add(panelTitleCPU); + panelPower.Controls.Add(panelEPP); + panelPower.Controls.Add(panelEPPTitle); panelPower.Controls.Add(panelBoost); panelPower.Controls.Add(panelBoostTitle); panelPower.Controls.Add(panelPowerMode); @@ -1176,6 +1218,81 @@ private void InitializeComponent() labelBoost.Size = new Size(133, 32); labelBoost.TabIndex = 39; labelBoost.Text = "CPU Boost"; + + if (AppConfig.IsAlly()) + { + // + // panelEPP + // + panelEPP.Controls.Add(sliderEPP); + panelEPP.Controls.Add(labelEPPSliderLeft); + panelEPP.Controls.Add(labelEPPSliderRight); + panelEPP.Dock = DockStyle.Top; + panelEPP.Location = new Point(0, 184); + panelEPP.Margin = new Padding(4); + panelEPP.Name = "panelEPP"; + // panelEPP.Size = new Size(520, 90); + panelTotal.MaximumSize = new Size(0, 124); + panelEPP.TabIndex = 13; + // + // panelEPPTitle + // + panelEPPTitle.AutoSize = true; + panelEPPTitle.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelEPPTitle.Controls.Add(pictureEPP); + panelEPPTitle.Controls.Add(labelEPP); + panelEPPTitle.Dock = DockStyle.Top; + panelEPPTitle.Location = new Point(0, 248); + panelEPPTitle.Margin = new Padding(4); + panelEPPTitle.Name = "panelEPPTitle"; + panelEPPTitle.Size = new Size(520, 60); + panelEPPTitle.TabIndex = 49; + // + // labelEPP + // + labelEPP.AutoSize = true; + labelEPP.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelEPP.Location = new Point(46, 18); + labelEPP.Margin = new Padding(4, 0, 4, 0); + labelEPP.Name = "labelEPP"; + labelEPP.Size = new Size(133, 32); + labelEPP.TabIndex = 39; + labelEPP.Text = "EPP"; + // + // pictureEPP + // + pictureEPP.BackgroundImage = Properties.Resources.icons8_leaf_48; + pictureEPP.BackgroundImageLayout = ImageLayout.Zoom; + pictureEPP.InitialImage = null; + pictureEPP.Location = new Point(10, 18); + pictureEPP.Margin = new Padding(4, 2, 4, 10); + pictureEPP.Name = "pictureEPP"; + pictureEPP.Size = new Size(32, 32); + pictureEPP.TabIndex = 40; + pictureEPP.TabStop = false; + // + // labelEPPSliderLeft + // + labelEPPSliderLeft.AutoSize = true; + labelEPPSliderLeft.Location = new Point(10, 10); + labelEPPSliderLeft.Margin = new Padding(4, 0, 4, 0); + labelEPPSliderLeft.Name = "labelEPPSliderLeft"; + labelEPPSliderLeft.Size = new Size(51, 32); + labelEPPSliderLeft.TabIndex = 11; + labelEPPSliderLeft.Text = "GPU Priority"; + // + // labelEPPSliderRight + // + labelEPPSliderRight.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelEPPSliderRight.Location = new Point(396, 10); + labelEPPSliderRight.Margin = new Padding(4, 0, 4, 0); + labelEPPSliderRight.Name = "labelEPPSliderRight"; + labelEPPSliderRight.Size = new Size(116, 32); + labelEPPSliderRight.TabIndex = 12; + labelEPPSliderRight.Text = "%"; + labelEPPSliderRight.TextAlign = ContentAlignment.TopRight; + } + // // panelPowerMode // @@ -1747,6 +1864,12 @@ private void InitializeComponent() panelBoost.ResumeLayout(false); panelBoostTitle.ResumeLayout(false); panelBoostTitle.PerformLayout(); + panelEPP.ResumeLayout(false); + panelEPPTitle.ResumeLayout(false); + panelEPPTitle.PerformLayout(); + labelEPPSliderLeft.ResumeLayout(false); + labelEPPSliderRight.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureEPP).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBoost).EndInit(); panelPowerMode.ResumeLayout(false); panelPowerModeTItle.ResumeLayout(false); @@ -1829,7 +1952,9 @@ private void InitializeComponent() private RCheckBox checkApplyFans; private RButton buttonReset; private Label labelBoost; + private Label labelEPP; private RComboBox comboBoost; + private TrackBar sliderEPP; private PictureBox picturePerf; private Label labelFans; private Panel panelFast; @@ -1837,6 +1962,11 @@ private void InitializeComponent() private Label labelLeftFast; private TrackBar trackFast; private Panel panelBoost; + private Panel panelEPP; + private Panel panelEPPTitle; + private Label labelEPPSliderLeft; + private Label labelEPPSliderRight; + private PictureBox pictureEPP; private RComboBox comboModes; private RButton buttonAdd; private RButton buttonRemove; diff --git a/app/Fans.cs b/app/Fans.cs index caf1bb5a..253afd14 100644 --- a/app/Fans.cs +++ b/app/Fans.cs @@ -189,6 +189,17 @@ public Fans() comboPowerMode.DisplayMember = "Value"; comboPowerMode.ValueMember = "Key"; + if (AppConfig.IsAlly()) + { + sliderEPP.Value = PowerNative.GetEPP(); + sliderEPP.Minimum = 0; + sliderEPP.Maximum = 100; + sliderEPP.Value = AppConfig.GetMode("epp_value", 0); // Default value is 0 if not set + sliderEPP.Scroll += SliderEPP_Scroll; + labelEPP.Text = $"EPP"; + labelEPPSliderRight.Text = $"{sliderEPP.Value}%"; + } + FillModes(); InitAll(); InitCPU(); @@ -408,7 +419,8 @@ private void VisualiseAdvanced() panelAdvancedApply.Visible = false; panelDownload.Visible = true; - } else + } + else { panelDownload.Visible = false; } @@ -828,7 +840,7 @@ public void InitPowerPlan() comboPowerMode.Enabled = !batterySaver; - if (batterySaver) + if (batterySaver) comboPowerMode.SelectedIndex = 0; else comboPowerMode.SelectedValue = powerMode; @@ -933,7 +945,7 @@ public void InitPower() labelLeftSlow.Text = "sPPT (CPU 2 min boost)"; labelLeftFast.Text = "fPPT (CPU 2 sec boost)"; panelFast.Visible = modeC1; - + } else { @@ -956,7 +968,7 @@ public void InitPower() if (limit_cpu > AsusACPI.MaxCPU) limit_cpu = AsusACPI.MaxCPU; if (limit_cpu < AsusACPI.MinCPU) limit_cpu = AsusACPI.MinCPU; - + if (limit_slow > AsusACPI.MaxTotal) limit_slow = AsusACPI.MaxTotal; if (limit_slow < AsusACPI.MinTotal) limit_slow = AsusACPI.MinTotal; @@ -1157,13 +1169,13 @@ private void ButtonReset_Click(object? sender, EventArgs e) trackGPUClockLimit.Value = NvidiaGpuControl.MaxClockLimit; trackGPUCore.Value = 0; trackGPUMemory.Value = 0; - + trackGPUBoost.Value = AsusACPI.MaxGPUBoost; trackGPUTemp.Value = AsusACPI.MaxGPUTemp; //AppConfig.SetMode("gpu_boost", trackGPUBoost.Value); //AppConfig.SetMode("gpu_temp", trackGPUTemp.Value); - + AppConfig.RemoveMode("gpu_boost"); AppConfig.RemoveMode("gpu_temp"); @@ -1370,6 +1382,13 @@ private void AdjustAllLevels(int index, double curXVal, double curYVal, Series s } } + private void SliderEPP_Scroll(object? sender, EventArgs e) + { + AppConfig.SetMode("epp_value", sliderEPP.Value); + labelEPPSliderRight.Text = $"{sliderEPP.Value}%"; + AppConfig.SetEPP(sliderEPP.Value); + } + } } diff --git a/app/Mode/PowerNative.cs b/app/Mode/PowerNative.cs index 267d64bd..1ddc7fde 100644 --- a/app/Mode/PowerNative.cs +++ b/app/Mode/PowerNative.cs @@ -1,4 +1,5 @@ -using System.Runtime.InteropServices; +using System.Diagnostics; +using System.Runtime.InteropServices; namespace GHelper.Mode { @@ -57,6 +58,10 @@ static extern UInt32 PowerSetActiveScheme(IntPtr RootPowerKey, static readonly Guid GUID_CPU = new Guid("54533251-82be-4824-96c1-47b60b740d00"); static readonly Guid GUID_BOOST = new Guid("be337238-0d82-4146-a960-4f3749d470c7"); + static readonly Guid GUID_SUB_PROCESSOR = new Guid("54533251-82be-4824-96c1-47b60b740d00"); + static readonly Guid GUID_PERFEPP = new Guid("36687f9e-e3a5-4dbf-b1dc-15eb381c6863"); + static readonly Guid GUID_PERFEPP1 = new Guid("36687f9e-e3a5-4dbf-b1dc-15eb381c6864"); + private static Guid GUID_SLEEP_SUBGROUP = new Guid("238c9fa8-0aad-41ed-83f4-97be242c8f20"); private static Guid GUID_HIBERNATEIDLE = new Guid("9d7815a6-7ee4-497e-8888-515a05f02364"); @@ -141,6 +146,42 @@ public static void SetCPUBoost(int boost = 0) Logger.WriteLine("Boost " + boost); } + public static int GetEPP() + { + IntPtr AcValueIndex; + Guid activeSchemeGuid = GetActiveScheme(); + Guid subGroupOfPowerSettingsGuid = GUID_SUB_PROCESSOR; + Guid perfEPPGuid = GUID_PERFEPP; + + UInt32 value = PowerReadACValueIndex(IntPtr.Zero, + activeSchemeGuid, + subGroupOfPowerSettingsGuid, + perfEPPGuid, + out AcValueIndex); + + Logger.WriteLine("EPP: " + AcValueIndex.ToInt32()); + return AcValueIndex.ToInt32(); + } + + public static void SetEPP(int value) + { + Guid activeSchemeGuid = GetActiveScheme(); + Guid subGroupOfPowerSettingsGuid = GUID_SUB_PROCESSOR; + Guid PerfEPPGuid = GUID_PERFEPP; + Guid PerfEPP1Guid = GUID_PERFEPP1; + + PowerWriteACValueIndex(IntPtr.Zero, activeSchemeGuid, subGroupOfPowerSettingsGuid, PerfEPPGuid, value); + PowerWriteACValueIndex(IntPtr.Zero, activeSchemeGuid, subGroupOfPowerSettingsGuid, PerfEPP1Guid, value); + + PowerWriteDCValueIndex(IntPtr.Zero, activeSchemeGuid, subGroupOfPowerSettingsGuid, PerfEPPGuid, value); + PowerWriteDCValueIndex(IntPtr.Zero, activeSchemeGuid, subGroupOfPowerSettingsGuid, PerfEPP1Guid, value); + + // Apply the active power scheme + PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid); + + Logger.WriteLine("EPP set to " + value); + } + public static string GetPowerMode() { if (GetActiveScheme().ToString() == PLAN_HIGH_PERFORMANCE) return PLAN_HIGH_PERFORMANCE;