Re: [patch] ACPI battery driver emits POWER_SUPPLY_STATUS_FULL when power lead plugged in

Henrique de Moraes Holschuh
2009-01-25T13:42:08Z

On Sun, 25 Jan 2009, Richard Hughes wrote:
> + /* good batteries update full_charge as the batteries degrade */
> + if (battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN &&
> + battery->full_charge_capacity != 0) {
> + percentage = (100 * battery->capacity_now) / battery->full_charge_capacity;
> + if (percentage > 90)
> + return 1;

You guys have to remember that the hardware can know when the cells are
physically full. That has _nothing_ to do with any level estimation,
battery cells behave differently when they are full, and that's what the
overcharge protection circuitry detects.

So, the above test will still break on any proper battery subsystem with the
high watermark set below 100%, as those systems update full_charge_capacity
*only* when the cells really are full (and not because the EC decided to
stop the charging before they were full).

Thus, it will break if you set the threshold to stop charging (high
watermark) above 90% but below 100% on a T-, X-, R- or W-series ThinkPad,
for example.

The test would still have to be:
if (battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN &&
battery->full_charge_capacity != 0 &&
battery->capacity_now == battery->full_charge_capacity)
return 1;

or, if there is crap so bad out there that requires it:
if (battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN &&
battery->full_charge_capacity != 0 &&
battery->capacity_now == battery->full_charge_capacity) {
percentage = (100 * battery->capacity_now) / battery->full_charge_capacity;
if (percentage > 90)
return 1;

to work well on proper battery firmware set to stop before the battery is
full.

If that can't work well enough with the crap out there, I am out of ideas,
and I'd say we'd have to quirk either the good or the bad systems to
properly implement the FULL state.

As for the sub-second "blinks" the EC does in battery states, if one wants
to avoid that, better report states only after they have been stable for one
or two seconds. Not that a report of CHARGING->IDLE->FULL is incorrect or a
problem IMHO, but I don't know if that's what you guys are observing.

--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh