Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi Print also the so-called "granularity" values w...



details:   https://anonhg.NetBSD.org/src/rev/46ae78dae3f3
branches:  trunk
changeset: 753137:46ae78dae3f3
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Wed Mar 17 11:07:59 2010 +0000

description:
Print also the so-called "granularity" values when the _BIF is evaluated.
These refer to the smallest increment in capacity that the battery is
capable of measuring.

diffstat:

 sys/dev/acpi/acpi_bat.c |  27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diffs (62 lines):

diff -r 00308da485dc -r 46ae78dae3f3 sys/dev/acpi/acpi_bat.c
--- a/sys/dev/acpi/acpi_bat.c   Wed Mar 17 09:21:50 2010 +0000
+++ b/sys/dev/acpi/acpi_bat.c   Wed Mar 17 11:07:59 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_bat.c,v 1.90 2010/03/17 09:21:50 jruoho Exp $     */
+/*     $NetBSD: acpi_bat.c,v 1.91 2010/03/17 11:07:59 jruoho Exp $     */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.90 2010/03/17 09:21:50 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_bat.c,v 1.91 2010/03/17 11:07:59 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/condvar.h>
@@ -438,7 +438,7 @@
 static void
 acpibat_print_info(device_t dv, ACPI_OBJECT *elm)
 {
-       const char *tech;
+       const char *tech, *unit = "Wh";
        int i;
 
        for (i = ACPIBAT_BIF_OEM; i > ACPIBAT_BIF_GRANULARITY2; i--) {
@@ -453,6 +453,9 @@
        tech = (elm[ACPIBAT_BIF_TECHNOLOGY].Integer.Value != 0) ?
            "secondary (rechargeable)" : "primary (non-rechargeable)";
 
+       if ((elm[ACPIBAT_BIF_UNIT].Integer.Value & ACPIBAT_PWRUNIT_MA) != 0)
+               unit = "Ah";
+
        aprint_normal_dev(dv, "%s %s %s battery\n", tech,
            elm[ACPIBAT_BIF_OEM].String.Pointer,
            elm[ACPIBAT_BIF_TYPE].String.Pointer);
@@ -460,6 +463,24 @@
        aprint_verbose_dev(dv, "serial number %s, model number %s\n",
            elm[ACPIBAT_BIF_SERIAL].String.Pointer,
            elm[ACPIBAT_BIF_MODEL].String.Pointer);
+
+#define SCALE(x) (((int)x) / 1000000), ((((int)x) % 1000000) / 1000)
+
+       /*
+        * These values are defined as follows (ACPI 4.0, p. 388):
+        *
+        * Granularity 1.       "Battery capacity granularity between low
+        *                       and warning in [mAh] or [mWh]. That is,
+        *                       this is the smallest increment in capacity
+        *                       that the battery is capable of measuring."
+        *
+        * Granularity 2.       "Battery capacity granularity between warning
+        *                       and full in [mAh] or [mWh]. [...]"
+        */
+       aprint_verbose_dev(dv,
+           "granularity 1. %d.%03d %s, granularity 2. %d.%03d %s\n",
+           SCALE(elm[ACPIBAT_BIF_GRANULARITY1].Integer.Value * 1000), unit,
+           SCALE(elm[ACPIBAT_BIF_GRANULARITY2].Integer.Value * 1000), unit);
 }
 
 /*



Home | Main Index | Thread Index | Old Index