From 5b9881a18ba54f13ce9839a44a3edc417cd00cc6 Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Thu, 7 Jan 2016 12:08:19 +0000 Subject: Use a resune hook to re-evaluate the "_LID" status upon resume. This fixes the lid sensor for machines, like the x220, that do not generate an event when the lid opens. ok kettenis@, deraadt@ --- sys/dev/acpi/acpibtn.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpi/acpibtn.c b/sys/dev/acpi/acpibtn.c index dada815d555..2f5ca6bd647 100644 --- a/sys/dev/acpi/acpibtn.c +++ b/sys/dev/acpi/acpibtn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibtn.c,v 1.41 2015/01/27 19:40:14 kettenis Exp $ */ +/* $OpenBSD: acpibtn.c,v 1.42 2016/01/07 12:08:18 mpi Exp $ */ /* * Copyright (c) 2005 Marco Peereboom * @@ -35,6 +35,7 @@ int acpibtn_match(struct device *, void *, void *); void acpibtn_attach(struct device *, struct device *, void *); int acpibtn_notify(struct aml_node *, int, void *); +int acpibtn_activate(struct device *, int); struct acpibtn_softc { struct device sc_dev; @@ -65,7 +66,8 @@ SLIST_HEAD(acpi_lid_head, acpi_lid) acpibtn_lids = SLIST_HEAD_INITIALIZER(acpibtn_lids); struct cfattach acpibtn_ca = { - sizeof(struct acpibtn_softc), acpibtn_match, acpibtn_attach + sizeof(struct acpibtn_softc), acpibtn_match, acpibtn_attach, NULL, + acpibtn_activate }; struct cfdriver acpibtn_cd = { @@ -155,7 +157,7 @@ acpibtn_attach(struct device *parent, struct device *self, void *aux) struct acpibtn_softc *sc = (struct acpibtn_softc *)self; struct acpi_attach_args *aa = aux; struct acpi_lid *lid; - int64_t lid_open; + int64_t lid_open = 1; int64_t st; sc->sc_acpi = (struct acpi_softc *)parent; @@ -260,3 +262,23 @@ sleep: return (0); } + +int +acpibtn_activate(struct device *self, int act) +{ + struct acpibtn_softc *sc = (struct acpibtn_softc *)self; + int64_t lid_open = 1; + + switch (act) { + case DVACT_WAKEUP: + switch (sc->sc_btn_type) { + case ACPIBTN_LID: + aml_evalinteger(sc->sc_acpi, sc->sc_devnode, + "_LID", 0, NULL, &lid_open); + sc->sc_sens.value = lid_open; + break; + } + break; + } + return (0); +} -- cgit v1.2.3