_BTP is an optional, write-only method in control method batteries.
It allows you to set a warning level (trip point), which will
generate a devd CMBAT event.
If supported, sysctl dev.battery.X.warning_level is created.
Details
acpidump -dt |grep _BTP tells you whether your battery supports this.
I tested it on a Thinkpad x220.
It should be noted that I am fairly new at kernel programming.
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 35027 Build 32012: arc lint + arc unit
Event Timeline
Looks good. I have one comment inline.
sys/dev/acpica/acpi_cmbat.c | ||
---|---|---|
619 | How about allowing 0 to clear trip point ? |
For some reason I overlooked that the battery device exists, no matter whether the battery is plugged in or not. E.g. if you unplug the battery after booting, and plug it in again, the sysctl won't care, and display a wrong value. I'll think about this.
sys/dev/acpica/acpi_cmbat.c | ||
---|---|---|
619 |
Yes, sounds good. |
Updating D25908: Add _BTP method to control method batteries
On device attach, we check for the optional method (_BTP). If it exists,
a sysctl is created, dev.battery.X.warning_level.
Since the battery initialization is mostly done in
acpi_cmbat_init_battery(), which also gets called after resuming from a
sleep state (where the battery can be unplugged), I added code there,
too: acpi_cmbat_btp_set(). This will initially set the warning level to
20%.
A sysctl handler function will change the warning level, if the user
chooses so.
Updating D25908: Add _BTP method to control method batteries
On device attach, we check for the optional method (_BTP). If it exists,
a sysctl is created, dev.battery.X.warning_level.
Since the battery initialization is mostly done in
acpi_cmbat_init_battery(), which also gets called after resuming from a
sleep state (where the battery can be unplugged), I added code there,
too: acpi_cmbat_btp_set(). This will initially set the warning level to
20%.
A sysctl handler function will change the warning level, if the user
chooses so.