Provide apm(4/arm64) with battery information
authorkn <kn@openbsd.org>
Thu, 25 Mar 2021 12:18:27 +0000 (12:18 +0000)
committerkn <kn@openbsd.org>
Thu, 25 Mar 2021 12:18:27 +0000 (12:18 +0000)
commit8de5ec0a5e056d7e00e6507516ae0f40330eb178
treee34d4d69e8632b717b4971d377fb1ffa469b68f4
parentaebfeadbe62f7780f4e32b470b973876b1364d4c
Provide apm(4/arm64) with battery information

apm merely provides an all zero/unknown stub for those values, e.g. apm(8)
output is useless.

Hardware sensors however provide this information:

hw.sensors.cwfg0.volt0=3.76 VDC (battery voltage)
hw.sensors.cwfg0.raw0=259 (battery remaining minutes)
hw.sensors.cwfg0.percent0=58.00% (battery percent)

Make cwfg(4) copy those over using apm_setinfohook() for apm to show it:

Battery state: high, 58% remaining, 259 minutes life estimate
A/C adapter state: not known
Performance adjustment mode: auto (408 MHz)

In cwfg's update routine, to keep values coherent, always reset them to
zero/unknown and only set those that came from a valid reading.

Input OK jca
sys/dev/fdt/cwfg.c