From owner-acpi-jp@jp.freebsd.org  Mon Dec 25 16:20:32 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id QAA46200;
	Mon, 25 Dec 2000 16:20:32 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from kbtfw.kubota.co.jp (firewall-user@kbtfw.kubota.co.jp [133.253.102.202])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id QAA46180;
	Mon, 25 Dec 2000 16:20:28 +0900 (JST)
	(envelope-from haro@tk.kubota.co.jp)
Received: by kbtfw.kubota.co.jp; id QAA10096; Mon, 25 Dec 2000 16:20:27 +0900 (JST)
Received: from unknown(133.253.122.4) by kbtfw.kubota.co.jp via smap (V4.2)
	id xma010061; Mon, 25 Dec 00 16:20:19 +0900
Received: from ktkl129.tk.kubota.co.jp (IDENT:root@kbtgk.eto.kubota.co.jp [133.253.122.3])
	by kbtmk.eto.kubota.co.jp (8.11.1/8.11.1) with ESMTP id eBP7KIJ78005;
	Mon, 25 Dec 2000 16:20:18 +0900 (JST)
Received: from jkpc15.tk.kubota.co.jp by ktkl129.tk.kubota.co.jp (8.6.13+2.4W/3.4W3-97053016)
	id QAA08403; Mon, 25 Dec 2000 16:18:37 +0900
Received: from localhost (localhost.tk.kubota.co.jp [127.0.0.1])
	by jkpc15.tk.kubota.co.jp (8.11.1/3.7W-02/21/99) with ESMTP id eBP7HxH00810;
	Mon, 25 Dec 2000 16:17:59 +0900 (JST)
To: iwasaki@jp.freebsd.org
Cc: acpi-jp@jp.freebsd.org
In-Reply-To: <20001225042054Q.iwasaki@jp.FreeBSD.org>
References: <200012241912.eBOJCBf17468@freefall.freebsd.org>
	<20001225042054Q.iwasaki@jp.FreeBSD.org>
X-Mailer: Mew version 1.94.1 on Emacs 20.7 / Mule 4.0 (HANANOEN)
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Mon_Dec_25_16:17:04_2000_809)--"
Content-Transfer-Encoding: 7bit
Message-Id: <20001225161759S.haro@tk.kubota.co.jp>
Date: Mon, 25 Dec 2000 16:17:59 +0900
From: Munehiro Matsuda <haro@tk.kubota.co.jp>
X-Dispatcher: imput version 20000228(IM140)
Lines: 113
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 996
Subject: [acpi-jp 996] Re: cvs commit: src/sys/dev/acpica acpi.c
 acpi_acad.c acpi_cmbat.c acpiio.h
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: haro@tk.kubota.co.jp

----Next_Part(Mon_Dec_25_16:17:04_2000_809)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
Date: Mon, 25 Dec 2000 04:20:54 +0900
::
::Updated acpibatt utility is available at
::http://people.freebsd.org/~iwasaki/acpi/acpibatt-20001225.tar.gz
::
::Matsuda-san, could you merge your latest patch if you have ?

Iwasaki-san,

Here's my updated patch. It should work with your PC now.

 Thanks,
  Haro
=------------------------------------------------------------------------------
           _ _    Munehiro (haro) Matsuda
 -|- /_\  |_|_|   Business Incubation Dept., Kubota Corp.
 /|\ |_|  |_|_|   1-3 Nihonbashi-Muromachi 3-Chome
                  Chuo-ku Tokyo 103-8310, Japan
                  Tel: +81-3-3245-3318  Fax: +81-3-3245-3315
                  Email: haro@kubota.co.jp

----Next_Part(Mon_Dec_25_16:17:04_2000_809)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="acpibatt.c.patch3"

Index: acpibatt.c
===================================================================
RCS file: /usr/CVS/src/usr.sbin/acpi/acpibatt/Attic/acpibatt.c,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 acpibatt.c
--- acpibatt.c	2000/12/25 01:19:41	1.1.2.4
+++ acpibatt.c	2000/12/25 07:12:29
@@ -162,9 +162,6 @@
 		argv += optind;
 	}
 
-	if (acpi_acad_status()) {
-		stat |= BATT_AC_ONLINE;
-	}
 	acpi_cmbat_get_units(&units);
 
 	bat = (struct cmbat_info *)malloc(sizeof(struct cmbat_info) * units);
@@ -191,18 +188,18 @@
 		if (bat[i].bst.rate > 0) {
 			/*
 			 * XXX Hack to calculate total battery time.
-			 * Systems with two or more battries, they get used
+			 * Systems with 2 or more battries, they may get used
 			 * one by one, thus bst.rate is set only to the one
 			 * in use. For remaining batteries bst.rate = 0, which
 			 * makes it impossible to calculate remaining time.
-			 *
-			 * There for we find the largest bst.rate that is
-			 * valid (the one in dis-charging state), and use its
-			 * value to calcutate remaining batteries' time.
+			 * Some other systems may need sum of bst.rate in 
+			 * dis-charging state.
+			 * There for we sum up the bst.rate that is valid
+			 * (in dis-charging state), and use the sum to
+			 * calcutate remaining batteries' time.
 			 */
-			if ((bat[i].bst.state & BATT_STAT_DISCHARG) &&
-			    (valid_rate < bat[i].bst.rate)) {
-				valid_rate = bat[i].bst.rate;
+			if (bat[i].bst.state & BATT_STAT_DISCHARG) {
+				valid_rate += bat[i].bst.rate;
 			}
 		}
 	}
@@ -218,21 +215,12 @@
 		if (bat[i].bst.state >= BATT_STAT_MAX)
 			break;
 
-		if (bat[i].bst.rate > 0) {
-			/* Do the proper way */
-			bat[i].min = 60 * bat[i].bst.cap / bat[i].bst.rate;
-#if 0
-			bat[i].min /= units;
-#endif
+		if (valid_rate > 0) {
+			/* Use the sum of bsd.rate */
+			bat[i].min = 60 * bat[i].bst.cap / valid_rate;
 		} else {
-			if (valid_rate != 0) {
-				/* We've found valid bst.rate, let's use it */
-				bat[i].min = 60 * bat[i].bst.cap / valid_rate;
-				bat[i].bst.rate = valid_rate;
-			} else {
-				/* Couldn't find valid bst.rate */
-				bat[i].min = 0;
-			}
+			/* Couldn't find valid rate */
+			bat[i].min = 0;
 		}
 		total_min += bat[i].min;
 		total_cap += bat[i].cap;
@@ -272,7 +260,7 @@
 		printf("\tRemaining battery life: %d%%\n", bat[i].cap);
 
 		printf("\tRemaining battery time: ");
-		if ((stat > 0) || (bat[i].bst.rate == 0)) {
+		if ((stat > 0) || (valid_rate == 0)) {
 			printf("unknown\n");
 		} else {
 			printf("%d minutes\n", bat[i].min);

----Next_Part(Mon_Dec_25_16:17:04_2000_809)----
