Bug 207223

Summary: acpica/acpi_battery.c: introduce hw.acpi.battery.rate sysctl
Product: Base System Reporter: Johannes Jost Meixner <xmj>
Component: kernAssignee: freebsd-acpi mailing list <acpi>
Status: New ---    
Severity: Affects Only Me CC: cem, emaste, jkim, kbowling, lme, sbruno
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
add hw.acpi.battery.rate sysctl oid
none
add hw.acpi.battery.rate sysctl oid none

Description Johannes Jost Meixner freebsd_committer 2016-02-15 18:29:25 UTC
Created attachment 167043 [details]
add hw.acpi.battery.rate sysctl oid

Patch attached introduces a sysctl to display the discharging rate of a battery.

It seems to me (but, I'm not particularly sure) that the info populated into &acpi_battery_battinfo.rate is -always- converted to Watts (cf acpi_battery_get_battinfo() lines 202-203.

So we could probably append "mW" to the output, however I'm quite fond of having it be an integer for the purposes of extending i3 to read this new sysctl and output it to my status bar. ;-)
Comment 1 Lars Engels freebsd_committer 2016-02-15 19:33:28 UTC
Works for me (TP X230):

# sysctl hw.acpi.battery.rate 
hw.acpi.battery.rate: 13834
Comment 2 Sean Bruno freebsd_committer 2016-03-10 14:51:02 UTC
Please add something to the description to indicate the units of the sysctl (mW?).
Comment 3 Johannes Jost Meixner freebsd_committer 2016-03-10 14:59:14 UTC
Created attachment 167967 [details]
add hw.acpi.battery.rate sysctl oid
Comment 4 Sean Bruno freebsd_committer 2016-03-10 15:35:57 UTC
hrm.  Is it mW/second or something?  A rate indicates some factor of time.
Comment 5 Conrad Meyer freebsd_committer 2016-03-10 16:17:30 UTC
(In reply to Sean Bruno from comment #4)

mW is a rate :).
Comment 6 Ed Maste freebsd_committer 2016-03-14 15:52:25 UTC
> Please add something to the description to indicate the units of the sysctl (mW?).

Note that acpiconf -i0 reports mW on some systems and mA on others, so I'm not sure that mW is always correct.
Comment 7 Johannes Jost Meixner freebsd_committer 2016-03-15 10:54:58 UTC
(In reply to Ed Maste from comment #6)

This should be dealt with by the following code in the same file, if I'm not mistaken:


https://svnweb.freebsd.org/base/head/sys/dev/acpica/acpi_battery.c?view=markup#l196
Comment 8 Johannes Jost Meixner freebsd_committer 2016-03-15 11:08:05 UTC
Hence: Yes, you're right - in the case that battery voltage can't be obtained the item stays in mA.

What's the best way to solve this in the description?