From owner-acpi-jp@jp.freebsd.org  Wed Dec 27 11:54:47 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id LAA38581;
	Wed, 27 Dec 2000 11:54:47 +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 LAA38566;
	Wed, 27 Dec 2000 11:54:43 +0900 (JST)
	(envelope-from haro@tk.kubota.co.jp)
Received: by kbtfw.kubota.co.jp; id LAA06059; Wed, 27 Dec 2000 11:54:41 +0900 (JST)
Received: from unknown(133.253.122.4) by kbtfw.kubota.co.jp via smap (V4.2)
	id xma005975; Wed, 27 Dec 00 11:53:47 +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 eBR2rlJ56017;
	Wed, 27 Dec 2000 11:53:47 +0900 (JST)
Received: from jkpc15.tk.kubota.co.jp by ktkl129.tk.kubota.co.jp (8.6.13+2.4W/3.4W3-97053016)
	id LAA16356; Wed, 27 Dec 2000 11:52:06 +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 eBR2pPo09481;
	Wed, 27 Dec 2000 11:51:25 +0900 (JST)
To: iwasaki@jp.freebsd.org
Cc: acpi-jp@jp.freebsd.org
In-Reply-To: <20001227024346T.iwasaki@jp.FreeBSD.org>
References: <20001222001625L.iwasaki@jp.FreeBSD.org>
	<200012261440.eBQEeZj86154@mass.osd.bsdi.com>
	<20001227024346T.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(Wed_Dec_27_11:49:47_2000_809)--"
Content-Transfer-Encoding: 7bit
Message-Id: <20001227115125L.haro@tk.kubota.co.jp>
Date: Wed, 27 Dec 2000 11:51:25 +0900
From: Munehiro Matsuda <haro@tk.kubota.co.jp>
X-Dispatcher: imput version 20000228(IM140)
Lines: 173
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 1003
Subject: [acpi-jp 1003] Re: Generalised power-management interface (was
 Re: Some power device driver. ) 
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: haro@tk.kubota.co.jp

----Next_Part(Wed_Dec_27_11:49:47_2000_809)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
Date: Wed, 27 Dec 2000 02:43:46 +0900
::http://people.FreeBSD.org/~iwasaki/acpi/power-20001227.tar.gz
::
::This includes generalized power management interface of acpi_cmbat
::ported Matsuda-san's acpibatt with some modifications, and
::standby/suspend/hibernation state transition (of course I made things
::simple :-).
::Also I added new options to acpibatt to set/get full charged battery
::time to/from acpi_cmbat so that acpibatt calculate battery time event
::when acline is on-line.
::
::Matsuda-san, I made changes on acpibatt utility, mainly cleanup.
::Could you check them?

Hi,

For the main part, it seems ok.

But:
1) I would like to change acpibatt's 'Remaing time' format to 'hh:mm:00'.
  Because, apm and power commands use 'hh:mm:ss' format for remaning time,
  why should acpibatt be different?

2) The kernel has included the main time calculation part, why should we
   duplicate the same code (or almost same) in user-land? 

3) Acpibatt dumps core. :-)
   # acpibatt -s 1
   Segmentation fault (core dumped)
   # 

  Also, I'm not sure if getopt(..,"s::") is a valid usage.

For other part of power-20001227.tar.gz:

4) Some of the ioctl's in acpiio.h should be _IOR()?

5) 'make depend' fails with libpower and power command.

6) The power command reports 'Remaining battey time' to be "unknown"
   even when apcibatt suceeds.
   If I do 'acpibatt -s [01] 0', after that power command seems to work.

   I think it's caused by the following line in sys/dev/acpica/acpi.c,
   that bat[unit].min is not calculated before:

   1489         if (bat[unit].min > 0) {
   1490                 info->batt_time = 60 * bat[unit].min;
   1491         } else {
   1492                 info->batt_time = POWER_BATT_TIME_UNKNOWN;
   1493         }
   
   I'm not sure what's the correct way to fix it. :-(

  Hope this helps,
   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(Wed_Dec_27_11:49:47_2000_809)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="power.patch1"

diff -ru ./lib/libpower/Makefile /usr/src/lib/libpower/Makefile
--- ./lib/libpower/Makefile	Wed Dec 27 00:41:56 2000
+++ /usr/src/lib/libpower/Makefile	Wed Dec 27 09:31:36 2000
@@ -9,7 +9,7 @@
 SRCS=		libpower.c
 INCS=		libpower.h
 
-CFLAGS+=	-I../../sys
+CFLAGS+=	-I${.CURDIR}/../../sys
 
 .include <bsd.lib.mk>
 
diff -ru ./sys/dev/acpica/acpiio.h /usr/src/sys/dev/acpica/acpiio.h
--- ./sys/dev/acpica/acpiio.h	Wed Dec 27 10:48:02 2000
+++ /usr/src/sys/dev/acpica/acpiio.h	Wed Dec 27 11:16:22 2000
@@ -81,10 +81,10 @@
 } while (0)
 
 #define ACPIIO_CMBAT_GET_UNITS	_IOR('B', 1, int)
