1.5
Transfer of event reports
Input subsystem device to report various events passed
Input_report_xxx
Family functions, such
Program list
1
. 5
Report button events. Buttons, relative coordinates, absolute coordinates, and synchronization event report functions are as follows:
Program list
1
. 12
.
Program list
1
.
12
Event reporting functions
/* Include/Linux/input. H */
Static inline void input_report_key (struct input_dev
* Dev, unsigned int code, int value)
{
Input_event (Dev,
Ev_key, code ,!! Value );
(1)
}
Static inline void input_report_rel (struct input_dev
* Dev, unsigned int code, int value)
{
Input_event (Dev,
Ev_rel, code, value );
}
Static inline void input_report_abs (struct input_dev
* Dev, unsigned int code, int value)
{
Input_event (Dev,
Ev_abs, code, value );
}
Static inline void input_sync (struct input_dev * Dev)
{
Input_event (Dev,
Ev_syn, syn_report, 0 );
}
We can see that all four functions are called.
Input_event
And
(1)
Location
Press
Value
Convert to a Boolean value. So press the key to pass
Input Core
Of
Value
Yes
0 (
Release
)
Or
1 (
Press
)
.
Input_event
The function code is as follows:
Program list
1
. 13
.
Program list
1
.
13
Input_event
/* Driver/input. C */
Void input_event (struct input_dev * Dev, unsigned int
Type, unsigned int code, int value)
{
Unsigned
Long flags;
If
(Is_event_supported (type, Dev-> evbit, ev_max )){
Spin_lock_irqsave (& Dev-> event_lock,
Flags );
Add_input_randomness (type,
Code, value );
(1)
Input_handle_event (Dev,
Type, code, value );
(2)
Spin_unlock_irqrestore (& Dev-> event_lock,
Flags );
}
}
Export_symbol (input_event );
There are two valid calls to this function:
(1)
Because the input events are random, the input events are used to increase the entropy of the kernel entropy pool.
(2)
Call the event Distribution Function
Input_handle_event
.
Input_handle_event
Shows the code.
/* Driver/input. C */
# Define input_ignore_event
0
# Define input_pass_to_handlers
1
# Define input_pass_to_device
2
# Define input_pass_to_all
(Input_pass_to_handlers
| Input_pass_to_device)
Static void input_handle_event (struct input_dev * Dev,
Unsigned int type, unsigned int code,
Int value)
{
Int
Disposition = input_ignore_event;
Switch
(Type ){
····························
Case
Ev_key:
If
(Is_event_supported (Code, Dev-> keybit, key_max )&&
(1)
!! Test_bit (Code, Dev-> key )! = Value ){
(2)
If
(Value! = 2 ){
(3)
_ Change_bit (code,
Dev-> key );
(4)
If
(Value)
Bytes
Input_start_autorepeat (Dev,
Code );
}
Disposition
= Input_pass_to_handlers;
Bytes
}
Break;
Case
Ev_abs:
If
(Is_event_supported (Code, Dev-> absbit, abs_max )){
Bytes
Value
= Input_defuzz_abs_event (value,
Bytes
Dev-> ABS [Code],
Dev-> absfuzz [Code]);
If
(Dev-> ABS [Code]! = Value ){
Bytes
Dev-> ABS [Code]
= Value;
Disposition
= Input_pass_to_handlers;
}
}
Break;
Case
Ev_rel:
If
(Is_event_supported (Code, Dev-> relbit, rel_max) & value)
Bytes
Disposition
= Input_pass_to_handlers;
Break;
························
}
If
(Disposition! = Input_ignore_event & type! = Ev_syn)
Dev-> sync
= 0;
If
(Disposition & input_pass_to_device) & Dev-> event)
Dev-> event (Dev,
Type, code, value );
If
(Disposition & input_pass_to_handlers)
Input_pass_event (Dev,
Type, code, value );
}
In the above Code, remove the parts of other events. The line surface describes the processing parts of buttons, relative coordinates, and absolute coordinates:
(1)
Check whether the buttons are supported by the driver. Only the previously registered buttons will be passed on.
(2)
Check whether the button status of the report is the same as that of the previous report. If you press the button multiple times in a row, only the first time is processed.
(3)
If not.
(4)
Current status of the flip button
(
Press and release
)
.
Bytes
If you press the button, start the timing of the combo.
Bytes
Mark the message transmission direction.
Bytes
Check whether the absolute axis is supported by the driver.
Bytes
Determine the absolute value of the value passed to the handler based on the value of the current report and the value of the previous report.
Bytes
If the absolute value of this report is different from that of the previous report, the event is passed to the processing function.
Bytes
Check whether the relative coordinate axis is supported by the driver.
We can see that
Input_handle_event
There are two ways to distribute events: the driver's callback function
Dev-> event
And
Input Core
Of
Input_pass_event
. Continue the analysis below
Input_pass_event
, Code such
Program list
1
. 14
.
Program list
1
.
14
Input_pass_event
/* Driver/input. C */
Static void input_pass_event (struct input_dev * Dev, unsigned
Int type, unsigned int code, int value)
{
Struct
Input_handle * handle;
Rcu_read_lock ();
Handle =
Rcu_dereference (Dev-> grab );
(1)
If
(Handle)
Handle-> Handler-> event (handle,
Type, code, value );
Else
List_for_each_entry_rcu (handle,
& Dev-> h_list, d_node)
(2)
If
(Handle-> open)
(3)
Handle-> Handler-> event (handle,
Type, code, value );
(4)
Rcu_read_unlock ();
}
This function distributes events to related
Handler
.
(1)
Obtain
Handle
Pointer. If an exclusive Device
Handle
Only send the event to the exclusive
Handle
Corresponding
Handler
.
(2)
Traverse each connected to this device
Handle
.
(3)
If
Hnadle
It has been opened.
(4)
Distribute events
Handler
Event processing functions.
Here,
Input Core
The task of event distribution has been completed.
Handler
Process received events.