Skip to content

Commit

Permalink
add support for AMD GPU's, improve WOL, refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
Maassoft committed Mar 20, 2021
1 parent 7f6175f commit a33543a
Show file tree
Hide file tree
Showing 26 changed files with 2,284 additions and 1,069 deletions.
326 changes: 94 additions & 232 deletions ColorControl/ADL.cs

Large diffs are not rendered by default.

335 changes: 283 additions & 52 deletions ColorControl/ADLWrapper.cs

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions ColorControl/AmdDisplayInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using ATI.ADL;
using System.Collections.Generic;

namespace ColorControl
{
class AmdDisplayInfo
{
public ADLDisplayInfo Display { get; }

public List<string> Values { get; }

public string InfoLine { get; }

public AmdDisplayInfo(ADLDisplayInfo display, List<string> values, string infoLine)
{
Display = display;
Values = values;
InfoLine = infoLine;
}
}
}
91 changes: 19 additions & 72 deletions ColorControl/AmdPreset.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NvAPIWrapper.Display;
using NvAPIWrapper.Native.Display;
using System;
using System;
using System.Collections.Generic;
using System.Text;

Expand All @@ -9,12 +7,13 @@ namespace ColorControl
class AmdPreset : PresetBase
{
public bool applyColorData { get; set; }
public ColorData colorData { get; set; }
public ADLColorDepth colorDepth { get; set; }
public ADLPixelFormat pixelFormat { get; set; }
public bool applyHDR { get; set; }
public bool HDREnabled { get; set; }
public bool toggleHDR { get; set; }
public bool applyDithering { get; set; }
public bool ditheringEnabled { get; set; }
public ADLDitherState ditherState { get; set; }
public bool applyRefreshRate { get; set; }
public uint refreshRate { get; set; }
public bool primaryDisplay { get; set; }
Expand All @@ -24,7 +23,7 @@ public AmdPreset()
{
applyColorData = true;
applyDithering = false;
ditheringEnabled = true;
ditherState = ADLDitherState.DRIVER_DEFAULT;
applyHDR = false;
HDREnabled = false;
toggleHDR = false;
Expand All @@ -33,28 +32,22 @@ public AmdPreset()
primaryDisplay = true;
}

public AmdPreset(ColorData colorData) : this()
{
id = GetNewId();
this.colorData = colorData;
}

public AmdPreset(AmdPreset preset): this()
{
id = GetNewId();

primaryDisplay = preset.primaryDisplay;
displayName = preset.displayName;

var colorData = preset.colorData;
this.colorData = new ColorData(colorData.ColorFormat, dynamicRange: colorData.DynamicRange, colorDepth: colorData.ColorDepth, colorSelectionPolicy: colorData.SelectionPolicy);
applyColorData = preset.applyColorData;
colorDepth = preset.colorDepth;
pixelFormat = preset.pixelFormat;

applyHDR = preset.applyHDR;
HDREnabled = preset.HDREnabled;
toggleHDR = preset.toggleHDR;
applyDithering = preset.applyDithering;
ditheringEnabled = preset.ditheringEnabled;
ditherState = preset.ditherState;
applyRefreshRate = preset.applyRefreshRate;
refreshRate = preset.refreshRate;
}
Expand All @@ -69,28 +62,24 @@ public AmdPreset Clone()
public static string[] GetColumnNames()
{
//return new[] { "BPC", "Format", "Dynamic range", "Toggle HDR", "Shortcut" };
return new[] { "Display|140", "Color settings (BPC, format, dyn. range, color space)|260", "Refresh rate|100", "Dithering", "HDR", "Shortcut" };
return new[] { "Display|140", "Color settings (BPC, format)|260", "Refresh rate|100", "Dithering", "HDR", "Shortcut", "Apply on startup" };
}

public List<string> GetDisplayValues()
public override List<string> GetDisplayValues(Config config = null)
{
var values = new List<string>();

var display = string.Format("{0}", primaryDisplay ? "Primary" : displayName);
values.Add(display);

var colorSettings = string.Format("{0}: {1}, {2}, {3}, {4}", applyColorData ? "Included" : "Excluded", colorData.ColorDepth, colorData.ColorFormat, colorData.DynamicRange, colorData.Colorimetry);
var colorSettings = string.Format("{0}: {1}, {2}", applyColorData ? "Included" : "Excluded", colorDepth, pixelFormat);

values.Add(colorSettings);
values.Add(string.Format("{0}: {1}Hz", applyRefreshRate ? "Included" : "Excluded", refreshRate));
values.Add(string.Format("{0}: {1}", applyDithering ? "Included" : "Excluded", ditheringEnabled ? "Enabled" : "Disabled"));
values.Add(string.Format("{0}: {1}", applyDithering ? "Included" : "Excluded", ditherState));
values.Add(string.Format("{0}: {1}", applyHDR ? "Included" : "Excluded", toggleHDR ? "Toggle" : HDREnabled ? "Enabled" : "Disabled"));

//values.Add(colorData.ColorDepth.ToString());
//values.Add(colorData.ColorFormat.ToString());
//values.Add(colorData.DynamicRange.ToString());
//values.Add(toggleHDR.ToString());
values.Add(shortcut);
values.Add(string.Format("{0}", config?.AmdPresetId_ApplyOnStartup == id ? "Yes" : string.Empty));

return values;
}
Expand All @@ -99,21 +88,11 @@ public static List<AmdPreset> GetDefaultPresets()
{
var presets = new List<AmdPreset>();

presets.Add(new AmdPreset(new ColorData(ColorDataFormat.Auto, dynamicRange: ColorDataDynamicRange.Auto, colorDepth: ColorDataDepth.Default, colorSelectionPolicy: ColorDataSelectionPolicy.BestQuality)));

for (var dynamicRange = ColorDataDynamicRange.VESA; dynamicRange <= ColorDataDynamicRange.CEA; dynamicRange++)
{
presets.Add(new AmdPreset(new ColorData(ColorDataFormat.RGB, dynamicRange: dynamicRange, colorDepth: ColorDataDepth.BPC8, colorSelectionPolicy: ColorDataSelectionPolicy.User)));
presets.Add(new AmdPreset(new ColorData(ColorDataFormat.RGB, dynamicRange: dynamicRange, colorDepth: ColorDataDepth.BPC10, colorSelectionPolicy: ColorDataSelectionPolicy.User)));
presets.Add(new AmdPreset(new ColorData(ColorDataFormat.RGB, dynamicRange: dynamicRange, colorDepth: ColorDataDepth.BPC12, colorSelectionPolicy: ColorDataSelectionPolicy.User)));
}
var preset = new AmdPreset();
preset.colorDepth = ADLColorDepth.BPC8;
preset.pixelFormat = ADLPixelFormat.RGB_FULL_RANGE;

for (var format = ColorDataFormat.YUV422; format <= ColorDataFormat.YUV420; format++)
{
presets.Add(new AmdPreset(new ColorData(format, dynamicRange: ColorDataDynamicRange.Auto, colorDepth: ColorDataDepth.BPC8, colorSelectionPolicy: ColorDataSelectionPolicy.User)));
presets.Add(new AmdPreset(new ColorData(format, dynamicRange: ColorDataDynamicRange.Auto, colorDepth: ColorDataDepth.BPC10, colorSelectionPolicy: ColorDataSelectionPolicy.User)));
presets.Add(new AmdPreset(new ColorData(format, dynamicRange: ColorDataDynamicRange.Auto, colorDepth: ColorDataDepth.BPC12, colorSelectionPolicy: ColorDataSelectionPolicy.User)));
}
presets.Add(preset);

return presets;
}
Expand All @@ -127,7 +106,7 @@ public string GetTextForMenuItem()
}
if (applyColorData)
{
var colorSettings = string.Format("Format: {0}, {1}, {2}", colorData.ColorDepth, colorData.ColorFormat, colorData.DynamicRange);
var colorSettings = string.Format("Format: {0}, {1}", colorDepth, pixelFormat);
sb.Append(colorSettings);
sb.Append(" / ");
}
Expand All @@ -138,7 +117,7 @@ public string GetTextForMenuItem()
}
if (applyDithering)
{
sb.AppendFormat("Dithering: {0}", ditheringEnabled ? "Yes" : "No");
sb.AppendFormat("Dithering: {0}", ditherState);
sb.Append(" / ");
}
if (applyHDR)
Expand All @@ -149,38 +128,6 @@ public string GetTextForMenuItem()

