From owner-acpi-jp@jp.freebsd.org  Sun Oct  8 19:08:55 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id TAA75582;
	Sun, 8 Oct 2000 19:08:55 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from tasogare.imasy.or.jp (daemon@tasogare.imasy.or.jp [202.227.24.5])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id TAA75577
	for <acpi-jp@jp.freebsd.org>; Sun, 8 Oct 2000 19:08:54 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Received: from localhost (iwasaki.imasy.or.jp [202.227.24.92])
	by tasogare.imasy.or.jp (8.10.2+3.3W/3.7W-tasogare/smtpfeed 1.07) with ESMTP id e98A8or29057
	for <acpi-jp@jp.freebsd.org>; Sun, 8 Oct 2000 19:08:50 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
To: acpi-jp@jp.freebsd.org
In-Reply-To: <200010080455.e984tnh00773@mass.osd.bsdi.com>
References: <20001007042124G.iwasaki@jp.FreeBSD.org>
	<200010080455.e984tnh00773@mass.osd.bsdi.com>
X-Mailer: Mew version 1.94.1 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20001008190846M.iwasaki@jp.FreeBSD.org>
Date: Sun, 08 Oct 2000 19:08:46 +0900
From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
X-Dispatcher: imput version 20000228(IM140)
Lines: 159
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 824
Subject: [acpi-jp 824] Re: acpi_lid patch 
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: iwasaki@jp.freebsd.org

> > Here is the patch for AcpiSetSystemSxState.  With this patch, my main
> > machine (Chandra2) can transit to S1/S5 perfectly :-)
> 
> Whoops, I left this out of the last megapatch.  I've been so damn busy 
> trying to work out what's going wrong with the EC code. 8(
> 
> I've merged it (looks good, just some comment fixes) and it'll go out in 
> the next patchset.

Thanks, mike.

> BTW, did you plan to implement support for fixed sleep/power buttons as 
> well in the button driver?  I have a machine here with a control method 
> sleep button but a fixed power button (I think).  It also has a 
> front-panel NMI button, which is really scary. 8)

Yes, I attached my latest patch, but not in acpi_button.c.  Fixed
sleep/power button feature is specified in FACP table and cannot be
probed by matching _HID, so it was difficult to integrate fixed
sleep/power initialization in acpi_button.c.  These are in acpi.c as
fixed events initialization in my latest patch attached.

The patch also includes;
 - Save softc pointer in sc->acpi_dev_t->si_drv1 for ioctls.
 - timeout -> AcpiOsQueueForExecution in acpi_button.c.
 - Add watanabe-san's name in acpi_lid.c because he originally wrote this driver.
 - Remove lid_status checking because some _LID method is bogus.
   My main laptop's _LID always returns ZERO :-(
   -- ACPI/data/chandra2.asl --
    Device(LID) {
        Name(_HID, 0xd0cd041)   
        Method(_LID) {
            Return(0x0)
        }
    }

  - Add my name in acpieventhandler.h.

Thanks

Index: acpi.c
===================================================================
RCS file: /home/iwasaki/cvs/acpica-bsd/dev/acpica/acpi.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 acpi.c
--- acpi.c	2000/10/08 05:06:24	1.1.1.4
+++ acpi.c	2000/10/08 09:22:20
@@ -286,9 +286,19 @@
     sc->acpi_sleep_button_sx = ACPI_SLEEP_BUTTON_DEFAULT_SX;
     sc->acpi_lid_switch_sx = ACPI_LID_SWITCH_DEFAULT_SX;
 
-    /* Install fixed-event handlers */
-    AcpiInstallFixedEventHandler(ACPI_EVENT_POWER_BUTTON, acpi_eventhandler_power_button_for_sleep, sc);
-    AcpiInstallFixedEventHandler(ACPI_EVENT_SLEEP_BUTTON, acpi_eventhandler_sleep_button_for_sleep, sc);
+    /* Enable and clear fixed events and install handlers. */
+    if (AcpiGbl_FACP != NULL && AcpiGbl_FACP->PwrButton == 0) {
+	AcpiEnableEvent(ACPI_EVENT_POWER_BUTTON, ACPI_EVENT_FIXED);
+	AcpiClearEvent(ACPI_EVENT_POWER_BUTTON, ACPI_EVENT_FIXED);
+	AcpiInstallFixedEventHandler(ACPI_EVENT_POWER_BUTTON, acpi_eventhandler_power_button_for_sleep, sc);
+	device_printf(dev, "power button is handled as a fixed feature programming model.\n");
+    }
+    if (AcpiGbl_FACP != NULL && AcpiGbl_FACP->SleepButton == 0) {
+	AcpiEnableEvent(ACPI_EVENT_SLEEP_BUTTON, ACPI_EVENT_FIXED);
+	AcpiClearEvent(ACPI_EVENT_SLEEP_BUTTON, ACPI_EVENT_FIXED);
+	AcpiInstallFixedEventHandler(ACPI_EVENT_SLEEP_BUTTON, acpi_eventhandler_sleep_button_for_sleep, sc);
+	device_printf(dev, "sleep button is handled as a fixed feature programming model.\n");
+    }
 
     /*
      * Scan the namespace and attach/initialise children.
@@ -322,6 +332,7 @@
      * Create the control device
      */
     sc->acpi_dev_t = make_dev(&acpi_cdevsw, 0, 0, 5, 0660, "acpi");
