[Bug 283683] [PATCH] dev/acpica/acpi_cmbat.c: Add battery trip point (_BTP)
Date: Sat, 28 Dec 2024 13:39:29 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=283683 Bug ID: 283683 Summary: [PATCH] dev/acpica/acpi_cmbat.c: Add battery trip point (_BTP) Product: Base System Version: 15.0-CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: georg.lastname@web.de Created attachment 256226 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=256226&action=edit diff for sys/dev/acpica/acpi_cmbat.c [PATCH] Affected file: sys/dev/acpica/acpi_cmbat.c This patch implements _BTP (battery trip point). This is basically for laptop users. You set a warning level, e.g. 20%. Then devd will notify you when the battery reaches 20%. Quoting the ACPI specification version 6.5 section 10.2.2.14 ("_BTP"): "This object is used to set a trip point to generate an SCI whenever the Battery Remaining Capacity reaches or crosses the value specified in the _BTP object." I have another explanation here: https://github.com/random532/FreeBSD_Battery_Trip_Point The _BTP method is optional, so not every battery supports it. -- What I did (aka design choices): 1. The cmbat driver has a unique device_attach() routine. It loops multipe times until the battery controller is ready. So once that process is finished (aka the battery is registered), I feel like that is a good place to add all the optional acpi methods. For now, the only optional method that is supported would be _BTP. I add a function acpi_initialize_btp() and a handler function acpi_cmbat_btp_sysctl(). 2. I chose a sysctl for the trip point. It is possible to use /dev/acpi and acpiconf for this, which at first glance is more consistent with the current design. However, the trip point is read-write. The current battery reporting is read-only. Also, we'd need a new argument for acpiconf, because right now, there is only acpiconf -i X, which reads battery information. I can see a design where the userland command would be "acpiconf -i 0 -w 20", where w would be the warning level. But I think the sysctl is just fine. 3. More information is on github. I just want to put this out there. 4. So far tested on: ThinkPad x220 Thanks everyone. -- You are receiving this mail because: You are the assignee for the bug.