ReactOS 0.4.15-dev-7953-g1f49173
button.c File Reference
#include <precomp.h>
#include <debug.h>
Include dependency graph for button.c:

Go to the source code of this file.

Classes

struct  acpi_button
 

Macros

#define NDEBUG
 
#define _COMPONENT   ACPI_BUTTON_COMPONENT
 

Functions

static int acpi_button_add (struct acpi_device *device)
 
static int acpi_button_remove (struct acpi_device *device, int type)
 
void acpi_button_notify (ACPI_HANDLE handle, UINT32 event, void *data)
 
ACPI_STATUS acpi_button_notify_fixed (void *data)
 
int acpi_button_init (void)
 
void acpi_button_exit (void)
 

Variables

static struct acpi_driver acpi_button_driver
 
struct acpi_devicepower_button
 
struct acpi_devicesleep_button
 
struct acpi_devicelid_button
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_BUTTON_COMPONENT

Definition at line 31 of file button.c.

◆ NDEBUG

#define NDEBUG

Definition at line 28 of file button.c.

Function Documentation

◆ acpi_button_add()

static int acpi_button_add ( struct acpi_device device)
static

Definition at line 108 of file button.c.

110{
111 int result = 0;
113 struct acpi_button *button = NULL;
114
115 ACPI_FUNCTION_TRACE("acpi_button_add");
116
117 if (!device)
118 return_VALUE(-1);
119
120 button = ExAllocatePoolWithTag(NonPagedPool,sizeof(struct acpi_button), 'IPCA');
121 if (!button)
122 return_VALUE(-4);
123 memset(button, 0, sizeof(struct acpi_button));
124
125 button->device = device;
126 button->handle = device->handle;
128
129 /*
130 * Determine the button type (via hid), as fixed-feature buttons
131 * need to be handled a bit differently than generic-space.
132 */
139 }
146 }
153 }
160 }
167 }
168 else {
169 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n",
171 result = -15;
172 goto end;
173 }
174
175 /*
176 * Ensure only one button of each type is used.
177 */
178 switch (button->type) {
181 if (!power_button)
183 else {
184 ExFreePoolWithTag(button, 'IPCA');
185 return_VALUE(-15);
186 }
187 break;
190 if (!sleep_button)
192 else {
193 ExFreePoolWithTag(button, 'IPCA');
194 return_VALUE(-15);
195 }
196 break;
198 if (!lid_button)
200 else {
201 ExFreePoolWithTag(button, 'IPCA');
202 return_VALUE(-15);
203 }
204 break;
205 }
206
207 switch (button->type) {
212 button);
213 break;
218 button);
219 break;
224 button);
225 break;
226 default:
228 button->handle,
231 button);
232 break;
233 }
234
235 if (ACPI_FAILURE(status)) {
236 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
237 "Error installing notify handler\n"));
238 result = -15;
239 goto end;
240 }
241
242 DPRINT("%s [%s]\n",
244
245end:
246 if (result) {
247 ExFreePoolWithTag(button, 'IPCA');
248 }
249
251}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_OK
Definition: acexcep.h:97
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define return_VALUE(s)
Definition: acoutput.h:499
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define acpi_device_bid(d)
Definition: acpi_bus.h:186
#define acpi_driver_data(d)
Definition: acpi_bus.h:289
#define acpi_device_class(d)
Definition: acpi_bus.h:191
#define acpi_device_hid(d)
Definition: acpi_bus.h:188
#define acpi_device_name(d)
Definition: acpi_bus.h:190
#define ACPI_BUTTON_HID_LID
Definition: acpi_drivers.h:106
#define ACPI_BUTTON_TYPE_SLEEPF
Definition: acpi_drivers.h:103
#define ACPI_BUTTON_TYPE_SLEEP
Definition: acpi_drivers.h:102
#define ACPI_BUTTON_HID_SLEEPF
Definition: acpi_drivers.h:99
#define ACPI_BUTTON_HID_POWERF
Definition: acpi_drivers.h:91
#define ACPI_BUTTON_DEVICE_NAME_SLEEPF
Definition: acpi_drivers.h:101
#define ACPI_BUTTON_HID_POWER
Definition: acpi_drivers.h:90
#define ACPI_BUTTON_CLASS
Definition: acpi_drivers.h:83
#define ACPI_BUTTON_TYPE_LID
Definition: acpi_drivers.h:108
#define ACPI_BUTTON_TYPE_POWER
Definition: acpi_drivers.h:94
#define ACPI_BUTTON_TYPE_POWERF
Definition: acpi_drivers.h:95
#define ACPI_BUTTON_HID_SLEEP
Definition: acpi_drivers.h:98
#define ACPI_BUTTON_SUBCLASS_POWER
Definition: acpi_drivers.h:89
#define ACPI_BUTTON_DEVICE_NAME_SLEEP
Definition: acpi_drivers.h:100
#define ACPI_BUTTON_SUBCLASS_SLEEP
Definition: acpi_drivers.h:97
#define ACPI_BUTTON_DEVICE_NAME_POWER
Definition: acpi_drivers.h:92
#define ACPI_BUTTON_DEVICE_NAME_LID
Definition: acpi_drivers.h:107
#define ACPI_BUTTON_SUBCLASS_LID
Definition: acpi_drivers.h:105
#define ACPI_BUTTON_DEVICE_NAME_POWERF
Definition: acpi_drivers.h:93
#define ACPI_EVENT_POWER_BUTTON
Definition: actypes.h:765
#define ACPI_DEVICE_NOTIFY
Definition: actypes.h:845
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_EVENT_SLEEP_BUTTON
Definition: actypes.h:766
#define NULL
Definition: types.h:112
struct acpi_device * sleep_button
Definition: button.c:56
struct acpi_device * power_button
Definition: button.c:55
void acpi_button_notify(ACPI_HANDLE handle, UINT32 event, void *data)
Definition: button.c:64
ACPI_STATUS acpi_button_notify_fixed(void *data)
Definition: button.c:91
struct acpi_device * lid_button
Definition: button.c:57
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
ACPI_STATUS AcpiInstallNotifyHandler(ACPI_HANDLE Device, UINT32 HandlerType, ACPI_NOTIFY_HANDLER Handler, void *Context)
Definition: evxface.c:96
ACPI_STATUS AcpiInstallFixedEventHandler(UINT32 Event, ACPI_EVENT_HANDLER Handler, void *Context)
Definition: evxface.c:707
GLuint GLuint end
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD button
Definition: button.c:166
#define memset(x, y, z)
Definition: compat.h:39
#define DPRINT
Definition: sndvol32.h:71
struct acpi_device * device
Definition: button.c:50
Definition: devices.h:37
Definition: ps.c:97

