summaryrefslogtreecommitdiffstats
path: root/sys/dev/acpica
diff options
context:
space:
mode:
authorbruno <bruno@FreeBSD.org>2006-01-12 21:56:37 +0000
committerbruno <bruno@FreeBSD.org>2006-01-12 21:56:37 +0000
commit7f7a28fe5e182a2ce5bb912689a497f2ed4dd109 (patch)
tree46d1ee321e7daa8c2f69d14fe54b9f97a4f43747 /sys/dev/acpica
parent91d3ed73322f8d835faf2c835c37d0d9184b3b57 (diff)
downloadFreeBSD-src-7f7a28fe5e182a2ce5bb912689a497f2ed4dd109.zip
FreeBSD-src-7f7a28fe5e182a2ce5bb912689a497f2ed4dd109.tar.gz
* fix bst.status. We mark some bits, but forgot to reset all of them
before. The symptom is that the battery inform us its charge and discharge at the same time... * fix bst.rate to correctly output the (dis)charging rate. We'll use the current average over one minute command and not the at_rate command. Note that this method is not correct if the capacity_mode is set, but since we don't set it ourself, it is not a problem. The at_rate do not give the actual rate but is used to compute the estimated time for (dis)charging a battery. We should actually write an estimation of the actual rate using at_rate cmd and then perform a read to the various estimators. Approved by: njl MFC after: 2 days
Diffstat (limited to 'sys/dev/acpica')
-rw-r--r--sys/dev/acpica/acpi_smbat.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/sys/dev/acpica/acpi_smbat.c b/sys/dev/acpica/acpi_smbat.c
index 39bfb3c..4383e21 100644
--- a/sys/dev/acpica/acpi_smbat.c
+++ b/sys/dev/acpica/acpi_smbat.c
@@ -341,27 +341,28 @@ acpi_smbat_get_bst(device_t dev, struct acpi_bst *bst)
if (acpi_smbus_read_2(sc, addr, SMBATT_CMD_BATTERY_STATUS, &val))
goto out;
- if (val & SMBATT_BS_DISCHARGING) {
+ sc->bst.state = 0;
+ if (val & SMBATT_BS_DISCHARGING)
sc->bst.state |= ACPI_BATT_STAT_DISCHARG;
- /*
- * If the rate is negative, it is discharging. Otherwise,
- * it is charging.
- */
- if (acpi_smbus_read_2(sc, addr, SMBATT_CMD_AT_RATE, &val))
- goto out;
- if (val < 0)
- sc->bst.rate = (-val) * factor;
- else
- sc->bst.rate = -1;
- } else {
- sc->bst.state |= ACPI_BATT_STAT_CHARGING;
- sc->bst.rate = -1;
- }
-
if (val & SMBATT_BS_REMAINING_CAPACITY_ALARM)
sc->bst.state |= ACPI_BATT_STAT_CRITICAL;
+ /*
+ * If the rate is negative, it is discharging. Otherwise,
+ * it is charging.
+ */
+ if (acpi_smbus_read_2(sc, addr, SMBATT_CMD_CURRENT, &val))
+ goto out;
+
+ if (val > 0) {
+ sc->bst.rate = val * factor;
+ sc->bst.state |= ACPI_BATT_STAT_CHARGING;
+ } else if (val < 0)
+ sc->bst.rate = (-val) * factor;
+ else
+ sc->bst.rate = 0;
+
if (acpi_smbus_read_2(sc, addr, SMBATT_CMD_REMAINING_CAPACITY, &val))
goto out;
sc->bst.cap = val * factor;
OpenPOWER on IntegriCloud