Deleted Added
full compact
acpi_button.c (118783) acpi_button.c (120308)
1/*-
2 * Copyright (c) 2000 Mitsaru IWASAKI <iwasaki@jp.freebsd.org>
3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org>
4 * Copyright (c) 2000 BSDi
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
1/*-
2 * Copyright (c) 2000 Mitsaru IWASAKI <iwasaki@jp.freebsd.org>
3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org>
4 * Copyright (c) 2000 BSDi
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/dev/acpica/acpi_button.c 118783 2003-08-11 15:34:43Z njl $
28 * $FreeBSD: head/sys/dev/acpica/acpi_button.c 120308 2003-09-21 02:49:59Z njl $
29 */
30
31#include "opt_acpi.h"
32#include <sys/param.h>
33#include <sys/kernel.h>
34#include <sys/bus.h>
35
36#include "acpi.h"
37#include <dev/acpica/acpivar.h>
38
39/* Hooks for the ACPI CA debugging infrastructure */
40#define _COMPONENT ACPI_BUTTON
41ACPI_MODULE_NAME("BUTTON")
42
43struct acpi_button_softc {
44 device_t button_dev;
45 ACPI_HANDLE button_handle;
29 */
30
31#include "opt_acpi.h"
32#include <sys/param.h>
33#include <sys/kernel.h>
34#include <sys/bus.h>
35
36#include "acpi.h"
37#include <dev/acpica/acpivar.h>
38
39/* Hooks for the ACPI CA debugging infrastructure */
40#define _COMPONENT ACPI_BUTTON
41ACPI_MODULE_NAME("BUTTON")
42
43struct acpi_button_softc {
44 device_t button_dev;
45 ACPI_HANDLE button_handle;
46 boolean_t button_type; /* Power or Sleep Button */
46 boolean_t button_type;
47#define ACPI_POWER_BUTTON 0
48#define ACPI_SLEEP_BUTTON 1
47#define ACPI_POWER_BUTTON 0
48#define ACPI_SLEEP_BUTTON 1
49 boolean_t fixed;
49};
50
51#define ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP 0x80
52#define ACPI_NOTIFY_BUTTON_PRESSED_FOR_WAKEUP 0x02
53
54static int acpi_button_probe(device_t dev);
55static int acpi_button_attach(device_t dev);
56static int acpi_button_suspend(device_t dev);
57static int acpi_button_resume(device_t dev);
58static void acpi_button_notify_handler(ACPI_HANDLE h, UINT32 notify,
59 void *context);
50};
51
52#define ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP 0x80
53#define ACPI_NOTIFY_BUTTON_PRESSED_FOR_WAKEUP 0x02
54
55static int acpi_button_probe(device_t dev);
56static int acpi_button_attach(device_t dev);
57static int acpi_button_suspend(device_t dev);
58static int acpi_button_resume(device_t dev);
59static void acpi_button_notify_handler(ACPI_HANDLE h, UINT32 notify,
60 void *context);
61static ACPI_STATUS
62 acpi_button_fixed_handler(void *context);
60static void acpi_button_notify_pressed_for_sleep(void *arg);
61static void acpi_button_notify_pressed_for_wakeup(void *arg);
62
63static device_method_t acpi_button_methods[] = {
64 /* Device interface */
65 DEVMETHOD(device_probe, acpi_button_probe),
66 DEVMETHOD(device_attach, acpi_button_attach),
67 DEVMETHOD(device_suspend, acpi_button_suspend),

--- 12 unchanged lines hidden (view full) ---

80static devclass_t acpi_button_devclass;
81DRIVER_MODULE(acpi_button, acpi, acpi_button_driver, acpi_button_devclass,
82 0, 0);
83
84static int
85acpi_button_probe(device_t dev)
86{
87 struct acpi_button_softc *sc;
63static void acpi_button_notify_pressed_for_sleep(void *arg);
64static void acpi_button_notify_pressed_for_wakeup(void *arg);
65
66static device_method_t acpi_button_methods[] = {
67 /* Device interface */
68 DEVMETHOD(device_probe, acpi_button_probe),
69 DEVMETHOD(device_attach, acpi_button_attach),
70 DEVMETHOD(device_suspend, acpi_button_suspend),

--- 12 unchanged lines hidden (view full) ---

83static devclass_t acpi_button_devclass;
84DRIVER_MODULE(acpi_button, acpi, acpi_button_driver, acpi_button_devclass,
85 0, 0);
86
87static int
88acpi_button_probe(device_t dev)
89{
90 struct acpi_button_softc *sc;
91 int ret = ENXIO;
88
89 sc = device_get_softc(dev);
92
93 sc = device_get_softc(dev);
90 if (acpi_get_type(dev) == ACPI_TYPE_DEVICE) {
91 if (!acpi_disabled("button")) {
92 if (acpi_MatchHid(dev, "PNP0C0C")) {
93 device_set_desc(dev, "Power Button");
94 sc->button_type = ACPI_POWER_BUTTON;
95 return (0);
96 }
97 if (acpi_MatchHid(dev, "PNP0C0E")) {
98 device_set_desc(dev, "Sleep Button");
99 sc->button_type = ACPI_SLEEP_BUTTON;
100 return (0);
101 }
94 if (acpi_get_type(dev) == ACPI_TYPE_DEVICE && !acpi_disabled("button")) {
95 if (acpi_MatchHid(dev, "PNP0C0C")) {
96 device_set_desc(dev, "Power Button");
97 sc->button_type = ACPI_POWER_BUTTON;
98 ret = 0;
99 } else if (acpi_MatchHid(dev, "ACPI_FPB")) {
100 device_set_desc(dev, "Power Button (fixed)");
101 sc->button_type = ACPI_POWER_BUTTON;
102 sc->fixed = 1;
103 ret = 0;
104 } else if (acpi_MatchHid(dev, "PNP0C0E")) {
105 device_set_desc(dev, "Sleep Button");
106 sc->button_type = ACPI_SLEEP_BUTTON;
107 ret = 0;
108 } else if (acpi_MatchHid(dev, "ACPI_FSB")) {
109 device_set_desc(dev, "Sleep Button (fixed)");
110 sc->button_type = ACPI_SLEEP_BUTTON;
111 sc->fixed = 1;
112 ret = 0;
102 }
103 }
113 }
114 }
104 return (ENXIO);
115 return (ret);
105}
106
107static int
108acpi_button_attach(device_t dev)
109{
110 struct acpi_button_softc *sc;
111 ACPI_STATUS status;
116}
117
118static int
119acpi_button_attach(device_t dev)
120{
121 struct acpi_button_softc *sc;
122 ACPI_STATUS status;
123 int event;
112
113 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
114
115 sc = device_get_softc(dev);
116 sc->button_dev = dev;
117 sc->button_handle = acpi_get_handle(dev);
118
124
125 ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
126
127 sc = device_get_softc(dev);
128 sc->button_dev = dev;
129 sc->button_handle = acpi_get_handle(dev);
130
119 status = AcpiInstallNotifyHandler(sc->button_handle, ACPI_DEVICE_NOTIFY,
120 acpi_button_notify_handler, sc);
131 if (sc->fixed) {
132 event = (sc->button_type == ACPI_SLEEP_BUTTON) ?
133 ACPI_EVENT_SLEEP_BUTTON : ACPI_EVENT_POWER_BUTTON;
134 status = AcpiInstallFixedEventHandler(event,
135 acpi_button_fixed_handler, sc);
136 } else {
137 status = AcpiInstallNotifyHandler(sc->button_handle,
138 ACPI_DEVICE_NOTIFY, acpi_button_notify_handler, sc);
139 }
121 if (ACPI_FAILURE(status)) {
140 if (ACPI_FAILURE(status)) {
122 device_printf(sc->button_dev, "couldn't install Notify handler - %s\n",
141 device_printf(sc->button_dev, "couldn't install notify handler - %s\n",
123 AcpiFormatException(status));
124 return_VALUE (ENXIO);
125 }
126 acpi_device_enable_wake_capability(sc->button_handle, 1);
127 return_VALUE (0);
128}
129
130static int

--- 81 unchanged lines hidden (view full) ---

212 case ACPI_NOTIFY_BUTTON_PRESSED_FOR_WAKEUP:
213 AcpiOsQueueForExecution(OSD_PRIORITY_LO,
214 acpi_button_notify_pressed_for_wakeup, sc);
215 break;
216 default:
217 break; /* unknown notification value */
218 }
219}
142 AcpiFormatException(status));
143 return_VALUE (ENXIO);
144 }
145 acpi_device_enable_wake_capability(sc->button_handle, 1);
146 return_VALUE (0);
147}
148
149static int

--- 81 unchanged lines hidden (view full) ---

231 case ACPI_NOTIFY_BUTTON_PRESSED_FOR_WAKEUP:
232 AcpiOsQueueForExecution(OSD_PRIORITY_LO,
233 acpi_button_notify_pressed_for_wakeup, sc);
234 break;
235 default:
236 break; /* unknown notification value */
237 }
238}
239
240static ACPI_STATUS
241acpi_button_fixed_handler(void *context)
242{
243 struct acpi_button_softc *sc = (struct acpi_button_softc *)context;
244
245 if (context == NULL)
246 return_ACPI_STATUS (AE_BAD_PARAMETER);
247
248 acpi_button_notify_handler(sc->button_handle,
249 ACPI_NOTIFY_BUTTON_PRESSED_FOR_SLEEP, sc);
250 return_VALUE (AE_OK);
251}