This is a discussion on [PATCH] acpibtn(4) -- added sensor framework support within the mailing.openbsd.tech forums, part of the OpenBSD category; --> this patch add button status control to acpibtn(4) driver via sensor framework. % dmesg | grep acpibtn acpibtn0 at ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| this patch add button status control to acpibtn(4) driver via sensor framework. % dmesg | grep acpibtn acpibtn0 at acpi0: LID_ acpibtn1 at acpi0: SLPB % sysctl hw.sensors hw.sensors.0=acpibtn0, button status, Off hw.sensors.1=acpibtn1, button status, Off please test, comment Index: acpibtn.c ================================================== ================= RCS file: /cvs/src/sys/dev/acpi/acpibtn.c,v retrieving revision 1.10 diff -u -p -u -r1.10 acpibtn.c --- acpibtn.c 31 May 2006 10:01:56 -0000 1.10 +++ acpibtn.c 10 Oct 2006 09:44:59 -0000 @@ -34,6 +34,7 @@ int acpibtn_match(struct device *, void *, void *); void acpibtn_attach(struct device *, struct device *, void *); +void acpibtn_refresh(void *); int acpibtn_notify(struct aml_node *, int, void *); struct acpibtn_softc { @@ -46,6 +47,8 @@ struct acpibtn_softc { struct aml_node *sc_devnode; int sc_btn_type; + int sc_flag; + struct sensor sc_sens; #define ACPIBTN_LID 0 #define ACPIBTN_POWER 1 #define ACPIBTN_SLEEP 2 @@ -96,7 +99,27 @@ acpibtn_attach(struct device *parent, st printf(": %s\n", sc->sc_devnode->parent->name); - aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev, acpibtn_notify, sc); + aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev, + acpibtn_notify, sc); + + memset(&sc->sc_sens, 0, sizeof(sc->sc_sens)); + strlcpy(sc->sc_sens.device, DEVNAME(sc), sizeof(sc->sc_sens.device)); + strlcpy(sc->sc_sens.desc, "button status", + sizeof(sc->sc_sens.desc)); + sc->sc_sens.type = SENSOR_INDICATOR; + sensor_add(&sc->sc_sens); + sc->sc_sens.value = 0; + + if (sensor_task_register(sc, acpibtn_refresh, 5)) + printf(", unable to register update task\n"); +} + +void +acpibtn_refresh(void *arg) +{ + struct acpibtn_softc *sc = arg; + + sc->sc_sens.value = sc->sc_flag; } int @@ -125,6 +148,11 @@ acpibtn_notify(struct aml_node *node, in dnprintf(10, "acpibtn_notify: %.2x %s\n", notify_type, sc->sc_devnode->parent->name); + + if (sc->sc_flag == 0) + sc->sc_flag = 1; + else + sc->sc_flag = 0; switch (sc->sc_btn_type) { case ACPIBTN_LID: |