tech@

The diff here is the start of an ACPI WMI implementation to try and
support the hotkeys on my newer asus laptop. I wanted to get some
feedback on this before I went any further.

With this patch I get a line like this in dmesg:

acpiwmi at acpi0 not configured

so I think it is detecting correctly. Ignore the junk in acpiwmi.c.


Index: arch/amd64/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.352
diff -u -p -r1.352 GENERIC
--- arch/amd64/conf/GENERIC     4 Nov 2013 14:07:15 -0000       1.352
+++ arch/amd64/conf/GENERIC     9 Nov 2013 05:18:31 -0000
@@ -58,6 +58,7 @@ acpitoshiba*  at acpi?
 acpivideo*     at acpi?
 acpivout*      at acpivideo?
 acpipwrres*    at acpi?
+acpiwmi*       at acpi?
 aibs*          at acpi?
 
 mpbios0                at bios0
Index: dev/acpi/acpi.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.247
diff -u -p -r1.247 acpi.c
--- dev/acpi/acpi.c     6 Nov 2013 10:40:36 -0000       1.247
+++ dev/acpi/acpi.c     9 Nov 2013 05:18:33 -0000
@@ -124,6 +124,7 @@ int acpi_foundtmp(struct aml_node *, voi
 int    acpi_foundprw(struct aml_node *, void *);
 int    acpi_foundvideo(struct aml_node *, void *);
 int    acpi_foundsony(struct aml_node *node, void *arg);
+int    acpi_foundwmi(struct aml_node *, void *);
 
 int    acpi_foundide(struct aml_node *node, void *arg);
 int    acpiide_notify(struct aml_node *, int, void *);
@@ -945,6 +946,9 @@ acpi_attach(struct device *parent, struc
        /* attach docks */
        aml_find_node(&aml_root, "_DCK", acpi_founddock, sc);
 
+       /* check if WMI present */
+       aml_find_node(&aml_root, "_WDG", acpi_foundwmi, sc);
+
        /* check if we're running on a sony */
        aml_find_node(&aml_root, "GBRT", acpi_foundsony, sc);
 
@@ -2490,6 +2494,26 @@ acpi_foundsony(struct aml_node *node, vo
        aaa.aaa_memt = sc->sc_memt;
        aaa.aaa_node = node->parent;
        aaa.aaa_name = "acpisony";
+
+       config_found(self, &aaa, acpi_print);
+
+       return 0;
+}
+
+int
+acpi_foundwmi(struct aml_node *node, void *arg)
+{
+       struct acpi_softc       *sc = (struct acpi_softc *)arg;
+       struct device           *self = (struct device *)arg;
+       struct acpi_attach_args aaa;
+
+       dnprintf(10, "found wmi entry: %s\n", node->parent->name);
+
+       memset(&aaa, 0, sizeof(aaa));
+       aaa.aaa_iot = sc->sc_iot;
+       aaa.aaa_memt = sc->sc_memt;
+       aaa.aaa_node = node->parent;
+       aaa.aaa_name = "acpiwmi";
 
        config_found(self, &aaa, acpi_print);
 
Index: dev/acpi/acpireg.h
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpireg.h,v
retrieving revision 1.29
diff -u -p -r1.29 acpireg.h
--- dev/acpi/acpireg.h  6 Nov 2013 10:40:36 -0000       1.29
+++ dev/acpi/acpireg.h  9 Nov 2013 05:18:33 -0000
@@ -728,6 +728,7 @@ struct acpi_ivrs {
 #define ACPI_DEV_LD    "PNP0C0D"       /* Lid Device */
 #define ACPI_DEV_SBD   "PNP0C0E"       /* Sleep Button Device */
 #define ACPI_DEV_PILD  "PNP0C0F"       /* PCI Interrupt Link Device */
+#define ACPI_DEV_WMI   "PNP0C14"       /* Windows Management Instrumentation */
 #define ACPI_DEV_MEMD  "PNP0C80"       /* Memory Device */
 #define ACPI_DEV_SHC   "ACPI0001"      /* SMBus 1.0 Host Controller */
 #define ACPI_DEV_SMS1  "ACPI0002"      /* Smart Battery Subsystem */
Index: dev/acpi/acpiwmi.c
===================================================================
RCS file: dev/acpi/acpiwmi.c
diff -N dev/acpi/acpiwmi.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ dev/acpi/acpiwmi.c  9 Nov 2013 05:18:33 -0000
@@ -0,0 +1,63 @@
+/* $OpenBSD$ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/systm.h>
+#include <sys/workq.h>
+
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpidev.h>
+#include <dev/acpi/amltypes.h>
+#include <dev/acpi/dsdt.h>
+
+struct acpiwmi_softc {
+       struct device           sc_dev;
+
+       struct acpi_softc       *sc_acpi;
+       struct aml_node         *sc_devnode;
+};
+
+int    acpiwmi_match(struct device *, void *, void *);
+void   acpiwmi_attach(struct device *, struct device *, void *);
+int    acpiwmi_activate(struct device *, int);
+
+struct cfattach acpiwmi_ca = {
+       sizeof(struct acpiwmi_softc),
+       acpiwmi_match,
+       acpiwmi_attach,
+       acpiwmi_activate
+};
+
+struct cfdriver acpiwmi_cd = {
+       NULL, "acpiwmi", DV_DULL
+};
+
+const char *acpiwmi_hids[] = { ACPI_DEV_WMI, 0 };
+
+int
+acpiwmi_match(struct device *parent, void *match, void *aux)
+{
+       struct acpi_attach_args *aa = aux;
+       struct cfdata *cf = match;
+
+       return (acpi_matchhids(aa, acpiwmi_hids, cf->cf_driver->cd_name));
+}
+
+void
+acpiwmi_attach(struct device *parent, struct device *self, void *aux)
+{
+       struct acpiwmi_softc *sc = (struct acpiwmi_softc *)self;
+       struct acpi_attach_args *aa = aux;
+
+       sc->sc_acpi = (struct acpi_softc *)parent;
+       sc->sc_devnode = aa->aaa_node;
+
+       printf("\n");
+}
+
+int
+acpiwmi_activate(struct device *self, int act)
+{
+       return (0);
+}
Index: dev/acpi/files.acpi
===================================================================
RCS file: /cvs/src/sys/dev/acpi/files.acpi,v
retrieving revision 1.27
diff -u -p -r1.27 files.acpi
--- dev/acpi/files.acpi 6 Nov 2013 10:40:36 -0000       1.27
+++ dev/acpi/files.acpi 9 Nov 2013 05:18:33 -0000
@@ -107,6 +107,11 @@ device     acpipwrres
 attach acpipwrres at acpi
 file   dev/acpi/acpipwrres.c           acpipwrres needs-flag
 
+# ACPI wmi
+device acpiwmi
+attach acpiwmi at acpi
+file   dev/acpi/acpiwmi.c              acpiwmi
+
 # ASUSTeK AI Booster ATK0110
 device aibs
 attach aibs at acpi

Reply via email to