Hi,
This is a patch to fix these:
https://bugs.launchpad.net/ubuntu/+source/devicekit-power/+bug/403303
https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/460631
https://bugzilla.redhat.com/show_bug.cgi?id=439460
http://ubuntuforums.org/showthread.php?t=1317434
https://bugs.launchpad.net/ubuntu/+source/devicekit-power/+bug/403303
This is a hardware bug. It could also be fixed at the ACPI level,
but having this fix here doesn't hurt.
Tested on Ubuntu 10.04 Desktop, 2.6.32-24-generic.
The patch is against upower 0.9.1-1
Regards,
--
M
diff -rc upower-0.9.1-origdeb/src/linux/up-device-supply.c upower-0.9.1/src/linux/up-device-supply.c
*** upower-0.9.1-origdeb/src/linux/up-device-supply.c 2010-02-10 18:09:31.000000000 +0100
--- upower-0.9.1/src/linux/up-device-supply.c 2010-09-02 18:13:24.263856783 +0200
***************
*** 48,53 ****
--- 48,56 ----
{
guint poll_timer_id;
gboolean has_coldplug_values;
+ // Some notbooks (asus eeepc 900 series is an example) report 'charge_full'
+ // and 'charge' in percetages (instead of mAh). Let' fix that.
+ gboolean broken_percentage_reporting;
gdouble energy_old;
GTimeVal energy_old_timespec;
guint unknown_retries;
***************
*** 91,96 ****
--- 94,100 ----
UpDevice *device = UP_DEVICE (supply);
supply->priv->has_coldplug_values = FALSE;
+ supply->priv->broken_percentage_reporting = FALSE;
supply->priv->energy_old = 0;
supply->priv->energy_old_timespec.tv_sec = 0;
***************
*** 474,481 ****
--- 478,494 ----
if (energy == 0) {
energy_full = sysfs_get_double (native_path, "charge_full") / 1000000.0;
energy_full_design = sysfs_get_double (native_path, "charge_full_design") / 1000000.0;
+ if (energy_full <= 0.101) { // 0.1 = 100 mAh (100%)
+ energy_full = energy_full * 10 * energy_full_design;
+ supply->priv->broken_percentage_reporting = TRUE;
+ }
energy_full *= voltage_design;
energy_full_design *= voltage_design;
+ } else {
+ if (energy_full <= 0.101) { // 0.1 = 100 mAh (100%)
+ energy_full = energy_full * 10 * energy_full_design;
+ supply->priv->broken_percentage_reporting = TRUE;
+ }
}
/* the last full should not be bigger than the design */
***************
*** 544,551 ****
--- 557,571 ----
energy = sysfs_get_double (native_path, "charge_now") / 1000000.0;
if (energy == 0)
energy = sysfs_get_double (native_path, "charge_avg") / 1000000.0;
+ if (supply->priv->broken_percentage_reporting) {
+ energy = energy * 10 * energy_full_design / voltage_design;
+ }
energy *= voltage_design;
energy_rate *= voltage_design;
+ } else {
+ if (supply->priv->broken_percentage_reporting) {
+ energy = energy * 10 * energy_full_design;
+ }
}
/* some batteries don't update last_full attribute */
_______________________________________________
devkit-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/devkit-devel