diff --git a/app/AsusACPI.cs b/app/AsusACPI.cs index a091e4cb..1e955c7b 100644 --- a/app/AsusACPI.cs +++ b/app/AsusACPI.cs @@ -2,6 +2,7 @@ using GHelper.USB; using System.Management; using System.Runtime.InteropServices; +using static System.Runtime.InteropServices.JavaScript.JSType; public enum AsusFan { @@ -98,6 +99,9 @@ public class AsusACPI public const int PPT_APUC1 = 0x001200C1; // fPPT (fast boost limit) public const int PPT_GPUC2 = 0x001200C2; // NVIDIA GPU Temp Target (75.. 87 C) + public const uint CORES_CPU = 0x001200D2; // Intel E-core and P-core configuration in a format 0x0[E]0[P] + public const uint CORES_MAX = 0x001200D3; // Maximum Intel E-core and P-core availability + public const int APU_MEM = 0x000600C1; public const int TUF_KB_BRIGHTNESS = 0x00050021; @@ -141,7 +145,7 @@ public class AsusACPI public const int DefaultCPU = 80; public const int MinGPUBoost = 5; - public static int MaxGPUBoost = 25; + public static int MaxGPUBoost = 50; public const int MinGPUTemp = 75; public const int MaxGPUTemp = 87; @@ -674,6 +678,24 @@ public class AsusACPI } } + public (int, int) GetCores(bool max = false) + { + int value = Program.acpi.DeviceGet(max ? CORES_MAX : CORES_CPU); + //value = max ? 0x806 : 0x605; + + if (value < 0) return (-1, -1); + Logger.WriteLine("Cores" + (max ? "Max" : "") + ": 0x" + value.ToString("X4")); + + return ((value >> 8) & 0xFF, (value) & 0xFF); + } + + public void SetCores(int eCores, int pCores) + { + if (eCores < 0 || eCores > 16 || pCores < 0 || pCores > 16) return; + int value = (eCores << 8) | pCores; + Program.acpi.DeviceSet(CORES_CPU, value, "Cores (0x" + value.ToString("X4")+")"); + } + public string ScanRange() { int value; diff --git a/app/Extra.Designer.cs b/app/Extra.Designer.cs index 70a9d626..d65b07e8 100644 --- a/app/Extra.Designer.cs +++ b/app/Extra.Designer.cs @@ -99,6 +99,7 @@ namespace GHelper checkSleepLid = new CheckBox(); checkShutdownLid = new CheckBox(); panelSettingsHeader = new Panel(); + pictureScan = new PictureBox(); pictureLog = new PictureBox(); pictureSettings = new PictureBox(); labelSettings = new Label(); @@ -120,7 +121,11 @@ namespace GHelper comboAPU = new RComboBox(); pictureAPUMem = new PictureBox(); labelAPUMem = new Label(); - pictureScan = new PictureBox(); + panelCores = new Panel(); + comboCoresP = new RComboBox(); + comboCoresE = new RComboBox(); + pictureCores = new PictureBox(); + label1 = new Label(); panelServices.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureService).BeginInit(); panelBindingsHeader.SuspendLayout(); @@ -137,6 +142,7 @@ namespace GHelper panelXMG.SuspendLayout(); tableBacklight.SuspendLayout(); panelSettingsHeader.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureScan).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureLog).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureSettings).BeginInit(); panelSettings.SuspendLayout(); @@ -145,7 +151,8 @@ namespace GHelper ((System.ComponentModel.ISupportInitialize)pictureHibernate).BeginInit(); panelAPU.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureAPUMem).BeginInit(); - ((System.ComponentModel.ISupportInitialize)pictureScan).BeginInit(); + panelCores.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureCores).BeginInit(); SuspendLayout(); // // panelServices @@ -155,7 +162,7 @@ namespace GHelper panelServices.Controls.Add(labelServices); panelServices.Controls.Add(buttonServices); panelServices.Dock = DockStyle.Top; - panelServices.Location = new Point(15, 1378); + panelServices.Location = new Point(15, 1436); panelServices.Name = "panelServices"; panelServices.Size = new Size(983, 75); panelServices.TabIndex = 5; @@ -1016,6 +1023,20 @@ namespace GHelper panelSettingsHeader.Size = new Size(983, 51); panelSettingsHeader.TabIndex = 45; // + // pictureScan + // + pictureScan.Anchor = AnchorStyles.Top | AnchorStyles.Right; + pictureScan.BackgroundImage = Resources.icons8_search_32; + pictureScan.BackgroundImageLayout = ImageLayout.Zoom; + pictureScan.Cursor = Cursors.Hand; + pictureScan.Location = new Point(891, 11); + pictureScan.Margin = new Padding(4, 3, 4, 3); + pictureScan.Name = "pictureScan"; + pictureScan.Size = new Size(32, 32); + pictureScan.TabIndex = 13; + pictureScan.TabStop = false; + pictureScan.Visible = false; + // // pictureLog // pictureLog.Anchor = AnchorStyles.Top | AnchorStyles.Right; @@ -1063,7 +1084,7 @@ namespace GHelper panelSettings.Controls.Add(checkGpuApps); panelSettings.Controls.Add(checkGPUFix); panelSettings.Dock = DockStyle.Top; - panelSettings.Location = new Point(15, 978); + panelSettings.Location = new Point(15, 1036); panelSettings.Name = "panelSettings"; panelSettings.Padding = new Padding(20, 5, 11, 5); panelSettings.Size = new Size(983, 346); @@ -1178,7 +1199,7 @@ namespace GHelper panelPower.Controls.Add(labelHibernateAfter); panelPower.Controls.Add(pictureHibernate); panelPower.Dock = DockStyle.Top; - panelPower.Location = new Point(15, 1324); + panelPower.Location = new Point(15, 1382); panelPower.Name = "panelPower"; panelPower.Size = new Size(983, 54); panelPower.TabIndex = 4; @@ -1221,7 +1242,7 @@ namespace GHelper panelAPU.Controls.Add(pictureAPUMem); panelAPU.Controls.Add(labelAPUMem); panelAPU.Dock = DockStyle.Top; - panelAPU.Location = new Point(15, 921); + panelAPU.Location = new Point(15, 979); panelAPU.Name = "panelAPU"; panelAPU.Padding = new Padding(11, 5, 11, 0); panelAPU.Size = new Size(983, 57); @@ -1239,10 +1260,10 @@ namespace GHelper comboAPU.FormattingEnabled = true; comboAPU.ItemHeight = 32; comboAPU.Items.AddRange(new object[] { "Auto", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G" }); - comboAPU.Location = new Point(663, 8); + comboAPU.Location = new Point(647, 8); comboAPU.Margin = new Padding(4, 12, 4, 9); comboAPU.Name = "comboAPU"; - comboAPU.Size = new Size(293, 40); + comboAPU.Size = new Size(309, 40); comboAPU.TabIndex = 12; comboAPU.TabStop = false; // @@ -1266,19 +1287,72 @@ namespace GHelper labelAPUMem.TabIndex = 0; labelAPUMem.Text = "Memory Assigned to GPU"; // - // pictureScan + // panelCores // - pictureScan.Anchor = AnchorStyles.Top | AnchorStyles.Right; - pictureScan.BackgroundImage = Resources.icons8_heartbeat_32; - pictureScan.BackgroundImageLayout = ImageLayout.Zoom; - pictureScan.Cursor = Cursors.Hand; - pictureScan.Location = new Point(891, 11); - pictureScan.Margin = new Padding(4, 3, 4, 3); - pictureScan.Name = "pictureScan"; - pictureScan.Size = new Size(32, 32); - pictureScan.TabIndex = 13; - pictureScan.TabStop = false; - pictureScan.Visible = false; + panelCores.AutoSize = true; + panelCores.Controls.Add(comboCoresP); + panelCores.Controls.Add(comboCoresE); + panelCores.Controls.Add(pictureCores); + panelCores.Controls.Add(label1); + panelCores.Dock = DockStyle.Top; + panelCores.Location = new Point(15, 921); + panelCores.Name = "panelCores"; + panelCores.Padding = new Padding(11, 5, 11, 0); + panelCores.Size = new Size(983, 58); + panelCores.TabIndex = 47; + panelCores.Visible = false; + // + // comboCoresP + // + comboCoresP.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboCoresP.BorderColor = Color.White; + comboCoresP.ButtonColor = SystemColors.ControlLight; + comboCoresP.FlatStyle = FlatStyle.Flat; + comboCoresP.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); + comboCoresP.FormattingEnabled = true; + comboCoresP.ItemHeight = 32; + comboCoresP.Location = new Point(805, 9); + comboCoresP.Margin = new Padding(4, 12, 4, 9); + comboCoresP.Name = "comboCoresP"; + comboCoresP.Size = new Size(150, 40); + comboCoresP.TabIndex = 13; + comboCoresP.TabStop = false; + // + // comboCoresE + // + comboCoresE.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboCoresE.BorderColor = Color.White; + comboCoresE.ButtonColor = SystemColors.ControlLight; + comboCoresE.FlatStyle = FlatStyle.Flat; + comboCoresE.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); + comboCoresE.FormattingEnabled = true; + comboCoresE.ItemHeight = 32; + comboCoresE.Location = new Point(647, 9); + comboCoresE.Margin = new Padding(4, 12, 4, 9); + comboCoresE.Name = "comboCoresE"; + comboCoresE.Size = new Size(150, 40); + comboCoresE.TabIndex = 12; + comboCoresE.TabStop = false; + // + // pictureCores + // + pictureCores.BackgroundImage = Resources.icons8_processor_32; + pictureCores.BackgroundImageLayout = ImageLayout.Zoom; + pictureCores.Location = new Point(20, 15); + pictureCores.Name = "pictureCores"; + pictureCores.Size = new Size(32, 32); + pictureCores.TabIndex = 1; + pictureCores.TabStop = false; + // + // label1 + // + label1.AutoSize = true; + label1.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + label1.Location = new Point(64, 14); + label1.Name = "label1"; + label1.Size = new Size(299, 32); + label1.TabIndex = 0; + label1.Text = "CPU Cores Configuration"; // // Extra // @@ -1292,6 +1366,7 @@ namespace GHelper Controls.Add(panelPower); Controls.Add(panelSettings); Controls.Add(panelAPU); + Controls.Add(panelCores); Controls.Add(panelSettingsHeader); Controls.Add(panelBacklight); Controls.Add(panelBacklightHeader); @@ -1332,6 +1407,7 @@ namespace GHelper tableBacklight.ResumeLayout(false); panelSettingsHeader.ResumeLayout(false); panelSettingsHeader.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureScan).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureLog).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureSettings).EndInit(); panelSettings.ResumeLayout(false); @@ -1343,7 +1419,9 @@ namespace GHelper panelAPU.ResumeLayout(false); panelAPU.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureAPUMem).EndInit(); - ((System.ComponentModel.ISupportInitialize)pictureScan).EndInit(); + panelCores.ResumeLayout(false); + panelCores.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureCores).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -1439,5 +1517,10 @@ namespace GHelper private Label labelAPUMem; private RComboBox comboAPU; private PictureBox pictureScan; + private Panel panelCores; + private RComboBox comboCoresE; + private PictureBox pictureCores; + private Label label1; + private RComboBox comboCoresP; } } \ No newline at end of file diff --git a/app/Extra.cs b/app/Extra.cs index a5fc9bf9..e3c21d0d 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -388,17 +388,60 @@ namespace GHelper pictureLog.Click += PictureLog_Click; pictureScan.Click += PictureScan_Click; + pictureScan.Visible = true; + checkGPUFix.Visible = Program.acpi.IsNVidiaGPU(); checkGPUFix.Checked = AppConfig.IsGPUFix(); checkGPUFix.CheckedChanged += CheckGPUFix_CheckedChanged; toolTip.SetToolTip(checkAutoToggleClamshellMode, "Disable sleep on lid close when plugged in and external monitor is connected"); + InitCores(); InitVariBright(); InitServices(); InitHibernate(); } + + private void InitCores() + { + (int eCores, int pCores) = Program.acpi.GetCores(); + (int eCoresMax, int pCoresMax) = Program.acpi.GetCores(true); + + if (eCores < 0 || pCores < 0 || eCoresMax < 0 || pCoresMax < 0) + { + panelCores.Visible = false; + return; + } + + panelCores.Visible = true; + + comboCoresE.DropDownStyle = ComboBoxStyle.DropDownList; + comboCoresP.DropDownStyle = ComboBoxStyle.DropDownList; + + for (int i = 0; i <= eCoresMax; i++) comboCoresE.Items.Add(i.ToString() + "E-cores"); + for (int i = 0; i <= pCoresMax; i++) comboCoresP.Items.Add(i.ToString() + "P-cores"); + + comboCoresE.SelectedIndex = Math.Min(eCores, eCoresMax); + comboCoresP.SelectedIndex = Math.Min(pCores, pCoresMax); + + comboCoresP.SelectedIndexChanged += ComboCores_SelectedIndexChanged; + comboCoresE.SelectedIndexChanged += ComboCores_SelectedIndexChanged; + + } + + private void ComboCores_SelectedIndexChanged(object? sender, EventArgs e) + { + Program.acpi.SetCores(comboCoresE.SelectedIndex, comboCoresP.SelectedIndex); + + DialogResult dialogResult = MessageBox.Show(Properties.Strings.AlertAPUMemoryRestart, Properties.Strings.AlertAPUMemoryRestartTitle, MessageBoxButtons.YesNo); + + if (dialogResult == DialogResult.Yes) + { + Process.Start("shutdown", "/r /t 1"); + } + } + private void PictureScan_Click(object? sender, EventArgs e) { string logFile = Program.acpi.ScanRange(); diff --git a/app/Properties/Resources.Designer.cs b/app/Properties/Resources.Designer.cs index 971b35c6..3dcf312f 100644 --- a/app/Properties/Resources.Designer.cs +++ b/app/Properties/Resources.Designer.cs @@ -600,6 +600,16 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_search_32 { + get { + object obj = ResourceManager.GetObject("icons8-search-32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/app/Properties/Resources.resx b/app/Properties/Resources.resx index ea07c07c..c728bd5a 100644 --- a/app/Properties/Resources.resx +++ b/app/Properties/Resources.resx @@ -136,9 +136,6 @@ ..\Resources\icons8-bicycle-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\eco.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -166,9 +163,6 @@ ..\Resources\icons8-automation-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-settings-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\brightness-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -178,8 +172,8 @@ ..\Resources\icons8-processor-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-fiat-500-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Font.otf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ..\Resources\icons8-touchpad-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -199,6 +193,9 @@ ..\Resources\icons8-remove-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-share-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-function-mac-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -217,6 +214,9 @@ ..\Resources\backlight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-brightness-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-refresh-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -232,11 +232,14 @@ ..\Resources\icons8-xbox-rt-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-controller-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-fan-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-controller-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-settings-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-maus-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -286,8 +289,8 @@ ..\Resources\icons8-video-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Font.otf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\icons8-fiat-500-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\dot-eco.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -322,8 +325,8 @@ ..\Resources\icons8-software-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-share-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\standard.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-soonvibes-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -334,7 +337,7 @@ ..\Resources\icons8-charging-battery-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-brightness-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-search-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/app/Resources/icons8-search-32.png b/app/Resources/icons8-search-32.png new file mode 100644 index 00000000..4a37cd5b Binary files /dev/null and b/app/Resources/icons8-search-32.png differ