From owner-acpi-jp@jp.freebsd.org  Fri Jan 12 11:27:11 2001
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id LAA84687;
	Fri, 12 Jan 2001 11:27:11 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from meow.osd.bsdi.com (meow.osd.bsdi.com [204.216.28.88])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id LAA84680
	for <acpi-jp@jp.freebsd.org>; Fri, 12 Jan 2001 11:27:10 +0900 (JST)
	(envelope-from jhb@FreeBSD.org)
Received: from laptop.baldwin.cx (john@jhb-laptop.osd.bsdi.com [204.216.28.241])
	by meow.osd.bsdi.com (8.11.1/8.9.3) with ESMTP id f0C2QF121803
	for <acpi-jp@jp.freebsd.org>; Thu, 11 Jan 2001 18:26:15 -0800 (PST)
	(envelope-from jhb@FreeBSD.org)
Message-ID: <XFMail.010111182644.jhb@FreeBSD.org>
X-Mailer: XFMail 1.4.0 on FreeBSD
X-Priority: 3 (Normal)
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0
Date: Thu, 11 Jan 2001 18:26:44 -0800 (PST)
From: John Baldwin <jhb@FreeBSD.org>
To: acpi-jp@jp.freebsd.org
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 1029
Subject: [acpi-jp 1029] Sysctls to control sleep states
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: jhb@FreeBSD.org

Hey all,

I've been playing with the latest ACPI code in -current on my Inspiron 5000e. 

First, there are times when I close the lid on my laptop that I don't want it
to actually suspend. (If I'm building world at night while I'm sleeping and want
the screen off, but for the machien to keep going for example.)  However, at
other times I do wish for it to suspend.  The easiest method of making this
configurable seemed to be to make the sleep state used on a sleep event to be
configured via sysctl.  This will allow a userland tool to set the default
states as well.  The result is this:

> sysctl hw.acpi0
hw.acpi0.power_button_state: 6
hw.acpi0.sleep_button_state: 1
hw.acpi0.lid_switch_state: 1

Right now the states are just the integer constants.  If S[0-5] had defined
names, I would prefer to use those, but I didn't find any official names for
them unfortunately.  Since ACPI_STATE_S5 is actually 6, it might make more
sense to use a function to map 0 to ACPI_STATE_S0, 2 to S2, 5 to S5, etc.  We
could even use the strings "S0", "S1", etc.  Whatever you all prefer can be
done with ease.

The patch to do this is available from
http://www.FreeBSD.org/~jhb/patches/acpi_sx.patch and applies to sys/.

Note that this uses dynamic sysctls to allocate and create a new sysctl tree
under hw during acpi_attach().  More sysctls could be added later on if needed.

Secondly, to actually get ACPI booting on my Inspiron, I had to disable the
Super I/O chip with help from Mike Smith via this loader tweak:

debug.acpi.avoid="_SB_.PCI0.PX40.SIO_"

I'm not sure if that is related to a problem I have or not, but when I try to
suspend the machine (either with the sleep button or by closing the lid) the
machine instantly resumes after trying to suspend.  The machine does shutdown
properly on a power button event however.  Any suggestions or requests for more
info welcome.  Good work so far!

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/
