Skip to content

Commit a21a271

Browse files
committed
OledPowerOptimization checker #4977 #5048
1 parent f661477 commit a21a271

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

app/Display/AmdDisplay.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Microsoft.Win32;
2+
using Ryzen;
3+
4+
namespace GHelper.Display
5+
{
6+
public static class AmdDisplay
7+
{
8+
private const string DisplayPath0 =
9+
@"SYSTEM\CurrentControlSet\Control\Class\" +
10+
@"{4d36e968-e325-11ce-bfc1-08002be10318}\" +
11+
@"0001\DAL2_DATA__2_0\DisplayPath_0";
12+
13+
public static bool IsOledPowerOptimizationOnBattery()
14+
{
15+
16+
if (!AppConfig.IsOLED()) return false;
17+
if (SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Offline) return false;
18+
if (!RyzenControl.IsAMD()) return false;
19+
20+
try
21+
{
22+
using RegistryKey dp0 = Registry.LocalMachine.OpenSubKey(DisplayPath0, writable: false);
23+
if (dp0 == null) return false;
24+
25+
// Find the first EDID_* subkey — there's only one for the internal panel
26+
string edidKey = Array.Find(dp0.GetSubKeyNames(),
27+
name => name.StartsWith("EDID_", StringComparison.OrdinalIgnoreCase));
28+
29+
if (edidKey == null) return false;
30+
31+
using RegistryKey adjustment = dp0.OpenSubKey($@"{edidKey}\Adjustment", writable: false);
32+
33+
if (adjustment?.GetValue("DAL_SCE_Settings") is not byte[] data || data.Length < 5)
34+
return false;
35+
36+
// Byte[4]: 0x02 = battery OLED optimization ON, 0x00 = OFF
37+
return (data[4] & 0x02) != 0;
38+
} catch
39+
{
40+
return false;
41+
}
42+
43+
}
44+
}
45+
}

app/Display/VisualControl.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@ private static int RunSplendid(SplendidCommand command, int? param1 = null, int?
367367
bool isVivo = AppConfig.IsVivoZenPro();
368368
bool isSplenddid = File.Exists(splendidExe);
369369

370+
if (AmdDisplay.IsOledPowerOptimizationOnBattery())
371+
{
372+
Logger.WriteLine("Skipping command due to AMD OLED Power Optimization flag");
373+
return 1;
374+
}
375+
370376
if (isSplenddid)
371377
{
372378
var result = ProcessHelper.RunCMD(splendidExe, (int)command + " " + param1 + " " + param2 + " " + param3, splendidPath);

0 commit comments

Comments
 (0)