diff -r 39ed1a16c32a -r 3c1cdc197b24 Hardware/ATI/ATIGPU.cs --- a/Hardware/ATI/ATIGPU.cs Sun Dec 28 22:42:36 2014 +0000 +++ b/Hardware/ATI/ATIGPU.cs Tue Dec 30 16:02:52 2014 +0000 @@ -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 + Copyright (C) 2009-2014 Michael Möller */ @@ -24,10 +24,7 @@ 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 @@ 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 @@ } 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 @@ this.fanControl.SoftwareControlValueChanged -= SoftwareControlValueChanged; - RestoreDefaultFanSpeed(); + if (this.fanControl.ControlMode != ControlMode.Undefined) + SetDefaultFanSpeed(); base.Close(); } }