input value representation
Definition
struct input_value {
__u16 type;
__u16 code;
__s32 value;
};
Members
represents an input device
Definition
struct input_dev {
const char * name;
const char * phys;
const char * uniq;
struct input_id id;
unsigned long propbit[BITS_TO_LONGS(INPUT_PROP_CNT)];
unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
unsigned long relbit[BITS_TO_LONGS(REL_CNT)];
unsigned long absbit[BITS_TO_LONGS(ABS_CNT)];
unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)];
unsigned long ledbit[BITS_TO_LONGS(LED_CNT)];
unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];
unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
unsigned int hint_events_per_packet;
unsigned int keycodemax;
unsigned int keycodesize;
void * keycode;
int (* setkeycode) (struct input_dev *dev,const struct input_keymap_entry *ke,unsigned int *old_keycode);
int (* getkeycode) (struct input_dev *dev,struct input_keymap_entry *ke);
struct ff_device * ff;
unsigned int repeat_key;
struct timer_list timer;
int rep[REP_CNT];
struct input_mt * mt;
struct input_absinfo * absinfo;
unsigned long key[BITS_TO_LONGS(KEY_CNT)];
unsigned long led[BITS_TO_LONGS(LED_CNT)];
unsigned long snd[BITS_TO_LONGS(SND_CNT)];
unsigned long sw[BITS_TO_LONGS(SW_CNT)];
int (* open) (struct input_dev *dev);
void (* close) (struct input_dev *dev);
int (* flush) (struct input_dev *dev, struct file *file);
int (* event) (struct input_dev *dev, unsigned int type, unsigned int code, int value);
struct input_handle __rcu * grab;
spinlock_t event_lock;
struct mutex mutex;
unsigned int users;
bool going_away;
struct device dev;
struct list_head h_list;
struct list_head node;
unsigned int num_vals;
unsigned int max_vals;
struct input_value * vals;
bool devres_managed;
};
Members
implements one of interfaces for input devices
Definition
struct input_handler {
void * private;
void (* event) (struct input_handle *handle, unsigned int type, unsigned int code, int value);
void (* events) (struct input_handle *handle,const struct input_value *vals, unsigned int count);
bool (* filter) (struct input_handle *handle, unsigned int type, unsigned int code, int value);
bool (* match) (struct input_handler *handler, struct input_dev *dev);
int (* connect) (struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id);
void (* disconnect) (struct input_handle *handle);
void (* start) (struct input_handle *handle);
bool legacy_minors;
int minor;
const char * name;
const struct input_device_id * id_table;
struct list_head h_list;
struct list_head node;
};
Members
Description
Input handlers attach to input devices and create input handles. There are likely several handlers attached to any given input device at the same time. All of them will get their copy of input event generated by the device.
The very same structure is used to implement input filters. Input core allows filters to run first and will not pass event to regular handlers if any of the filters indicate that the event should be filtered (by returning true from their filter() method).
Note that input core serializes calls to connect() and disconnect() methods.
links input device with an input handler
Definition
struct input_handle {
void * private;
int open;
const char * name;
struct input_dev * dev;
struct input_handler * handler;
struct list_head d_node;
struct list_head h_node;
};
Members
tell handlers about the driver event rate
Parameters
Description
If the event rate sent from a device is unusually large, use this function to set the expected event rate. This will allow handlers to set up an appropriate buffer size for the event stream, in order to minimize information loss.
force-feedback part of an input device
Definition
struct ff_device {
int (* upload) (struct input_dev *dev, struct ff_effect *effect,struct ff_effect *old);
int (* erase) (struct input_dev *dev, int effect_id);
int (* playback) (struct input_dev *dev, int effect_id, int value);
void (* set_gain) (struct input_dev *dev, u16 gain);
void (* set_autocenter) (struct input_dev *dev, u16 magnitude);
void (* destroy) (struct ff_device *);
void * private;
unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
struct mutex mutex;
int max_effects;
struct ff_effect * effects;
struct file * effect_owners[];
};
Members
Description
Every force-feedback device must implement upload() and playback() methods; erase() is optional. set_gain() and set_autocenter() need only be implemented if driver sets up FF_GAIN and FF_AUTOCENTER bits.
Note that playback(), set_gain() and set_autocenter() are called with dev->event_lock spinlock held and interrupts off and thus may not sleep.
report new input event
Parameters
Description
This function should be used by drivers implementing various input devices to report input events. See also input_inject_event().
NOTE
input_event() may be safely used right after input device was allocated with input_allocate_device(), even before it is registered with input_register_device(), but the event will not reach any of the input handlers. Such early invocation of input_event() may be used to ‘seed’ initial state of a switch or initial position of absolute axis, etc.
send input event from input handler
Parameters
Description
Similar to input_event() but will ignore event if device is “grabbed” and handle injecting event is not the one that owns the device.
Parameters
Description
If the absinfo struct the caller asked for is already allocated, this functions will not do anything.
grabs device for exclusive use
Parameters
Description
When a device is grabbed by an input handle all events generated by the device are delivered only to this handle. Also events injected by other input handles are ignored while device is grabbed.
release previously grabbed device
Parameters
Description
Releases previously grabbed device so that other input handles can start receiving input events. Upon release all handlers attached to the device have their start() method called so they have a change to synchronize device state with the rest of the system.
open input device
Parameters
Description
This function should be called by input handlers when they want to start receive events from given input device.
close input device
Parameters
Description
This function should be called by input handlers when they want to stop receive events from given input device.
converts scancode in struct input_keymap_entry
Parameters
Description
This function is used to convert scancode stored in struct keymap_entry into scalar form understood by legacy keymap handling methods. These methods expect scancodes to be represented as ‘unsigned int’.
retrieve keycode currently mapped to a given scancode
Parameters
Description
This function should be called by anyone interested in retrieving current keymap. Presently evdev handlers use it.
attribute a keycode to a given scancode
Parameters
Description
This function should be called by anyone needing to update current keymap. Presently keyboard and evdev handlers use it.
Parameters
Description
This function tries to reset the state of an opened input device and bring internal state and state if the hardware in sync with each other. We mark all keys as released, restore LED state, repeat rate, etc.
Parameters
Description
Returns prepared struct input_dev or NULL.
NOTE
Use input_free_device() to free devices that have not been registered; input_unregister_device() should be used for already registered devices.
Parameters
Description
Returns prepared struct input_dev or NULL.
Managed input devices do not need to be explicitly unregistered or freed as it will be done automatically when owner device unbinds from its driver (or binding fails). Once managed input device is allocated, it is ready to be set up and registered in the same fashion as regular input device. There are no special devm_input_device_[un]:c:func:register() variants, regular ones work with both managed and unmanaged devices, should you need them. In most cases however, managed input device need not be explicitly unregistered or freed.
NOTE
the owner device is set up as parent of input device and users should not override it.
Parameters
Description
This function should only be used if input_register_device() was not called yet or if it failed. Once device was registered use input_unregister_device() and memory will be freed once last reference to the device is dropped.
Device should be allocated by input_allocate_device().
NOTE
If there are references to the input device then memory will not be freed until last reference is dropped.
mark device as capable of a certain event
Parameters
Description
In addition to setting up corresponding bit in appropriate capability bitmap the function also adjusts dev->evbit.
enable software autorepeat
Parameters
Description
Enable software autorepeat on the input device.
Parameters
Description
This function registers device with input core. The device must be allocated with input_allocate_device() and all it’s capabilities set up before registering. If function fails the device must be freed with input_free_device(). Once device has been successfully registered it can be unregistered with input_unregister_device(); input_free_device() should not be called in this case.
Note that this function is also used to register managed input devices (ones allocated with devm_input_allocate_device()). Such managed input devices need not be explicitly unregistered or freed, their tear down is controlled by the devres infrastructure. It is also worth noting that tear down of managed input devices is internally a 2-step process: registered managed input device is first unregistered, but stays in memory and can still handle input_event() calls (although events will not be delivered anywhere). The freeing of managed input device will happen later, when devres stack is unwound to the point where device allocation was made.
Parameters
Description
This function unregisters an input device. Once device is unregistered the caller should not try to access it as it may get freed at any moment.
register a new input handler
Parameters
Description
This function registers a new input handler (interface) for input devices in the system and attaches it to all input devices that are compatible with the handler.
unregisters an input handler
Parameters
Description
This function disconnects a handler from its input devices and removes it from lists of known handlers.
handle iterator
Parameters
Description
Iterate over bus‘s list of devices, and call fn for each, passing it data and stop when fn returns a non-zero value. The function is using RCU to traverse the list and therefore may be using in atomic contexts. The fn callback is invoked from RCU critical section and thus must not sleep.
register a new input handle
Parameters
Description
This function puts a new input handle onto device’s and handler’s lists so that events can flow through it once it is opened using input_open_device().
This function is supposed to be called from handler’s connect() method.
unregister an input handle
Parameters
Description
This function removes input handle from device’s and handler’s lists.
This function is supposed to be called from handler’s disconnect() method.
allocates a new input minor number
Parameters
Description
This function allocates a new device minor for from input major namespace. Caller can request legacy minor by specifying legacy_base and legacy_num parameters and whether ID can be allocated from dynamic range if there are no free IDs in legacy range.
release previously allocated minor
Parameters
Description
This function releases previously allocated input minor so that it can be reused later.
upload effect into force-feedback device
Parameters
erase a force-feedback effect from device
Parameters
Description
This function erases a force-feedback effect from specified device. The effect will only be erased if it was uploaded through the same file handle that is requesting erase.
generic handler for force-feedback events
Parameters
Parameters
Description
This function allocates all necessary memory for a force feedback portion of an input device and installs all default handlers. dev->ffbit should be already set up before calling this function. Once ff device is created you need to setup its upload, erase, playback and other handlers before registering input device
Parameters
Description
This function is only needed in error path as input core will automatically free force feedback structures when device is destroyed.
create memoryless force-feedback device
Parameters
represents the state of an input MT slot
Definition
struct input_mt_slot {
int abs[ABS_MT_LAST - ABS_MT_FIRST + 1];
unsigned int frame;
unsigned int key;
};
Members
state of tracked contacts
Definition
struct input_mt {
int trkid;
int num_slots;
int slot;
unsigned int flags;
unsigned int frame;
int * red;
struct input_mt_slot slots[];
};
Members
contact position
Definition
struct input_mt_pos {
s16 x;
s16 y;
};
Members
initialize MT input slots
Parameters
Description
This function allocates all necessary memory for MT slot handling in the input device, prepares the ABS_MT_SLOT and ABS_MT_TRACKING_ID events for use and sets up appropriate buffers. Depending on the flags set, it also performs pointer emulation and frame synchronization.
May be called repeatedly. Returns -EINVAL if attempting to reinitialize with a different number of slots.
Parameters
Description
This function is only needed in error path as the input core will automatically free the MT slots when the device is destroyed.
report contact state
Parameters
Description
Reports a contact via ABS_MT_TRACKING_ID, and optionally ABS_MT_TOOL_TYPE. If active is true and the slot is currently inactive, or if the tool type is changed, a new tracking id is assigned to the slot. The tool type is only reported if the corresponding absbit field is set.
Parameters
Description
Reports the contact count via BTN_TOOL_FINGER, BTN_TOOL_DOUBLETAP, BTN_TOOL_TRIPLETAP and BTN_TOOL_QUADTAP.
The input core ensures only the KEY events already setup for this device will produce output.
common pointer emulation
Parameters
Description
Performs legacy pointer emulation via BTN_TOUCH, ABS_X, ABS_Y and ABS_PRESSURE. Touchpad finger count is emulated if use_count is true.
The input core ensures only the KEY and ABS axes already setup for this device will produce output.
Parameters
Description
Lift all slots not seen since the last call to this function.
Parameters
Description
Close the frame and prepare the internal state for a new one. Depending on the flags, marks unused slots as inactive and performs pointer emulation.
perform a best-match assignment
Parameters
Description
Performs a best match against the current contacts and returns the slot assignment list. New contacts are assigned to unused slots.
The assignments are balanced so that all coordinate displacements are below the euclidian distance dmax. If no such assignment can be found, some contacts are assigned to unused slots.
Returns zero on success, or negative error in case of failure.
Parameters
Description
Returns the slot of the given key, if it exists, otherwise set the key on the first unused slot and return.
If no available slot can be found, -1 is returned. Note that for this function to work properly, input_mt_sync_frame() has to be called at each frame.
simple polled input device
Definition
struct input_polled_dev {
void * private;
void (* open) (struct input_polled_dev *dev);
void (* close) (struct input_polled_dev *dev);
void (* poll) (struct input_polled_dev *dev);
unsigned int poll_interval;
unsigned int poll_interval_max;
unsigned int poll_interval_min;
struct input_dev * input;
};
Members
Description
Polled input device provides a skeleton for supporting simple input devices that do not raise interrupts but have to be periodically scanned or polled to detect changes in their state.
allocate memory for polled device
Parameters
Description
The function allocates memory for a polled device and also for an input device associated with this polled device.
allocate managed polled device
Parameters
Description
Returns prepared struct input_polled_dev or NULL.
Managed polled input devices do not need to be explicitly unregistered or freed as it will be done automatically when owner device unbinds from * its driver (or binding fails). Once such managed polled device is allocated, it is ready to be set up and registered in the same fashion as regular polled input devices (using input_register_polled_device() function).
If you want to manually unregister and free such managed polled devices, it can be still done by calling input_unregister_polled_device() and input_free_polled_device(), although it is rarely needed.
NOTE
the owner device is set up as parent of input device and users should not override it.
free memory allocated for polled device
Parameters
Description
The function frees memory allocated for polling device and drops reference to the associated input device.
register polled device
Parameters
Description
The function registers previously initialized polled input device with input layer. The device should be allocated with call to input_allocate_polled_device(). Callers should also set up poll() method and set up capabilities (id, name, phys, bits) of the corresponding input_dev structure.
unregister polled device
Parameters
Description
The function unregisters previously registered polled input device from input layer. Polling is stopped and device is ready to be freed with call to input_free_polled_device().
keymap for matrix keyboards
Definition
struct matrix_keymap_data {
const uint32_t * keymap;
unsigned int keymap_size;
};
Members
Description
This structure is supposed to be used by platform code to supply keymaps to drivers that implement matrix-like keypads/keyboards.
platform-dependent keypad data
Definition
struct matrix_keypad_platform_data {
const struct matrix_keymap_data * keymap_data;
const unsigned int * row_gpios;
const unsigned int * col_gpios;
unsigned int num_row_gpios;
unsigned int num_col_gpios;
unsigned int col_scan_delay_us;
unsigned int debounce_ms;
unsigned int clustered_irq;
unsigned int clustered_irq_flags;
bool active_low;
bool wakeup;
bool no_autorepeat;
};
Members
Description
This structure represents platform-specific data that use used by matrix_keypad driver to perform proper initialization.
keymap entry for use in sparse keymap
Definition
struct key_entry {
int type;
u32 code;
union {unnamed_union};
};
Members
Description
This structure defines an entry in a sparse keymap used by some input devices for which traditional table-based approach is not suitable.
perform sparse keymap lookup
Parameters
Description
This function is used to perform struct key_entry lookup in an input device using sparse keymap.
perform sparse keymap lookup
Parameters
Description
This function is used to perform struct key_entry lookup in an input device using sparse keymap.
set up sparse keymap for an input device
Parameters
Description
The function calculates size and allocates copy of the original keymap after which sets up input device event bits appropriately. Before destroying input device allocated keymap should be freed with a call to sparse_keymap_free().
Parameters
Description
This function is used to free memory allocated by sparse keymap in an input device that was set up by sparse_keymap_setup().
NOTE
It is safe to cal this function while input device is still registered (however the drivers should care not to try to use freed keymap and thus have to shut off interrupts/polling before freeing the keymap).
report event corresponding to given key entry
Parameters
Description
This function is used to report input event described by given struct key_entry.
report event corresponding to given scancode
Parameters
Description
This function is used to perform lookup in an input device using sparse keymap and report corresponding event. Returns true if lookup was successful and false otherwise.