| Summary: | apm(8) The total battery percentage is incorrect for multiple batteries | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | kd-dev | ||||
| Component: | kern | Assignee: | Allan Jude <allanjude> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | CC: | emaste | ||||
| Priority: | --- | Keywords: | patch | ||||
| Version: | CURRENT | Flags: | allanjude:
mfc-stable12?
allanjude: mfc-stable11? |
||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| See Also: | https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260214 | ||||||
| Attachments: |
|
||||||
A commit references this bug: Author: allanjude Date: Tue May 21 21:14:23 UTC 2019 New revision: 348065 URL: https://svnweb.freebsd.org/changeset/base/348065 Log: Correct the way remaining battery life is calculated Previously, if a system had multiple batteries, the remaining life percentage was calculated as the average of each battery's percent remaining. This results in rather incorrect values when you consider the case of the Thinkpad X270 that has a small 3 cell internally battery, and a hot-swappable 9 cell battery that is used first. Battery 0 is at 100%, but battery 1 is at 10%, you do not infact have 55% of your capacity remaining. The new method calculates the percentage based on remaining capacity out of total capacity, giving a much more accurate reading. PR: 229818 Submitted by: Keegan Drake H.P. <kd-dev@pm.me> MFC after: 2 weeks Sponsored by: Klara Systems Event: Waterloo Hackathon 2019 Changes: head/sys/dev/acpica/acpi_battery.c A commit references this bug: Author: allanjude Date: Wed Jun 5 20:31:09 UTC 2019 New revision: 348703 URL: https://svnweb.freebsd.org/changeset/base/348703 Log: MFC r348065: Correct the way remaining battery life is calculated Previously, if a system had multiple batteries, the remaining life percentage was calculated as the average of each battery's percent remaining. This results in rather incorrect values when you consider the case of the Thinkpad X270 that has a small 3 cell internally battery, and a hot-swappable 9 cell battery that is used first. Battery 0 is at 100%, but battery 1 is at 10%, you do not infact have 55% of your capacity remaining. The new method calculates the percentage based on remaining capacity out of total capacity, giving a much more accurate reading. PR: 229818 Submitted by: Keegan Drake H.P. <kd-dev@pm.me> Sponsored by: Klara Systems Event: Waterloo Hackathon 2019 Changes: _U stable/12/ stable/12/sys/dev/acpica/acpi_battery.c A commit references this bug: Author: allanjude Date: Thu Jun 6 05:10:33 UTC 2019 New revision: 348726 URL: https://svnweb.freebsd.org/changeset/base/348726 Log: MFC r348065: Correct the way remaining battery life is calculated Previously, if a system had multiple batteries, the remaining life percentage was calculated as the average of each battery's percent remaining. This results in rather incorrect values when you consider the case of the Thinkpad X270 that has a small 3 cell internally battery, and a hot-swappable 9 cell battery that is used first. Battery 0 is at 100%, but battery 1 is at 10%, you do not infact have 55% of your capacity remaining. The new method calculates the percentage based on remaining capacity out of total capacity, giving a much more accurate reading. PR: 229818 Submitted by: Keegan Drake H.P. <kd-dev@pm.me> Sponsored by: Klara Systems Event: Waterloo Hackathon 2019 Approved by: re (gjb) Changes: _U stable/11/ stable/11/sys/dev/acpica/acpi_battery.c |
Created attachment 195185 [details] Produce the total battery percentage from the capacity totals rather than the other percentages The total "Remaining battery life" field is the average of the per-battery "Remaining battery life" fields, rather than the percentage of the remaining battery life relative to the maximum battery life. Contrived expected output: APM version: 1.2 APM Management: Disabled AC Line status: off-line Battery Status: high Remaining battery life: 50% Remaining battery time: 4:00:00 Number of batteries: 2 Battery 0: Battery Status: high Remaining battery life: 100% Remaining battery time: 3:00:00 Battery 1: Battery Status: low Remaining battery life: 20% Remaining battery time: 1:00:00 Contrived example output: APM version: 1.2 APM Management: Disabled AC Line status: off-line Battery Status: high Remaining battery life: 60% Remaining battery time: 4:00:00 Number of batteries: 2 Battery 0: Battery Status: high Remaining battery life: 100% Remaining battery time: 3:00:00 Battery 1: Battery Status: low Remaining battery life: 20% Remaining battery time: 1:00:00 The included patch changes the way that value is generated to be from the sum-totals of the current and last-full battery capacities. This replaces the current behavior of averaging the percentages produced from each battery. The included patch was tested on an amd64 version of FreeBSD 12.0-CURRENT r336075. It builds and runs without any warnings nor errors.