+    sc->acpi_dev_t->si_drv1 = sc;
 
 #ifdef ENABLE_DEBUGGER
     if (debugpoint && !strcmp(debugpoint, "running"))
Index: acpi_button.c
===================================================================
RCS file: /home/iwasaki/cvs/acpica-bsd/dev/acpica/acpi_button.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 acpi_button.c
--- acpi_button.c	2000/10/08 05:06:25	1.1.1.1
+++ acpi_button.c	2000/10/08 09:14:17
@@ -116,14 +116,6 @@
 
     AcpiInstallNotifyHandler(sc->button_handle, ACPI_DEVICE_NOTIFY, acpi_button_notify_handler, sc);
 
-    /*
-     * Enable events of interest to us.
-     */
-    AcpiEnableEvent(ACPI_EVENT_POWER_BUTTON, ACPI_EVENT_FIXED);
-    AcpiEnableEvent(ACPI_EVENT_SLEEP_BUTTON, ACPI_EVENT_FIXED);
-    AcpiClearEvent(ACPI_EVENT_POWER_BUTTON, ACPI_EVENT_FIXED);
-    AcpiClearEvent(ACPI_EVENT_SLEEP_BUTTON, ACPI_EVENT_FIXED);
-
     return(0);
 }
 
@@ -186,11 +178,11 @@
 
     switch (notify) {
     case ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP:
-	timeout(acpi_button_notify_pressed_for_sleep, (void *)sc, hz/2);
+	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_button_notify_pressed_for_sleep, sc);
 	device_printf(sc->button_dev, "pressed for sleep, button type: %d\n", sc->button_type);
 	break;   
     case ACPI_NOTIFY_BUTTON_PRESSED_FOR_WAKEUP:
-	timeout(acpi_button_notify_pressed_for_wakeup, (void *)sc, hz/2);
+	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_button_notify_pressed_for_wakeup, sc);
 	device_printf(sc->button_dev, "pressed for wakeup, button type: %d\n", sc->button_type);
 	break;   
     default:
Index: acpi_lid.c
===================================================================
RCS file: /home/iwasaki/cvs/acpica-bsd/dev/acpica/acpi_lid.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 acpi_lid.c
--- acpi_lid.c	2000/10/08 05:06:24	1.1.1.2
+++ acpi_lid.c	2000/10/08 09:44:27
@@ -1,4 +1,5 @@
 /*-
+ * Copyright (c) 2000 Takanori Watanabe <takawata@jp.freebsd.org>
  * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
  * Copyright (c) 2000 Michael Smith <msmith@freebd.org>
  * Copyright (c) 2000 BSDi
@@ -127,8 +128,6 @@
 	return;
     if (Object.Type != ACPI_TYPE_NUMBER) 
 	return;
-    if (sc->lid_status == Object.Number.Value)
-	return;
 
     /*
      * Update lid status
@@ -156,6 +155,7 @@
 {
     struct acpi_lid_softc	*sc = (struct acpi_lid_softc *)context;
 
+device_printf(sc->lid_dev, "Notify(Lid, 0x%x)\n", notify);
     switch (notify) {
     case ACPI_NOTIFY_STATUS_CHANGED:
 	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_lid_notify_status_changed, sc);
Index: acpieventhandler.h
===================================================================
RCS file: /home/iwasaki/cvs/acpica-bsd/dev/acpica/acpieventhandler.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 acpieventhandler.h
--- acpieventhandler.h	2000/10/08 05:06:25	1.1.1.1
+++ acpieventhandler.h	2000/10/08 09:10:25
@@ -1,5 +1,6 @@
 /*-
- * Copyright (c) 2000 Michael Smith
+ * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
+ * Copyright (c) 2000 Michael Smith <msmith@freebsd.org>
  * Copyright (c) 2000 BSDi
  * All rights reserved.
  *
