mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-22 01:47:36 +00:00
Added a new "Undefined" control mode. Changed the GPU fan control to restore to default (auto) settings when the Open Hardware Monitor closes (unless the control remained in "Undefined" mode).
This commit is contained in:
parent
9eee90c076
commit
dc69a9431c
@ -4,7 +4,7 @@
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
Copyright (C) 2009-2011 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
Copyright (C) 2009-2014 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
|
||||
*/
|
||||
|
||||
@ -24,10 +24,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
private readonly Sensor coreVoltage;
|
||||
private readonly Sensor coreLoad;
|
||||
private readonly Sensor controlSensor;
|
||||
private readonly Control fanControl;
|
||||
|
||||
private bool restoreDefaultFanSpeedRequired = false;
|
||||
private ADLFanSpeedValue initialFanSpeedValue;
|
||||
private readonly Control fanControl;
|
||||
|
||||
public ATIGPU(string name, int adapterIndex, int busNumber,
|
||||
int deviceNumber, ISettings settings)
|
||||
@ -64,31 +61,8 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
Update();
|
||||
}
|
||||
|
||||
private void SaveDefaultFanSpeed() {
|
||||
if (!restoreDefaultFanSpeedRequired) {
|
||||
initialFanSpeedValue = new ADLFanSpeedValue();
|
||||
initialFanSpeedValue.SpeedType =
|
||||
ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
|
||||
restoreDefaultFanSpeedRequired =
|
||||
ADL.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0,
|
||||
ref initialFanSpeedValue) == ADL.ADL_OK;
|
||||
}
|
||||
}
|
||||
|
||||
private void RestoreDefaultFanSpeed() {
|
||||
if (restoreDefaultFanSpeedRequired) {
|
||||
ADL.ADL_Overdrive5_FanSpeed_Set(adapterIndex, 0,
|
||||
ref this.initialFanSpeedValue);
|
||||
if ((initialFanSpeedValue.Flags &
|
||||
ADL.ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) == 0)
|
||||
ADL.ADL_Overdrive5_FanSpeedToDefault_Set(adapterIndex, 0);
|
||||
restoreDefaultFanSpeedRequired = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SoftwareControlValueChanged(IControl control) {
|
||||
if (control.ControlMode == ControlMode.Software) {
|
||||
SaveDefaultFanSpeed();
|
||||
if (control.ControlMode == ControlMode.Software) {
|
||||
ADLFanSpeedValue adlf = new ADLFanSpeedValue();
|
||||
adlf.SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
|
||||
adlf.Flags = ADL.ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
|
||||
@ -98,13 +72,24 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
}
|
||||
|
||||
private void ControlModeChanged(IControl control) {
|
||||
if (control.ControlMode == ControlMode.Default) {
|
||||
RestoreDefaultFanSpeed();
|
||||
} else {
|
||||
SoftwareControlValueChanged(control);
|
||||
switch (control.ControlMode) {
|
||||
case ControlMode.Undefined:
|
||||
return;
|
||||
case ControlMode.Default:
|
||||
SetDefaultFanSpeed();
|
||||
break;
|
||||
case ControlMode.Software:
|
||||
SoftwareControlValueChanged(control);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetDefaultFanSpeed() {
|
||||
ADL.ADL_Overdrive5_FanSpeedToDefault_Set(adapterIndex, 0);
|
||||
}
|
||||
|
||||
public int BusNumber { get { return busNumber; } }
|
||||
|
||||
public int DeviceNumber { get { return deviceNumber; } }
|
||||
@ -186,7 +171,8 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
this.fanControl.SoftwareControlValueChanged -=
|
||||
SoftwareControlValueChanged;
|
||||
|
||||
RestoreDefaultFanSpeed();
|
||||
if (this.fanControl.ControlMode != ControlMode.Undefined)
|
||||
SetDefaultFanSpeed();
|
||||
base.Close();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
Copyright (C) 2010 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
Copyright (C) 2010-2014 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
|
||||
*/
|
||||
|
||||
@ -42,11 +42,11 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
int mode;
|
||||
if (!int.TryParse(settings.GetValue(
|
||||
new Identifier(identifier, "mode").ToString(),
|
||||
((int)ControlMode.Default).ToString(CultureInfo.InvariantCulture)),
|
||||
((int)ControlMode.Undefined).ToString(CultureInfo.InvariantCulture)),
|
||||
NumberStyles.Integer, CultureInfo.InvariantCulture,
|
||||
out mode))
|
||||
{
|
||||
this.mode = ControlMode.Default;
|
||||
this.mode = ControlMode.Undefined;
|
||||
} else {
|
||||
this.mode = (ControlMode)mode;
|
||||
}
|
||||
|
@ -4,15 +4,16 @@
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
Copyright (C) 2010 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
Copyright (C) 2010-2014 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
|
||||
*/
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
public enum ControlMode {
|
||||
Default,
|
||||
Software
|
||||
Undefined,
|
||||
Software,
|
||||
Default
|
||||
}
|
||||
|
||||
public interface IControl {
|
||||
|
@ -4,7 +4,7 @@
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
Copyright (C) 2009-2013 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
Copyright (C) 2009-2014 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
|
||||
*/
|
||||
|
||||
@ -72,18 +72,37 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
this, settings);
|
||||
Control control = new Control(sensor, settings, 0, 100);
|
||||
control.ControlModeChanged += (cc) => {
|
||||
if (cc.ControlMode == ControlMode.Default) {
|
||||
superIO.SetControl(index, null);
|
||||
} else {
|
||||
superIO.SetControl(index, (byte)(cc.SoftwareValue * 2.55));
|
||||
switch (cc.ControlMode) {
|
||||
case ControlMode.Undefined:
|
||||
return;
|
||||
case ControlMode.Default:
|
||||
superIO.SetControl(index, null);
|
||||
break;
|
||||
case ControlMode.Software:
|
||||
superIO.SetControl(index, (byte)(cc.SoftwareValue * 2.55));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
};
|
||||
control.SoftwareControlValueChanged += (cc) => {
|
||||
if (cc.ControlMode == ControlMode.Software)
|
||||
superIO.SetControl(index, (byte)(cc.SoftwareValue * 2.55));
|
||||
};
|
||||
if (control.ControlMode == ControlMode.Software)
|
||||
superIO.SetControl(index, (byte)(control.SoftwareValue * 2.55));
|
||||
|
||||
switch (control.ControlMode) {
|
||||
case ControlMode.Undefined:
|
||||
break;
|
||||
case ControlMode.Default:
|
||||
superIO.SetControl(index, null);
|
||||
break;
|
||||
case ControlMode.Software:
|
||||
superIO.SetControl(index, (byte)(control.SoftwareValue * 2.55));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
sensor.Control = control;
|
||||
controls.Add(sensor);
|
||||
ActivateSensor(sensor);
|
||||
|
@ -4,7 +4,7 @@
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
Copyright (C) 2009-2014 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
Copyright (C) 2011 Christian Vallières
|
||||
|
||||
*/
|
||||
@ -28,9 +28,6 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
private readonly Sensor memoryLoad;
|
||||
private readonly Control fanControl;
|
||||
|
||||
private bool restoreDefaultFanSpeedRequired;
|
||||
private NvLevel initialFanSpeedValue;
|
||||
|
||||
public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
|
||||
NvDisplayHandle? displayHandle, ISettings settings)
|
||||
: base(GetName(handle), new Identifier("nvidiagpu",
|
||||
@ -431,7 +428,6 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
}
|
||||
|
||||
private void SoftwareControlValueChanged(IControl control) {
|
||||
SaveDefaultFanSpeed();
|
||||
NvGPUCoolerLevels coolerLevels = new NvGPUCoolerLevels();
|
||||
coolerLevels.Version = NVAPI.GPU_COOLER_LEVELS_VER;
|
||||
coolerLevels.Levels = new NvLevel[NVAPI.MAX_COOLER_PER_GPU];
|
||||
@ -440,34 +436,39 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
NVAPI.NvAPI_GPU_SetCoolerLevels(handle, 0, ref coolerLevels);
|
||||
}
|
||||
|
||||
private void SaveDefaultFanSpeed() {
|
||||
if (!restoreDefaultFanSpeedRequired) {
|
||||
NvGPUCoolerSettings coolerSettings = GetCoolerSettings();
|
||||
if (coolerSettings.Count > 0) {
|
||||
restoreDefaultFanSpeedRequired = true;
|
||||
initialFanSpeedValue.Level = coolerSettings.Cooler[0].CurrentLevel;
|
||||
initialFanSpeedValue.Policy = coolerSettings.Cooler[0].CurrentPolicy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ControlModeChanged(IControl control) {
|
||||
if (control.ControlMode == ControlMode.Default) {
|
||||
RestoreDefaultFanSpeed();
|
||||
} else {
|
||||
SoftwareControlValueChanged(control);
|
||||
switch (control.ControlMode) {
|
||||
case ControlMode.Undefined:
|
||||
return;
|
||||
case ControlMode.Default:
|
||||
SetDefaultFanSpeed();
|
||||
break;
|
||||
case ControlMode.Software:
|
||||
SoftwareControlValueChanged(control);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void RestoreDefaultFanSpeed() {
|
||||
if (restoreDefaultFanSpeedRequired) {
|
||||
NvGPUCoolerLevels coolerLevels = new NvGPUCoolerLevels();
|
||||
coolerLevels.Version = NVAPI.GPU_COOLER_LEVELS_VER;
|
||||
coolerLevels.Levels = new NvLevel[NVAPI.MAX_COOLER_PER_GPU];
|
||||
coolerLevels.Levels[0] = initialFanSpeedValue;
|
||||
NVAPI.NvAPI_GPU_SetCoolerLevels(handle, 0, ref coolerLevels);
|
||||
restoreDefaultFanSpeedRequired = false;
|
||||
private void SetDefaultFanSpeed() {
|
||||
NvGPUCoolerLevels coolerLevels = new NvGPUCoolerLevels();
|
||||
coolerLevels.Version = NVAPI.GPU_COOLER_LEVELS_VER;
|
||||
coolerLevels.Levels = new NvLevel[NVAPI.MAX_COOLER_PER_GPU];
|
||||
coolerLevels.Levels[0].Policy = 0x20;
|
||||
NVAPI.NvAPI_GPU_SetCoolerLevels(handle, 0, ref coolerLevels);
|
||||
}
|
||||
|
||||
public override void Close() {
|
||||
if (this.fanControl != null) {
|
||||
this.fanControl.ControlModeChanged -= ControlModeChanged;
|
||||
this.fanControl.SoftwareControlValueChanged -=
|
||||
SoftwareControlValueChanged;
|
||||
|
||||
if (this.fanControl.ControlMode != ControlMode.Undefined)
|
||||
SetDefaultFanSpeed();
|
||||
}
|
||||
base.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
Copyright (C) 2009-2013 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
Copyright (C) 2009-2014 Michael Möller <mmoeller@openhardwaremonitor.org>
|
||||
|
||||
*/
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("0.6.0.15")]
|
||||
[assembly: AssemblyInformationalVersion("0.6.0.15 Alpha")]
|
||||
[assembly: AssemblyVersion("0.6.0.16")]
|
||||
[assembly: AssemblyInformationalVersion("0.6.0.16 Alpha")]
|
Loading…
x
Reference in New Issue
Block a user