amdgpu: update fan controller
This commit is contained in:
parent
72dfd33750
commit
2ae616758b
|
@ -18,7 +18,7 @@ bail() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
if ! [ -d $HWMON ]; then
|
||||
if ! [ -d "$HWMON" ]; then
|
||||
bail "Invalid HWMON"
|
||||
fi
|
||||
|
||||
|
@ -28,20 +28,31 @@ if ! [ -f $TEMP_INPUT ]; then
|
|||
bail "Invalid TEMP_INPUT"
|
||||
fi
|
||||
|
||||
MIN="$2"
|
||||
MAX="$3"
|
||||
TEMP_MIN="$2"
|
||||
TEMP_MAX="$3"
|
||||
|
||||
if [ -z "$TEMP_MIN" ];then
|
||||
bail "No minimum temperature provided"
|
||||
fi
|
||||
|
||||
if [ -z "$TEMP_MAX" ];then
|
||||
bail "No maximum temperature provided"
|
||||
fi
|
||||
|
||||
PWM_MIN=0
|
||||
PWM_MAX=255
|
||||
|
||||
echo "Running..." >&2
|
||||
while true; do
|
||||
TEMPERATURE_RAW=$(cat "$TEMP_INPUT")
|
||||
TEMPERATURE="$(( $TEMPERATURE_RAW / 1000 ))"
|
||||
# Remap from a number between 60_000..90_000 to 0..255
|
||||
PWM=$(( ($TEMPERATURE - $MIN) * 255 / ($MAX - $MIN) ))
|
||||
PWM=$(( ($TEMPERATURE - $TEMP_MIN) * $PWM_MAX / ($TEMP_MAX - $TEMP_MIN) ))
|
||||
|
||||
if [ "$PWM" -gt 255 ]; then
|
||||
PWM=255
|
||||
elif [ "$PWM" -lt 0 ]; then
|
||||
PWM=0
|
||||
if [ "$PWM" -gt $PWM_MAX ]; then
|
||||
PWM=$PWM_MAX
|
||||
elif [ "$PWM" -lt $PWM_MIN ]; then
|
||||
PWM=$PWM_MIN
|
||||
fi
|
||||
|
||||
echo 1 > "$HWMON/pwm1_enable"
|
||||
|
|
Loading…
Reference in a new issue