hal/hald/linux2 acpi.c,1.19,1.20 pmu.c,1.10,1.11

David Zeuthen david at freedesktop.org
Wed May 11 10:46:34 PDT 2005


Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv14166/hald/linux2

Modified Files:
	acpi.c pmu.c 
Log Message:
2005-05-11  David Zeuthen  <davidz at redhat.com>

        * hald/linux2/pmu.c (battery_refresh): Also use the
        util_compute_time_remaining here

2005-05-11  David Zeuthen  <davidz at redhat.com>

        Patch from Richard Hughes <richard at hughsie.com>

        * hald/util.c (util_compute_time_remaining): New function
        used to calculate the time remaining for ACPI laptops as the
        information is not provided.

        * hald/linux2/acpi.c (battery_refresh_poll): Add code to
        refresh "battery.remaining_time" using the new function
        util_compute_time_remaining.



Index: acpi.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/acpi.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- acpi.c	16 Mar 2005 20:09:47 -0000	1.19
+++ acpi.c	11 May 2005 17:46:32 -0000	1.20
@@ -73,6 +73,15 @@
 					 "state", "remaining capacity", 0, 10, TRUE);
 	hal_util_set_int_elem_from_file (d, "battery.charge_level.rate", path, 
 					 "state", "present rate", 0, 10, TRUE);
+	
+	hal_device_property_set_int (d, "battery.remaining_time", 
+				     util_compute_time_remaining (
+					     d->udi,
+					     hal_device_property_get_int (d, "battery.charge_level.rate"),
+					     hal_device_property_get_int (d, "battery.charge_level.current"),
+					     hal_device_property_get_int (d, "battery.charge_level.last_full"),
+					     hal_device_property_get_bool (d, "battery.rechargeable.is_discharging"),
+					     hal_device_property_get_bool (d, "battery.rechargeable.is_charging")));
 }
 
 static gboolean

Index: pmu.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/pmu.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- pmu.c	9 May 2005 03:43:26 -0000	1.10
+++ pmu.c	11 May 2005 17:46:32 -0000	1.11
@@ -113,6 +113,16 @@
 		else
 			hal_device_property_set_int (d, "battery.charge_level.rate", -current);
 
+		/* TODO: could read some pmu file? */
+		hal_device_property_set_int (d, "battery.remaining_time", 
+					     util_compute_time_remaining (
+						     d->udi,
+						     hal_device_property_get_int (d, "battery.charge_level.rate"),
+						     hal_device_property_get_int (d, "battery.charge_level.current"),
+						     hal_device_property_get_int (d, "battery.charge_level.last_full"),
+						     hal_device_property_get_bool (d, "battery.rechargeable.is_discharging"),
+						     hal_device_property_get_bool (d, "battery.rechargeable.is_charging")));
+
 		device_property_atomic_update_end ();
 	} else {
 		device_property_atomic_update_begin ();




More information about the hal-commit mailing list