1STRUCT INPUT_DEV(9) Input Subsystem STRUCT INPUT_DEV(9)
2
3
4
6 struct_input_dev - represents an input device
7
9 struct input_dev {
10 const char * name;
11 const char * phys;
12 const char * uniq;
13 struct input_id id;
14 unsigned long propbit[BITS_TO_LONGS(INPUT_PROP_CNT)];
15 unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
16 unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
17 unsigned long relbit[BITS_TO_LONGS(REL_CNT)];
18 unsigned long absbit[BITS_TO_LONGS(ABS_CNT)];
19 unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)];
20 unsigned long ledbit[BITS_TO_LONGS(LED_CNT)];
21 unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];
22 unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
23 unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
24 unsigned int hint_events_per_packet;
25 unsigned int keycodemax;
26 unsigned int keycodesize;
27 void * keycode;
28 int (* setkeycode) (struct input_dev *dev,const struct input_keymap_entry *ke,unsigned int *old_keycode);
29 int (* getkeycode) (struct input_dev *dev,struct input_keymap_entry *ke);
30 struct ff_device * ff;
31 unsigned int repeat_key;
32 struct timer_list timer;
33 int rep[REP_CNT];
34 struct input_mt * mt;
35 struct input_absinfo * absinfo;
36 unsigned long key[BITS_TO_LONGS(KEY_CNT)];
37 unsigned long led[BITS_TO_LONGS(LED_CNT)];
38 unsigned long snd[BITS_TO_LONGS(SND_CNT)];
39 unsigned long sw[BITS_TO_LONGS(SW_CNT)];
40 int (* open) (struct input_dev *dev);
41 void (* close) (struct input_dev *dev);
42 int (* flush) (struct input_dev *dev, struct file *file);
43 int (* event) (struct input_dev *dev, unsigned int type, unsigned int code, int value);
44 struct input_handle __rcu * grab;
45 spinlock_t event_lock;
46 struct mutex mutex;
47 unsigned int users;
48 bool going_away;
49 struct device dev;
50 struct list_head h_list;
51 struct list_head node;
52 unsigned int num_vals;
53 unsigned int max_vals;
54 struct input_value * vals;
55 bool devres_managed;
56 };
57
59 name
60 name of the device
61
62 phys
63 physical path to the device in the system hierarchy
64
65 uniq
66 unique identification code for the device (if device has it)
67
68 id
69 id of the device (struct input_id)
70
71 propbit[BITS_TO_LONGS(INPUT_PROP_CNT)]
72 bitmap of device properties and quirks
73
74 evbit[BITS_TO_LONGS(EV_CNT)]
75 bitmap of types of events supported by the device (EV_KEY, EV_REL,
76 etc.)
77
78 keybit[BITS_TO_LONGS(KEY_CNT)]
79 bitmap of keys/buttons this device has
80
81 relbit[BITS_TO_LONGS(REL_CNT)]
82 bitmap of relative axes for the device
83
84 absbit[BITS_TO_LONGS(ABS_CNT)]
85 bitmap of absolute axes for the device
86
87 mscbit[BITS_TO_LONGS(MSC_CNT)]
88 bitmap of miscellaneous events supported by the device
89
90 ledbit[BITS_TO_LONGS(LED_CNT)]
91 bitmap of leds present on the device
92
93 sndbit[BITS_TO_LONGS(SND_CNT)]
94 bitmap of sound effects supported by the device
95
96 ffbit[BITS_TO_LONGS(FF_CNT)]
97 bitmap of force feedback effects supported by the device
98
99 swbit[BITS_TO_LONGS(SW_CNT)]
100 bitmap of switches present on the device
101
102 hint_events_per_packet
103 average number of events generated by the device in a packet
104 (between EV_SYN/SYN_REPORT events). Used by event handlers to
105 estimate size of the buffer needed to hold events.
106
107 keycodemax
108 size of keycode table
109
110 keycodesize
111 size of elements in keycode table
112
113 keycode
114 map of scancodes to keycodes for this device
115
116 setkeycode
117 optional method to alter current keymap, used to implement sparse
118 keymaps. If not supplied default mechanism will be used. The method
119 is being called while holding event_lock and thus must not sleep
120
121 getkeycode
122 optional legacy method to retrieve current keymap.
123
124 ff
125 force feedback structure associated with the device if device
126 supports force feedback effects
127
128 repeat_key
129 stores key code of the last key pressed; used to implement software
130 autorepeat
131
132 timer
133 timer for software autorepeat
134
135 rep[REP_CNT]
136 current values for autorepeat parameters (delay, rate)
137
138 mt
139 pointer to multitouch state
140
141 absinfo
142 array of struct input_absinfo elements holding information about
143 absolute axes (current value, min, max, flat, fuzz, resolution)
144
145 key[BITS_TO_LONGS(KEY_CNT)]
146 reflects current state of device's keys/buttons
147
148 led[BITS_TO_LONGS(LED_CNT)]
149 reflects current state of device's LEDs
150
151 snd[BITS_TO_LONGS(SND_CNT)]
152 reflects current state of sound effects
153
154 sw[BITS_TO_LONGS(SW_CNT)]
155 reflects current state of device's switches
156
157 open
158 this method is called when the very first user calls
159 input_open_device. The driver must prepare the device to start
160 generating events (start polling thread, request an IRQ, submit
161 URB, etc.)
162
163 close
164 this method is called when the very last user calls
165 input_close_device.
166
167 flush
168 purges the device. Most commonly used to get rid of force feedback
169 effects loaded into the device when disconnecting from it
170
171 event
172 event handler for events sent _to_ the device, like EV_LED or
173 EV_SND. The device is expected to carry out the requested action
174 (turn on a LED, play sound, etc.) The call is protected by
175 event_lock and must not sleep
176
177 grab
178 input handle that currently has the device grabbed (via EVIOCGRAB
179 ioctl). When a handle grabs a device it becomes sole recipient for
180 all input events coming from the device
181
182 event_lock
183 this spinlock is is taken when input core receives and processes a
184 new event for the device (in input_event). Code that accesses
185 and/or modifies parameters of a device (such as keymap or absmin,
186 absmax, absfuzz, etc.) after device has been registered with input
187 core must take this lock.
188
189 mutex
190 serializes calls to open, close and flush methods
191
192 users
193 stores number of users (input handlers) that opened this device. It
194 is used by input_open_device and input_close_device to make sure
195 that dev->open is only called when the first user opens device and
196 dev->close is called when the very last user closes the device
197
198 going_away
199 marks devices that are in a middle of unregistering and causes
200 input_open_device*() fail with -ENODEV.
201
202 dev
203 driver model's view of this device
204
205 h_list
206 list of input handles associated with the device. When accessing
207 the list dev->mutex must be held
208
209 node
210 used to place the device onto input_dev_list
211
212 num_vals
213 number of values queued in the current frame
214
215 max_vals
216 maximum number of values queued in a frame
217
218 vals
219 array of values queued in the current frame
220
221 devres_managed
222 indicates that devices is managed with devres framework and needs
223 not be explicitly unregistered or freed.
224
226Kernel Hackers Manual 3.10 June 2019 STRUCT INPUT_DEV(9)