Module Name:    src
Committed By:   jruoho
Date:           Thu Dec 31 10:12:51 UTC 2009

Modified Files:
        src/sys/dev/acpi: acpi_lid.c

Log Message:
As the _PSW control method was deprecated in ACPI 3.0, augment the wake
event call with the newer _DSW control method.

ok pgoyette@, jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/acpi/acpi_lid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/acpi_lid.c
diff -u src/sys/dev/acpi/acpi_lid.c:1.29 src/sys/dev/acpi/acpi_lid.c:1.30
--- src/sys/dev/acpi/acpi_lid.c:1.29	Sun Nov 29 21:32:50 2009
+++ src/sys/dev/acpi/acpi_lid.c	Thu Dec 31 10:12:51 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_lid.c,v 1.29 2009/11/29 21:32:50 cegger Exp $	*/
+/*	$NetBSD: acpi_lid.c,v 1.30 2009/12/31 10:12:51 jruoho Exp $	*/
 
 /*
  * Copyright 2001, 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_lid.c,v 1.29 2009/11/29 21:32:50 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_lid.c,v 1.30 2009/12/31 10:12:51 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -153,15 +153,41 @@
 acpilid_wake_event(device_t dv, bool enable)
 {
 	struct acpilid_softc *sc = device_private(dv);
-
+	ACPI_OBJECT_LIST arg;
+	ACPI_OBJECT obj[3];
 	ACPI_STATUS rv;
 
+	/*
+	 * First try to call the Device Sleep Wake control method, _DSW.
+	 * Only if this is not available, resort to to the Power State
+	 * Wake control method, _PSW, which was deprecated in ACPI 3.0.
+	 */
+	obj[0].Integer.Value = enable ? 1 : 0;
+	obj[1].Integer.Value = obj[2].Integer.Value = 0;
+	obj[0].Type = obj[1].Type = obj[2].Type = ACPI_TYPE_INTEGER;
+
+	arg.Count = 3;
+	arg.Pointer = obj;
+
+	rv = AcpiEvaluateObject(sc->sc_node->ad_handle, "_DSW", &arg, NULL);
+
+	if (ACPI_SUCCESS(rv))
+		return;
+
+	if (rv != AE_NOT_FOUND)
+		goto fail;
+
 	rv = acpi_eval_set_integer(sc->sc_node->ad_handle, "_PSW",
 	    enable ? 1 : 0);
+
 	if (ACPI_FAILURE(rv) && rv != AE_NOT_FOUND)
-		aprint_error_dev(dv,
-		    "unable to evaluate _PSW handler: %s\n",
-		    AcpiFormatException(rv));
+		goto fail;
+
+	return;
+
+fail:
+	aprint_error_dev(dv, "unable to evaluate wake control method: %s\n",
+	    AcpiFormatException(rv));
 }
 
 /*

Reply via email to