Specifications

CHAPTER 2. DRIVERS AND INTERFACES 7
event to the input core, are named input event. Once an input device driver has reported
an event by calling input event(), the input core generates a structure input event which
is passed to the registered input event handlers. The function input event() is defined in
<linux/input.h>.
void input_event(struct input_dev *dev, unsigned int type,
unsigned int code, int value);
Instead of calling input event(), device drivers can use one of several wrapper functions;
for the most commonly used event types (e.g. EV KEY) the input core provides wrapper func-
tions which call input event() with a hard-coded value for type. For example:
static inline void input_report_key(struct input_dev *dev, unsigned int code,
int value)
{
input_event(dev, EV_KEY, code, !!value);
}
In this case, the wrapper function input report key() not only calls input event() but
also normalizes value to either 0 or 1.
The input device support for the Linux kernel is enabled by setting the configuration
option CONFIG INPUT to either y (compile static into kernel) or m (compile as module). Setting
CONFIG INPUT=n would result in a system which can not be controlled by a keyboard or another
input device. Thus, the default is CONFIG INPUT=y.
2.2 Keyboard Device Drivers
Drivers for desktop keyboards which are not connected using either USB or Bluetooth are
located in drivers/input/keyboard. All keyboard drivers register themselves with the func-
tion input register device() as described above and report occurring events by calling the
input core’s function input event() or respectively one of the wrapper functions.
Beside the driver for AT and PS/2 keyboards, Linux offers drivers for the following key-
boards: Sun Type 4 and Type 5, DECstation/VAXstation LK201/LK401, IBM PC/XT con-
nected by a parallel port keyboard adapter, the Apple Newton keyboard, keyboards connected
via the Maple bus found on the game console Dreamcast and Amiga keyboards. These drivers
are indicated as “Device Drivers” in Figure 2.1.
The corresponding event handler for input events generated by the various keyboard drivers
is keyboard.c, which is found in the directory drivers/char. All keyboard drivers de-
pend on this event handler. Upon connecting a new input device to the system the function
kbd connect() is called. This function is implemented by keyboard.c and validates the new
device for its capabilities. If the device has the ability to generate keyboard input events,
keyboard.c accepts this device by adding itself as an event handler for the input device and
therefore handles its future input events.
Since the keyboard device drivers are reporting scancodes to the input core, the event
handler keyboard.c is responsible to convert the scancodes to corresponding keycodes. For
each keypress a keyboard generates a sequence of scancodes which result in a series of input