On Thu, Aug 21, 2014 at 10:44:36AM +0200, Sébastien Marie wrote:
> Hi,
> 
> Another possibility (not tested) should be to change active cooling code
> to permit call acpitz_setfan(OFF) when sc_ac_stat == -1.
> 

Next is the patch that implement the other possibility (the code is
running, currently fan switchs ON and OFF following the temperature...)

The decision of call acpitz_setfan is now based on explicit values for
power status (as the ACPI spec define only two values: 0=OFF and 1=ON).

It should be valid if ACPI implementations don't use others values for
_STA... but I don't known (and previous code check >0 for ON, not just
==1).

The logic in pseudo code:

if active-point-temperature is valid (!= -1)
  if active-point-temperature <= current-temperature (temperature over 
active-point: active cooling need)
    if power-status != ON
      setfan(ON)
  else
    if power-status != OFF
      setfan(OFF)

-- 
Sébastien Marie

Index: src-sys-current/dev/acpi/acpitz.c
===================================================================
--- src-sys-current.orig/dev/acpi/acpitz.c
+++ src-sys-current/dev/acpi/acpitz.c
@@ -417,17 +417,20 @@ acpitz_refresh(void *arg)
        sc->sc_lasttmp = sc->sc_tmp;
 
        /* active cooling */
-       for (i = 0; i < ACPITZ_MAX_AC; i++) {
-               if (sc->sc_ac[i] != -1 && sc->sc_ac[i] <= sc->sc_tmp) {
-                       /* turn on fan i */
-                       if (sc->sc_ac_stat[i] <= 0)
-                               acpitz_setfan(sc, i, "_ON_");
-               } else if (sc->sc_ac[i] != -1) {
-                       /* turn off fan i */
-                       if (sc->sc_ac_stat[i] > 0)
-                               acpitz_setfan(sc, i, "_OFF");
+       for (i = 0; i < ACPITZ_MAX_AC; i++)
+               if (sc->sc_ac[i] != -1 ) {
+                       if (sc->sc_ac[i] <= sc->sc_tmp) {
+                               if (sc->sc_ac_stat[i] != 1)
+                                       /* turn on fan i */
+                                       acpitz_setfan(sc, i, "_ON_");
+
+                       } else {
+                               if (sc->sc_ac_stat[i] != 0)
+                                       /* turn off fan i */
+                                       acpitz_setfan(sc, i, "_OFF");
+                       }
                }
-       }
+       
        sc->sc_sens.value = sc->sc_tmp * 100000 - 50000;
 }
 

Reply via email to