lkml.org 
[lkml]   [1999]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectNEW APM patch (spelling error corrected)
some spelling error (baterry -> battery)


============= PATCH =============

--- linux.old/arch/i386/config.in Thu Sep 30 21:00:24 1999
+++ linux/arch/i386/config.in Thu Sep 30 21:08:29 1999
@@ -114,6 +114,7 @@
bool ' Ignore multiple suspend/resume cycles' CONFIG_APM_IGNORE_SUSPEND_BOUNCE
bool ' RTC stores time in GMT' CONFIG_APM_RTC_IS_GMT
bool ' Allow interrupts during APM BIOS calls' CONFIG_APM_ALLOW_INTS
+ bool ' Compute Battery time left (when BIOS do not provide the info)' CONFIG_APM_COMPUTE_TIME_LEFT
fi

endmenu
--- linux.old/arch/i386/kernel/apm.c Tue Sep 21 21:23:47 1999
+++ linux/arch/i386/kernel/apm.c Thu Sep 30 21:01:53 1999
@@ -90,6 +90,9 @@
* Use CONFIG_SMP instead of __SMP__
* Ignore BOUNCES for three seconds.
* Stephen Rothwell
+ * 1.10?:Added computing of possible time left for the battery
+ * when the bios return only the the % of the battery.
+ * Franck Sicard <Franck.Sicard@solsoft.fr>
*
* APM 1.1 Reference:
*
@@ -128,6 +131,7 @@
#include <linux/miscdevice.h>
#include <linux/apm_bios.h>
#include <linux/init.h>
+#include <linux/sched.h>

#include <asm/system.h>
#include <asm/uaccess.h>
@@ -1178,6 +1182,10 @@
return 0;
}

+#ifdef CONFIG_APM_COMPUTE_TIME_LEFT
+static int compute_battery_life(int battery_percentage);
+#endif
+
int apm_get_info(char *buf, char **start, off_t fpos, int length, int dummy)
{
char * p;
@@ -1210,6 +1218,12 @@
time_units = dx & 0x7fff;
}
}
+#ifdef CONFIG_APM_COMPUTE_TIME_LEFT
+ if ((percentage !=-1) && (time_units==-1)) {
+ time_units=compute_battery_life(percentage);
+ units="min";
+ }
+#endif
}
/* Arguments, with symbols from linux/apm_bios.h. Information is
from the Get Power Status (0x0a) call unless otherwise noted.
@@ -1473,3 +1487,38 @@

apm_enabled = 1;
}
+
+#ifdef CONFIG_APM_COMPUTE_TIME_LEFT
+/* compute time left battery for buggy
+ * APM Bios (=my gateway 3100)
+ */
+static int compute_battery_life(int battery_percentage)
+{
+ static int old_battery_percentage=-1;
+ static int old_time=0;
+ int new_time;
+ static int time_left;
+
+ if (battery_percentage != old_battery_percentage) {
+ new_time=CURRENT_TIME;
+ if (old_battery_percentage == -1) {
+ /* first call */
+ time_left= -1;
+ } else {
+ /* computing the number of second for 1 % */
+ time_left = (new_time - old_time)/(battery_percentage-old_battery_percentage);
+ /* computing the time left */
+ if (time_left<0) {
+ time_left *=-battery_percentage;
+ } else {
+ time_left *= (100- battery_percentage);
+ }
+ }
+ time_left/=60 /* time left in minutes */;
+ old_battery_percentage = battery_percentage;
+ old_time=new_time;
+ //printk(KERN_INFO "apm: time left %d%% at %d = %ds\n",old_battery_percentage,old_time,time_left);
+ }
+ return time_left;
+}
+#endif
--- linux.old/Documentation/Configure.help Thu Sep 30 21:00:04 1999
+++ linux/Documentation/Configure.help Thu Sep 30 21:07:57 1999
@@ -8993,6 +8993,13 @@
many of the newer IBM Thinkpads. If you experience hangs when you
suspend, try setting this to Y. Otherwise, say N.

+Compute Battery time left (when BIOS do not provide the info)
+CONFIG_APM_COMPUTE_TIME_LEFT
+ if you BIOS doesn't report the time left of your battery, but report
+ the current capacity of the battery, the kernel will compute an
+ estimation of the battery time left. Should be left to N with a
+ good BIOS.
+
Watchdog Timer Support
CONFIG_WATCHDOG
If you say Y here (and to one of the following options) and create a
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.071 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site