public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hysteresis for active cooling
@ 2005-07-23 18:56 Sanjoy Mahajan
       [not found] ` <E1DwPAQ-0006Oa-FA-BgpFEFc6EmUvjq1vVebcCXE/jYh+Q74khca9k7ZVKlY@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Sanjoy Mahajan @ 2005-07-23 18:56 UTC (permalink / raw)
  To: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

My laptop's fan was turning on and off as the temperature crossed the
active trip point.  The patch below adds hysteresis: It turns off active
cooling only when the temperature falls, say, 2 C below the trip point.
Maybe the magic difference should be 5 degrees; I'd be curious what
setting suits people best.

Tested and working on my TP 600X (Debian 'etch', kernel 2.6.11.4,
original DSDT with fixes).  It patches cleanly against 2.6.13-rc3 and is
conceptually simple, so I'd hope it works there too.

-Sanjoy

`A society of sheep must in time beget a government of wolves.'
   - Bertrand de Jouvenal


--- linux/drivers/acpi/thermal.c.old	2005-03-17 16:40:04.000000000 -0500
+++ linux/drivers/acpi/thermal.c	2005-07-23 13:44:35.000000000 -0400
@@ -66,6 +66,8 @@
 #define ACPI_THERMAL_MAX_ACTIVE	10
 #define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65
 
+#define AC_HYSTERESIS 2		/* active-cooling hysteresis, in C */
+
 #define KELVIN_TO_CELSIUS(t)    (long)(((long)t-2732>=0) ? ((long)t-2732+5)/10 : ((long)t-2732-5)/10)
 #define CELSIUS_TO_KELVIN(t)	((t+273)*10)
 
@@ -625,8 +627,14 @@
 		 * ----------------
 		 * Turn OFF all cooling devices associated with this
 		 * threshold.
+                 *
+		 * With hysteresis: Turn off only when temp is
+		 * AC_HYSTERESIS [in C] below threshold.  Safer to
+		 * adjust fan-off rather than fan-on behavior.
 		 */
-		else if (active->flags.enabled) {
+		else if (active->flags.enabled &&
+			 KELVIN_TO_CELSIUS(tz->temperature) <=
+			 KELVIN_TO_CELSIUS(active->temperature) - AC_HYSTERESIS) {
 			for (j = 0; j < active->devices.count; j++) {
 				result = acpi_bus_set_power(active->devices.handles[j], ACPI_STATE_D3);
 				if (result) {


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-08-01  1:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-23 18:56 [PATCH] hysteresis for active cooling Sanjoy Mahajan
     [not found] ` <E1DwPAQ-0006Oa-FA-BgpFEFc6EmUvjq1vVebcCXE/jYh+Q74khca9k7ZVKlY@public.gmane.org>
2005-07-24  4:21   ` Francisco Figueiredo Jr.
     [not found]     ` <42E31751.4080802-/E1597aS9LRfJ/NunPodnw@public.gmane.org>
2005-07-25  3:08       ` Sanjoy Mahajan
     [not found]         ` <E1DwtK9-000275-00-KmINTRm7+bkRAIupTkoUWTYRy0cijUJx@public.gmane.org>
2005-07-25  9:07           ` Jamie Lentin
2005-07-26 18:59             ` Sanjoy Mahajan
2005-08-01  1:59             ` Francisco Figueiredo Jr.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox