1.1 --- a/Hardware/ATI/ATIGPU.cs Sun Dec 28 22:42:36 2014 +0000
1.2 +++ b/Hardware/ATI/ATIGPU.cs Tue Dec 30 16:02:52 2014 +0000
1.3 @@ -4,7 +4,7 @@
1.4 License, v. 2.0. If a copy of the MPL was not distributed with this
1.5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
1.6
1.7 - Copyright (C) 2009-2011 Michael Möller <mmoeller@openhardwaremonitor.org>
1.8 + Copyright (C) 2009-2014 Michael Möller <mmoeller@openhardwaremonitor.org>
1.9
1.10 */
1.11
1.12 @@ -24,10 +24,7 @@
1.13 private readonly Sensor coreVoltage;
1.14 private readonly Sensor coreLoad;
1.15 private readonly Sensor controlSensor;
1.16 - private readonly Control fanControl;
1.17 -
1.18 - private bool restoreDefaultFanSpeedRequired = false;
1.19 - private ADLFanSpeedValue initialFanSpeedValue;
1.20 + private readonly Control fanControl;
1.21
1.22 public ATIGPU(string name, int adapterIndex, int busNumber,
1.23 int deviceNumber, ISettings settings)
1.24 @@ -64,31 +61,8 @@
1.25 Update();
1.26 }
1.27
1.28 - private void SaveDefaultFanSpeed() {
1.29 - if (!restoreDefaultFanSpeedRequired) {
1.30 - initialFanSpeedValue = new ADLFanSpeedValue();
1.31 - initialFanSpeedValue.SpeedType =
1.32 - ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
1.33 - restoreDefaultFanSpeedRequired =
1.34 - ADL.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0,
1.35 - ref initialFanSpeedValue) == ADL.ADL_OK;
1.36 - }
1.37 - }
1.38 -
1.39 - private void RestoreDefaultFanSpeed() {
1.40 - if (restoreDefaultFanSpeedRequired) {
1.41 - ADL.ADL_Overdrive5_FanSpeed_Set(adapterIndex, 0,
1.42 - ref this.initialFanSpeedValue);
1.43 - if ((initialFanSpeedValue.Flags &
1.44 - ADL.ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) == 0)
1.45 - ADL.ADL_Overdrive5_FanSpeedToDefault_Set(adapterIndex, 0);
1.46 - restoreDefaultFanSpeedRequired = false;
1.47 - }
1.48 - }
1.49 -
1.50 private void SoftwareControlValueChanged(IControl control) {
1.51 - if (control.ControlMode == ControlMode.Software) {
1.52 - SaveDefaultFanSpeed();
1.53 + if (control.ControlMode == ControlMode.Software) {
1.54 ADLFanSpeedValue adlf = new ADLFanSpeedValue();
1.55 adlf.SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
1.56 adlf.Flags = ADL.ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
1.57 @@ -98,13 +72,24 @@
1.58 }
1.59
1.60 private void ControlModeChanged(IControl control) {
1.61 - if (control.ControlMode == ControlMode.Default) {
1.62 - RestoreDefaultFanSpeed();
1.63 - } else {
1.64 - SoftwareControlValueChanged(control);
1.65 + switch (control.ControlMode) {
1.66 + case ControlMode.Undefined:
1.67 + return;
1.68 + case ControlMode.Default:
1.69 + SetDefaultFanSpeed();
1.70 + break;
1.71 + case ControlMode.Software:
1.72 + SoftwareControlValueChanged(control);
1.73 + break;
1.74 + default:
1.75 + return;
1.76 }
1.77 }
1.78
1.79 + private void SetDefaultFanSpeed() {
1.80 + ADL.ADL_Overdrive5_FanSpeedToDefault_Set(adapterIndex, 0);
1.81 + }
1.82 +
1.83 public int BusNumber { get { return busNumber; } }
1.84
1.85 public int DeviceNumber { get { return deviceNumber; } }
1.86 @@ -186,7 +171,8 @@
1.87 this.fanControl.SoftwareControlValueChanged -=
1.88 SoftwareControlValueChanged;
1.89
1.90 - RestoreDefaultFanSpeed();
1.91 + if (this.fanControl.ControlMode != ControlMode.Undefined)
1.92 + SetDefaultFanSpeed();
1.93 base.Close();
1.94 }
1.95 }