Specifications

CHAPTER 2. DRIVERS AND INTERFACES 12
reading from the ACPI event interface, the bus driver generates the actual ACPI event. An
ACPI event has the following data structure (defined in <acpi/acpi bus.h>):
struct acpi_bus_event {
struct list_head node;
acpi_device_class device_class;
acpi_bus_id bus_id;
u32 type;
u32 data;
};
To avoid race conditions, ACPI events are managed using the double linked list: if an ACPI
event occurs while another ACPI event is still being processed by the ACPI event driver, the
ACPI bus driver appends the new event to the tail of the list acpi bus event list. The
member device class is a char array which gives information about the device class. While
the ACPI device drivers are responsible to determine the device class for each ACPI device,
the ACPI bus driver copies this information to the ACPI event structure. The same procedure
applies to bus id. The members type and data contain additional information about the
actual event.
Button Driver
If the user presses one of the ACPI buttons and if the lid gets opened or closed a corresponding
ACPI event is generated by the ACPI button driver. The device class device class is set to
button/power for the power button, button/sleep for the sleep button and button/lid for the
lid switch. Correspondingly, the value of bus id is set to PWRF for the power button, SLPF
for the sleep button and LID for the lid switch. For all button events, type is set to 0x80.
Chapter 5.6.3 (Device Object Notifications) of the ACPI specification [Acp04] defines the valid
values for notifications. The member data is a counter and gets incremented each time the
corresponding button is pressed.
For example, a process reading from the ACPI event interface receives the following output
if first the power button is pressed, followed by pressing the sleep button and finally the lid is
closed and opened again.
button/power PWRF 00000080 00000001
button/sleep SLPF 00000080 00000001
button/lid LID 00000080 00000001
button/lid LID 00000080 00000002
While the events for the power button, sleep button and lid switch are common for all
ACPI compliant systems, there are several drivers for specific mobile computers which report
input events of special or function keys using ACPI, too. These drivers either use the ACPI
bus driver’s function acpi bus generate event()—and therefore generate events which can
be received using the ACPI event interface—or by implementing their own interface. Input
event drivers using ACPI which are part of the Linux kernel are discussed next, other ACPI
drivers which are available separately are discussed in Section §2.7.