Minimal sample custom devd.conf ( was Re: IBM T30 and suspend/resume capability )

Norberto Meijome freebsd at meijome.net
Fri Aug 25 09:06:06 UTC 2006


On Thu, 24 Aug 2006 17:14:01 +0200
Fabian Keil <freebsd-listen at fabiankeil.de> wrote:

> > nice one :) do u know if this works for other Thinkpad models? I'm on a much
> > newer  Z60m here - acpi works fine, suspend is much more reliable after I
> > wrote my own suspend script called by devd, but hibernation is something
> > I'd be interested in.
> 
> AFAIK there are two types of suspend to disk, one that heavily depends
> on the BIOS to do the work and one that doesn't. FreeBSD currently only
> supports the first one while modern laptops usually only support the second.

gotcha :) I would guess mine is supported by BIOS: (S4 )


hw.acpi.supported_sleep_state: S3 S4 S5
hw.acpi.power_button_state: S5
hw.acpi.sleep_button_state: S3
hw.acpi.lid_switch_state: NONE
hw.acpi.standby_state: S1
hw.acpi.suspend_state: S3

> 
> BTW: what exactly does your devd script do?

Nothing major really... I was getting some crashes on resume, and the default
acpi_ibm behaviours for the fn- keys weren't too much of my liking... so what I
did (for the archives... hopefully it'll be useful for someone else)

1) added to /etc/sysctl.conf
--
# Needed for custom ACPI control
# This will pass ACPI events to devd after acpi_ibm.
#    Custom devd config can be found in /usr/local/etc/devd
dev.acpi_ibm.0.events=1
---

2) ensured /etc/devd.conf contains in the options { } section:
 directory "/usr/local/etc/devd";


3) Created a ayiin.conf file in /usr/local/etc/devd  (ayiin = name of
machine... anything would work really), with the following lines
----
notify 10 {
## Fn-F4 : Suspend
        match "system"          "ACPI";
        match "subsystem"       "IBM";
        match "notify"          "0x04";
        action "/bin/sh -c /home/betom/bin/do_acpi_suspend.sh";
}; 


notify 10 {
## Closing lid : powerdown LCD with radeon tool
        match "system"          "ACPI";
        match "subsystem"       "Lid";
        match "notify"          "0x00";
        action "/usr/local/bin/radeontool light off; /usr/local/bin/radeontool
dac off"; };

notify 10 {
## Opening lid : power up LCD with radeon tool
        match "system"          "ACPI";
        match "subsystem"       "Lid";
        match "notify"          "0x01";
        action "/usr/local/bin/radeontool light on; /usr/local/bin/radeontool
dac off"; };  

notify 10 {
## Fn-F2 - Lock
        match "system"          "ACPI";
        match "subsystem"       "IBM";
        match "notify"          "0x02";
		action "/usr/X11R6/bin/xscreensaver-command -lock";
        #action "/bin/sh -c /home/betom/bin/do_acpi_x_lock.sh";
};  
------------------------------- end of /usr/local/etc/devd/ayiin.conf

4) Created /home/betom/bin/do_acpi_suspend.sh as follows:
----
#!/usr/local/bin/bash

# switch to first VC
vidcontrol -s 1 < /dev/ttyv0

# make sure we sync all the disk buffers ... in case we die on resume, this
minimises problems with fsck
sync 
sync
sleep 3
sync
sync
sleep 1
sync
zzz
----

and that's about it... I want to customise detaching devices ( hdac.ko from
multimedia@ usually dies after resume, but it's not so easy to handle, as
several apps keep the mixer / pcm open... in particular flash plugin in
firefox... ), but i havent done any more yet.

Anyway, some notes : 
on resume, the console stays on VC1, so I simply have to do Alt-F9 and I'm back
in X. When I used to run on MODE_24 (text mode), I'd get the actual console.
Now I'm running on MODE_279 (1024x768x16), so I get a soft-white screen
instead.. possibly related to this in dmesg on resume
Aug 23 09:44:37 ayiin kernel: vga0: failed to save state (nbytes=4)


The FnF2 call xscreensaver-command-lock needs me to have xhost +local: set in
my session script (devd runs as root, so it normally cannot execute on my X
Session).

Since I switched to custom devd msg handling, i've lost the bluetooth device  -
Fn-F5 (radio on) would attach the bt device... i'll have to configure that, or
maybe run


More information about the freebsd-mobile mailing list