From owner-freebsd-ppc@FreeBSD.ORG Thu Oct 13 02:25:24 2011 Return-Path: Delivered-To: freebsd-ppc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 539ED10656A5 for ; Thu, 13 Oct 2011 02:25:24 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id 0E03A8FC0A for ; Thu, 13 Oct 2011 02:25:23 +0000 (UTC) Received: by ywp17 with SMTP id 17so843386ywp.13 for ; Wed, 12 Oct 2011 19:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:message-id:from:to:content-type:mime-version:subject:date :x-mailer; bh=tWNQtl+9wLGff9cso/cpXwJCWFz9P+DGpzeZlo5z1N4=; b=VEoFhH5UZ5LV4fvgShwLbx7P09ugT1XY9RVHQ4ocChdYn3e2rQy8U9oNR7mlovraY/ gUAwctrnUAl39oLC1+TIkGQpod69srVjoH4FnN2MM2oR5iKIdBh35h4gZ+fpTABy1WkQ xLgtgvecHuUuyIb2fV8KW5Zj3PovSxCR4DN/0= Received: by 10.236.145.74 with SMTP id o50mr2198759yhj.36.1318472723319; Wed, 12 Oct 2011 19:25:23 -0700 (PDT) Received: from triad.knownspace (216-15-41-8.c3-0.gth-ubr1.lnh-gth.md.cable.rcn.com. [216.15.41.8]) by mx.google.com with ESMTPS id w70sm5309312yhk.6.2011.10.12.19.25.21 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Oct 2011 19:25:22 -0700 (PDT) Sender: Justin Hibbits Message-Id: <1AEF648C-5F24-44F6-893C-1E82C2192DE8@alumni.cwru.edu> From: Justin Hibbits To: FreeBSD PowerPC ML Content-Type: multipart/mixed; boundary=Apple-Mail-28-863103485 Mime-Version: 1.0 (Apple Message framework v936) Date: Wed, 12 Oct 2011 22:25:19 -0400 X-Mailer: Apple Mail (2.936) Subject: RFT: PowerBook lid detection X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Oct 2011 02:25:24 -0000 --Apple-Mail-28-863103485 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Attached is a patch which sends devctl notifications when the lid is opened and closed on a powerbook. It should turn off the backlight on PMU-controlled-backlight laptops (doesn't on mine, because mine is controlled by the video card). Testing please? - Justin --Apple-Mail-28-863103485 Content-Disposition: attachment; filename=pmu_lid.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="pmu_lid.diff" Content-Transfer-Encoding: 7bit Index: ../powermac/pmu.c =================================================================== --- ../powermac/pmu.c (revision 226307) +++ ../powermac/pmu.c (working copy) @@ -705,6 +705,24 @@ 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, do this + if ((resp[2] & PMU_ENV_LID_CLOSED) && (!sc->lid_closed)) { + uint8_t power_events = PMU_POW_BACKLIGHT | PMU_POW_OFF; + pmu_send(sc, PMU_POWER_CTRL, 1, &power_events, 16, resp); + 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)) { + uint8_t power_events = PMU_POW_BACKLIGHT | PMU_POW_ON; + // if the lid was just opened, do this + pmu_send(sc, PMU_POWER_CTRL, 1, &power_events, 16, resp); + if (devctl_process_running()) + devctl_notify("PMU", "lid", "open", NULL); + sc->lid_closed = 0; + } + } } static u_int Index: ../powermac/pmuvar.h =================================================================== --- ../powermac/pmuvar.h (revision 226307) +++ ../powermac/pmuvar.h (working copy) @@ -160,6 +160,7 @@ volatile int sc_autopoll; int sc_batteries; struct cdev *sc_leddev; + int lid_closed; }; struct pmu_battstate { --Apple-Mail-28-863103485 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-28-863103485--