Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Add sysmon pswitch hook so that powerd(8) can m...



details:   https://anonhg.NetBSD.org/src/rev/13e2729917da
branches:  trunk
changeset: 566278:13e2729917da
user:      kochi <kochi%NetBSD.org@localhost>
date:      Mon May 03 07:44:36 2004 +0000

description:
Add sysmon pswitch hook so that powerd(8) can monitor
AC adapter online/offline events.

diffstat:

 sys/dev/acpi/acpi_acad.c |  21 +++++++++++++++++++--
 sys/dev/acpi/files.acpi  |   4 ++--
 2 files changed, 21 insertions(+), 4 deletions(-)

diffs (74 lines):

diff -r 43154536e035 -r 13e2729917da sys/dev/acpi/acpi_acad.c
--- a/sys/dev/acpi/acpi_acad.c  Mon May 03 07:43:37 2004 +0000
+++ b/sys/dev/acpi/acpi_acad.c  Mon May 03 07:44:36 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_acad.c,v 1.15 2004/05/01 12:03:48 kochi Exp $     */
+/*     $NetBSD: acpi_acad.c,v 1.16 2004/05/03 07:44:36 kochi Exp $     */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_acad.c,v 1.15 2004/05/01 12:03:48 kochi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_acad.c,v 1.16 2004/05/03 07:44:36 kochi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -68,6 +68,7 @@
        int sc_flags;                   /* see below */
 
        struct sysmon_envsys sc_sysmon;
+       struct sysmon_pswitch sc_smpsw; /* our sysmon glue */
        struct envsys_basic_info sc_info[ACPIACAD_NSENSORS];
        struct envsys_tre_data sc_data[ACPIACAD_NSENSORS];
 
@@ -163,6 +164,14 @@
        sc->sc_node = aa->aa_node;
        simple_lock_init(&sc->sc_lock);
 
+       sc->sc_smpsw.smpsw_name = sc->sc_dev.dv_xname;
+       sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_ACADAPTER;
+       if (sysmon_pswitch_register(&sc->sc_smpsw) != 0) {
+               printf("%s: unable to register with sysmon\n",
+                      sc->sc_dev.dv_xname);
+               return;
+       }
+
        rv = AcpiInstallNotifyHandler(sc->sc_node->ad_handle,
            ACPI_DEVICE_NOTIFY, acpiacad_notify_handler, sc);
        if (ACPI_FAILURE(rv)) {
@@ -211,6 +220,14 @@
        AACAD_SET(sc, AACAD_F_AVAILABLE);
        AACAD_UNLOCK(sc, s);
 
+       /*
+        * PSWITCH_EVENT_RELEASED : AC offline
+        * PSWITCH_EVENT_PRESSED  : AC online
+        */
+
+       sysmon_pswitch_event(&sc->sc_smpsw, status == 0 ?
+           PSWITCH_EVENT_RELEASED : PSWITCH_EVENT_PRESSED);
+
        if (AACAD_ISSET(sc, AACAD_F_VERBOSE))
                printf("%s: AC adapter %sconnected\n",
                    sc->sc_dev.dv_xname, status == 0 ? "not " : "");
diff -r 43154536e035 -r 13e2729917da sys/dev/acpi/files.acpi
--- a/sys/dev/acpi/files.acpi   Mon May 03 07:43:37 2004 +0000
+++ b/sys/dev/acpi/files.acpi   Mon May 03 07:44:36 2004 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.acpi,v 1.23 2004/03/31 11:19:39 tron Exp $
+#      $NetBSD: files.acpi,v 1.24 2004/05/03 07:44:36 kochi Exp $
 
 include "dev/acpi/acpica/files.acpica"
 
@@ -27,7 +27,7 @@
 file   dev/acpi/acpi_button.c          acpibut
 
 # ACPI AC Adapter
-device acpiacad: sysmon_envsys
+device acpiacad: sysmon_envsys, sysmon_power
 attach acpiacad at acpi
 file   dev/acpi/acpi_acad.c            acpiacad
 



Home | Main Index | Thread Index | Old Index