ACPI
  list
   With FreeBSD
   Gnats database (panasonic)
  memo
  PR
  lid_sw
    powerd or script
    sysctl -w is the ..
    acpilid_notify_handler
  sequence
  acpi.c

Last Update: "2004/07/31 23:17:31 makoto"

lid_sw

PR pkg/42051 lid switch works only once
PR pkg/49024 Powerd invokes lid_switch by acpilid only ONCE after boot
  1. Stop powerd (see /etc/defaults/rc.conf, powerd may be "YES" by following lines)
    if /sbin/sysctl -q hw.acpi.root; then
            powerd=YES
    fi
    
    To disable powerd on boot, you need to say following in /etc/rc.conf
    powerd= NO
    
  2. Build kernel with following debug print:
    diff --git a/sys/dev/acpi/acpi_lid.c b/sys/dev/acpi/acpi_lid.c
    index 7ab5db269b6..f52d8305573 100644
    --- a/sys/dev/acpi/acpi_lid.c
    +++ b/sys/dev/acpi/acpi_lid.c
    @@ -159,6 +159,7 @@ acpilid_notify_handler(ACPI_HANDLE handle, uint32_t notify, void *context)
     	static const int handler = OSL_NOTIFY_HANDLER;
     	device_t dv = context;
     
    +	aprint_normal("notify 0x%02X\n", notify);
     	switch (notify) {
     
     	case ACPI_NOTIFY_LID:
    
  3. above line (in the function acpilid_notify_handler) is any times active whenever open and close lid.
    (Assuming powerd is not running).
  4. Then start powerd.
    It will get sleep only once.
    Another open/close lid won't give item 2 debug print anymore.
  5. Above acpilid_notify_handler is referenced only once at a line 115 inside the function of acpilid_attach at the part of acpi_register_notify

powerd or script

powerd invokes /etc/powerd/scripts/lid_switch
Let me decide which is harmfull, powerd itself or script invoked.
Try disabling sleep line in script. just not to issue following line
(Have # char in the beginning the line)
  #       sysctl -w hw.acpi.sleep.state=3
Then repeating lid open/close anytimes. Every time you do you may have following print out:
(If kernel is configured with 'options ACPI_DEBUG')
$dhcpd is not enabled - see rc.conf(5).                                         
Use the following if you wish to perform the operation:                         
  /etc/rc.d/dhcpd onestart                                                      
err: /etc/powerd/scripts/lid_switch exited with status 1dispatch_dev_power: even
t type 0                                                                        
<?xml version="1.0" encoding="UTF-8"?>                                          
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.
com/DTDs/PropertyList-1.0.dtd">                                                 
<plist version="1.0">
<dict>
        <key>driver-name</key>
        <string>acpilid0</string>
        <key>power-type</key>
        <string>pswitch</string>
        <key>powerd-event-name</key>
        <string>released</string>
        <key>powerd-script-name</key>
        <string>lid_switch</string>
</dict>
</plist>
running script: /etc/powerd/scripts/lid_switch acpilid0 released
wsconsctl: WSDISPLAYIO_PARAM_BACKLIGHT: Inappropriate ioctl for device

sysctl -w is the ..

  1. reboot
  2. make sure powerd is not running
  3. issue following command
      sysctl -w hw.acpi.sleep.state=3 
  4. run powerd
  5. close lid
This procedure won't give sleep. Step 3. above is the harmful point.

acpilid_notify_handler

is appeared only at
CF-SX2@makoto 23:33:40/170821(..git-work/netbsd-src)% grep -r acpilid_notify_handler sys  
sys/dev/acpi/acpi_lid.c:static void     acpilid_notify_handler(ACPI_HANDLE, uint32_t, void *);
sys/dev/acpi/acpi_lid.c:        (void)acpi_register_notify(sc->sc_node, acpilid_notify_handler);
sys/dev/acpi/acpi_lid.c: * acpilid_notify_handler:
sys/dev/acpi/acpi_lid.c:acpilid_notify_handler(ACPI_HANDLE handle, uint32_t notify, void *context)
Last Update: Mon, 21 Aug 2017 05:48:39 GMT 1.66 2008/03/08