Subject: acpi/apm code only uses last battery?
To: None <port-i386@netbsd.org>
From: Greg Troxel <gdt@ir.bbn.com>
List: port-i386
Date: 10/10/2006 20:53:22
I'm running current from 10/6.
I have a T60 which right now has two batteries:
acpibat0 present
acpibat0 design cap: 56.160 Wh
acpibat0 last full cap: 56.160 Wh
acpibat0 technology: 1
acpibat0 design voltage: 10.800 V
acpibat0 warn cap: 2.808 Wh ( 5.00%)
acpibat0 low cap: 0.200 Wh ( 0.36%)
acpibat0 voltage: 12.481 V
acpibat0 charge rate: 12.805 W
acpibat0 charge: 52.300 Wh (93.13%)
acpibat0 charging
acpibat1 present
acpibat1 design cap: 29.160 Wh
acpibat1 last full cap: 23.840 Wh
acpibat1 technology: 1
acpibat1 design voltage: 10.800 V
acpibat1 warn cap: 1.192 Wh ( 5.00%)
acpibat1 low cap: 0.200 Wh ( 0.84%)
acpibat1 voltage: 11.287 V
acpibat1 charge: 0.000 Wh ( 0.00%)
acpiacad0 disconnected
acpitz0 temperature: 42.000 degC
acpitz1 temperature: 26.800 degC
apm reports:
poblano gdt 57 ~ > apm
Battery charge state: CRITICAL
Battery remaining: 0 percent
A/C adapter state: not connected
Power management enabled
Number of batteries: 1
This is clearly wrong, and it's because the loop in
src/sys/dev/acpi/acpi_apm.c:acpiapm_get_powstat overwrites the battery
info as it finds each battery while looping over the data.
One fix would be to aggregate the 'design cap' and 'charge' levels, to
give the impression of a single battery with the sum of the charges.
Another would be to represent each battery as an apm battery.
Looking at this code, it seems note quite right (how is current
capacity stored), but I'm not very familiar with either APM or ACPI,
and the gnome battery applet was showing the % charge of battery 1
correctly.