[Pkg-acpi-devel] Bug#502511: acpi: Definitely mWh.
Paul Martin
pm at debian.org
Tue Dec 2 19:16:18 UTC 2008
Package: acpi
Version: 1.2-1
Followup-For: Bug #502511
# cat /proc/acpi/battery/BAT0/state
present: yes
capacity state: ok
charging state: charging
present rate: 15682 mW
remaining capacity: 30560 mWh
present voltage: 12378 mV
# cat /proc/acpi/battery/BAT0/info
present: yes
design capacity: 47510 mWh
last full capacity: 36160 mWh
battery technology: rechargeable
design voltage: 10800 mV
design capacity warning: 1808 mWh
design capacity low: 200 mWh
capacity granularity 1: 1 mWh
capacity granularity 2: 1 mWh
model number: IBM-92P1060
serial number: 1371
battery type: LION
OEM info: Panasonic
root at thinkpad:/sys/class/power_supply/BAT0# cat status
Charging
root at thinkpad:/sys/class/power_supply/BAT0# cat energy_now
30670000
root at thinkpad:/sys/class/power_supply/BAT0# cat energy_full
36160000
root at thinkpad:/sys/class/power_supply/BAT0# cat energy_full_design
47510000
root at thinkpad:/sys/class/power_supply/BAT0# cat current_now
1192000
root at thinkpad:/sys/class/power_supply/BAT0# cat voltage_now
12411000
So, energy_* are in µWh and current_now is in µA.
The battery is a nominal capacity of 4400mAh at 10.8V. That's 47.5Wh,
which corresponds with the "energy_full_design" value.
acpi.c incorrectly considers charge_* and energy_* values to be
equivalent. charge_* values (if present) will be in µAh, and energy_*
values (if present) are in µWh.
To convert energy_* values into the equivalent charge_* values, you need
to divide by (voltage_now/1000000), avoiding overflows or underflows in
the integer arithmetic.
eg. charge_value = (energy_value / (voltage_now/1000) ) *1000;
Note that 2.6.28-rc7 has the following patch, which triggers this:
commit 558073dd56707864f09d563b64e7c37c021e89d2
Author: Alexey Starikovskiy <aystarik at gmail.com>
Date: Fri Nov 21 22:41:01 2008 +0800
ACPI: battery: Convert discharge energy rate to current properly
ACPI battery interface reports its state either in mW or in mA, and
discharge rate in your case is reported in mW. power_supply interface
does not have such a parameter, so current_now parameter is used
for all cases. But in case of mW, reported discharge should
be converted into mA.
Signed-off-by: Alexey Starikovskiy <astarikovskiy at suse.de>
Tested-by: Ferenc Wagner <wferi at niif.hu>
Signed-off-by: Len Brown <len.brown at intel.com>
hal has a similar bug. powertop does not.
In addition, "acpi -p" fails because the string "present_rate" should be
"present rate":
} else if (!strcasecmp(value->attr, "present_rate")) {
present_rate = get_unit_value(value->value);
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (99, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.28-rc7
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages acpi depends on:
ii libc6 2.7-16 GNU C Library: Shared libraries
acpi recommends no packages.
acpi suggests no packages.
-- no debconf information
More information about the Pkg-acpi-devel
mailing list