Compare commits

..

4 Commits
v0.77 ... v0.78

Author SHA1 Message Date
Serge
f26585e73c Version bump 2023-06-04 23:21:29 +02:00
Serge
9f7da4c20a GPU Section UI fixes 2023-06-04 23:20:37 +02:00
Serge
eff45c1485 Curve editor fix 2023-06-04 23:09:56 +02:00
Serge
be6e5e8f23 Varibright control 2023-06-04 17:21:31 +02:00
8 changed files with 341 additions and 142 deletions

210
app/Extra.Designer.cs generated
View File

@@ -86,12 +86,13 @@ namespace GHelper
checkSleepLid = new CheckBox();
checkShutdownLid = new CheckBox();
groupOther = new GroupBox();
checkFnLock = new CheckBox();
checkGpuApps = new CheckBox();
checkAutoApplyWindowsPowerMode = new CheckBox();
checkUSBC = new CheckBox();
checkNoOverdrive = new CheckBox();
checkTopmost = new CheckBox();
checkNoOverdrive = new CheckBox();
checkUSBC = new CheckBox();
checkVariBright = new CheckBox();
checkGpuApps = new CheckBox();
checkFnLock = new CheckBox();
groupBindings.SuspendLayout();
tableKeys.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureHelp).BeginInit();
@@ -114,8 +115,8 @@ namespace GHelper
groupBindings.Location = new Point(9, 11);
groupBindings.Margin = new Padding(4, 2, 4, 2);
groupBindings.Name = "groupBindings";
groupBindings.Padding = new Padding(4, 2, 4, 2);
groupBindings.Size = new Size(966, 381);
groupBindings.Padding = new Padding(4, 2, 50, 2);
groupBindings.Size = new Size(966, 343);
groupBindings.TabIndex = 0;
groupBindings.TabStop = false;
groupBindings.Text = "Key Bindings";
@@ -144,10 +145,11 @@ namespace GHelper
tableKeys.Controls.Add(textFNF4, 2, 4);
tableKeys.Controls.Add(comboFNC, 1, 5);
tableKeys.Controls.Add(textFNC, 2, 5);
tableKeys.Location = new Point(13, 38);
tableKeys.Margin = new Padding(4, 2, 40, 2);
tableKeys.Dock = DockStyle.Top;
tableKeys.Location = new Point(4, 34);
tableKeys.Margin = new Padding(4, 2, 4, 2);
tableKeys.Name = "tableKeys";
tableKeys.Padding = new Padding(9, 11, 9, 11);
tableKeys.Padding = new Padding(9, 11, 0, 11);
tableKeys.RowCount = 6;
tableKeys.RowStyles.Add(new RowStyle(SizeType.Absolute, 49F));
tableKeys.RowStyles.Add(new RowStyle(SizeType.Absolute, 49F));
@@ -155,7 +157,7 @@ namespace GHelper
tableKeys.RowStyles.Add(new RowStyle(SizeType.Absolute, 49F));
tableKeys.RowStyles.Add(new RowStyle(SizeType.Absolute, 47F));
tableKeys.RowStyles.Add(new RowStyle(SizeType.Absolute, 21F));
tableKeys.Size = new Size(901, 307);
tableKeys.Size = new Size(912, 307);
tableKeys.TabIndex = 10;
//
// labelFNC
@@ -170,32 +172,35 @@ namespace GHelper
//
// textM2
//
textM2.Location = new Point(542, 62);
textM2.Dock = DockStyle.Top;
textM2.Location = new Point(554, 62);
textM2.Margin = new Padding(4, 2, 4, 2);
textM2.Name = "textM2";
textM2.PlaceholderText = "action";
textM2.Size = new Size(342, 39);
textM2.Size = new Size(354, 39);
textM2.TabIndex = 14;
//
// textM1
//
textM1.Location = new Point(542, 13);
textM1.Dock = DockStyle.Top;
textM1.Location = new Point(554, 13);
textM1.Margin = new Padding(4, 2, 4, 2);
textM1.Name = "textM1";
textM1.PlaceholderText = "action";
textM1.Size = new Size(342, 39);
textM1.Size = new Size(354, 39);
textM1.TabIndex = 13;
//
// comboM1
//
comboM1.BorderColor = Color.White;
comboM1.ButtonColor = Color.FromArgb(255, 255, 255);
comboM1.Dock = DockStyle.Top;
comboM1.FormattingEnabled = true;
comboM1.Items.AddRange(new object[] { Strings.Default, Strings.VolumeMute, Strings.PlayPause, Strings.PrintScreen, Strings.ToggleAura, Strings.Custom });
comboM1.Location = new Point(189, 13);
comboM1.Location = new Point(193, 13);
comboM1.Margin = new Padding(4, 2, 4, 2);
comboM1.Name = "comboM1";
comboM1.Size = new Size(312, 40);
comboM1.Size = new Size(353, 40);
comboM1.TabIndex = 11;
//
// labelM1
@@ -212,42 +217,46 @@ namespace GHelper
//
comboM4.BorderColor = Color.White;
comboM4.ButtonColor = Color.FromArgb(255, 255, 255);
comboM4.Dock = DockStyle.Top;
comboM4.FormattingEnabled = true;
comboM4.Items.AddRange(new object[] { Strings.PerformanceMode, Strings.OpenGHelper, Strings.Custom });
comboM4.Location = new Point(189, 160);
comboM4.Location = new Point(193, 160);
comboM4.Margin = new Padding(4, 2, 4, 2);
comboM4.Name = "comboM4";
comboM4.Size = new Size(312, 40);
comboM4.Size = new Size(353, 40);
comboM4.TabIndex = 3;
//
// comboM3
//
comboM3.BorderColor = Color.White;
comboM3.ButtonColor = Color.FromArgb(255, 255, 255);
comboM3.Dock = DockStyle.Top;
comboM3.FormattingEnabled = true;
comboM3.Items.AddRange(new object[] { Strings.Default, Strings.VolumeMute, Strings.PlayPause, Strings.PrintScreen, Strings.ToggleAura, Strings.Custom });
comboM3.Location = new Point(189, 111);
comboM3.Location = new Point(193, 111);
comboM3.Margin = new Padding(4, 2, 4, 2);
comboM3.Name = "comboM3";
comboM3.Size = new Size(312, 40);
comboM3.Size = new Size(353, 40);
comboM3.TabIndex = 1;
//
// textM4
//
textM4.Location = new Point(542, 160);
textM4.Dock = DockStyle.Top;
textM4.Location = new Point(554, 160);
textM4.Margin = new Padding(4, 2, 4, 2);
textM4.Name = "textM4";
textM4.PlaceholderText = "action";
textM4.Size = new Size(342, 39);
textM4.Size = new Size(354, 39);
textM4.TabIndex = 5;
//
// textM3
//
textM3.Location = new Point(542, 111);
textM3.Dock = DockStyle.Top;
textM3.Location = new Point(554, 111);
textM3.Margin = new Padding(4, 2, 4, 2);
textM3.Name = "textM3";
textM3.PlaceholderText = "action";
textM3.Size = new Size(342, 39);
textM3.Size = new Size(354, 39);
textM3.TabIndex = 4;
//
// labelM4
@@ -284,12 +293,13 @@ namespace GHelper
//
comboM2.BorderColor = Color.White;
comboM2.ButtonColor = Color.FromArgb(255, 255, 255);
comboM2.Dock = DockStyle.Top;
comboM2.FormattingEnabled = true;
comboM2.Items.AddRange(new object[] { Strings.Default, Strings.VolumeMute, Strings.PlayPause, Strings.PrintScreen, Strings.ToggleAura, Strings.Custom });
comboM2.Location = new Point(189, 62);
comboM2.Location = new Point(193, 62);
comboM2.Margin = new Padding(4, 2, 4, 2);
comboM2.Name = "comboM2";
comboM2.Size = new Size(312, 40);
comboM2.Size = new Size(353, 40);
comboM2.TabIndex = 12;
//
// labelFNF4
@@ -306,40 +316,44 @@ namespace GHelper
//
comboFNF4.BorderColor = Color.White;
comboFNF4.ButtonColor = Color.FromArgb(255, 255, 255);
comboFNF4.Dock = DockStyle.Top;
comboFNF4.FormattingEnabled = true;
comboFNF4.Location = new Point(189, 209);
comboFNF4.Location = new Point(193, 209);
comboFNF4.Margin = new Padding(4, 2, 4, 2);
comboFNF4.Name = "comboFNF4";
comboFNF4.Size = new Size(312, 40);
comboFNF4.Size = new Size(353, 40);
comboFNF4.TabIndex = 7;
//
// textFNF4
//
textFNF4.Location = new Point(542, 209);
textFNF4.Dock = DockStyle.Top;
textFNF4.Location = new Point(554, 209);
textFNF4.Margin = new Padding(4, 2, 4, 2);
textFNF4.Name = "textFNF4";
textFNF4.PlaceholderText = "action";
textFNF4.Size = new Size(342, 39);
textFNF4.Size = new Size(354, 39);
textFNF4.TabIndex = 8;
//
// comboFNC
//
comboFNC.BorderColor = Color.White;
comboFNC.ButtonColor = Color.FromArgb(255, 255, 255);
comboFNC.Dock = DockStyle.Top;
comboFNC.FormattingEnabled = true;
comboFNC.Location = new Point(189, 256);
comboFNC.Location = new Point(193, 256);
comboFNC.Margin = new Padding(4, 2, 4, 2);
comboFNC.Name = "comboFNC";
comboFNC.Size = new Size(312, 40);
comboFNC.Size = new Size(353, 40);
comboFNC.TabIndex = 16;
//
// textFNC
//
textFNC.Location = new Point(542, 256);
textFNC.Dock = DockStyle.Top;
textFNC.Location = new Point(554, 256);
textFNC.Margin = new Padding(4, 2, 4, 2);
textFNC.Name = "textFNC";
textFNC.PlaceholderText = "action";
textFNC.Size = new Size(342, 39);
textFNC.Size = new Size(354, 39);
textFNC.TabIndex = 17;
//
// pictureHelp
@@ -347,7 +361,7 @@ namespace GHelper
pictureHelp.BackgroundImage = Resources.icons8_help_64;
pictureHelp.BackgroundImageLayout = ImageLayout.Zoom;
pictureHelp.Cursor = Cursors.Hand;
pictureHelp.Location = new Point(915, 55);
pictureHelp.Location = new Point(921, 51);
pictureHelp.Margin = new Padding(4, 2, 4, 2);
pictureHelp.Name = "pictureHelp";
pictureHelp.Size = new Size(32, 32);
@@ -362,7 +376,7 @@ namespace GHelper
groupLight.Controls.Add(panelXMG);
groupLight.Controls.Add(tableBacklight);
groupLight.Dock = DockStyle.Top;
groupLight.Location = new Point(9, 392);
groupLight.Location = new Point(9, 354);
groupLight.Margin = new Padding(4, 2, 4, 2);
groupLight.Name = "groupLight";
groupLight.Padding = new Padding(4, 2, 4, 11);
@@ -778,88 +792,107 @@ namespace GHelper
//
groupOther.AutoSize = true;
groupOther.AutoSizeMode = AutoSizeMode.GrowAndShrink;
groupOther.Controls.Add(checkFnLock);
groupOther.Controls.Add(checkGpuApps);
groupOther.Controls.Add(checkAutoApplyWindowsPowerMode);
groupOther.Controls.Add(checkUSBC);
groupOther.Controls.Add(checkNoOverdrive);
groupOther.Controls.Add(checkTopmost);
groupOther.Controls.Add(checkNoOverdrive);
groupOther.Controls.Add(checkUSBC);
groupOther.Controls.Add(checkVariBright);
groupOther.Controls.Add(checkGpuApps);
groupOther.Controls.Add(checkFnLock);
groupOther.Dock = DockStyle.Top;
groupOther.Location = new Point(9, 946);
groupOther.Location = new Point(9, 908);
groupOther.Margin = new Padding(4, 2, 4, 2);
groupOther.Name = "groupOther";
groupOther.Padding = new Padding(4, 2, 4, 0);
groupOther.Size = new Size(966, 320);
groupOther.Padding = new Padding(20, 2, 4, 10);
groupOther.Size = new Size(966, 296);
groupOther.TabIndex = 2;
groupOther.TabStop = false;
groupOther.Text = "Other";
//
// checkFnLock
//
checkFnLock.AutoSize = true;
checkFnLock.Location = new Point(24, 45);
checkFnLock.Margin = new Padding(4, 2, 4, 2);
checkFnLock.MaximumSize = new Size(780, 0);
checkFnLock.Name = "checkFnLock";
checkFnLock.Size = new Size(397, 36);
checkFnLock.TabIndex = 49;
checkFnLock.Text = "Process Fn+F hotkeys without Fn";
checkFnLock.UseVisualStyleBackColor = true;
//
// checkGpuApps
//
checkGpuApps.AutoSize = true;
checkGpuApps.Location = new Point(24, 83);
checkGpuApps.Margin = new Padding(4, 2, 4, 2);
checkGpuApps.Name = "checkGpuApps";
checkGpuApps.Size = new Size(544, 36);
checkGpuApps.TabIndex = 48;
checkGpuApps.Text = "Stop all apps using GPU when switching to Eco";
checkGpuApps.UseVisualStyleBackColor = true;
//
// checkAutoApplyWindowsPowerMode
//
checkAutoApplyWindowsPowerMode.AutoSize = true;
checkAutoApplyWindowsPowerMode.Location = new Point(24, 250);
checkAutoApplyWindowsPowerMode.Dock = DockStyle.Top;
checkAutoApplyWindowsPowerMode.Location = new Point(20, 250);
checkAutoApplyWindowsPowerMode.Margin = new Padding(4, 2, 4, 2);
checkAutoApplyWindowsPowerMode.Name = "checkAutoApplyWindowsPowerMode";
checkAutoApplyWindowsPowerMode.Size = new Size(416, 36);
checkAutoApplyWindowsPowerMode.Size = new Size(942, 36);
checkAutoApplyWindowsPowerMode.TabIndex = 47;
checkAutoApplyWindowsPowerMode.Text = "Auto Adjust Windows Power Mode";
checkAutoApplyWindowsPowerMode.UseVisualStyleBackColor = true;
//
// checkUSBC
// checkTopmost
//
checkUSBC.AutoSize = true;
checkUSBC.Location = new Point(24, 126);
checkUSBC.Margin = new Padding(4, 2, 4, 2);
checkUSBC.Name = "checkUSBC";
checkUSBC.Size = new Size(659, 36);
checkUSBC.TabIndex = 4;
checkUSBC.Text = "Keep GPU disabled on USB-C charger in Optimized mode";
checkUSBC.UseVisualStyleBackColor = true;
checkTopmost.AutoSize = true;
checkTopmost.Dock = DockStyle.Top;
checkTopmost.Location = new Point(20, 214);
checkTopmost.Margin = new Padding(4, 2, 4, 2);
checkTopmost.Name = "checkTopmost";
checkTopmost.Size = new Size(942, 36);
checkTopmost.TabIndex = 1;
checkTopmost.Text = Strings.WindowTop;
checkTopmost.UseVisualStyleBackColor = true;
//
// checkNoOverdrive
//
checkNoOverdrive.AutoSize = true;
checkNoOverdrive.Location = new Point(24, 166);
checkNoOverdrive.Dock = DockStyle.Top;
checkNoOverdrive.Location = new Point(20, 178);
checkNoOverdrive.Margin = new Padding(4, 2, 4, 2);
checkNoOverdrive.Name = "checkNoOverdrive";
checkNoOverdrive.Size = new Size(307, 36);
checkNoOverdrive.Size = new Size(942, 36);
checkNoOverdrive.TabIndex = 3;
checkNoOverdrive.Text = Strings.DisableOverdrive;
checkNoOverdrive.UseVisualStyleBackColor = true;
//
// checkTopmost
// checkUSBC
//
checkTopmost.AutoSize = true;
checkTopmost.Location = new Point(24, 209);
checkTopmost.Margin = new Padding(4, 2, 4, 2);
checkTopmost.Name = "checkTopmost";
checkTopmost.Size = new Size(390, 36);
checkTopmost.TabIndex = 1;
checkTopmost.Text = Strings.WindowTop;
checkTopmost.UseVisualStyleBackColor = true;
checkUSBC.AutoSize = true;
checkUSBC.Dock = DockStyle.Top;
checkUSBC.Location = new Point(20, 142);
checkUSBC.Margin = new Padding(4, 2, 4, 2);
checkUSBC.Name = "checkUSBC";
checkUSBC.Size = new Size(942, 36);
checkUSBC.TabIndex = 4;
checkUSBC.Text = "Keep GPU disabled on USB-C charger in Optimized mode";
checkUSBC.UseVisualStyleBackColor = true;
//
// checkVariBright
//
checkVariBright.AutoSize = true;
checkVariBright.Dock = DockStyle.Top;
checkVariBright.Location = new Point(20, 106);
checkVariBright.Margin = new Padding(4, 2, 4, 2);
checkVariBright.Name = "checkVariBright";
checkVariBright.Size = new Size(942, 36);
checkVariBright.TabIndex = 50;
checkVariBright.Text = "AMD Display VariBright";
checkVariBright.UseVisualStyleBackColor = true;
//
// checkGpuApps
//
checkGpuApps.AutoSize = true;
checkGpuApps.Dock = DockStyle.Top;
checkGpuApps.Location = new Point(20, 70);
checkGpuApps.Margin = new Padding(4, 2, 4, 2);
checkGpuApps.Name = "checkGpuApps";
checkGpuApps.Size = new Size(942, 36);
checkGpuApps.TabIndex = 48;
checkGpuApps.Text = "Stop all apps using GPU when switching to Eco";
checkGpuApps.UseVisualStyleBackColor = true;
//
// checkFnLock
//
checkFnLock.AutoSize = true;
checkFnLock.Dock = DockStyle.Top;
checkFnLock.Location = new Point(20, 34);
checkFnLock.Margin = new Padding(4, 2, 4, 2);
checkFnLock.MaximumSize = new Size(780, 0);
checkFnLock.Name = "checkFnLock";
checkFnLock.Size = new Size(780, 36);
checkFnLock.TabIndex = 49;
checkFnLock.Text = "Process Fn+F hotkeys without Fn";
checkFnLock.UseVisualStyleBackColor = true;
//
// Extra
//
@@ -965,5 +998,6 @@ namespace GHelper
private Label labelFNC;
private RComboBox comboFNC;
private TextBox textFNC;
private CheckBox checkVariBright;
}
}