◆ acpi_button_exit()

void acpi_button_exit ( void  )

Definition at line 314 of file button.c.

315{
316 ACPI_FUNCTION_TRACE("acpi_button_exit");
317
319
321}
#define return_VOID
Definition: acoutput.h:495
void acpi_bus_unregister_driver(struct acpi_driver *driver)
Definition: bus.c:1056
static struct acpi_driver acpi_button_driver
Definition: button.c:38

◆ acpi_button_init()

int acpi_button_init ( void  )

Definition at line 298 of file button.c.

299{
300 int result = 0;
301
302 ACPI_FUNCTION_TRACE("acpi_button_init");
303
305 if (result < 0) {
306 return_VALUE(-15);
307 }
308
309 return_VALUE(0);
310}
int acpi_bus_register_driver(struct acpi_driver *driver)
Definition: bus.c:1029

Referenced by acpi_init().

◆ acpi_button_notify()

void acpi_button_notify ( ACPI_HANDLE  handle,
UINT32  event,
void data 
)

Definition at line 64 of file button.c.

68{
69 struct acpi_button *button = (struct acpi_button *) data;
70
71 ACPI_FUNCTION_TRACE("acpi_button_notify");
72
73 if (!button || !button->device)
75
76 switch (event) {
78 acpi_bus_generate_event(button->device, event, ++button->pushed);
79 break;
80 default:
82 "Unsupported event [0x%x]\n", event));
83 break;
84 }
85
87}
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define ACPI_BUTTON_NOTIFY_STATUS
Definition: acpi_drivers.h:87
int acpi_bus_generate_event(struct acpi_device *device, UINT8 type, int data)
Definition: bus.c:485
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
struct _cl_event * event
Definition: glext.h:7739

Referenced by acpi_button_add(), acpi_button_notify_fixed(), and acpi_button_remove().

◆ acpi_button_notify_fixed()

ACPI_STATUS acpi_button_notify_fixed ( void data)

Definition at line 91 of file button.c.

93{
94 struct acpi_button *button = (struct acpi_button *) data;
95
96 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
97
98 if (!button)
100
102
104}
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496

Referenced by acpi_button_add(), and acpi_button_remove().

◆ acpi_button_remove()

static int acpi_button_remove ( struct acpi_device device,
int  type 
)
static

Definition at line 255 of file button.c.

256{
258 struct acpi_button *button = NULL;
259
260 ACPI_FUNCTION_TRACE("acpi_button_remove");
261
263 return_VALUE(-1);
264
266
267 /* Unregister for device notifications. */
268 switch (button->type) {
272 break;
276 break;
280 break;
281 default:
284 break;
285 }
286
287 if (ACPI_FAILURE(status))
288 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
289 "Error removing notify handler\n"));
290
291 ExFreePoolWithTag(button, 'IPCA');
292
293 return_VALUE(0);
294}
ACPI_STATUS AcpiRemoveNotifyHandler(ACPI_HANDLE Device, UINT32 HandlerType, ACPI_NOTIFY_HANDLER Handler)
Definition: evxface.c:273
ACPI_STATUS AcpiRemoveFixedEventHandler(UINT32 Event, ACPI_EVENT_HANDLER Handler)
Definition: evxface.c:786

Variable Documentation

◆ acpi_button_driver

struct acpi_driver acpi_button_driver
static
Initial value:
= {
{0,0},
0,
0,
"ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E",
}
#define ACPI_BUTTON_DRIVER_NAME
Definition: acpi_drivers.h:82
static int acpi_button_remove(struct acpi_device *device, int type)
Definition: button.c:255
static int acpi_button_add(struct acpi_device *device)
Definition: button.c:108

Definition at line 38 of file button.c.

Referenced by acpi_button_exit(), and acpi_button_init().

◆ lid_button

struct acpi_device* lid_button

Definition at line 57 of file button.c.

Referenced by acpi_button_add().

◆ power_button

struct acpi_device* power_button

Definition at line 55 of file button.c.

Referenced by acpi_button_add(), and ACPIDispatchDeviceControl().

◆ sleep_button

struct acpi_device* sleep_button

Definition at line 56 of file button.c.

Referenced by acpi_button_add(), and ACPIDispatchDeviceControl().