ACPI_BATTERY(4)

🌸 NAME 🌸

acpi_battery β€” the ACPI battery management subsystem, aka the thing that tells you why your laptop is about to die at the worst possible moment πŸ’€


✨ SYNOPSIS ✨

device acpi

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so acpi_battery is a driver for the battery management features of the ACPI module. it's giving "your battery, but make it kernel-level" πŸ’…

An ACPI-compatible battery device supports either a Control Method Battery interface or a Smart Battery subsystem interface. the first one gets accessed by the AML (ACPI Machine Language) code control methods, and the second one is controlled directly through the ACPI EC (Embedded Controller), typically via an SMBus interface. two whole flavors, both iconic πŸŽ€

This driver supports the sysctl(8) and ioctl(2) interfaces as well as the devd(8) event notification interface. yeah bestie, it does it all. main character energy fr fr ✨


πŸ’… IOCTLS πŸ’…

Every ioctl for the acpi_battery driver takes a single integer value for the battery unit number as an argument, and returns a specific structure for each request. and there's a special unit number, ACPI_BATTERY_ALL_UNITS, that specifies all of the attached units and reports accumulated information. group project but make it battery data 🫢

  • ACPIIO_BATT_GET_UNITS int β€” Returns the number of battery units in the system. the unit number argument gets straight-up ignored here, she said "no thoughts, head empty" πŸ™ˆ
  • ACPIIO_BATT_GET_BATTINFO struct acpi_battinfo β€” Returns the following:
    • cap β€” Battery capacity in percent,
    • min β€” Remaining battery life in minutes,
    • state β€” Current status of the battery, encoded in the following:
      • ACPI_BATT_STAT_DISCHARG (0x0001) β€” Battery is discharging,
      • ACPI_BATT_STAT_CHARGING (0x0002) β€” Battery is being charged, or
      • ACPI_BATT_STAT_CRITICAL (0x0004) β€” Remaining battery life is critically low.
Note that the status bits of each battery will be consolidated when ACPI_BATTERY_ALL_UNITS is specified. so all the drama gets merged into one report πŸ’–
  • rate β€” Current battery discharging rate in mW. -1 means not discharging right now. she's just chillin 😌
  • ACPIIO_BATT_GET_BIX struct acpi_bix β€” Returns battery information given by the ACPI _BIX (Battery Information) object, which is the static portion of the Control Method Battery information. In the case of a Smart Battery attached to SMBus, or a Control Method Battery with a _BIF object, this ioctl will build a struct acpi_bix structure based on the obtained information and return it. slay, it adapts ✨
    • rev β€” Revision number of the object. There are the following well-known values:
      • ACPI_BIX_REV_0 (0x0000) β€” A _BIX object in ACPI 4.0.
      • ACPI_BIX_REV_1 (0x0001) β€” A _BIX object in ACPI 6.0.
      • ACPI_BIX_REV_BIF (0xffff) β€” A _BIX object built from the _BIF object found on the system.
Note that this field should be checked by using the ACPI_BIX_REV_MIN_CHECK(var, rev) macro when checking the minimum revision number. don't eyeball it bestie, use the macro πŸŽ€
  • units β€” Indicates the units used by the battery to report its capacity and charge rate, encoded in the following:
    • ACPI_BIX_UNITS_MW (0x00000000) β€” in mW (power)
    • ACPI_BIX_UNITS_MA (0x00000001) β€” in mA (current)