return sb.ToString(0, Math.Max(0, sb.Length - 3));
}

public static ColorData GenerateColorData(IDictionary<string, object> dictionary)
{
var format = ColorDataFormat.RGB;
var dynamicRange = ColorDataDynamicRange.VESA;
var colorDepth = ColorDataDepth.BPC8;
var colorimetry = ColorDataColorimetry.Auto;
var selectionPolicy = ColorDataSelectionPolicy.User;
object value;
if (dictionary.TryGetValue("ColorFormat", out value))
{
format = (ColorDataFormat)Enum.ToObject(typeof(ColorDataFormat), value);
}
if (dictionary.TryGetValue("ColorDepth", out value))
{
colorDepth = (ColorDataDepth)Enum.ToObject(typeof(ColorDataDepth), value);
}
if (dictionary.TryGetValue("Colorimetry", out value))
{
colorimetry = (ColorDataColorimetry)Enum.ToObject(typeof(ColorDataColorimetry), value);
}
if (dictionary.TryGetValue("DynamicRange", out value))
{
dynamicRange = (ColorDataDynamicRange)Enum.ToObject(typeof(ColorDataDynamicRange), value);
}
if (dictionary.TryGetValue("SelectionPolicy", out value))
{
selectionPolicy = (ColorDataSelectionPolicy)Enum.ToObject(typeof(ColorDataSelectionPolicy), value);
}
return new ColorData(format, dynamicRange: dynamicRange, colorimetry: colorimetry, colorDepth: colorDepth, colorSelectionPolicy: selectionPolicy);
}

}
}

Loading

0 comments on commit a33543a

Please sign in to comment.