mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-22 09:57:20 +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
|
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/.
|
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 coreVoltage;
|
||||||
private readonly Sensor coreLoad;
|
private readonly Sensor coreLoad;
|
||||||
private readonly Sensor controlSensor;
|
private readonly Sensor controlSensor;
|
||||||
private readonly Control fanControl;
|
private readonly Control fanControl;
|
||||||
|
|
||||||
private bool restoreDefaultFanSpeedRequired = false;
|
|
||||||
private ADLFanSpeedValue initialFanSpeedValue;
|
|
||||||
|
|
||||||
public ATIGPU(string name, int adapterIndex, int busNumber,
|
public ATIGPU(string name, int adapterIndex, int busNumber,
|
||||||
int deviceNumber, ISettings settings)
|
int deviceNumber, ISettings settings)
|
||||||
@ -64,31 +61,8 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
Update();
|
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) {
|
private void SoftwareControlValueChanged(IControl control) {
|
||||||
if (control.ControlMode == ControlMode.Software) {
|
if (control.ControlMode == ControlMode.Software) {
|
||||||
SaveDefaultFanSpeed();
|
|
||||||
ADLFanSpeedValue adlf = new ADLFanSpeedValue();
|
ADLFanSpeedValue adlf = new ADLFanSpeedValue();
|
||||||
adlf.SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
|
adlf.SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
|
||||||
adlf.Flags = ADL.ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
|
adlf.Flags = ADL.ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
|
||||||
@ -98,13 +72,24 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ControlModeChanged(IControl control) {
|
private void ControlModeChanged(IControl control) {
|
||||||
if (control.ControlMode == ControlMode.Default) {
|
switch (control.ControlMode) {
|
||||||
RestoreDefaultFanSpeed();
|
case ControlMode.Undefined:
|
||||||
} else {
|
return;
|
||||||
SoftwareControlValueChanged(control);
|
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 BusNumber { get { return busNumber; } }
|
||||||
|
|
||||||
public int DeviceNumber { get { return deviceNumber; } }
|
public int DeviceNumber { get { return deviceNumber; } }
|
||||||
@ -186,7 +171,8 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
|||||||
this.fanControl.SoftwareControlValueChanged -=
|
this.fanControl.SoftwareControlValueChanged -=
|
||||||
SoftwareControlValueChanged;
|
SoftwareControlValueChanged;
|
||||||
|
|
||||||
RestoreDefaultFanSpeed();
|
if (this.fanControl.ControlMode != ControlMode.Undefined)
|
||||||
|
SetDefaultFanSpeed();
|
||||||
base.Close();
|
base.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
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/.
|
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;
|
int mode;
|
||||||
if (!int.TryParse(settings.GetValue(
|
if (!int.TryParse(settings.GetValue(
|
||||||
new Identifier(identifier, "mode").ToString(),
|
new Identifier(identifier, "mode").ToString(),
|
||||||
((int)ControlMode.Default).ToString(CultureInfo.InvariantCulture)),
|
((int)ControlMode.Undefined).ToString(CultureInfo.InvariantCulture)),
|
||||||
NumberStyles.Integer, CultureInfo.InvariantCulture,
|
NumberStyles.Integer, CultureInfo.InvariantCulture,
|
||||||
out mode))
|
out mode))
|
||||||
{
|
{
|
||||||
this.mode = ControlMode.Default;
|
this.mode = ControlMode.Undefined;
|
||||||
} else {
|
} else {
|
||||||
this.mode = (ControlMode)mode;
|
this.mode = (ControlMode)mode;
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,16 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
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/.
|
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 {
|
namespace OpenHardwareMonitor.Hardware {
|
||||||
|
|
||||||
public enum ControlMode {
|
public enum ControlMode {
|
||||||
Default,
|
Undefined,
|
||||||
Software
|
Software,
|
||||||
|
Default
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IControl {
|
public interface IControl {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
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/.
|
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);
|
this, settings);
|
||||||
Control control = new Control(sensor, settings, 0, 100);
|
Control control = new Control(sensor, settings, 0, 100);
|
||||||
control.ControlModeChanged += (cc) => {
|
control.ControlModeChanged += (cc) => {
|
||||||
if (cc.ControlMode == ControlMode.Default) {
|
switch (cc.ControlMode) {
|
||||||
superIO.SetControl(index, null);
|
case ControlMode.Undefined:
|
||||||
} else {
|
return;
|
||||||
superIO.SetControl(index, (byte)(cc.SoftwareValue * 2.55));
|
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) => {
|
control.SoftwareControlValueChanged += (cc) => {
|
||||||
if (cc.ControlMode == ControlMode.Software)
|
if (cc.ControlMode == ControlMode.Software)
|
||||||
superIO.SetControl(index, (byte)(cc.SoftwareValue * 2.55));
|
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;
|
sensor.Control = control;
|
||||||
controls.Add(sensor);
|
controls.Add(sensor);
|
||||||
ActivateSensor(sensor);
|
ActivateSensor(sensor);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
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/.
|
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
|
Copyright (C) 2011 Christian Vallières
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -28,9 +28,6 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
|||||||
private readonly Sensor memoryLoad;
|
private readonly Sensor memoryLoad;
|
||||||
private readonly Control fanControl;
|
private readonly Control fanControl;
|
||||||
|
|
||||||
private bool restoreDefaultFanSpeedRequired;
|
|
||||||
private NvLevel initialFanSpeedValue;
|
|
||||||
|
|
||||||
public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
|
public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
|
||||||
NvDisplayHandle? displayHandle, ISettings settings)
|
NvDisplayHandle? displayHandle, ISettings settings)
|
||||||
: base(GetName(handle), new Identifier("nvidiagpu",
|
: base(GetName(handle), new Identifier("nvidiagpu",
|
||||||
@ -431,7 +428,6 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void SoftwareControlValueChanged(IControl control) {
|
private void SoftwareControlValueChanged(IControl control) {
|
||||||
SaveDefaultFanSpeed();
|
|
||||||
NvGPUCoolerLevels coolerLevels = new NvGPUCoolerLevels();
|
NvGPUCoolerLevels coolerLevels = new NvGPUCoolerLevels();
|
||||||
coolerLevels.Version = NVAPI.GPU_COOLER_LEVELS_VER;
|
coolerLevels.Version = NVAPI.GPU_COOLER_LEVELS_VER;
|
||||||
coolerLevels.Levels = new NvLevel[NVAPI.MAX_COOLER_PER_GPU];
|
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);
|
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) {
|
private void ControlModeChanged(IControl control) {
|
||||||
if (control.ControlMode == ControlMode.Default) {
|
switch (control.ControlMode) {
|
||||||
RestoreDefaultFanSpeed();
|
case ControlMode.Undefined:
|
||||||
} else {
|
return;
|
||||||
SoftwareControlValueChanged(control);
|
case ControlMode.Default:
|
||||||
|
SetDefaultFanSpeed();
|
||||||
|
break;
|
||||||
|
case ControlMode.Software:
|
||||||
|
SoftwareControlValueChanged(control);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RestoreDefaultFanSpeed() {
|
private void SetDefaultFanSpeed() {
|
||||||
if (restoreDefaultFanSpeedRequired) {
|
NvGPUCoolerLevels coolerLevels = new NvGPUCoolerLevels();
|
||||||
NvGPUCoolerLevels coolerLevels = new NvGPUCoolerLevels();
|
coolerLevels.Version = NVAPI.GPU_COOLER_LEVELS_VER;
|
||||||
coolerLevels.Version = NVAPI.GPU_COOLER_LEVELS_VER;
|
coolerLevels.Levels = new NvLevel[NVAPI.MAX_COOLER_PER_GPU];
|
||||||
coolerLevels.Levels = new NvLevel[NVAPI.MAX_COOLER_PER_GPU];
|
coolerLevels.Levels[0].Policy = 0x20;
|
||||||
coolerLevels.Levels[0] = initialFanSpeedValue;
|
NVAPI.NvAPI_GPU_SetCoolerLevels(handle, 0, ref coolerLevels);
|
||||||
NVAPI.NvAPI_GPU_SetCoolerLevels(handle, 0, ref coolerLevels);
|
}
|
||||||
restoreDefaultFanSpeedRequired = false;
|
|
||||||
|
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
|
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/.
|
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;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion("0.6.0.15")]
|
[assembly: AssemblyVersion("0.6.0.16")]
|
||||||
[assembly: AssemblyInformationalVersion("0.6.0.15 Alpha")]
|
[assembly: AssemblyInformationalVersion("0.6.0.16 Alpha")]
|
Loading…
x
Reference in New Issue
Block a user