-#define ACPIIO_CMBAT_GET_BIF	_IOWR('B', 2, union acpi_cmbat_ioctl_arg)
-#define ACPIIO_CMBAT_GET_BST	_IOWR('B', 3, union acpi_cmbat_ioctl_arg)
+#define ACPIIO_CMBAT_GET_BIF	_IOR('B', 2, union acpi_cmbat_ioctl_arg)
+#define ACPIIO_CMBAT_GET_BST	_IOR('B', 3, union acpi_cmbat_ioctl_arg)
 #define ACPIIO_CMBAT_SET_FULL_BATT _IOWR('B', 4, union acpi_cmbat_ioctl_arg)
-#define ACPIIO_CMBAT_GET_FULL_BATT _IOWR('B', 5, union acpi_cmbat_ioctl_arg)
+#define ACPIIO_CMBAT_GET_FULL_BATT _IOR('B', 5, union acpi_cmbat_ioctl_arg)
 
 #define ACPIIO_ACAD_GET_STATUS	_IOR('A', 1, int)
 
diff -ru ./usr.sbin/acpi/acpibatt/acpibatt.c /usr/src/usr.sbin/acpi/acpibatt/acpibatt.c
--- ./usr.sbin/acpi/acpibatt/acpibatt.c	Wed Dec 27 01:45:01 2000
+++ /usr/src/usr.sbin/acpi/acpibatt/acpibatt.c	Wed Dec 27 11:24:39 2000
@@ -181,7 +181,7 @@
 	char	*power_units[]= { "mWh", "mAh" };
 
 	verbose = debug = 0;
-	while ((c = getopt(argc, argv, "dg:s::v?")) != -1) {
+	while ((c = getopt(argc, argv, "dg:s:v?")) != -1) {
 		switch (c) {
 		case 'd':
 			debug++;
@@ -191,7 +191,12 @@
 			return (0);
 			break;
 		case 's':
-			return (acpi_cmbat_set_full_batt(atoi(optarg), atoi(argv[optind])));
+			if (argv[optind] != NULL) {
+				return (acpi_cmbat_set_full_batt(atoi(optarg),
+					    atoi(argv[optind])));
+			} else {
+				usage();
+			}
 			break;
 		case 'v':
 			verbose++;
@@ -297,7 +302,13 @@
 			    (total_full * (total_cap / valid_units)) / 100);
 		}
 	} else {
-		printf("%d minutes\n", total_min);
+		int t, h, m;
+
+		t = total_min;
+		m = t % 60;
+		t /= 60;
+		h = t;
+		printf("%2d:%02d:00\n", h, m);
 	}
 
 	printf("Number of batteries: %d\n", units);
@@ -312,7 +323,13 @@
 
 		printf("\tRemaining battery time: ");
 		if (bat[i].min > 0) {
-			printf("%d minutes\n", bat[i].min);
+			int t, h, m;
+
+			t = bat[i].min;
+			m = t % 60;
+			t /= 60;
+			h = t;
+			printf("%2d:%02d:00\n", h, m);
 		} else {
 			printf("unknown\n");
 		}
diff -ru ./usr.sbin/power/Makefile /usr/src/usr.sbin/power/Makefile
--- ./usr.sbin/power/Makefile	Wed Dec 27 00:44:36 2000
+++ /usr/src/usr.sbin/power/Makefile	Wed Dec 27 09:34:15 2000
@@ -5,7 +5,7 @@
 SRCS=		power.c
 NOMAN=		YES
 
-CFLAGS+=	-I../../sys
+CFLAGS+=	-I${.CURDIR}/../../sys -I${.CURDIR}/../../lib/libpower
 DEBUG_FLAGS+=	-g -Wall
 LDFLAGS+=	-lpower
 

----Next_Part(Wed_Dec_27_11:49:47_2000_809)----