Note that capacity is expressed in mWh or mAh, and rate is expressed in mW or mA, respectively. units, but make it consistent πŸ’…
  • dcap β€” The Battery's design capacity, which is the nominal capacity of a new battery. This is expressed as power or current depending on the value of units.
  • lfcap β€” Predicted battery capacity when fully charged. Typically this will decrease every charging cycle. it's giving "aging gracefully" 😭
  • btech β€” Battery technology:
    • 0x00000000 β€” Primary cell (non-rechargable)
    • 0x00000001 β€” Secondary cell (rechargable)
  • dvol β€” Design voltage in mV, which is the nominal voltage of a new battery.
  • wcap β€” Design capacity of warning. When a discharging battery device reaches this capacity, notification is sent to the system. πŸ””
  • lcap β€” Design capacity of low.
  • cycles β€” (rev 0 or newer) The number of cycles the battery has experienced. A cycle means an amount of discharge occurred which was approximately equal to the value of Design Capacity. she's got lore now πŸ“–
  • accuracy β€” (rev 0 or newer) The accuracy of the battery capacity measurement, in thousandth of a percent.
  • stmax β€” (rev 0 or newer) The Maximum Sampling Time of the battery in milliseconds. This is the maximum duration between two consecutive measurements of the battery's capacities specified in _BST. If two succeeding readings of _BST beyond this duration occur, two different results can be returned. so yeah, timing matters ⏱️
  • stmin β€” (rev 0 or newer) The Minimum Sampling Time of the battery in milliseconds.
  • aimax β€” (rev 0 or newer) The Maximum Average Interval of the battery in milliseconds. This is the length of time within which the battery averages the capacity measurements specified in _BST. The Sampling Time specifies the frequency of measurements, and the Average Interval specifies the width of the time window of every measurement. window, frequency, width β€” it's a whole vibe πŸͺŸ
  • aimin β€” (rev 0 or newer) The Minimum Average Interval of the battery in milliseconds.
  • gra1 β€” Battery capacity granularity between low and warning. This is expressed as power or current depending on the value of units.
  • gra2 β€” Battery capacity granularity between warning and full. This is expressed as power or current depending on the value of units.
  • model β€” Model number of the battery as a string.
  • serial β€” Serial number of the battery as a string.
  • type β€” Type identifier of the battery as a string.
  • oeminfo β€” OEM-specific information of the battery as a string.
  • scap β€” (rev 1 or newer) Battery swapping capability, encoded in the following:
    • ACPI_BIX_SCAP_NO (0x00000000) β€” Non-swappable
    • ACPI_BIX_SCAP_COLD (0x00000001) β€” Cold-swappable
    • ACPI_BIX_SCAP_HOT (0x00000010) β€” Hot-swappable πŸ”₯
  • ACPIIO_BATT_GET_BIF struct acpi_bif β€” (deprecated) Returns battery information given by the ACPI _BIF (Battery Information) object, which was deprecated in the ACPI 4.0 specification. The data structure is a subset of struct acpi_bix.
Note that this ioctl will built a struct acpi_bif structure based on the obtained information even if this object is not available and a _BIX object is found. yeah she's deprecated but she still shows up πŸ’€
  • ACPIIO_BATT_GET_BST struct acpi_bst β€” Returns battery information given by the ACPI _BST (Battery Status) object, which is the present battery status. In the case of a Smart Battery attached to SMBus, this ioctl will build a struct acpi_bst structure based on the obtained information and return it. right now, live, no filter πŸ“Έ
    • state β€” Battery state. The value is encoded in the same way as state of struct acpi_battinfo.
    • rate β€” Battery present rate of charging or discharging. The unit of the value depends on unit of struct acpi_bif.
    • cap β€” Battery remaining capacity. The unit of this value depends on unit of struct acpi_bif.
    • volt β€” Battery present voltage. ⚑

πŸŽ€ SYSCTL VARIABLES πŸŽ€

The following sysctl(8) variables export battery status. note that they are accumulated status of all of the connected batteries β€” so yeah, it's the group chat summary, not the individual DMs πŸ’¬

  • hw.acpi.battery.info_expire β€” Information cache expiration time in seconds. The battery information obtained by _BIX or _BIF object will be stored and reused for successive read access to this MIB within the specified period. caching era ✨
  • hw.acpi.battery.units β€” Number of battery units in the system.
  • hw.acpi.battery.state β€” Current battery charging status. This is same as state of struct acpi_battinfo.
  • hw.acpi.battery.rate β€” Current battery discharging rate in mW.
  • hw.acpi.battery.time β€” Remaining battery life in minutes. If the battery is not discharging, the value shows -1.
  • hw.acpi.battery.life β€” Battery capacity in percent. πŸ“

πŸ”” EVENT NOTIFICATIONS πŸ””

Battery-related event notifications are sent to the userland via the devd(8) interface. See /etc/devd.conf and devd.conf(5) for more details.

Note that notifications are supported only by the Control Method Battery. so if you're on the other flavor, no notifs for you bestie πŸ˜”

The acpi_battery driver sends events with the following attributes:

  • system β€” ACPI
  • subsystem β€” CMBAT
  • type β€” The fully qualified battery object path as in the ASL.
  • notify β€” An integer designating the event:
    • 0x80 β€” Battery status was changed.
    • 0x81 β€” Battery information was changed.

🌈 SEE ALSO 🌈

acpi(4), acpiconf(8)


πŸ‘‘ AUTHORS πŸ‘‘

Nate Lawson <njl@FreeBSD.org>, Munehiro Matsuda, Takanori Watanabe <takawata@FreeBSD.org>, Mitsuru IWASAKI <iwasaki@FreeBSD.org>, Hans Petter Selasky <hselasky@FreeBSD.org>, and Hiroki Sato <hrs@FreeBSD.org>.

This manual page was written by Takanori Watanabe <takawata@FreeBSD.org> and Hiroki Sato <hrs@FreeBSD.org>. absolute legends, we stan 🫢✨


and that's the whole page bestie, no cap πŸ’– this one came out of the Debian corner of the world, dated February 16, 2020, and yeah it lives under the name ACPI_BATTERY(4). go forth and read your battery stats, you icon πŸŒΈπŸ’…

πŸ“¦ where this page comes from