From owner-svn-src-all@FreeBSD.ORG Mon Dec 5 00:12:10 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83D9E106564A; Mon, 5 Dec 2011 00:12:10 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 59C118FC13; Mon, 5 Dec 2011 00:12:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB50CA7I008921; Mon, 5 Dec 2011 00:12:10 GMT (envelope-from jhibbits@svn.freebsd.org) Received: (from jhibbits@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB50CATY008917; Mon, 5 Dec 2011 00:12:10 GMT (envelope-from jhibbits@svn.freebsd.org) Message-Id: <201112050012.pB50CATY008917@svn.freebsd.org> From: Justin Hibbits Date: Mon, 5 Dec 2011 00:12:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228270 - in head: etc/devd sys/powerpc/powermac X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Dec 2011 00:12:10 -0000 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 {