View File

@@ -1,4 +1,5 @@
using CustomControls;
using GHelper.Gpu;
using Microsoft.VisualBasic.Devices;
using System.Diagnostics;
@@ -227,6 +228,44 @@ namespace GHelper
checkFnLock.CheckedChanged += CheckFnLock_CheckedChanged; ;
pictureHelp.Click += PictureHelp_Click;
InitVariBright();
}
private void InitVariBright()
{
try
{
using (var amdControl = new AmdGpuControl())
{
int variBrightSupported = 0, VariBrightEnabled;
if (amdControl.GetVariBright(out variBrightSupported, out VariBrightEnabled))
{
Logger.WriteLine("Varibright: " + variBrightSupported + "," + VariBrightEnabled);
checkVariBright.Checked = (VariBrightEnabled == 3);
}
checkVariBright.Visible = (variBrightSupported > 0);
checkVariBright.CheckedChanged += CheckVariBright_CheckedChanged;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
checkVariBright.Visible = false;
}
}
private void CheckVariBright_CheckedChanged(object? sender, EventArgs e)
{
using (var amdControl = new AmdGpuControl())
{
amdControl.SetVariBright(checkVariBright.Checked ? 1 : 0);
ProcessHelper.KillByName("RadeonSoftware");
}
}
private void CheckFnLock_CheckedChanged(object? sender, EventArgs e)

View File

@@ -9,7 +9,9 @@ namespace GHelper
public partial class Fans : RForm
{
int curIndex = -1;
DataPoint curPoint = null;
Series seriesCPU;
Series seriesGPU;
Series seriesMid;
@@ -640,6 +642,8 @@ namespace GHelper
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
{
curPoint = null;
curIndex = -1;
labelTip.Visible = false;
SaveProfile(seriesCPU, AsusFan.CPU);
@@ -669,9 +673,12 @@ namespace GHelper
bool tip = false;
HitTestResult hit = chart.HitTest(e.X, e.Y);
Series series = chart.Series[0];
if (hit.Series is not null && hit.PointIndex >= 0)
{
curPoint = hit.Series.Points[hit.PointIndex];
curIndex = hit.PointIndex;
curPoint = hit.Series.Points[curIndex];
tip = true;
}
@@ -696,18 +703,19 @@ namespace GHelper
if (dy < dymin) dy = dymin;
if (e.Button.HasFlag(MouseButtons.Left) && hit.Series is not null)
if (e.Button.HasFlag(MouseButtons.Left))
{
double deltaY = dy - curPoint.YValues[0];
double deltaX = dx - curPoint.XValue;
curPoint.XValue = dx;
if (Control.ModifierKeys == Keys.Shift)
{
AdjustAllDots(0, dy - curPoint.YValues[0], hit.Series);
} else
AdjustAll(0, deltaY, series);
else
{
curPoint.YValues[0] = dy;
AdjustAllLevels(hit.PointIndex, dx, dy, hit.Series);
AdjustAllLevels(curIndex, dx, dy, series);
}
tip = true;
@@ -731,7 +739,7 @@ namespace GHelper
}
private void AdjustAllDots(double deltaX, double deltaY, Series series)
private void AdjustAll(double deltaX, double deltaY, Series series)
{
for (int i = 0; i < series.Points.Count; i++)
{

View File

@@ -16,7 +16,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.77</AssemblyVersion>
<AssemblyVersion>0.78</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using static AmdAdl2.Adl2.NativeMethods;
namespace AmdAdl2;
@@ -515,6 +516,63 @@ public class Adl2 {
out int lpNumApps,
out IntPtr lppAppList);
[DllImport(Atiadlxx_FileName)]
public static extern int ADL2_Adapter_VariBright_Caps(
IntPtr context,
int iAdapterIndex,
out int iSupported,
out int iEnabled,
out int iVersion);
[DllImport(Atiadlxx_FileName)]
public static extern int ADL2_Adapter_VariBrightEnable_Set(
IntPtr context,
int iAdapterIndex,
int iEnabled);
// Clocks
[StructLayout(LayoutKind.Sequential)]
public struct ADLODNPerformanceLevel
{
public int iClock;
public int iVddc;
public int iEnabled;
}
[StructLayout(LayoutKind.Sequential)]
public struct ADLODNPerformanceLevels
{
public int iSize;
public int iMode;
public int iNumberOfPerformanceLevels;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public ADLODNPerformanceLevel[] aLevels;
}
[DllImport(Atiadlxx_FileName)]
public static extern int ADL2_OverdriveN_SystemClocks_Get(
IntPtr context,
int adapterIndex,
ref ADLODNPerformanceLevels performanceLevels);
[DllImport(Atiadlxx_FileName)]
public static extern int ADL2_OverdriveN_SystemClocks_Set(
IntPtr context,
int adapterIndex,
ref ADLODNPerformanceLevels performanceLevels);
[DllImport(Atiadlxx_FileName)]
public static extern int ADL2_OverdriveN_MemoryClocks_Get(
IntPtr context,
int adapterIndex,
ref ADLODNPerformanceLevels performanceLevels);
[DllImport(Atiadlxx_FileName)]
public static extern int ADL2_OverdriveN_MemoryClocks_Set(
IntPtr context,
int adapterIndex,
ref ADLODNPerformanceLevels performanceLevels);
}
}

View File

@@ -1,6 +1,6 @@
using AmdAdl2;
using System.Diagnostics;
using System.Runtime.InteropServices;
using static AmdAdl2.Adl2.NativeMethods;
namespace GHelper.Gpu;
@@ -14,24 +14,19 @@ public class AmdGpuControl : IGpuControl
public bool IsNvidia => false;
public string FullName => _internalDiscreteAdapter!.AdapterName;
public AmdGpuControl()
private ADLAdapterInfo? FindByType(ADLAsicFamilyType type = ADLAsicFamilyType.Discrete)
{
if (!Adl2.Load())
return;
if (Adl2.ADL2_Main_Control_Create(1, out _adlContextHandle) != Adl2.ADL_SUCCESS)
return;
Adl2.NativeMethods.ADL2_Adapter_NumberOfAdapters_Get(_adlContextHandle, out int numberOfAdapters);
ADL2_Adapter_NumberOfAdapters_Get(_adlContextHandle, out int numberOfAdapters);
if (numberOfAdapters <= 0)
return;
return null;
ADLAdapterInfoArray osAdapterInfoData = new();
int osAdapterInfoDataSize = Marshal.SizeOf(osAdapterInfoData);
IntPtr AdapterBuffer = Marshal.AllocCoTaskMem(osAdapterInfoDataSize);
Marshal.StructureToPtr(osAdapterInfoData, AdapterBuffer, false);
if (Adl2.NativeMethods.ADL2_Adapter_AdapterInfo_Get(_adlContextHandle, AdapterBuffer, osAdapterInfoDataSize) != Adl2.ADL_SUCCESS)
return;
if (ADL2_Adapter_AdapterInfo_Get(_adlContextHandle, AdapterBuffer, osAdapterInfoDataSize) != Adl2.ADL_SUCCESS)
return null;
osAdapterInfoData = (ADLAdapterInfoArray)Marshal.PtrToStructure(AdapterBuffer, osAdapterInfoData.GetType())!;
@@ -48,20 +43,37 @@ public class AmdGpuControl : IGpuControl
if (adapter.VendorID != amdVendorId)
return false;
if (Adl2.NativeMethods.ADL2_Adapter_ASICFamilyType_Get(_adlContextHandle, adapter.AdapterIndex, out ADLAsicFamilyType asicFamilyType, out int asicFamilyTypeValids) != Adl2.ADL_SUCCESS)
if (ADL2_Adapter_ASICFamilyType_Get(_adlContextHandle, adapter.AdapterIndex, out ADLAsicFamilyType asicFamilyType, out int asicFamilyTypeValids) != Adl2.ADL_SUCCESS)
return false;
asicFamilyType = (ADLAsicFamilyType)((int)asicFamilyType & asicFamilyTypeValids);
// FIXME: is this correct for G14 2022?
return (asicFamilyType & ADLAsicFamilyType.Discrete) != 0;
return (asicFamilyType & type) != 0;
});
if (internalDiscreteAdapter.Exist == 0)
return null;
return internalDiscreteAdapter;
}
public AmdGpuControl()
{
if (!Adl2.Load())
return;
_internalDiscreteAdapter = internalDiscreteAdapter;
_isReady = true;
if (Adl2.ADL2_Main_Control_Create(1, out _adlContextHandle) != Adl2.ADL_SUCCESS)
return;
ADLAdapterInfo? internalDiscreteAdapter = FindByType(ADLAsicFamilyType.Discrete);
if (internalDiscreteAdapter is not null)
{
_internalDiscreteAdapter = (ADLAdapterInfo)internalDiscreteAdapter;
_isReady = true;
}
}
public bool IsValid => _isReady && _adlContextHandle != IntPtr.Zero;
@@ -71,7 +83,7 @@ public class AmdGpuControl : IGpuControl
if (!IsValid)
return null;
if (Adl2.NativeMethods.ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
if (ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
return null;
ADLSingleSensorData temperatureSensor = adlpmLogDataOutput.Sensors[(int)ADLSensorType.PMLOG_TEMPERATURE_EDGE];
@@ -86,7 +98,7 @@ public class AmdGpuControl : IGpuControl
{
if (!IsValid) return null;
if (Adl2.NativeMethods.ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
if (ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
return null;
ADLSingleSensorData gpuUsage = adlpmLogDataOutput.Sensors[(int)ADLSensorType.PMLOG_INFO_ACTIVITY_GFX];
@@ -97,6 +109,46 @@ public class AmdGpuControl : IGpuControl
}
public bool SetVariBright(int enabled)
{
if (_adlContextHandle == IntPtr.Zero) return false;
ADLAdapterInfo? iGPU = FindByType(ADLAsicFamilyType.Integrated);
if (iGPU is null) return false;
return ADL2_Adapter_VariBrightEnable_Set(_adlContextHandle, ((ADLAdapterInfo)iGPU).AdapterIndex, enabled) == Adl2.ADL_SUCCESS;
}
public bool GetVariBright(out int supported, out int enabled)
{
supported = enabled = -1;
if (_adlContextHandle == IntPtr.Zero) return false;
ADLAdapterInfo? iGPU = FindByType(ADLAsicFamilyType.Integrated);
if (iGPU is null) return false;
if (ADL2_Adapter_VariBright_Caps(_adlContextHandle, ((ADLAdapterInfo)iGPU).AdapterIndex, out int supportedOut, out int enabledOut, out int version) != Adl2.ADL_SUCCESS)
return false;
supported = supportedOut;
enabled = enabledOut;
return true;
}
public ADLODNPerformanceLevels? GetGPUClocks()
{
if (!IsValid) return null;
ADLODNPerformanceLevels performanceLevels = new();
ADL2_OverdriveN_SystemClocks_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, ref performanceLevels);
return performanceLevels;
}
public void KillGPUApps()
{
@@ -108,7 +160,7 @@ public class AmdGpuControl : IGpuControl
try
{
// Get switchable graphics applications information
var result = Adl2.NativeMethods.ADL2_SwitchableGraphics_Applications_Get(_adlContextHandle, 2, out appCount, out appInfoPtr);
var result = ADL2_SwitchableGraphics_Applications_Get(_adlContextHandle, 2, out appCount, out appInfoPtr);
if (result != 0)
{
throw new Exception("Failed to get switchable graphics applications. Error code: " + result);
@@ -138,7 +190,8 @@ public class AmdGpuControl : IGpuControl
foreach (string kill in appNames) ProcessHelper.KillByName(kill);
} catch (Exception ex)
}
catch (Exception ex)
{
Logger.WriteLine(ex.Message);
}
@@ -158,7 +211,7 @@ public class AmdGpuControl : IGpuControl
{
if (_adlContextHandle != IntPtr.Zero)
{
Adl2.NativeMethods.ADL2_Main_Control_Destroy(_adlContextHandle);
ADL2_Main_Control_Destroy(_adlContextHandle);
_adlContextHandle = IntPtr.Zero;
_isReady = false;
}

View File

@@ -31,7 +31,7 @@ public static class HardwareControl
{
AppConfig.setConfig("fan_max", fan);
}
private static string FormatFan(int fan)
public static string FormatFan(int fan)
{
// fix for old models
if (fan < 0)

View File

@@ -34,6 +34,8 @@ namespace GHelper
private bool customFans = false;
private int customPower = 0;
bool isGpuSection = true;
public SettingsForm()
{
@@ -256,32 +258,36 @@ namespace GHelper
contextMenuStrip.Items.Add("-");
var titleGPU = new ToolStripMenuItem(Properties.Strings.GPUMode);
titleGPU.Margin = padding;
titleGPU.Enabled = false;
contextMenuStrip.Items.Add(titleGPU);
if (isGpuSection)
{
var titleGPU = new ToolStripMenuItem(Properties.Strings.GPUMode);
titleGPU.Margin = padding;
titleGPU.Enabled = false;
contextMenuStrip.Items.Add(titleGPU);
menuEco = new ToolStripMenuItem(Properties.Strings.EcoMode);
menuEco.Click += ButtonEco_Click;
menuEco.Margin = padding;
contextMenuStrip.Items.Add(menuEco);
menuEco = new ToolStripMenuItem(Properties.Strings.EcoMode);
menuEco.Click += ButtonEco_Click;
menuEco.Margin = padding;
contextMenuStrip.Items.Add(menuEco);
menuStandard = new ToolStripMenuItem(Properties.Strings.StandardMode);
menuStandard.Click += ButtonStandard_Click;
menuStandard.Margin = padding;
contextMenuStrip.Items.Add(menuStandard);
menuStandard = new ToolStripMenuItem(Properties.Strings.StandardMode);
menuStandard.Click += ButtonStandard_Click;
menuStandard.Margin = padding;
contextMenuStrip.Items.Add(menuStandard);
menuUltimate = new ToolStripMenuItem(Properties.Strings.UltimateMode);
menuUltimate.Click += ButtonUltimate_Click;
menuUltimate.Margin = padding;
contextMenuStrip.Items.Add(menuUltimate);
menuUltimate = new ToolStripMenuItem(Properties.Strings.UltimateMode);
menuUltimate.Click += ButtonUltimate_Click;
menuUltimate.Margin = padding;
contextMenuStrip.Items.Add(menuUltimate);
menuOptimized = new ToolStripMenuItem(Properties.Strings.Optimized);
menuOptimized.Click += ButtonOptimized_Click;
menuOptimized.Margin = padding;
contextMenuStrip.Items.Add(menuOptimized);
menuOptimized = new ToolStripMenuItem(Properties.Strings.Optimized);
menuOptimized.Click += ButtonOptimized_Click;
menuOptimized.Margin = padding;
contextMenuStrip.Items.Add(menuOptimized);
contextMenuStrip.Items.Add("-");
}
contextMenuStrip.Items.Add("-");
var quit = new ToolStripMenuItem(Properties.Strings.Quit);
quit.Click += ButtonQuit_Click;
@@ -1470,8 +1476,9 @@ namespace GHelper
if (eco < 0)
{
tableGPU.Visible = false;
if (Program.acpi.DeviceGet(AsusACPI.GPU_Fan) < -65536) panelGPU.Visible = false;
isGpuSection = tableGPU.Visible = false;
SetContextMenu();
if (HardwareControl.FormatFan(Program.acpi.DeviceGet(AsusACPI.GPU_Fan)) is null) panelGPU.Visible = false;
}
}