Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Dec 2011 00:12:10 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r228270 - in head: etc/devd sys/powerpc/powermac
Message-ID:  <201112050012.pB50CATY008917@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Mon Dec  5 00:12:10 2011
New Revision: 228270
URL: http://svn.freebsd.org/changeset/base/228270

Log:
  Add a devd notification for closing/opening the lid on PowerBooks and iBooks.
  
  Approved by:	nwhitehorn (mentor)

Modified:
  head/etc/devd/apple.conf
  head/sys/powerpc/powermac/pmu.c
  head/sys/powerpc/powermac/pmuvar.h

Modified: head/etc/devd/apple.conf
==============================================================================
--- head/etc/devd/apple.conf	Mon Dec  5 00:00:47 2011	(r228269)
+++ head/etc/devd/apple.conf	Mon Dec  5 00:12:10 2011	(r228270)
@@ -11,6 +11,16 @@ notify 0 {
 };
 
 
+# Keyboard power key
+notify 0 {
+	match "system"		"PMU";
+	match "subsystem"	"lid";
+	match "type"		"close";
+	match "notify"		"0x0";
+	action			"shutdown -p now";
+};
+
+
 # The next blocks enable volume hotkeys that can be found on Apple laptops
 notify 0 {
 	match "system"		"PMU";

Modified: head/sys/powerpc/powermac/pmu.c
==============================================================================
--- head/sys/powerpc/powermac/pmu.c	Mon Dec  5 00:00:47 2011	(r228269)
+++ head/sys/powerpc/powermac/pmu.c	Mon Dec  5 00:12:10 2011	(r228270)
@@ -701,6 +701,20 @@ pmu_intr(void *arg)
 		adb_receive_raw_packet(sc->adb_bus,resp[1],resp[2],
 			len - 3,&resp[3]);
 	}
+	if (resp[1] & PMU_INT_ENVIRONMENT) {
+		// if the lid was just closed, notify devd.
+		if ((resp[2] & PMU_ENV_LID_CLOSED) && (!sc->lid_closed)) {
+			sc->lid_closed = 1;
+			if (devctl_process_running())
+				devctl_notify("PMU", "lid", "close", NULL);
+		}
+		else if (!(resp[2] & PMU_ENV_LID_CLOSED) && (sc->lid_closed)) {
+			// if the lid was just opened, notify devd.
+			if (devctl_process_running())
+				devctl_notify("PMU", "lid", "open", NULL);
+			sc->lid_closed = 0;
+		}
+	}
 }
 
 static u_int

Modified: head/sys/powerpc/powermac/pmuvar.h
==============================================================================
--- head/sys/powerpc/powermac/pmuvar.h	Mon Dec  5 00:00:47 2011	(r228269)
+++ head/sys/powerpc/powermac/pmuvar.h	Mon Dec  5 00:12:10 2011	(r228270)
@@ -160,6 +160,7 @@ struct pmu_softc {
 	volatile int	sc_autopoll;
 	int		sc_batteries;
 	struct cdev	*sc_leddev;
+	int	lid_closed;
 };
 
 struct pmu_battstate {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112050012.pB50CATY008917>