Commit bf3204cbff7d2606e758afb0994e8da6ae1c6c26
1 parent
558a5e296a
Exists in
master
and in
7 other branches
Input: fix locking in memoryless force-feedback devices
Now that input core acquires dev->event_lock spinlock and disables interrupts when propagating input events, using spin_lock_bh() in ff-memless driver is not allowed. Actually, the timer_lock itself is not needed anymore, we should simply use dev->event_lock as well. Also do a small cleanup in force-feedback core. Reported-by: kerneloops.org Reported-by: http://www.kerneloops.org/searchweek.php?search=ml_ff_set_gain Reported-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Showing 3 changed files with 26 additions and 24 deletions Inline Diff
drivers/input/ff-core.c
1 | /* | 1 | /* |
2 | * Force feedback support for Linux input subsystem | 2 | * Force feedback support for Linux input subsystem |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Anssi Hannula <anssi.hannula@gmail.com> | 4 | * Copyright (c) 2006 Anssi Hannula <anssi.hannula@gmail.com> |
5 | * Copyright (c) 2006 Dmitry Torokhov <dtor@mail.ru> | 5 | * Copyright (c) 2006 Dmitry Torokhov <dtor@mail.ru> |
6 | */ | 6 | */ |
7 | 7 | ||
8 | /* | 8 | /* |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or | 11 | * the Free Software Foundation; either version 2 of the License, or |
12 | * (at your option) any later version. | 12 | * (at your option) any later version. |
13 | * | 13 | * |
14 | * This program is distributed in the hope that it will be useful, | 14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. | 17 | * GNU General Public License for more details. |
18 | * | 18 | * |
19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software | 20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* #define DEBUG */ | 24 | /* #define DEBUG */ |
25 | 25 | ||
26 | #define debug(format, arg...) pr_debug("ff-core: " format "\n", ## arg) | 26 | #define debug(format, arg...) pr_debug("ff-core: " format "\n", ## arg) |
27 | 27 | ||
28 | #include <linux/input.h> | 28 | #include <linux/input.h> |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/mutex.h> | 30 | #include <linux/mutex.h> |
31 | #include <linux/sched.h> | 31 | #include <linux/sched.h> |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * Check that the effect_id is a valid effect and whether the user | 34 | * Check that the effect_id is a valid effect and whether the user |
35 | * is the owner | 35 | * is the owner |
36 | */ | 36 | */ |
37 | static int check_effect_access(struct ff_device *ff, int effect_id, | 37 | static int check_effect_access(struct ff_device *ff, int effect_id, |
38 | struct file *file) | 38 | struct file *file) |
39 | { | 39 | { |
40 | if (effect_id < 0 || effect_id >= ff->max_effects || | 40 | if (effect_id < 0 || effect_id >= ff->max_effects || |
41 | !ff->effect_owners[effect_id]) | 41 | !ff->effect_owners[effect_id]) |
42 | return -EINVAL; | 42 | return -EINVAL; |
43 | 43 | ||
44 | if (file && ff->effect_owners[effect_id] != file) | 44 | if (file && ff->effect_owners[effect_id] != file) |
45 | return -EACCES; | 45 | return -EACCES; |
46 | 46 | ||
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | /* | 50 | /* |
51 | * Checks whether 2 effects can be combined together | 51 | * Checks whether 2 effects can be combined together |
52 | */ | 52 | */ |
53 | static inline int check_effects_compatible(struct ff_effect *e1, | 53 | static inline int check_effects_compatible(struct ff_effect *e1, |
54 | struct ff_effect *e2) | 54 | struct ff_effect *e2) |
55 | { | 55 | { |
56 | return e1->type == e2->type && | 56 | return e1->type == e2->type && |
57 | (e1->type != FF_PERIODIC || | 57 | (e1->type != FF_PERIODIC || |
58 | e1->u.periodic.waveform == e2->u.periodic.waveform); | 58 | e1->u.periodic.waveform == e2->u.periodic.waveform); |
59 | } | 59 | } |
60 | 60 | ||
61 | /* | 61 | /* |
62 | * Convert an effect into compatible one | 62 | * Convert an effect into compatible one |
63 | */ | 63 | */ |
64 | static int compat_effect(struct ff_device *ff, struct ff_effect *effect) | 64 | static int compat_effect(struct ff_device *ff, struct ff_effect *effect) |
65 | { | 65 | { |
66 | int magnitude; | 66 | int magnitude; |
67 | 67 | ||
68 | switch (effect->type) { | 68 | switch (effect->type) { |
69 | case FF_RUMBLE: | 69 | case FF_RUMBLE: |
70 | if (!test_bit(FF_PERIODIC, ff->ffbit)) | 70 | if (!test_bit(FF_PERIODIC, ff->ffbit)) |
71 | return -EINVAL; | 71 | return -EINVAL; |
72 | 72 | ||
73 | /* | 73 | /* |
74 | * calculate manginude of sine wave as average of rumble's | 74 | * calculate manginude of sine wave as average of rumble's |
75 | * 2/3 of strong magnitude and 1/3 of weak magnitude | 75 | * 2/3 of strong magnitude and 1/3 of weak magnitude |
76 | */ | 76 | */ |
77 | magnitude = effect->u.rumble.strong_magnitude / 3 + | 77 | magnitude = effect->u.rumble.strong_magnitude / 3 + |
78 | effect->u.rumble.weak_magnitude / 6; | 78 | effect->u.rumble.weak_magnitude / 6; |
79 | 79 | ||
80 | effect->type = FF_PERIODIC; | 80 | effect->type = FF_PERIODIC; |
81 | effect->u.periodic.waveform = FF_SINE; | 81 | effect->u.periodic.waveform = FF_SINE; |
82 | effect->u.periodic.period = 50; | 82 | effect->u.periodic.period = 50; |
83 | effect->u.periodic.magnitude = max(magnitude, 0x7fff); | 83 | effect->u.periodic.magnitude = max(magnitude, 0x7fff); |
84 | effect->u.periodic.offset = 0; | 84 | effect->u.periodic.offset = 0; |
85 | effect->u.periodic.phase = 0; | 85 | effect->u.periodic.phase = 0; |
86 | effect->u.periodic.envelope.attack_length = 0; | 86 | effect->u.periodic.envelope.attack_length = 0; |
87 | effect->u.periodic.envelope.attack_level = 0; | 87 | effect->u.periodic.envelope.attack_level = 0; |
88 | effect->u.periodic.envelope.fade_length = 0; | 88 | effect->u.periodic.envelope.fade_length = 0; |
89 | effect->u.periodic.envelope.fade_level = 0; | 89 | effect->u.periodic.envelope.fade_level = 0; |
90 | 90 | ||
91 | return 0; | 91 | return 0; |
92 | 92 | ||
93 | default: | 93 | default: |
94 | /* Let driver handle conversion */ | 94 | /* Let driver handle conversion */ |
95 | return 0; | 95 | return 0; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * input_ff_upload() - upload effect into force-feedback device | 100 | * input_ff_upload() - upload effect into force-feedback device |
101 | * @dev: input device | 101 | * @dev: input device |
102 | * @effect: effect to be uploaded | 102 | * @effect: effect to be uploaded |
103 | * @file: owner of the effect | 103 | * @file: owner of the effect |
104 | */ | 104 | */ |
105 | int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, | 105 | int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, |
106 | struct file *file) | 106 | struct file *file) |
107 | { | 107 | { |
108 | struct ff_device *ff = dev->ff; | 108 | struct ff_device *ff = dev->ff; |
109 | struct ff_effect *old; | 109 | struct ff_effect *old; |
110 | int ret = 0; | 110 | int ret = 0; |
111 | int id; | 111 | int id; |
112 | 112 | ||
113 | if (!test_bit(EV_FF, dev->evbit)) | 113 | if (!test_bit(EV_FF, dev->evbit)) |
114 | return -ENOSYS; | 114 | return -ENOSYS; |
115 | 115 | ||
116 | if (effect->type < FF_EFFECT_MIN || effect->type > FF_EFFECT_MAX || | 116 | if (effect->type < FF_EFFECT_MIN || effect->type > FF_EFFECT_MAX || |
117 | !test_bit(effect->type, dev->ffbit)) { | 117 | !test_bit(effect->type, dev->ffbit)) { |
118 | debug("invalid or not supported effect type in upload"); | 118 | debug("invalid or not supported effect type in upload"); |
119 | return -EINVAL; | 119 | return -EINVAL; |
120 | } | 120 | } |
121 | 121 | ||
122 | if (effect->type == FF_PERIODIC && | 122 | if (effect->type == FF_PERIODIC && |
123 | (effect->u.periodic.waveform < FF_WAVEFORM_MIN || | 123 | (effect->u.periodic.waveform < FF_WAVEFORM_MIN || |
124 | effect->u.periodic.waveform > FF_WAVEFORM_MAX || | 124 | effect->u.periodic.waveform > FF_WAVEFORM_MAX || |
125 | !test_bit(effect->u.periodic.waveform, dev->ffbit))) { | 125 | !test_bit(effect->u.periodic.waveform, dev->ffbit))) { |
126 | debug("invalid or not supported wave form in upload"); | 126 | debug("invalid or not supported wave form in upload"); |
127 | return -EINVAL; | 127 | return -EINVAL; |
128 | } | 128 | } |
129 | 129 | ||
130 | if (!test_bit(effect->type, ff->ffbit)) { | 130 | if (!test_bit(effect->type, ff->ffbit)) { |
131 | ret = compat_effect(ff, effect); | 131 | ret = compat_effect(ff, effect); |
132 | if (ret) | 132 | if (ret) |
133 | return ret; | 133 | return ret; |
134 | } | 134 | } |
135 | 135 | ||
136 | mutex_lock(&ff->mutex); | 136 | mutex_lock(&ff->mutex); |
137 | 137 | ||
138 | if (effect->id == -1) { | 138 | if (effect->id == -1) { |
139 | for (id = 0; id < ff->max_effects; id++) | 139 | for (id = 0; id < ff->max_effects; id++) |
140 | if (!ff->effect_owners[id]) | 140 | if (!ff->effect_owners[id]) |
141 | break; | 141 | break; |
142 | 142 | ||
143 | if (id >= ff->max_effects) { | 143 | if (id >= ff->max_effects) { |
144 | ret = -ENOSPC; | 144 | ret = -ENOSPC; |
145 | goto out; | 145 | goto out; |
146 | } | 146 | } |
147 | 147 | ||
148 | effect->id = id; | 148 | effect->id = id; |
149 | old = NULL; | 149 | old = NULL; |
150 | 150 | ||
151 | } else { | 151 | } else { |
152 | id = effect->id; | 152 | id = effect->id; |
153 | 153 | ||
154 | ret = check_effect_access(ff, id, file); | 154 | ret = check_effect_access(ff, id, file); |
155 | if (ret) | 155 | if (ret) |
156 | goto out; | 156 | goto out; |
157 | 157 | ||
158 | old = &ff->effects[id]; | 158 | old = &ff->effects[id]; |
159 | 159 | ||
160 | if (!check_effects_compatible(effect, old)) { | 160 | if (!check_effects_compatible(effect, old)) { |
161 | ret = -EINVAL; | 161 | ret = -EINVAL; |
162 | goto out; | 162 | goto out; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | ret = ff->upload(dev, effect, old); | 166 | ret = ff->upload(dev, effect, old); |
167 | if (ret) | 167 | if (ret) |
168 | goto out; | 168 | goto out; |
169 | 169 | ||
170 | spin_lock_irq(&dev->event_lock); | 170 | spin_lock_irq(&dev->event_lock); |
171 | ff->effects[id] = *effect; | 171 | ff->effects[id] = *effect; |
172 | ff->effect_owners[id] = file; | 172 | ff->effect_owners[id] = file; |
173 | spin_unlock_irq(&dev->event_lock); | 173 | spin_unlock_irq(&dev->event_lock); |
174 | 174 | ||
175 | out: | 175 | out: |
176 | mutex_unlock(&ff->mutex); | 176 | mutex_unlock(&ff->mutex); |
177 | return ret; | 177 | return ret; |
178 | } | 178 | } |
179 | EXPORT_SYMBOL_GPL(input_ff_upload); | 179 | EXPORT_SYMBOL_GPL(input_ff_upload); |
180 | 180 | ||
181 | /* | 181 | /* |
182 | * Erases the effect if the requester is also the effect owner. The mutex | 182 | * Erases the effect if the requester is also the effect owner. The mutex |
183 | * should already be locked before calling this function. | 183 | * should already be locked before calling this function. |
184 | */ | 184 | */ |
185 | static int erase_effect(struct input_dev *dev, int effect_id, | 185 | static int erase_effect(struct input_dev *dev, int effect_id, |
186 | struct file *file) | 186 | struct file *file) |
187 | { | 187 | { |
188 | struct ff_device *ff = dev->ff; | 188 | struct ff_device *ff = dev->ff; |
189 | int error; | 189 | int error; |
190 | 190 | ||
191 | error = check_effect_access(ff, effect_id, file); | 191 | error = check_effect_access(ff, effect_id, file); |
192 | if (error) | 192 | if (error) |
193 | return error; | 193 | return error; |
194 | 194 | ||
195 | spin_lock_irq(&dev->event_lock); | 195 | spin_lock_irq(&dev->event_lock); |
196 | ff->playback(dev, effect_id, 0); | 196 | ff->playback(dev, effect_id, 0); |
197 | ff->effect_owners[effect_id] = NULL; | 197 | ff->effect_owners[effect_id] = NULL; |
198 | spin_unlock_irq(&dev->event_lock); | 198 | spin_unlock_irq(&dev->event_lock); |
199 | 199 | ||
200 | if (ff->erase) { | 200 | if (ff->erase) { |
201 | error = ff->erase(dev, effect_id); | 201 | error = ff->erase(dev, effect_id); |
202 | if (error) { | 202 | if (error) { |
203 | spin_lock_irq(&dev->event_lock); | 203 | spin_lock_irq(&dev->event_lock); |
204 | ff->effect_owners[effect_id] = file; | 204 | ff->effect_owners[effect_id] = file; |
205 | spin_unlock_irq(&dev->event_lock); | 205 | spin_unlock_irq(&dev->event_lock); |
206 | 206 | ||
207 | return error; | 207 | return error; |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | return 0; | 211 | return 0; |
212 | } | 212 | } |
213 | 213 | ||
214 | /** | 214 | /** |
215 | * input_ff_erase - erase a force-feedback effect from device | 215 | * input_ff_erase - erase a force-feedback effect from device |
216 | * @dev: input device to erase effect from | 216 | * @dev: input device to erase effect from |
217 | * @effect_id: id of the ffect to be erased | 217 | * @effect_id: id of the ffect to be erased |
218 | * @file: purported owner of the request | 218 | * @file: purported owner of the request |
219 | * | 219 | * |
220 | * This function erases a force-feedback effect from specified device. | 220 | * This function erases a force-feedback effect from specified device. |
221 | * The effect will only be erased if it was uploaded through the same | 221 | * The effect will only be erased if it was uploaded through the same |
222 | * file handle that is requesting erase. | 222 | * file handle that is requesting erase. |
223 | */ | 223 | */ |
224 | int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file) | 224 | int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file) |
225 | { | 225 | { |
226 | struct ff_device *ff = dev->ff; | 226 | struct ff_device *ff = dev->ff; |
227 | int ret; | 227 | int ret; |
228 | 228 | ||
229 | if (!test_bit(EV_FF, dev->evbit)) | 229 | if (!test_bit(EV_FF, dev->evbit)) |
230 | return -ENOSYS; | 230 | return -ENOSYS; |
231 | 231 | ||
232 | mutex_lock(&ff->mutex); | 232 | mutex_lock(&ff->mutex); |
233 | ret = erase_effect(dev, effect_id, file); | 233 | ret = erase_effect(dev, effect_id, file); |
234 | mutex_unlock(&ff->mutex); | 234 | mutex_unlock(&ff->mutex); |
235 | 235 | ||
236 | return ret; | 236 | return ret; |
237 | } | 237 | } |
238 | EXPORT_SYMBOL_GPL(input_ff_erase); | 238 | EXPORT_SYMBOL_GPL(input_ff_erase); |
239 | 239 | ||
240 | /* | 240 | /* |
241 | * flush_effects - erase all effects owned by a file handle | 241 | * flush_effects - erase all effects owned by a file handle |
242 | */ | 242 | */ |
243 | static int flush_effects(struct input_dev *dev, struct file *file) | 243 | static int flush_effects(struct input_dev *dev, struct file *file) |
244 | { | 244 | { |
245 | struct ff_device *ff = dev->ff; | 245 | struct ff_device *ff = dev->ff; |
246 | int i; | 246 | int i; |
247 | 247 | ||
248 | debug("flushing now"); | 248 | debug("flushing now"); |
249 | 249 | ||
250 | mutex_lock(&ff->mutex); | 250 | mutex_lock(&ff->mutex); |
251 | 251 | ||
252 | for (i = 0; i < ff->max_effects; i++) | 252 | for (i = 0; i < ff->max_effects; i++) |
253 | erase_effect(dev, i, file); | 253 | erase_effect(dev, i, file); |
254 | 254 | ||
255 | mutex_unlock(&ff->mutex); | 255 | mutex_unlock(&ff->mutex); |
256 | 256 | ||
257 | return 0; | 257 | return 0; |
258 | } | 258 | } |
259 | 259 | ||
260 | /** | 260 | /** |
261 | * input_ff_event() - generic handler for force-feedback events | 261 | * input_ff_event() - generic handler for force-feedback events |
262 | * @dev: input device to send the effect to | 262 | * @dev: input device to send the effect to |
263 | * @type: event type (anything but EV_FF is ignored) | 263 | * @type: event type (anything but EV_FF is ignored) |
264 | * @code: event code | 264 | * @code: event code |
265 | * @value: event value | 265 | * @value: event value |
266 | */ | 266 | */ |
267 | int input_ff_event(struct input_dev *dev, unsigned int type, | 267 | int input_ff_event(struct input_dev *dev, unsigned int type, |
268 | unsigned int code, int value) | 268 | unsigned int code, int value) |
269 | { | 269 | { |
270 | struct ff_device *ff = dev->ff; | 270 | struct ff_device *ff = dev->ff; |
271 | 271 | ||
272 | if (type != EV_FF) | 272 | if (type != EV_FF) |
273 | return 0; | 273 | return 0; |
274 | 274 | ||
275 | switch (code) { | 275 | switch (code) { |
276 | case FF_GAIN: | 276 | case FF_GAIN: |
277 | if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff) | 277 | if (!test_bit(FF_GAIN, dev->ffbit) || value > 0xffff) |
278 | break; | 278 | break; |
279 | 279 | ||
280 | ff->set_gain(dev, value); | 280 | ff->set_gain(dev, value); |
281 | break; | 281 | break; |
282 | 282 | ||
283 | case FF_AUTOCENTER: | 283 | case FF_AUTOCENTER: |
284 | if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffff) | 284 | if (!test_bit(FF_AUTOCENTER, dev->ffbit) || value > 0xffff) |
285 | break; | 285 | break; |
286 | 286 | ||
287 | ff->set_autocenter(dev, value); | 287 | ff->set_autocenter(dev, value); |
288 | break; | 288 | break; |
289 | 289 | ||
290 | default: | 290 | default: |
291 | if (check_effect_access(ff, code, NULL) == 0) | 291 | if (check_effect_access(ff, code, NULL) == 0) |
292 | ff->playback(dev, code, value); | 292 | ff->playback(dev, code, value); |
293 | break; | 293 | break; |
294 | } | 294 | } |
295 | 295 | ||
296 | return 0; | 296 | return 0; |
297 | } | 297 | } |
298 | EXPORT_SYMBOL_GPL(input_ff_event); | 298 | EXPORT_SYMBOL_GPL(input_ff_event); |
299 | 299 | ||
300 | /** | 300 | /** |
301 | * input_ff_create() - create force-feedback device | 301 | * input_ff_create() - create force-feedback device |
302 | * @dev: input device supporting force-feedback | 302 | * @dev: input device supporting force-feedback |
303 | * @max_effects: maximum number of effects supported by the device | 303 | * @max_effects: maximum number of effects supported by the device |
304 | * | 304 | * |
305 | * This function allocates all necessary memory for a force feedback | 305 | * This function allocates all necessary memory for a force feedback |
306 | * portion of an input device and installs all default handlers. | 306 | * portion of an input device and installs all default handlers. |
307 | * @dev->ffbit should be already set up before calling this function. | 307 | * @dev->ffbit should be already set up before calling this function. |
308 | * Once ff device is created you need to setup its upload, erase, | 308 | * Once ff device is created you need to setup its upload, erase, |
309 | * playback and other handlers before registering input device | 309 | * playback and other handlers before registering input device |
310 | */ | 310 | */ |
311 | int input_ff_create(struct input_dev *dev, int max_effects) | 311 | int input_ff_create(struct input_dev *dev, int max_effects) |
312 | { | 312 | { |
313 | struct ff_device *ff; | 313 | struct ff_device *ff; |
314 | int i; | 314 | int i; |
315 | 315 | ||
316 | if (!max_effects) { | 316 | if (!max_effects) { |
317 | printk(KERN_ERR | 317 | printk(KERN_ERR |
318 | "ff-core: cannot allocate device without any effects\n"); | 318 | "ff-core: cannot allocate device without any effects\n"); |
319 | return -EINVAL; | 319 | return -EINVAL; |
320 | } | 320 | } |
321 | 321 | ||
322 | ff = kzalloc(sizeof(struct ff_device) + | 322 | ff = kzalloc(sizeof(struct ff_device) + |
323 | max_effects * sizeof(struct file *), GFP_KERNEL); | 323 | max_effects * sizeof(struct file *), GFP_KERNEL); |
324 | if (!ff) | 324 | if (!ff) |
325 | return -ENOMEM; | 325 | return -ENOMEM; |
326 | 326 | ||
327 | ff->effects = kcalloc(max_effects, sizeof(struct ff_effect), | 327 | ff->effects = kcalloc(max_effects, sizeof(struct ff_effect), |
328 | GFP_KERNEL); | 328 | GFP_KERNEL); |
329 | if (!ff->effects) { | 329 | if (!ff->effects) { |
330 | kfree(ff); | 330 | kfree(ff); |
331 | return -ENOMEM; | 331 | return -ENOMEM; |
332 | } | 332 | } |
333 | 333 | ||
334 | ff->max_effects = max_effects; | 334 | ff->max_effects = max_effects; |
335 | mutex_init(&ff->mutex); | 335 | mutex_init(&ff->mutex); |
336 | 336 | ||
337 | dev->ff = ff; | 337 | dev->ff = ff; |
338 | dev->flush = flush_effects; | 338 | dev->flush = flush_effects; |
339 | dev->event = input_ff_event; | 339 | dev->event = input_ff_event; |
340 | set_bit(EV_FF, dev->evbit); | 340 | __set_bit(EV_FF, dev->evbit); |
341 | 341 | ||
342 | /* Copy "true" bits into ff device bitmap */ | 342 | /* Copy "true" bits into ff device bitmap */ |
343 | for (i = 0; i <= FF_MAX; i++) | 343 | for (i = 0; i <= FF_MAX; i++) |
344 | if (test_bit(i, dev->ffbit)) | 344 | if (test_bit(i, dev->ffbit)) |
345 | set_bit(i, ff->ffbit); | 345 | __set_bit(i, ff->ffbit); |
346 | 346 | ||
347 | /* we can emulate RUMBLE with periodic effects */ | 347 | /* we can emulate RUMBLE with periodic effects */ |
348 | if (test_bit(FF_PERIODIC, ff->ffbit)) | 348 | if (test_bit(FF_PERIODIC, ff->ffbit)) |
349 | set_bit(FF_RUMBLE, dev->ffbit); | 349 | __set_bit(FF_RUMBLE, dev->ffbit); |
350 | 350 | ||
351 | return 0; | 351 | return 0; |
352 | } | 352 | } |
353 | EXPORT_SYMBOL_GPL(input_ff_create); | 353 | EXPORT_SYMBOL_GPL(input_ff_create); |
354 | 354 | ||
355 | /** | 355 | /** |
356 | * input_ff_free() - frees force feedback portion of input device | 356 | * input_ff_free() - frees force feedback portion of input device |
357 | * @dev: input device supporting force feedback | 357 | * @dev: input device supporting force feedback |
358 | * | 358 | * |
359 | * This function is only needed in error path as input core will | 359 | * This function is only needed in error path as input core will |
360 | * automatically free force feedback structures when device is | 360 | * automatically free force feedback structures when device is |
361 | * destroyed. | 361 | * destroyed. |
362 | */ | 362 | */ |
363 | void input_ff_destroy(struct input_dev *dev) | 363 | void input_ff_destroy(struct input_dev *dev) |
364 | { | 364 | { |
365 | clear_bit(EV_FF, dev->evbit); | 365 | struct ff_device *ff = dev->ff; |
366 | if (dev->ff) { | 366 | |
367 | if (dev->ff->destroy) | 367 | __clear_bit(EV_FF, dev->evbit); |
368 | dev->ff->destroy(dev->ff); | 368 | if (ff) { |
369 | kfree(dev->ff->private); | 369 | if (ff->destroy) |
370 | kfree(dev->ff); | 370 | ff->destroy(ff); |
371 | kfree(ff->private); | ||
372 | kfree(ff); | ||
371 | dev->ff = NULL; | 373 | dev->ff = NULL; |
372 | } | 374 | } |
373 | } | 375 | } |
374 | EXPORT_SYMBOL_GPL(input_ff_destroy); | 376 | EXPORT_SYMBOL_GPL(input_ff_destroy); |
375 | 377 |
drivers/input/ff-memless.c
1 | /* | 1 | /* |
2 | * Force feedback support for memoryless devices | 2 | * Force feedback support for memoryless devices |
3 | * | 3 | * |
4 | * Copyright (c) 2006 Anssi Hannula <anssi.hannula@gmail.com> | 4 | * Copyright (c) 2006 Anssi Hannula <anssi.hannula@gmail.com> |
5 | * Copyright (c) 2006 Dmitry Torokhov <dtor@mail.ru> | 5 | * Copyright (c) 2006 Dmitry Torokhov <dtor@mail.ru> |
6 | */ | 6 | */ |
7 | 7 | ||
8 | /* | 8 | /* |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or | 11 | * the Free Software Foundation; either version 2 of the License, or |
12 | * (at your option) any later version. | 12 | * (at your option) any later version. |
13 | * | 13 | * |
14 | * This program is distributed in the hope that it will be useful, | 14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. | 17 | * GNU General Public License for more details. |
18 | * | 18 | * |
19 | * You should have received a copy of the GNU General Public License | 19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software | 20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* #define DEBUG */ | 24 | /* #define DEBUG */ |
25 | 25 | ||
26 | #define debug(format, arg...) pr_debug("ff-memless: " format "\n", ## arg) | 26 | #define debug(format, arg...) pr_debug("ff-memless: " format "\n", ## arg) |
27 | 27 | ||
28 | #include <linux/input.h> | 28 | #include <linux/input.h> |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/mutex.h> | 30 | #include <linux/mutex.h> |
31 | #include <linux/spinlock.h> | 31 | #include <linux/spinlock.h> |
32 | #include <linux/jiffies.h> | 32 | #include <linux/jiffies.h> |
33 | 33 | ||
34 | #include "fixp-arith.h" | 34 | #include "fixp-arith.h" |
35 | 35 | ||
36 | MODULE_LICENSE("GPL"); | 36 | MODULE_LICENSE("GPL"); |
37 | MODULE_AUTHOR("Anssi Hannula <anssi.hannula@gmail.com>"); | 37 | MODULE_AUTHOR("Anssi Hannula <anssi.hannula@gmail.com>"); |
38 | MODULE_DESCRIPTION("Force feedback support for memoryless devices"); | 38 | MODULE_DESCRIPTION("Force feedback support for memoryless devices"); |
39 | 39 | ||
40 | /* Number of effects handled with memoryless devices */ | 40 | /* Number of effects handled with memoryless devices */ |
41 | #define FF_MEMLESS_EFFECTS 16 | 41 | #define FF_MEMLESS_EFFECTS 16 |
42 | 42 | ||
43 | /* Envelope update interval in ms */ | 43 | /* Envelope update interval in ms */ |
44 | #define FF_ENVELOPE_INTERVAL 50 | 44 | #define FF_ENVELOPE_INTERVAL 50 |
45 | 45 | ||
46 | #define FF_EFFECT_STARTED 0 | 46 | #define FF_EFFECT_STARTED 0 |
47 | #define FF_EFFECT_PLAYING 1 | 47 | #define FF_EFFECT_PLAYING 1 |
48 | #define FF_EFFECT_ABORTING 2 | 48 | #define FF_EFFECT_ABORTING 2 |
49 | 49 | ||
50 | struct ml_effect_state { | 50 | struct ml_effect_state { |
51 | struct ff_effect *effect; | 51 | struct ff_effect *effect; |
52 | unsigned long flags; /* effect state (STARTED, PLAYING, etc) */ | 52 | unsigned long flags; /* effect state (STARTED, PLAYING, etc) */ |
53 | int count; /* loop count of the effect */ | 53 | int count; /* loop count of the effect */ |
54 | unsigned long play_at; /* start time */ | 54 | unsigned long play_at; /* start time */ |
55 | unsigned long stop_at; /* stop time */ | 55 | unsigned long stop_at; /* stop time */ |
56 | unsigned long adj_at; /* last time the effect was sent */ | 56 | unsigned long adj_at; /* last time the effect was sent */ |
57 | }; | 57 | }; |
58 | 58 | ||
59 | struct ml_device { | 59 | struct ml_device { |
60 | void *private; | 60 | void *private; |
61 | struct ml_effect_state states[FF_MEMLESS_EFFECTS]; | 61 | struct ml_effect_state states[FF_MEMLESS_EFFECTS]; |
62 | int gain; | 62 | int gain; |
63 | struct timer_list timer; | 63 | struct timer_list timer; |
64 | spinlock_t timer_lock; | ||
65 | struct input_dev *dev; | 64 | struct input_dev *dev; |
66 | 65 | ||
67 | int (*play_effect)(struct input_dev *dev, void *data, | 66 | int (*play_effect)(struct input_dev *dev, void *data, |
68 | struct ff_effect *effect); | 67 | struct ff_effect *effect); |
69 | }; | 68 | }; |
70 | 69 | ||
71 | static const struct ff_envelope *get_envelope(const struct ff_effect *effect) | 70 | static const struct ff_envelope *get_envelope(const struct ff_effect *effect) |
72 | { | 71 | { |
73 | static const struct ff_envelope empty_envelope; | 72 | static const struct ff_envelope empty_envelope; |
74 | 73 | ||
75 | switch (effect->type) { | 74 | switch (effect->type) { |
76 | case FF_PERIODIC: | 75 | case FF_PERIODIC: |
77 | return &effect->u.periodic.envelope; | 76 | return &effect->u.periodic.envelope; |
78 | case FF_CONSTANT: | 77 | case FF_CONSTANT: |
79 | return &effect->u.constant.envelope; | 78 | return &effect->u.constant.envelope; |
80 | default: | 79 | default: |
81 | return &empty_envelope; | 80 | return &empty_envelope; |
82 | } | 81 | } |
83 | } | 82 | } |
84 | 83 | ||
85 | /* | 84 | /* |
86 | * Check for the next time envelope requires an update on memoryless devices | 85 | * Check for the next time envelope requires an update on memoryless devices |
87 | */ | 86 | */ |
88 | static unsigned long calculate_next_time(struct ml_effect_state *state) | 87 | static unsigned long calculate_next_time(struct ml_effect_state *state) |
89 | { | 88 | { |
90 | const struct ff_envelope *envelope = get_envelope(state->effect); | 89 | const struct ff_envelope *envelope = get_envelope(state->effect); |
91 | unsigned long attack_stop, fade_start, next_fade; | 90 | unsigned long attack_stop, fade_start, next_fade; |
92 | 91 | ||
93 | if (envelope->attack_length) { | 92 | if (envelope->attack_length) { |
94 | attack_stop = state->play_at + | 93 | attack_stop = state->play_at + |
95 | msecs_to_jiffies(envelope->attack_length); | 94 | msecs_to_jiffies(envelope->attack_length); |
96 | if (time_before(state->adj_at, attack_stop)) | 95 | if (time_before(state->adj_at, attack_stop)) |
97 | return state->adj_at + | 96 | return state->adj_at + |
98 | msecs_to_jiffies(FF_ENVELOPE_INTERVAL); | 97 | msecs_to_jiffies(FF_ENVELOPE_INTERVAL); |
99 | } | 98 | } |
100 | 99 | ||
101 | if (state->effect->replay.length) { | 100 | if (state->effect->replay.length) { |
102 | if (envelope->fade_length) { | 101 | if (envelope->fade_length) { |
103 | /* check when fading should start */ | 102 | /* check when fading should start */ |
104 | fade_start = state->stop_at - | 103 | fade_start = state->stop_at - |
105 | msecs_to_jiffies(envelope->fade_length); | 104 | msecs_to_jiffies(envelope->fade_length); |
106 | 105 | ||
107 | if (time_before(state->adj_at, fade_start)) | 106 | if (time_before(state->adj_at, fade_start)) |
108 | return fade_start; | 107 | return fade_start; |
109 | 108 | ||
110 | /* already fading, advance to next checkpoint */ | 109 | /* already fading, advance to next checkpoint */ |
111 | next_fade = state->adj_at + | 110 | next_fade = state->adj_at + |
112 | msecs_to_jiffies(FF_ENVELOPE_INTERVAL); | 111 | msecs_to_jiffies(FF_ENVELOPE_INTERVAL); |
113 | if (time_before(next_fade, state->stop_at)) | 112 | if (time_before(next_fade, state->stop_at)) |
114 | return next_fade; | 113 | return next_fade; |
115 | } | 114 | } |
116 | 115 | ||
117 | return state->stop_at; | 116 | return state->stop_at; |
118 | } | 117 | } |
119 | 118 | ||
120 | return state->play_at; | 119 | return state->play_at; |
121 | } | 120 | } |
122 | 121 | ||
123 | static void ml_schedule_timer(struct ml_device *ml) | 122 | static void ml_schedule_timer(struct ml_device *ml) |
124 | { | 123 | { |
125 | struct ml_effect_state *state; | 124 | struct ml_effect_state *state; |
126 | unsigned long now = jiffies; | 125 | unsigned long now = jiffies; |
127 | unsigned long earliest = 0; | 126 | unsigned long earliest = 0; |
128 | unsigned long next_at; | 127 | unsigned long next_at; |
129 | int events = 0; | 128 | int events = 0; |
130 | int i; | 129 | int i; |
131 | 130 | ||
132 | debug("calculating next timer"); | 131 | debug("calculating next timer"); |
133 | 132 | ||
134 | for (i = 0; i < FF_MEMLESS_EFFECTS; i++) { | 133 | for (i = 0; i < FF_MEMLESS_EFFECTS; i++) { |
135 | 134 | ||
136 | state = &ml->states[i]; | 135 | state = &ml->states[i]; |
137 | 136 | ||
138 | if (!test_bit(FF_EFFECT_STARTED, &state->flags)) | 137 | if (!test_bit(FF_EFFECT_STARTED, &state->flags)) |
139 | continue; | 138 | continue; |
140 | 139 | ||
141 | if (test_bit(FF_EFFECT_PLAYING, &state->flags)) | 140 | if (test_bit(FF_EFFECT_PLAYING, &state->flags)) |
142 | next_at = calculate_next_time(state); | 141 | next_at = calculate_next_time(state); |
143 | else | 142 | else |
144 | next_at = state->play_at; | 143 | next_at = state->play_at; |
145 | 144 | ||
146 | if (time_before_eq(now, next_at) && | 145 | if (time_before_eq(now, next_at) && |
147 | (++events == 1 || time_before(next_at, earliest))) | 146 | (++events == 1 || time_before(next_at, earliest))) |
148 | earliest = next_at; | 147 | earliest = next_at; |
149 | } | 148 | } |
150 | 149 | ||
151 | if (!events) { | 150 | if (!events) { |
152 | debug("no actions"); | 151 | debug("no actions"); |
153 | del_timer(&ml->timer); | 152 | del_timer(&ml->timer); |
154 | } else { | 153 | } else { |
155 | debug("timer set"); | 154 | debug("timer set"); |
156 | mod_timer(&ml->timer, earliest); | 155 | mod_timer(&ml->timer, earliest); |
157 | } | 156 | } |
158 | } | 157 | } |
159 | 158 | ||
160 | /* | 159 | /* |
161 | * Apply an envelope to a value | 160 | * Apply an envelope to a value |
162 | */ | 161 | */ |
163 | static int apply_envelope(struct ml_effect_state *state, int value, | 162 | static int apply_envelope(struct ml_effect_state *state, int value, |
164 | struct ff_envelope *envelope) | 163 | struct ff_envelope *envelope) |
165 | { | 164 | { |
166 | struct ff_effect *effect = state->effect; | 165 | struct ff_effect *effect = state->effect; |
167 | unsigned long now = jiffies; | 166 | unsigned long now = jiffies; |
168 | int time_from_level; | 167 | int time_from_level; |
169 | int time_of_envelope; | 168 | int time_of_envelope; |
170 | int envelope_level; | 169 | int envelope_level; |
171 | int difference; | 170 | int difference; |
172 | 171 | ||
173 | if (envelope->attack_length && | 172 | if (envelope->attack_length && |
174 | time_before(now, | 173 | time_before(now, |
175 | state->play_at + msecs_to_jiffies(envelope->attack_length))) { | 174 | state->play_at + msecs_to_jiffies(envelope->attack_length))) { |
176 | debug("value = 0x%x, attack_level = 0x%x", value, | 175 | debug("value = 0x%x, attack_level = 0x%x", value, |
177 | envelope->attack_level); | 176 | envelope->attack_level); |
178 | time_from_level = jiffies_to_msecs(now - state->play_at); | 177 | time_from_level = jiffies_to_msecs(now - state->play_at); |
179 | time_of_envelope = envelope->attack_length; | 178 | time_of_envelope = envelope->attack_length; |
180 | envelope_level = min_t(__s16, envelope->attack_level, 0x7fff); | 179 | envelope_level = min_t(__s16, envelope->attack_level, 0x7fff); |
181 | 180 | ||
182 | } else if (envelope->fade_length && effect->replay.length && | 181 | } else if (envelope->fade_length && effect->replay.length && |
183 | time_after(now, | 182 | time_after(now, |
184 | state->stop_at - msecs_to_jiffies(envelope->fade_length)) && | 183 | state->stop_at - msecs_to_jiffies(envelope->fade_length)) && |
185 | time_before(now, state->stop_at)) { | 184 | time_before(now, state->stop_at)) { |
186 | time_from_level = jiffies_to_msecs(state->stop_at - now); | 185 | time_from_level = jiffies_to_msecs(state->stop_at - now); |
187 | time_of_envelope = envelope->fade_length; | 186 | time_of_envelope = envelope->fade_length; |
188 | envelope_level = min_t(__s16, envelope->fade_level, 0x7fff); | 187 | envelope_level = min_t(__s16, envelope->fade_level, 0x7fff); |
189 | } else | 188 | } else |
190 | return value; | 189 | return value; |
191 | 190 | ||
192 | difference = abs(value) - envelope_level; | 191 | difference = abs(value) - envelope_level; |
193 | 192 | ||
194 | debug("difference = %d", difference); | 193 | debug("difference = %d", difference); |
195 | debug("time_from_level = 0x%x", time_from_level); | 194 | debug("time_from_level = 0x%x", time_from_level); |
196 | debug("time_of_envelope = 0x%x", time_of_envelope); | 195 | debug("time_of_envelope = 0x%x", time_of_envelope); |
197 | 196 | ||
198 | difference = difference * time_from_level / time_of_envelope; | 197 | difference = difference * time_from_level / time_of_envelope; |
199 | 198 | ||
200 | debug("difference = %d", difference); | 199 | debug("difference = %d", difference); |
201 | 200 | ||
202 | return value < 0 ? | 201 | return value < 0 ? |
203 | -(difference + envelope_level) : (difference + envelope_level); | 202 | -(difference + envelope_level) : (difference + envelope_level); |
204 | } | 203 | } |
205 | 204 | ||
206 | /* | 205 | /* |
207 | * Return the type the effect has to be converted into (memless devices) | 206 | * Return the type the effect has to be converted into (memless devices) |
208 | */ | 207 | */ |
209 | static int get_compatible_type(struct ff_device *ff, int effect_type) | 208 | static int get_compatible_type(struct ff_device *ff, int effect_type) |
210 | { | 209 | { |
211 | 210 | ||
212 | if (test_bit(effect_type, ff->ffbit)) | 211 | if (test_bit(effect_type, ff->ffbit)) |
213 | return effect_type; | 212 | return effect_type; |
214 | 213 | ||
215 | if (effect_type == FF_PERIODIC && test_bit(FF_RUMBLE, ff->ffbit)) | 214 | if (effect_type == FF_PERIODIC && test_bit(FF_RUMBLE, ff->ffbit)) |
216 | return FF_RUMBLE; | 215 | return FF_RUMBLE; |
217 | 216 | ||
218 | printk(KERN_ERR | 217 | printk(KERN_ERR |
219 | "ff-memless: invalid type in get_compatible_type()\n"); | 218 | "ff-memless: invalid type in get_compatible_type()\n"); |
220 | 219 | ||
221 | return 0; | 220 | return 0; |
222 | } | 221 | } |
223 | 222 | ||
224 | /* | 223 | /* |
225 | * Combine two effects and apply gain. | 224 | * Combine two effects and apply gain. |
226 | */ | 225 | */ |
227 | static void ml_combine_effects(struct ff_effect *effect, | 226 | static void ml_combine_effects(struct ff_effect *effect, |
228 | struct ml_effect_state *state, | 227 | struct ml_effect_state *state, |
229 | unsigned int gain) | 228 | unsigned int gain) |
230 | { | 229 | { |
231 | struct ff_effect *new = state->effect; | 230 | struct ff_effect *new = state->effect; |
232 | unsigned int strong, weak, i; | 231 | unsigned int strong, weak, i; |
233 | int x, y; | 232 | int x, y; |
234 | fixp_t level; | 233 | fixp_t level; |
235 | 234 | ||
236 | switch (new->type) { | 235 | switch (new->type) { |
237 | case FF_CONSTANT: | 236 | case FF_CONSTANT: |
238 | i = new->direction * 360 / 0xffff; | 237 | i = new->direction * 360 / 0xffff; |
239 | level = fixp_new16(apply_envelope(state, | 238 | level = fixp_new16(apply_envelope(state, |
240 | new->u.constant.level, | 239 | new->u.constant.level, |
241 | &new->u.constant.envelope)); | 240 | &new->u.constant.envelope)); |
242 | x = fixp_mult(fixp_sin(i), level) * gain / 0xffff; | 241 | x = fixp_mult(fixp_sin(i), level) * gain / 0xffff; |
243 | y = fixp_mult(-fixp_cos(i), level) * gain / 0xffff; | 242 | y = fixp_mult(-fixp_cos(i), level) * gain / 0xffff; |
244 | /* | 243 | /* |
245 | * here we abuse ff_ramp to hold x and y of constant force | 244 | * here we abuse ff_ramp to hold x and y of constant force |
246 | * If in future any driver wants something else than x and y | 245 | * If in future any driver wants something else than x and y |
247 | * in s8, this should be changed to something more generic | 246 | * in s8, this should be changed to something more generic |
248 | */ | 247 | */ |
249 | effect->u.ramp.start_level = | 248 | effect->u.ramp.start_level = |
250 | clamp_val(effect->u.ramp.start_level + x, -0x80, 0x7f); | 249 | clamp_val(effect->u.ramp.start_level + x, -0x80, 0x7f); |
251 | effect->u.ramp.end_level = | 250 | effect->u.ramp.end_level = |
252 | clamp_val(effect->u.ramp.end_level + y, -0x80, 0x7f); | 251 | clamp_val(effect->u.ramp.end_level + y, -0x80, 0x7f); |
253 | break; | 252 | break; |
254 | 253 | ||
255 | case FF_RUMBLE: | 254 | case FF_RUMBLE: |
256 | strong = new->u.rumble.strong_magnitude * gain / 0xffff; | 255 | strong = new->u.rumble.strong_magnitude * gain / 0xffff; |
257 | weak = new->u.rumble.weak_magnitude * gain / 0xffff; | 256 | weak = new->u.rumble.weak_magnitude * gain / 0xffff; |
258 | effect->u.rumble.strong_magnitude = | 257 | effect->u.rumble.strong_magnitude = |
259 | min(strong + effect->u.rumble.strong_magnitude, | 258 | min(strong + effect->u.rumble.strong_magnitude, |
260 | 0xffffU); | 259 | 0xffffU); |
261 | effect->u.rumble.weak_magnitude = | 260 | effect->u.rumble.weak_magnitude = |
262 | min(weak + effect->u.rumble.weak_magnitude, 0xffffU); | 261 | min(weak + effect->u.rumble.weak_magnitude, 0xffffU); |
263 | break; | 262 | break; |
264 | 263 | ||
265 | case FF_PERIODIC: | 264 | case FF_PERIODIC: |
266 | i = apply_envelope(state, abs(new->u.periodic.magnitude), | 265 | i = apply_envelope(state, abs(new->u.periodic.magnitude), |
267 | &new->u.periodic.envelope); | 266 | &new->u.periodic.envelope); |
268 | 267 | ||
269 | /* here we also scale it 0x7fff => 0xffff */ | 268 | /* here we also scale it 0x7fff => 0xffff */ |
270 | i = i * gain / 0x7fff; | 269 | i = i * gain / 0x7fff; |
271 | 270 | ||
272 | effect->u.rumble.strong_magnitude = | 271 | effect->u.rumble.strong_magnitude = |
273 | min(i + effect->u.rumble.strong_magnitude, 0xffffU); | 272 | min(i + effect->u.rumble.strong_magnitude, 0xffffU); |
274 | effect->u.rumble.weak_magnitude = | 273 | effect->u.rumble.weak_magnitude = |
275 | min(i + effect->u.rumble.weak_magnitude, 0xffffU); | 274 | min(i + effect->u.rumble.weak_magnitude, 0xffffU); |
276 | break; | 275 | break; |
277 | 276 | ||
278 | default: | 277 | default: |
279 | printk(KERN_ERR "ff-memless: invalid type in ml_combine_effects()\n"); | 278 | printk(KERN_ERR "ff-memless: invalid type in ml_combine_effects()\n"); |
280 | break; | 279 | break; |
281 | } | 280 | } |
282 | 281 | ||
283 | } | 282 | } |
284 | 283 | ||
285 | 284 | ||
286 | /* | 285 | /* |
287 | * Because memoryless devices have only one effect per effect type active | 286 | * Because memoryless devices have only one effect per effect type active |
288 | * at one time we have to combine multiple effects into one | 287 | * at one time we have to combine multiple effects into one |
289 | */ | 288 | */ |
290 | static int ml_get_combo_effect(struct ml_device *ml, | 289 | static int ml_get_combo_effect(struct ml_device *ml, |
291 | unsigned long *effect_handled, | 290 | unsigned long *effect_handled, |
292 | struct ff_effect *combo_effect) | 291 | struct ff_effect *combo_effect) |
293 | { | 292 | { |
294 | struct ff_effect *effect; | 293 | struct ff_effect *effect; |
295 | struct ml_effect_state *state; | 294 | struct ml_effect_state *state; |
296 | int effect_type; | 295 | int effect_type; |
297 | int i; | 296 | int i; |
298 | 297 | ||
299 | memset(combo_effect, 0, sizeof(struct ff_effect)); | 298 | memset(combo_effect, 0, sizeof(struct ff_effect)); |
300 | 299 | ||
301 | for (i = 0; i < FF_MEMLESS_EFFECTS; i++) { | 300 | for (i = 0; i < FF_MEMLESS_EFFECTS; i++) { |
302 | if (__test_and_set_bit(i, effect_handled)) | 301 | if (__test_and_set_bit(i, effect_handled)) |
303 | continue; | 302 | continue; |
304 | 303 | ||
305 | state = &ml->states[i]; | 304 | state = &ml->states[i]; |
306 | effect = state->effect; | 305 | effect = state->effect; |
307 | 306 | ||
308 | if (!test_bit(FF_EFFECT_STARTED, &state->flags)) | 307 | if (!test_bit(FF_EFFECT_STARTED, &state->flags)) |
309 | continue; | 308 | continue; |
310 | 309 | ||
311 | if (time_before(jiffies, state->play_at)) | 310 | if (time_before(jiffies, state->play_at)) |
312 | continue; | 311 | continue; |
313 | 312 | ||
314 | /* | 313 | /* |
315 | * here we have started effects that are either | 314 | * here we have started effects that are either |
316 | * currently playing (and may need be aborted) | 315 | * currently playing (and may need be aborted) |
317 | * or need to start playing. | 316 | * or need to start playing. |
318 | */ | 317 | */ |
319 | effect_type = get_compatible_type(ml->dev->ff, effect->type); | 318 | effect_type = get_compatible_type(ml->dev->ff, effect->type); |
320 | if (combo_effect->type != effect_type) { | 319 | if (combo_effect->type != effect_type) { |
321 | if (combo_effect->type != 0) { | 320 | if (combo_effect->type != 0) { |
322 | __clear_bit(i, effect_handled); | 321 | __clear_bit(i, effect_handled); |
323 | continue; | 322 | continue; |
324 | } | 323 | } |
325 | combo_effect->type = effect_type; | 324 | combo_effect->type = effect_type; |
326 | } | 325 | } |
327 | 326 | ||
328 | if (__test_and_clear_bit(FF_EFFECT_ABORTING, &state->flags)) { | 327 | if (__test_and_clear_bit(FF_EFFECT_ABORTING, &state->flags)) { |
329 | __clear_bit(FF_EFFECT_PLAYING, &state->flags); | 328 | __clear_bit(FF_EFFECT_PLAYING, &state->flags); |
330 | __clear_bit(FF_EFFECT_STARTED, &state->flags); | 329 | __clear_bit(FF_EFFECT_STARTED, &state->flags); |
331 | } else if (effect->replay.length && | 330 | } else if (effect->replay.length && |
332 | time_after_eq(jiffies, state->stop_at)) { | 331 | time_after_eq(jiffies, state->stop_at)) { |
333 | 332 | ||
334 | __clear_bit(FF_EFFECT_PLAYING, &state->flags); | 333 | __clear_bit(FF_EFFECT_PLAYING, &state->flags); |
335 | 334 | ||
336 | if (--state->count <= 0) { | 335 | if (--state->count <= 0) { |
337 | __clear_bit(FF_EFFECT_STARTED, &state->flags); | 336 | __clear_bit(FF_EFFECT_STARTED, &state->flags); |
338 | } else { | 337 | } else { |
339 | state->play_at = jiffies + | 338 | state->play_at = jiffies + |
340 | msecs_to_jiffies(effect->replay.delay); | 339 | msecs_to_jiffies(effect->replay.delay); |
341 | state->stop_at = state->play_at + | 340 | state->stop_at = state->play_at + |
342 | msecs_to_jiffies(effect->replay.length); | 341 | msecs_to_jiffies(effect->replay.length); |
343 | } | 342 | } |
344 | } else { | 343 | } else { |
345 | __set_bit(FF_EFFECT_PLAYING, &state->flags); | 344 | __set_bit(FF_EFFECT_PLAYING, &state->flags); |
346 | state->adj_at = jiffies; | 345 | state->adj_at = jiffies; |
347 | ml_combine_effects(combo_effect, state, ml->gain); | 346 | ml_combine_effects(combo_effect, state, ml->gain); |
348 | } | 347 | } |
349 | } | 348 | } |
350 | 349 | ||
351 | return combo_effect->type != 0; | 350 | return combo_effect->type != 0; |
352 | } | 351 | } |
353 | 352 | ||
354 | static void ml_play_effects(struct ml_device *ml) | 353 | static void ml_play_effects(struct ml_device *ml) |
355 | { | 354 | { |
356 | struct ff_effect effect; | 355 | struct ff_effect effect; |
357 | DECLARE_BITMAP(handled_bm, FF_MEMLESS_EFFECTS); | 356 | DECLARE_BITMAP(handled_bm, FF_MEMLESS_EFFECTS); |
358 | 357 | ||
359 | memset(handled_bm, 0, sizeof(handled_bm)); | 358 | memset(handled_bm, 0, sizeof(handled_bm)); |
360 | 359 | ||
361 | while (ml_get_combo_effect(ml, handled_bm, &effect)) | 360 | while (ml_get_combo_effect(ml, handled_bm, &effect)) |
362 | ml->play_effect(ml->dev, ml->private, &effect); | 361 | ml->play_effect(ml->dev, ml->private, &effect); |
363 | 362 | ||
364 | ml_schedule_timer(ml); | 363 | ml_schedule_timer(ml); |
365 | } | 364 | } |
366 | 365 | ||
367 | static void ml_effect_timer(unsigned long timer_data) | 366 | static void ml_effect_timer(unsigned long timer_data) |
368 | { | 367 | { |
369 | struct input_dev *dev = (struct input_dev *)timer_data; | 368 | struct input_dev *dev = (struct input_dev *)timer_data; |
370 | struct ml_device *ml = dev->ff->private; | 369 | struct ml_device *ml = dev->ff->private; |
370 | unsigned long flags; | ||
371 | 371 | ||
372 | debug("timer: updating effects"); | 372 | debug("timer: updating effects"); |
373 | 373 | ||
374 | spin_lock(&ml->timer_lock); | 374 | spin_lock_irqsave(&dev->event_lock, flags); |
375 | ml_play_effects(ml); | 375 | ml_play_effects(ml); |
376 | spin_unlock(&ml->timer_lock); | 376 | spin_unlock_irqrestore(&dev->event_lock, flags); |
377 | } | 377 | } |
378 | 378 | ||
379 | /* | ||
380 | * Sets requested gain for FF effects. Called with dev->event_lock held. | ||
381 | */ | ||
379 | static void ml_ff_set_gain(struct input_dev *dev, u16 gain) | 382 | static void ml_ff_set_gain(struct input_dev *dev, u16 gain) |
380 | { | 383 | { |
381 | struct ml_device *ml = dev->ff->private; | 384 | struct ml_device *ml = dev->ff->private; |
382 | int i; | 385 | int i; |
383 | 386 | ||
384 | spin_lock_bh(&ml->timer_lock); | ||
385 | |||
386 | ml->gain = gain; | 387 | ml->gain = gain; |
387 | 388 | ||
388 | for (i = 0; i < FF_MEMLESS_EFFECTS; i++) | 389 | for (i = 0; i < FF_MEMLESS_EFFECTS; i++) |
389 | __clear_bit(FF_EFFECT_PLAYING, &ml->states[i].flags); | 390 | __clear_bit(FF_EFFECT_PLAYING, &ml->states[i].flags); |
390 | 391 | ||
391 | ml_play_effects(ml); | 392 | ml_play_effects(ml); |
392 | |||
393 | spin_unlock_bh(&ml->timer_lock); | ||
394 | } | 393 | } |
395 | 394 | ||
395 | /* | ||
396 | * Start/stop specified FF effect. Called with dev->event_lock held. | ||
397 | */ | ||
396 | static int ml_ff_playback(struct input_dev *dev, int effect_id, int value) | 398 | static int ml_ff_playback(struct input_dev *dev, int effect_id, int value) |
397 | { | 399 | { |
398 | struct ml_device *ml = dev->ff->private; | 400 | struct ml_device *ml = dev->ff->private; |
399 | struct ml_effect_state *state = &ml->states[effect_id]; | 401 | struct ml_effect_state *state = &ml->states[effect_id]; |
400 | unsigned long flags; | ||
401 | 402 | ||
402 | spin_lock_irqsave(&ml->timer_lock, flags); | ||
403 | |||
404 | if (value > 0) { | 403 | if (value > 0) { |
405 | debug("initiated play"); | 404 | debug("initiated play"); |
406 | 405 | ||
407 | __set_bit(FF_EFFECT_STARTED, &state->flags); | 406 | __set_bit(FF_EFFECT_STARTED, &state->flags); |
408 | state->count = value; | 407 | state->count = value; |
409 | state->play_at = jiffies + | 408 | state->play_at = jiffies + |
410 | msecs_to_jiffies(state->effect->replay.delay); | 409 | msecs_to_jiffies(state->effect->replay.delay); |
411 | state->stop_at = state->play_at + | 410 | state->stop_at = state->play_at + |
412 | msecs_to_jiffies(state->effect->replay.length); | 411 | msecs_to_jiffies(state->effect->replay.length); |
413 | state->adj_at = state->play_at; | 412 | state->adj_at = state->play_at; |
414 | 413 | ||
415 | ml_schedule_timer(ml); | 414 | ml_schedule_timer(ml); |
416 | 415 | ||
417 | } else { | 416 | } else { |
418 | debug("initiated stop"); | 417 | debug("initiated stop"); |
419 | 418 | ||
420 | if (test_bit(FF_EFFECT_PLAYING, &state->flags)) | 419 | if (test_bit(FF_EFFECT_PLAYING, &state->flags)) |
421 | __set_bit(FF_EFFECT_ABORTING, &state->flags); | 420 | __set_bit(FF_EFFECT_ABORTING, &state->flags); |
422 | else | 421 | else |
423 | __clear_bit(FF_EFFECT_STARTED, &state->flags); | 422 | __clear_bit(FF_EFFECT_STARTED, &state->flags); |
424 | 423 | ||
425 | ml_play_effects(ml); | 424 | ml_play_effects(ml); |
426 | } | 425 | } |
427 | 426 | ||
428 | spin_unlock_irqrestore(&ml->timer_lock, flags); | ||
429 | |||
430 | return 0; | 427 | return 0; |
431 | } | 428 | } |
432 | 429 | ||
433 | static int ml_ff_upload(struct input_dev *dev, | 430 | static int ml_ff_upload(struct input_dev *dev, |
434 | struct ff_effect *effect, struct ff_effect *old) | 431 | struct ff_effect *effect, struct ff_effect *old) |
435 | { | 432 | { |
436 | struct ml_device *ml = dev->ff->private; | 433 | struct ml_device *ml = dev->ff->private; |
437 | struct ml_effect_state *state = &ml->states[effect->id]; | 434 | struct ml_effect_state *state = &ml->states[effect->id]; |
438 | 435 | ||
439 | spin_lock_bh(&ml->timer_lock); | 436 | spin_lock_irq(&dev->event_lock); |
440 | 437 | ||
441 | if (test_bit(FF_EFFECT_STARTED, &state->flags)) { | 438 | if (test_bit(FF_EFFECT_STARTED, &state->flags)) { |
442 | __clear_bit(FF_EFFECT_PLAYING, &state->flags); | 439 | __clear_bit(FF_EFFECT_PLAYING, &state->flags); |
443 | state->play_at = jiffies + | 440 | state->play_at = jiffies + |
444 | msecs_to_jiffies(state->effect->replay.delay); | 441 | msecs_to_jiffies(state->effect->replay.delay); |
445 | state->stop_at = state->play_at + | 442 | state->stop_at = state->play_at + |
446 | msecs_to_jiffies(state->effect->replay.length); | 443 | msecs_to_jiffies(state->effect->replay.length); |
447 | state->adj_at = state->play_at; | 444 | state->adj_at = state->play_at; |
448 | ml_schedule_timer(ml); | 445 | ml_schedule_timer(ml); |
449 | } | 446 | } |
450 | 447 | ||
451 | spin_unlock_bh(&ml->timer_lock); | 448 | spin_unlock_irq(&dev->event_lock); |
452 | 449 | ||
453 | return 0; | 450 | return 0; |
454 | } | 451 | } |
455 | 452 | ||
456 | static void ml_ff_destroy(struct ff_device *ff) | 453 | static void ml_ff_destroy(struct ff_device *ff) |
457 | { | 454 | { |
458 | struct ml_device *ml = ff->private; | 455 | struct ml_device *ml = ff->private; |
459 | 456 | ||
460 | kfree(ml->private); | 457 | kfree(ml->private); |
461 | } | 458 | } |
462 | 459 | ||
463 | /** | 460 | /** |
464 | * input_ff_create_memless() - create memoryless force-feedback device | 461 | * input_ff_create_memless() - create memoryless force-feedback device |
465 | * @dev: input device supporting force-feedback | 462 | * @dev: input device supporting force-feedback |
466 | * @data: driver-specific data to be passed into @play_effect | 463 | * @data: driver-specific data to be passed into @play_effect |
467 | * @play_effect: driver-specific method for playing FF effect | 464 | * @play_effect: driver-specific method for playing FF effect |
468 | */ | 465 | */ |
469 | int input_ff_create_memless(struct input_dev *dev, void *data, | 466 | int input_ff_create_memless(struct input_dev *dev, void *data, |
470 | int (*play_effect)(struct input_dev *, void *, struct ff_effect *)) | 467 | int (*play_effect)(struct input_dev *, void *, struct ff_effect *)) |
471 | { | 468 | { |
472 | struct ml_device *ml; | 469 | struct ml_device *ml; |
473 | struct ff_device *ff; | 470 | struct ff_device *ff; |
474 | int error; | 471 | int error; |
475 | int i; | 472 | int i; |
476 | 473 | ||
477 | ml = kzalloc(sizeof(struct ml_device), GFP_KERNEL); | 474 | ml = kzalloc(sizeof(struct ml_device), GFP_KERNEL); |
478 | if (!ml) | 475 | if (!ml) |
479 | return -ENOMEM; | 476 | return -ENOMEM; |
480 | 477 | ||
481 | ml->dev = dev; | 478 | ml->dev = dev; |
482 | ml->private = data; | 479 | ml->private = data; |
483 | ml->play_effect = play_effect; | 480 | ml->play_effect = play_effect; |
484 | ml->gain = 0xffff; | 481 | ml->gain = 0xffff; |
485 | spin_lock_init(&ml->timer_lock); | ||
486 | setup_timer(&ml->timer, ml_effect_timer, (unsigned long)dev); | 482 | setup_timer(&ml->timer, ml_effect_timer, (unsigned long)dev); |
487 | 483 | ||
488 | set_bit(FF_GAIN, dev->ffbit); | 484 | set_bit(FF_GAIN, dev->ffbit); |
489 | 485 | ||
490 | error = input_ff_create(dev, FF_MEMLESS_EFFECTS); | 486 | error = input_ff_create(dev, FF_MEMLESS_EFFECTS); |
491 | if (error) { | 487 | if (error) { |
492 | kfree(ml); | 488 | kfree(ml); |
493 | return error; | 489 | return error; |
494 | } | 490 | } |
495 | 491 | ||
496 | ff = dev->ff; | 492 | ff = dev->ff; |
497 | ff->private = ml; | 493 | ff->private = ml; |
498 | ff->upload = ml_ff_upload; | 494 | ff->upload = ml_ff_upload; |
499 | ff->playback = ml_ff_playback; | 495 | ff->playback = ml_ff_playback; |
500 | ff->set_gain = ml_ff_set_gain; | 496 | ff->set_gain = ml_ff_set_gain; |
501 | ff->destroy = ml_ff_destroy; | 497 | ff->destroy = ml_ff_destroy; |
502 | 498 | ||
503 | /* we can emulate periodic effects with RUMBLE */ | 499 | /* we can emulate periodic effects with RUMBLE */ |
504 | if (test_bit(FF_RUMBLE, ff->ffbit)) { | 500 | if (test_bit(FF_RUMBLE, ff->ffbit)) { |
505 | set_bit(FF_PERIODIC, dev->ffbit); | 501 | set_bit(FF_PERIODIC, dev->ffbit); |
506 | set_bit(FF_SINE, dev->ffbit); | 502 | set_bit(FF_SINE, dev->ffbit); |
507 | set_bit(FF_TRIANGLE, dev->ffbit); | 503 | set_bit(FF_TRIANGLE, dev->ffbit); |
508 | set_bit(FF_SQUARE, dev->ffbit); | 504 | set_bit(FF_SQUARE, dev->ffbit); |
509 | } | 505 | } |
510 | 506 |
include/linux/input.h
1 | #ifndef _INPUT_H | 1 | #ifndef _INPUT_H |
2 | #define _INPUT_H | 2 | #define _INPUT_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | * Copyright (c) 1999-2002 Vojtech Pavlik | 5 | * Copyright (c) 1999-2002 Vojtech Pavlik |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify it | 7 | * This program is free software; you can redistribute it and/or modify it |
8 | * under the terms of the GNU General Public License version 2 as published by | 8 | * under the terms of the GNU General Public License version 2 as published by |
9 | * the Free Software Foundation. | 9 | * the Free Software Foundation. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #ifdef __KERNEL__ | 12 | #ifdef __KERNEL__ |
13 | #include <linux/time.h> | 13 | #include <linux/time.h> |
14 | #include <linux/list.h> | 14 | #include <linux/list.h> |
15 | #else | 15 | #else |
16 | #include <sys/time.h> | 16 | #include <sys/time.h> |
17 | #include <sys/ioctl.h> | 17 | #include <sys/ioctl.h> |
18 | #include <sys/types.h> | 18 | #include <sys/types.h> |
19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * The event structure itself | 23 | * The event structure itself |
24 | */ | 24 | */ |
25 | 25 | ||
26 | struct input_event { | 26 | struct input_event { |
27 | struct timeval time; | 27 | struct timeval time; |
28 | __u16 type; | 28 | __u16 type; |
29 | __u16 code; | 29 | __u16 code; |
30 | __s32 value; | 30 | __s32 value; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * Protocol version. | 34 | * Protocol version. |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #define EV_VERSION 0x010000 | 37 | #define EV_VERSION 0x010000 |
38 | 38 | ||
39 | /* | 39 | /* |
40 | * IOCTLs (0x00 - 0x7f) | 40 | * IOCTLs (0x00 - 0x7f) |
41 | */ | 41 | */ |
42 | 42 | ||
43 | struct input_id { | 43 | struct input_id { |
44 | __u16 bustype; | 44 | __u16 bustype; |
45 | __u16 vendor; | 45 | __u16 vendor; |
46 | __u16 product; | 46 | __u16 product; |
47 | __u16 version; | 47 | __u16 version; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | struct input_absinfo { | 50 | struct input_absinfo { |
51 | __s32 value; | 51 | __s32 value; |
52 | __s32 minimum; | 52 | __s32 minimum; |
53 | __s32 maximum; | 53 | __s32 maximum; |
54 | __s32 fuzz; | 54 | __s32 fuzz; |
55 | __s32 flat; | 55 | __s32 flat; |
56 | __s32 resolution; | 56 | __s32 resolution; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ | 59 | #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ |
60 | #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ | 60 | #define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ |
61 | #define EVIOCGREP _IOR('E', 0x03, int[2]) /* get repeat settings */ | 61 | #define EVIOCGREP _IOR('E', 0x03, int[2]) /* get repeat settings */ |
62 | #define EVIOCSREP _IOW('E', 0x03, int[2]) /* set repeat settings */ | 62 | #define EVIOCSREP _IOW('E', 0x03, int[2]) /* set repeat settings */ |
63 | #define EVIOCGKEYCODE _IOR('E', 0x04, int[2]) /* get keycode */ | 63 | #define EVIOCGKEYCODE _IOR('E', 0x04, int[2]) /* get keycode */ |
64 | #define EVIOCSKEYCODE _IOW('E', 0x04, int[2]) /* set keycode */ | 64 | #define EVIOCSKEYCODE _IOW('E', 0x04, int[2]) /* set keycode */ |
65 | 65 | ||
66 | #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ | 66 | #define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ |
67 | #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ | 67 | #define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ |
68 | #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */ | 68 | #define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */ |
69 | 69 | ||
70 | #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */ | 70 | #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */ |
71 | #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ | 71 | #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ |
72 | #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ | 72 | #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ |
73 | #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */ | 73 | #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */ |
74 | 74 | ||
75 | #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */ | 75 | #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */ |
76 | #define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */ | 76 | #define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */ |
77 | #define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */ | 77 | #define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */ |
78 | 78 | ||
79 | #define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */ | 79 | #define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */ |
80 | #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ | 80 | #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ |
81 | #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ | 81 | #define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */ |
82 | 82 | ||
83 | #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ | 83 | #define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */ |
84 | 84 | ||
85 | /* | 85 | /* |
86 | * Event types | 86 | * Event types |
87 | */ | 87 | */ |
88 | 88 | ||
89 | #define EV_SYN 0x00 | 89 | #define EV_SYN 0x00 |
90 | #define EV_KEY 0x01 | 90 | #define EV_KEY 0x01 |
91 | #define EV_REL 0x02 | 91 | #define EV_REL 0x02 |
92 | #define EV_ABS 0x03 | 92 | #define EV_ABS 0x03 |
93 | #define EV_MSC 0x04 | 93 | #define EV_MSC 0x04 |
94 | #define EV_SW 0x05 | 94 | #define EV_SW 0x05 |
95 | #define EV_LED 0x11 | 95 | #define EV_LED 0x11 |
96 | #define EV_SND 0x12 | 96 | #define EV_SND 0x12 |
97 | #define EV_REP 0x14 | 97 | #define EV_REP 0x14 |
98 | #define EV_FF 0x15 | 98 | #define EV_FF 0x15 |
99 | #define EV_PWR 0x16 | 99 | #define EV_PWR 0x16 |
100 | #define EV_FF_STATUS 0x17 | 100 | #define EV_FF_STATUS 0x17 |
101 | #define EV_MAX 0x1f | 101 | #define EV_MAX 0x1f |
102 | #define EV_CNT (EV_MAX+1) | 102 | #define EV_CNT (EV_MAX+1) |
103 | 103 | ||
104 | /* | 104 | /* |
105 | * Synchronization events. | 105 | * Synchronization events. |
106 | */ | 106 | */ |
107 | 107 | ||
108 | #define SYN_REPORT 0 | 108 | #define SYN_REPORT 0 |
109 | #define SYN_CONFIG 1 | 109 | #define SYN_CONFIG 1 |
110 | #define SYN_MT_REPORT 2 | 110 | #define SYN_MT_REPORT 2 |
111 | 111 | ||
112 | /* | 112 | /* |
113 | * Keys and buttons | 113 | * Keys and buttons |
114 | * | 114 | * |
115 | * Most of the keys/buttons are modeled after USB HUT 1.12 | 115 | * Most of the keys/buttons are modeled after USB HUT 1.12 |
116 | * (see http://www.usb.org/developers/hidpage). | 116 | * (see http://www.usb.org/developers/hidpage). |
117 | * Abbreviations in the comments: | 117 | * Abbreviations in the comments: |
118 | * AC - Application Control | 118 | * AC - Application Control |
119 | * AL - Application Launch Button | 119 | * AL - Application Launch Button |
120 | * SC - System Control | 120 | * SC - System Control |
121 | */ | 121 | */ |
122 | 122 | ||
123 | #define KEY_RESERVED 0 | 123 | #define KEY_RESERVED 0 |
124 | #define KEY_ESC 1 | 124 | #define KEY_ESC 1 |
125 | #define KEY_1 2 | 125 | #define KEY_1 2 |
126 | #define KEY_2 3 | 126 | #define KEY_2 3 |
127 | #define KEY_3 4 | 127 | #define KEY_3 4 |
128 | #define KEY_4 5 | 128 | #define KEY_4 5 |
129 | #define KEY_5 6 | 129 | #define KEY_5 6 |
130 | #define KEY_6 7 | 130 | #define KEY_6 7 |
131 | #define KEY_7 8 | 131 | #define KEY_7 8 |
132 | #define KEY_8 9 | 132 | #define KEY_8 9 |
133 | #define KEY_9 10 | 133 | #define KEY_9 10 |
134 | #define KEY_0 11 | 134 | #define KEY_0 11 |
135 | #define KEY_MINUS 12 | 135 | #define KEY_MINUS 12 |
136 | #define KEY_EQUAL 13 | 136 | #define KEY_EQUAL 13 |
137 | #define KEY_BACKSPACE 14 | 137 | #define KEY_BACKSPACE 14 |
138 | #define KEY_TAB 15 | 138 | #define KEY_TAB 15 |
139 | #define KEY_Q 16 | 139 | #define KEY_Q 16 |
140 | #define KEY_W 17 | 140 | #define KEY_W 17 |
141 | #define KEY_E 18 | 141 | #define KEY_E 18 |
142 | #define KEY_R 19 | 142 | #define KEY_R 19 |
143 | #define KEY_T 20 | 143 | #define KEY_T 20 |
144 | #define KEY_Y 21 | 144 | #define KEY_Y 21 |
145 | #define KEY_U 22 | 145 | #define KEY_U 22 |
146 | #define KEY_I 23 | 146 | #define KEY_I 23 |
147 | #define KEY_O 24 | 147 | #define KEY_O 24 |
148 | #define KEY_P 25 | 148 | #define KEY_P 25 |
149 | #define KEY_LEFTBRACE 26 | 149 | #define KEY_LEFTBRACE 26 |
150 | #define KEY_RIGHTBRACE 27 | 150 | #define KEY_RIGHTBRACE 27 |
151 | #define KEY_ENTER 28 | 151 | #define KEY_ENTER 28 |
152 | #define KEY_LEFTCTRL 29 | 152 | #define KEY_LEFTCTRL 29 |
153 | #define KEY_A 30 | 153 | #define KEY_A 30 |
154 | #define KEY_S 31 | 154 | #define KEY_S 31 |
155 | #define KEY_D 32 | 155 | #define KEY_D 32 |
156 | #define KEY_F 33 | 156 | #define KEY_F 33 |
157 | #define KEY_G 34 | 157 | #define KEY_G 34 |
158 | #define KEY_H 35 | 158 | #define KEY_H 35 |
159 | #define KEY_J 36 | 159 | #define KEY_J 36 |
160 | #define KEY_K 37 | 160 | #define KEY_K 37 |
161 | #define KEY_L 38 | 161 | #define KEY_L 38 |
162 | #define KEY_SEMICOLON 39 | 162 | #define KEY_SEMICOLON 39 |
163 | #define KEY_APOSTROPHE 40 | 163 | #define KEY_APOSTROPHE 40 |
164 | #define KEY_GRAVE 41 | 164 | #define KEY_GRAVE 41 |
165 | #define KEY_LEFTSHIFT 42 | 165 | #define KEY_LEFTSHIFT 42 |
166 | #define KEY_BACKSLASH 43 | 166 | #define KEY_BACKSLASH 43 |
167 | #define KEY_Z 44 | 167 | #define KEY_Z 44 |
168 | #define KEY_X 45 | 168 | #define KEY_X 45 |
169 | #define KEY_C 46 | 169 | #define KEY_C 46 |
170 | #define KEY_V 47 | 170 | #define KEY_V 47 |
171 | #define KEY_B 48 | 171 | #define KEY_B 48 |
172 | #define KEY_N 49 | 172 | #define KEY_N 49 |
173 | #define KEY_M 50 | 173 | #define KEY_M 50 |
174 | #define KEY_COMMA 51 | 174 | #define KEY_COMMA 51 |
175 | #define KEY_DOT 52 | 175 | #define KEY_DOT 52 |
176 | #define KEY_SLASH 53 | 176 | #define KEY_SLASH 53 |
177 | #define KEY_RIGHTSHIFT 54 | 177 | #define KEY_RIGHTSHIFT 54 |
178 | #define KEY_KPASTERISK 55 | 178 | #define KEY_KPASTERISK 55 |
179 | #define KEY_LEFTALT 56 | 179 | #define KEY_LEFTALT 56 |
180 | #define KEY_SPACE 57 | 180 | #define KEY_SPACE 57 |
181 | #define KEY_CAPSLOCK 58 | 181 | #define KEY_CAPSLOCK 58 |
182 | #define KEY_F1 59 | 182 | #define KEY_F1 59 |
183 | #define KEY_F2 60 | 183 | #define KEY_F2 60 |
184 | #define KEY_F3 61 | 184 | #define KEY_F3 61 |
185 | #define KEY_F4 62 | 185 | #define KEY_F4 62 |
186 | #define KEY_F5 63 | 186 | #define KEY_F5 63 |
187 | #define KEY_F6 64 | 187 | #define KEY_F6 64 |
188 | #define KEY_F7 65 | 188 | #define KEY_F7 65 |
189 | #define KEY_F8 66 | 189 | #define KEY_F8 66 |
190 | #define KEY_F9 67 | 190 | #define KEY_F9 67 |
191 | #define KEY_F10 68 | 191 | #define KEY_F10 68 |
192 | #define KEY_NUMLOCK 69 | 192 | #define KEY_NUMLOCK 69 |
193 | #define KEY_SCROLLLOCK 70 | 193 | #define KEY_SCROLLLOCK 70 |
194 | #define KEY_KP7 71 | 194 | #define KEY_KP7 71 |
195 | #define KEY_KP8 72 | 195 | #define KEY_KP8 72 |
196 | #define KEY_KP9 73 | 196 | #define KEY_KP9 73 |
197 | #define KEY_KPMINUS 74 | 197 | #define KEY_KPMINUS 74 |
198 | #define KEY_KP4 75 | 198 | #define KEY_KP4 75 |
199 | #define KEY_KP5 76 | 199 | #define KEY_KP5 76 |
200 | #define KEY_KP6 77 | 200 | #define KEY_KP6 77 |
201 | #define KEY_KPPLUS 78 | 201 | #define KEY_KPPLUS 78 |
202 | #define KEY_KP1 79 | 202 | #define KEY_KP1 79 |
203 | #define KEY_KP2 80 | 203 | #define KEY_KP2 80 |
204 | #define KEY_KP3 81 | 204 | #define KEY_KP3 81 |
205 | #define KEY_KP0 82 | 205 | #define KEY_KP0 82 |
206 | #define KEY_KPDOT 83 | 206 | #define KEY_KPDOT 83 |
207 | 207 | ||
208 | #define KEY_ZENKAKUHANKAKU 85 | 208 | #define KEY_ZENKAKUHANKAKU 85 |
209 | #define KEY_102ND 86 | 209 | #define KEY_102ND 86 |
210 | #define KEY_F11 87 | 210 | #define KEY_F11 87 |
211 | #define KEY_F12 88 | 211 | #define KEY_F12 88 |
212 | #define KEY_RO 89 | 212 | #define KEY_RO 89 |
213 | #define KEY_KATAKANA 90 | 213 | #define KEY_KATAKANA 90 |
214 | #define KEY_HIRAGANA 91 | 214 | #define KEY_HIRAGANA 91 |
215 | #define KEY_HENKAN 92 | 215 | #define KEY_HENKAN 92 |
216 | #define KEY_KATAKANAHIRAGANA 93 | 216 | #define KEY_KATAKANAHIRAGANA 93 |
217 | #define KEY_MUHENKAN 94 | 217 | #define KEY_MUHENKAN 94 |
218 | #define KEY_KPJPCOMMA 95 | 218 | #define KEY_KPJPCOMMA 95 |
219 | #define KEY_KPENTER 96 | 219 | #define KEY_KPENTER 96 |
220 | #define KEY_RIGHTCTRL 97 | 220 | #define KEY_RIGHTCTRL 97 |
221 | #define KEY_KPSLASH 98 | 221 | #define KEY_KPSLASH 98 |
222 | #define KEY_SYSRQ 99 | 222 | #define KEY_SYSRQ 99 |
223 | #define KEY_RIGHTALT 100 | 223 | #define KEY_RIGHTALT 100 |
224 | #define KEY_LINEFEED 101 | 224 | #define KEY_LINEFEED 101 |
225 | #define KEY_HOME 102 | 225 | #define KEY_HOME 102 |
226 | #define KEY_UP 103 | 226 | #define KEY_UP 103 |
227 | #define KEY_PAGEUP 104 | 227 | #define KEY_PAGEUP 104 |
228 | #define KEY_LEFT 105 | 228 | #define KEY_LEFT 105 |
229 | #define KEY_RIGHT 106 | 229 | #define KEY_RIGHT 106 |
230 | #define KEY_END 107 | 230 | #define KEY_END 107 |
231 | #define KEY_DOWN 108 | 231 | #define KEY_DOWN 108 |
232 | #define KEY_PAGEDOWN 109 | 232 | #define KEY_PAGEDOWN 109 |
233 | #define KEY_INSERT 110 | 233 | #define KEY_INSERT 110 |
234 | #define KEY_DELETE 111 | 234 | #define KEY_DELETE 111 |
235 | #define KEY_MACRO 112 | 235 | #define KEY_MACRO 112 |
236 | #define KEY_MUTE 113 | 236 | #define KEY_MUTE 113 |
237 | #define KEY_VOLUMEDOWN 114 | 237 | #define KEY_VOLUMEDOWN 114 |
238 | #define KEY_VOLUMEUP 115 | 238 | #define KEY_VOLUMEUP 115 |
239 | #define KEY_POWER 116 /* SC System Power Down */ | 239 | #define KEY_POWER 116 /* SC System Power Down */ |
240 | #define KEY_KPEQUAL 117 | 240 | #define KEY_KPEQUAL 117 |
241 | #define KEY_KPPLUSMINUS 118 | 241 | #define KEY_KPPLUSMINUS 118 |
242 | #define KEY_PAUSE 119 | 242 | #define KEY_PAUSE 119 |
243 | #define KEY_SCALE 120 /* AL Compiz Scale (Expose) */ | 243 | #define KEY_SCALE 120 /* AL Compiz Scale (Expose) */ |
244 | 244 | ||
245 | #define KEY_KPCOMMA 121 | 245 | #define KEY_KPCOMMA 121 |
246 | #define KEY_HANGEUL 122 | 246 | #define KEY_HANGEUL 122 |
247 | #define KEY_HANGUEL KEY_HANGEUL | 247 | #define KEY_HANGUEL KEY_HANGEUL |
248 | #define KEY_HANJA 123 | 248 | #define KEY_HANJA 123 |
249 | #define KEY_YEN 124 | 249 | #define KEY_YEN 124 |
250 | #define KEY_LEFTMETA 125 | 250 | #define KEY_LEFTMETA 125 |
251 | #define KEY_RIGHTMETA 126 | 251 | #define KEY_RIGHTMETA 126 |
252 | #define KEY_COMPOSE 127 | 252 | #define KEY_COMPOSE 127 |
253 | 253 | ||
254 | #define KEY_STOP 128 /* AC Stop */ | 254 | #define KEY_STOP 128 /* AC Stop */ |
255 | #define KEY_AGAIN 129 | 255 | #define KEY_AGAIN 129 |
256 | #define KEY_PROPS 130 /* AC Properties */ | 256 | #define KEY_PROPS 130 /* AC Properties */ |
257 | #define KEY_UNDO 131 /* AC Undo */ | 257 | #define KEY_UNDO 131 /* AC Undo */ |
258 | #define KEY_FRONT 132 | 258 | #define KEY_FRONT 132 |
259 | #define KEY_COPY 133 /* AC Copy */ | 259 | #define KEY_COPY 133 /* AC Copy */ |
260 | #define KEY_OPEN 134 /* AC Open */ | 260 | #define KEY_OPEN 134 /* AC Open */ |
261 | #define KEY_PASTE 135 /* AC Paste */ | 261 | #define KEY_PASTE 135 /* AC Paste */ |
262 | #define KEY_FIND 136 /* AC Search */ | 262 | #define KEY_FIND 136 /* AC Search */ |
263 | #define KEY_CUT 137 /* AC Cut */ | 263 | #define KEY_CUT 137 /* AC Cut */ |
264 | #define KEY_HELP 138 /* AL Integrated Help Center */ | 264 | #define KEY_HELP 138 /* AL Integrated Help Center */ |
265 | #define KEY_MENU 139 /* Menu (show menu) */ | 265 | #define KEY_MENU 139 /* Menu (show menu) */ |
266 | #define KEY_CALC 140 /* AL Calculator */ | 266 | #define KEY_CALC 140 /* AL Calculator */ |
267 | #define KEY_SETUP 141 | 267 | #define KEY_SETUP 141 |
268 | #define KEY_SLEEP 142 /* SC System Sleep */ | 268 | #define KEY_SLEEP 142 /* SC System Sleep */ |
269 | #define KEY_WAKEUP 143 /* System Wake Up */ | 269 | #define KEY_WAKEUP 143 /* System Wake Up */ |
270 | #define KEY_FILE 144 /* AL Local Machine Browser */ | 270 | #define KEY_FILE 144 /* AL Local Machine Browser */ |
271 | #define KEY_SENDFILE 145 | 271 | #define KEY_SENDFILE 145 |
272 | #define KEY_DELETEFILE 146 | 272 | #define KEY_DELETEFILE 146 |
273 | #define KEY_XFER 147 | 273 | #define KEY_XFER 147 |
274 | #define KEY_PROG1 148 | 274 | #define KEY_PROG1 148 |
275 | #define KEY_PROG2 149 | 275 | #define KEY_PROG2 149 |
276 | #define KEY_WWW 150 /* AL Internet Browser */ | 276 | #define KEY_WWW 150 /* AL Internet Browser */ |
277 | #define KEY_MSDOS 151 | 277 | #define KEY_MSDOS 151 |
278 | #define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */ | 278 | #define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */ |
279 | #define KEY_SCREENLOCK KEY_COFFEE | 279 | #define KEY_SCREENLOCK KEY_COFFEE |
280 | #define KEY_DIRECTION 153 | 280 | #define KEY_DIRECTION 153 |
281 | #define KEY_CYCLEWINDOWS 154 | 281 | #define KEY_CYCLEWINDOWS 154 |
282 | #define KEY_MAIL 155 | 282 | #define KEY_MAIL 155 |
283 | #define KEY_BOOKMARKS 156 /* AC Bookmarks */ | 283 | #define KEY_BOOKMARKS 156 /* AC Bookmarks */ |
284 | #define KEY_COMPUTER 157 | 284 | #define KEY_COMPUTER 157 |
285 | #define KEY_BACK 158 /* AC Back */ | 285 | #define KEY_BACK 158 /* AC Back */ |
286 | #define KEY_FORWARD 159 /* AC Forward */ | 286 | #define KEY_FORWARD 159 /* AC Forward */ |
287 | #define KEY_CLOSECD 160 | 287 | #define KEY_CLOSECD 160 |
288 | #define KEY_EJECTCD 161 | 288 | #define KEY_EJECTCD 161 |
289 | #define KEY_EJECTCLOSECD 162 | 289 | #define KEY_EJECTCLOSECD 162 |
290 | #define KEY_NEXTSONG 163 | 290 | #define KEY_NEXTSONG 163 |
291 | #define KEY_PLAYPAUSE 164 | 291 | #define KEY_PLAYPAUSE 164 |
292 | #define KEY_PREVIOUSSONG 165 | 292 | #define KEY_PREVIOUSSONG 165 |
293 | #define KEY_STOPCD 166 | 293 | #define KEY_STOPCD 166 |
294 | #define KEY_RECORD 167 | 294 | #define KEY_RECORD 167 |
295 | #define KEY_REWIND 168 | 295 | #define KEY_REWIND 168 |
296 | #define KEY_PHONE 169 /* Media Select Telephone */ | 296 | #define KEY_PHONE 169 /* Media Select Telephone */ |
297 | #define KEY_ISO 170 | 297 | #define KEY_ISO 170 |
298 | #define KEY_CONFIG 171 /* AL Consumer Control Configuration */ | 298 | #define KEY_CONFIG 171 /* AL Consumer Control Configuration */ |
299 | #define KEY_HOMEPAGE 172 /* AC Home */ | 299 | #define KEY_HOMEPAGE 172 /* AC Home */ |
300 | #define KEY_REFRESH 173 /* AC Refresh */ | 300 | #define KEY_REFRESH 173 /* AC Refresh */ |
301 | #define KEY_EXIT 174 /* AC Exit */ | 301 | #define KEY_EXIT 174 /* AC Exit */ |
302 | #define KEY_MOVE 175 | 302 | #define KEY_MOVE 175 |
303 | #define KEY_EDIT 176 | 303 | #define KEY_EDIT 176 |
304 | #define KEY_SCROLLUP 177 | 304 | #define KEY_SCROLLUP 177 |
305 | #define KEY_SCROLLDOWN 178 | 305 | #define KEY_SCROLLDOWN 178 |
306 | #define KEY_KPLEFTPAREN 179 | 306 | #define KEY_KPLEFTPAREN 179 |
307 | #define KEY_KPRIGHTPAREN 180 | 307 | #define KEY_KPRIGHTPAREN 180 |
308 | #define KEY_NEW 181 /* AC New */ | 308 | #define KEY_NEW 181 /* AC New */ |
309 | #define KEY_REDO 182 /* AC Redo/Repeat */ | 309 | #define KEY_REDO 182 /* AC Redo/Repeat */ |
310 | 310 | ||
311 | #define KEY_F13 183 | 311 | #define KEY_F13 183 |
312 | #define KEY_F14 184 | 312 | #define KEY_F14 184 |
313 | #define KEY_F15 185 | 313 | #define KEY_F15 185 |
314 | #define KEY_F16 186 | 314 | #define KEY_F16 186 |
315 | #define KEY_F17 187 | 315 | #define KEY_F17 187 |
316 | #define KEY_F18 188 | 316 | #define KEY_F18 188 |
317 | #define KEY_F19 189 | 317 | #define KEY_F19 189 |
318 | #define KEY_F20 190 | 318 | #define KEY_F20 190 |
319 | #define KEY_F21 191 | 319 | #define KEY_F21 191 |
320 | #define KEY_F22 192 | 320 | #define KEY_F22 192 |
321 | #define KEY_F23 193 | 321 | #define KEY_F23 193 |
322 | #define KEY_F24 194 | 322 | #define KEY_F24 194 |
323 | 323 | ||
324 | #define KEY_PLAYCD 200 | 324 | #define KEY_PLAYCD 200 |
325 | #define KEY_PAUSECD 201 | 325 | #define KEY_PAUSECD 201 |
326 | #define KEY_PROG3 202 | 326 | #define KEY_PROG3 202 |
327 | #define KEY_PROG4 203 | 327 | #define KEY_PROG4 203 |
328 | #define KEY_DASHBOARD 204 /* AL Dashboard */ | 328 | #define KEY_DASHBOARD 204 /* AL Dashboard */ |
329 | #define KEY_SUSPEND 205 | 329 | #define KEY_SUSPEND 205 |
330 | #define KEY_CLOSE 206 /* AC Close */ | 330 | #define KEY_CLOSE 206 /* AC Close */ |
331 | #define KEY_PLAY 207 | 331 | #define KEY_PLAY 207 |
332 | #define KEY_FASTFORWARD 208 | 332 | #define KEY_FASTFORWARD 208 |
333 | #define KEY_BASSBOOST 209 | 333 | #define KEY_BASSBOOST 209 |
334 | #define KEY_PRINT 210 /* AC Print */ | 334 | #define KEY_PRINT 210 /* AC Print */ |
335 | #define KEY_HP 211 | 335 | #define KEY_HP 211 |
336 | #define KEY_CAMERA 212 | 336 | #define KEY_CAMERA 212 |
337 | #define KEY_SOUND 213 | 337 | #define KEY_SOUND 213 |
338 | #define KEY_QUESTION 214 | 338 | #define KEY_QUESTION 214 |
339 | #define KEY_EMAIL 215 | 339 | #define KEY_EMAIL 215 |
340 | #define KEY_CHAT 216 | 340 | #define KEY_CHAT 216 |
341 | #define KEY_SEARCH 217 | 341 | #define KEY_SEARCH 217 |
342 | #define KEY_CONNECT 218 | 342 | #define KEY_CONNECT 218 |
343 | #define KEY_FINANCE 219 /* AL Checkbook/Finance */ | 343 | #define KEY_FINANCE 219 /* AL Checkbook/Finance */ |
344 | #define KEY_SPORT 220 | 344 | #define KEY_SPORT 220 |
345 | #define KEY_SHOP 221 | 345 | #define KEY_SHOP 221 |
346 | #define KEY_ALTERASE 222 | 346 | #define KEY_ALTERASE 222 |
347 | #define KEY_CANCEL 223 /* AC Cancel */ | 347 | #define KEY_CANCEL 223 /* AC Cancel */ |
348 | #define KEY_BRIGHTNESSDOWN 224 | 348 | #define KEY_BRIGHTNESSDOWN 224 |
349 | #define KEY_BRIGHTNESSUP 225 | 349 | #define KEY_BRIGHTNESSUP 225 |
350 | #define KEY_MEDIA 226 | 350 | #define KEY_MEDIA 226 |
351 | 351 | ||
352 | #define KEY_SWITCHVIDEOMODE 227 /* Cycle between available video | 352 | #define KEY_SWITCHVIDEOMODE 227 /* Cycle between available video |
353 | outputs (Monitor/LCD/TV-out/etc) */ | 353 | outputs (Monitor/LCD/TV-out/etc) */ |
354 | #define KEY_KBDILLUMTOGGLE 228 | 354 | #define KEY_KBDILLUMTOGGLE 228 |
355 | #define KEY_KBDILLUMDOWN 229 | 355 | #define KEY_KBDILLUMDOWN 229 |
356 | #define KEY_KBDILLUMUP 230 | 356 | #define KEY_KBDILLUMUP 230 |
357 | 357 | ||
358 | #define KEY_SEND 231 /* AC Send */ | 358 | #define KEY_SEND 231 /* AC Send */ |
359 | #define KEY_REPLY 232 /* AC Reply */ | 359 | #define KEY_REPLY 232 /* AC Reply */ |
360 | #define KEY_FORWARDMAIL 233 /* AC Forward Msg */ | 360 | #define KEY_FORWARDMAIL 233 /* AC Forward Msg */ |
361 | #define KEY_SAVE 234 /* AC Save */ | 361 | #define KEY_SAVE 234 /* AC Save */ |
362 | #define KEY_DOCUMENTS 235 | 362 | #define KEY_DOCUMENTS 235 |
363 | 363 | ||
364 | #define KEY_BATTERY 236 | 364 | #define KEY_BATTERY 236 |
365 | 365 | ||
366 | #define KEY_BLUETOOTH 237 | 366 | #define KEY_BLUETOOTH 237 |
367 | #define KEY_WLAN 238 | 367 | #define KEY_WLAN 238 |
368 | #define KEY_UWB 239 | 368 | #define KEY_UWB 239 |
369 | 369 | ||
370 | #define KEY_UNKNOWN 240 | 370 | #define KEY_UNKNOWN 240 |
371 | 371 | ||
372 | #define KEY_VIDEO_NEXT 241 /* drive next video source */ | 372 | #define KEY_VIDEO_NEXT 241 /* drive next video source */ |
373 | #define KEY_VIDEO_PREV 242 /* drive previous video source */ | 373 | #define KEY_VIDEO_PREV 242 /* drive previous video source */ |
374 | #define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */ | 374 | #define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */ |
375 | #define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */ | 375 | #define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */ |
376 | #define KEY_DISPLAY_OFF 245 /* display device to off state */ | 376 | #define KEY_DISPLAY_OFF 245 /* display device to off state */ |
377 | 377 | ||
378 | #define KEY_WIMAX 246 | 378 | #define KEY_WIMAX 246 |
379 | 379 | ||
380 | /* Range 248 - 255 is reserved for special needs of AT keyboard driver */ | 380 | /* Range 248 - 255 is reserved for special needs of AT keyboard driver */ |
381 | 381 | ||
382 | #define BTN_MISC 0x100 | 382 | #define BTN_MISC 0x100 |
383 | #define BTN_0 0x100 | 383 | #define BTN_0 0x100 |
384 | #define BTN_1 0x101 | 384 | #define BTN_1 0x101 |
385 | #define BTN_2 0x102 | 385 | #define BTN_2 0x102 |
386 | #define BTN_3 0x103 | 386 | #define BTN_3 0x103 |
387 | #define BTN_4 0x104 | 387 | #define BTN_4 0x104 |
388 | #define BTN_5 0x105 | 388 | #define BTN_5 0x105 |
389 | #define BTN_6 0x106 | 389 | #define BTN_6 0x106 |
390 | #define BTN_7 0x107 | 390 | #define BTN_7 0x107 |
391 | #define BTN_8 0x108 | 391 | #define BTN_8 0x108 |
392 | #define BTN_9 0x109 | 392 | #define BTN_9 0x109 |
393 | 393 | ||
394 | #define BTN_MOUSE 0x110 | 394 | #define BTN_MOUSE 0x110 |
395 | #define BTN_LEFT 0x110 | 395 | #define BTN_LEFT 0x110 |
396 | #define BTN_RIGHT 0x111 | 396 | #define BTN_RIGHT 0x111 |
397 | #define BTN_MIDDLE 0x112 | 397 | #define BTN_MIDDLE 0x112 |
398 | #define BTN_SIDE 0x113 | 398 | #define BTN_SIDE 0x113 |
399 | #define BTN_EXTRA 0x114 | 399 | #define BTN_EXTRA 0x114 |
400 | #define BTN_FORWARD 0x115 | 400 | #define BTN_FORWARD 0x115 |
401 | #define BTN_BACK 0x116 | 401 | #define BTN_BACK 0x116 |
402 | #define BTN_TASK 0x117 | 402 | #define BTN_TASK 0x117 |
403 | 403 | ||
404 | #define BTN_JOYSTICK 0x120 | 404 | #define BTN_JOYSTICK 0x120 |
405 | #define BTN_TRIGGER 0x120 | 405 | #define BTN_TRIGGER 0x120 |
406 | #define BTN_THUMB 0x121 | 406 | #define BTN_THUMB 0x121 |
407 | #define BTN_THUMB2 0x122 | 407 | #define BTN_THUMB2 0x122 |
408 | #define BTN_TOP 0x123 | 408 | #define BTN_TOP 0x123 |
409 | #define BTN_TOP2 0x124 | 409 | #define BTN_TOP2 0x124 |
410 | #define BTN_PINKIE 0x125 | 410 | #define BTN_PINKIE 0x125 |
411 | #define BTN_BASE 0x126 | 411 | #define BTN_BASE 0x126 |
412 | #define BTN_BASE2 0x127 | 412 | #define BTN_BASE2 0x127 |
413 | #define BTN_BASE3 0x128 | 413 | #define BTN_BASE3 0x128 |
414 | #define BTN_BASE4 0x129 | 414 | #define BTN_BASE4 0x129 |
415 | #define BTN_BASE5 0x12a | 415 | #define BTN_BASE5 0x12a |
416 | #define BTN_BASE6 0x12b | 416 | #define BTN_BASE6 0x12b |
417 | #define BTN_DEAD 0x12f | 417 | #define BTN_DEAD 0x12f |
418 | 418 | ||
419 | #define BTN_GAMEPAD 0x130 | 419 | #define BTN_GAMEPAD 0x130 |
420 | #define BTN_A 0x130 | 420 | #define BTN_A 0x130 |
421 | #define BTN_B 0x131 | 421 | #define BTN_B 0x131 |
422 | #define BTN_C 0x132 | 422 | #define BTN_C 0x132 |
423 | #define BTN_X 0x133 | 423 | #define BTN_X 0x133 |
424 | #define BTN_Y 0x134 | 424 | #define BTN_Y 0x134 |
425 | #define BTN_Z 0x135 | 425 | #define BTN_Z 0x135 |
426 | #define BTN_TL 0x136 | 426 | #define BTN_TL 0x136 |
427 | #define BTN_TR 0x137 | 427 | #define BTN_TR 0x137 |
428 | #define BTN_TL2 0x138 | 428 | #define BTN_TL2 0x138 |
429 | #define BTN_TR2 0x139 | 429 | #define BTN_TR2 0x139 |
430 | #define BTN_SELECT 0x13a | 430 | #define BTN_SELECT 0x13a |
431 | #define BTN_START 0x13b | 431 | #define BTN_START 0x13b |
432 | #define BTN_MODE 0x13c | 432 | #define BTN_MODE 0x13c |
433 | #define BTN_THUMBL 0x13d | 433 | #define BTN_THUMBL 0x13d |
434 | #define BTN_THUMBR 0x13e | 434 | #define BTN_THUMBR 0x13e |
435 | 435 | ||
436 | #define BTN_DIGI 0x140 | 436 | #define BTN_DIGI 0x140 |
437 | #define BTN_TOOL_PEN 0x140 | 437 | #define BTN_TOOL_PEN 0x140 |
438 | #define BTN_TOOL_RUBBER 0x141 | 438 | #define BTN_TOOL_RUBBER 0x141 |
439 | #define BTN_TOOL_BRUSH 0x142 | 439 | #define BTN_TOOL_BRUSH 0x142 |
440 | #define BTN_TOOL_PENCIL 0x143 | 440 | #define BTN_TOOL_PENCIL 0x143 |
441 | #define BTN_TOOL_AIRBRUSH 0x144 | 441 | #define BTN_TOOL_AIRBRUSH 0x144 |
442 | #define BTN_TOOL_FINGER 0x145 | 442 | #define BTN_TOOL_FINGER 0x145 |
443 | #define BTN_TOOL_MOUSE 0x146 | 443 | #define BTN_TOOL_MOUSE 0x146 |
444 | #define BTN_TOOL_LENS 0x147 | 444 | #define BTN_TOOL_LENS 0x147 |
445 | #define BTN_TOUCH 0x14a | 445 | #define BTN_TOUCH 0x14a |
446 | #define BTN_STYLUS 0x14b | 446 | #define BTN_STYLUS 0x14b |
447 | #define BTN_STYLUS2 0x14c | 447 | #define BTN_STYLUS2 0x14c |
448 | #define BTN_TOOL_DOUBLETAP 0x14d | 448 | #define BTN_TOOL_DOUBLETAP 0x14d |
449 | #define BTN_TOOL_TRIPLETAP 0x14e | 449 | #define BTN_TOOL_TRIPLETAP 0x14e |
450 | #define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ | 450 | #define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ |
451 | 451 | ||
452 | #define BTN_WHEEL 0x150 | 452 | #define BTN_WHEEL 0x150 |
453 | #define BTN_GEAR_DOWN 0x150 | 453 | #define BTN_GEAR_DOWN 0x150 |
454 | #define BTN_GEAR_UP 0x151 | 454 | #define BTN_GEAR_UP 0x151 |
455 | 455 | ||
456 | #define KEY_OK 0x160 | 456 | #define KEY_OK 0x160 |
457 | #define KEY_SELECT 0x161 | 457 | #define KEY_SELECT 0x161 |
458 | #define KEY_GOTO 0x162 | 458 | #define KEY_GOTO 0x162 |
459 | #define KEY_CLEAR 0x163 | 459 | #define KEY_CLEAR 0x163 |
460 | #define KEY_POWER2 0x164 | 460 | #define KEY_POWER2 0x164 |
461 | #define KEY_OPTION 0x165 | 461 | #define KEY_OPTION 0x165 |
462 | #define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */ | 462 | #define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */ |
463 | #define KEY_TIME 0x167 | 463 | #define KEY_TIME 0x167 |
464 | #define KEY_VENDOR 0x168 | 464 | #define KEY_VENDOR 0x168 |
465 | #define KEY_ARCHIVE 0x169 | 465 | #define KEY_ARCHIVE 0x169 |
466 | #define KEY_PROGRAM 0x16a /* Media Select Program Guide */ | 466 | #define KEY_PROGRAM 0x16a /* Media Select Program Guide */ |
467 | #define KEY_CHANNEL 0x16b | 467 | #define KEY_CHANNEL 0x16b |
468 | #define KEY_FAVORITES 0x16c | 468 | #define KEY_FAVORITES 0x16c |
469 | #define KEY_EPG 0x16d | 469 | #define KEY_EPG 0x16d |
470 | #define KEY_PVR 0x16e /* Media Select Home */ | 470 | #define KEY_PVR 0x16e /* Media Select Home */ |
471 | #define KEY_MHP 0x16f | 471 | #define KEY_MHP 0x16f |
472 | #define KEY_LANGUAGE 0x170 | 472 | #define KEY_LANGUAGE 0x170 |
473 | #define KEY_TITLE 0x171 | 473 | #define KEY_TITLE 0x171 |
474 | #define KEY_SUBTITLE 0x172 | 474 | #define KEY_SUBTITLE 0x172 |
475 | #define KEY_ANGLE 0x173 | 475 | #define KEY_ANGLE 0x173 |
476 | #define KEY_ZOOM 0x174 | 476 | #define KEY_ZOOM 0x174 |
477 | #define KEY_MODE 0x175 | 477 | #define KEY_MODE 0x175 |
478 | #define KEY_KEYBOARD 0x176 | 478 | #define KEY_KEYBOARD 0x176 |
479 | #define KEY_SCREEN 0x177 | 479 | #define KEY_SCREEN 0x177 |
480 | #define KEY_PC 0x178 /* Media Select Computer */ | 480 | #define KEY_PC 0x178 /* Media Select Computer */ |
481 | #define KEY_TV 0x179 /* Media Select TV */ | 481 | #define KEY_TV 0x179 /* Media Select TV */ |
482 | #define KEY_TV2 0x17a /* Media Select Cable */ | 482 | #define KEY_TV2 0x17a /* Media Select Cable */ |
483 | #define KEY_VCR 0x17b /* Media Select VCR */ | 483 | #define KEY_VCR 0x17b /* Media Select VCR */ |
484 | #define KEY_VCR2 0x17c /* VCR Plus */ | 484 | #define KEY_VCR2 0x17c /* VCR Plus */ |
485 | #define KEY_SAT 0x17d /* Media Select Satellite */ | 485 | #define KEY_SAT 0x17d /* Media Select Satellite */ |
486 | #define KEY_SAT2 0x17e | 486 | #define KEY_SAT2 0x17e |
487 | #define KEY_CD 0x17f /* Media Select CD */ | 487 | #define KEY_CD 0x17f /* Media Select CD */ |
488 | #define KEY_TAPE 0x180 /* Media Select Tape */ | 488 | #define KEY_TAPE 0x180 /* Media Select Tape */ |
489 | #define KEY_RADIO 0x181 | 489 | #define KEY_RADIO 0x181 |
490 | #define KEY_TUNER 0x182 /* Media Select Tuner */ | 490 | #define KEY_TUNER 0x182 /* Media Select Tuner */ |
491 | #define KEY_PLAYER 0x183 | 491 | #define KEY_PLAYER 0x183 |
492 | #define KEY_TEXT 0x184 | 492 | #define KEY_TEXT 0x184 |
493 | #define KEY_DVD 0x185 /* Media Select DVD */ | 493 | #define KEY_DVD 0x185 /* Media Select DVD */ |
494 | #define KEY_AUX 0x186 | 494 | #define KEY_AUX 0x186 |
495 | #define KEY_MP3 0x187 | 495 | #define KEY_MP3 0x187 |
496 | #define KEY_AUDIO 0x188 | 496 | #define KEY_AUDIO 0x188 |
497 | #define KEY_VIDEO 0x189 | 497 | #define KEY_VIDEO 0x189 |
498 | #define KEY_DIRECTORY 0x18a | 498 | #define KEY_DIRECTORY 0x18a |
499 | #define KEY_LIST 0x18b | 499 | #define KEY_LIST 0x18b |
500 | #define KEY_MEMO 0x18c /* Media Select Messages */ | 500 | #define KEY_MEMO 0x18c /* Media Select Messages */ |
501 | #define KEY_CALENDAR 0x18d | 501 | #define KEY_CALENDAR 0x18d |
502 | #define KEY_RED 0x18e | 502 | #define KEY_RED 0x18e |
503 | #define KEY_GREEN 0x18f | 503 | #define KEY_GREEN 0x18f |
504 | #define KEY_YELLOW 0x190 | 504 | #define KEY_YELLOW 0x190 |
505 | #define KEY_BLUE 0x191 | 505 | #define KEY_BLUE 0x191 |
506 | #define KEY_CHANNELUP 0x192 /* Channel Increment */ | 506 | #define KEY_CHANNELUP 0x192 /* Channel Increment */ |
507 | #define KEY_CHANNELDOWN 0x193 /* Channel Decrement */ | 507 | #define KEY_CHANNELDOWN 0x193 /* Channel Decrement */ |
508 | #define KEY_FIRST 0x194 | 508 | #define KEY_FIRST 0x194 |
509 | #define KEY_LAST 0x195 /* Recall Last */ | 509 | #define KEY_LAST 0x195 /* Recall Last */ |
510 | #define KEY_AB 0x196 | 510 | #define KEY_AB 0x196 |
511 | #define KEY_NEXT 0x197 | 511 | #define KEY_NEXT 0x197 |
512 | #define KEY_RESTART 0x198 | 512 | #define KEY_RESTART 0x198 |
513 | #define KEY_SLOW 0x199 | 513 | #define KEY_SLOW 0x199 |
514 | #define KEY_SHUFFLE 0x19a | 514 | #define KEY_SHUFFLE 0x19a |
515 | #define KEY_BREAK 0x19b | 515 | #define KEY_BREAK 0x19b |
516 | #define KEY_PREVIOUS 0x19c | 516 | #define KEY_PREVIOUS 0x19c |
517 | #define KEY_DIGITS 0x19d | 517 | #define KEY_DIGITS 0x19d |
518 | #define KEY_TEEN 0x19e | 518 | #define KEY_TEEN 0x19e |
519 | #define KEY_TWEN 0x19f | 519 | #define KEY_TWEN 0x19f |
520 | #define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */ | 520 | #define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */ |
521 | #define KEY_GAMES 0x1a1 /* Media Select Games */ | 521 | #define KEY_GAMES 0x1a1 /* Media Select Games */ |
522 | #define KEY_ZOOMIN 0x1a2 /* AC Zoom In */ | 522 | #define KEY_ZOOMIN 0x1a2 /* AC Zoom In */ |
523 | #define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */ | 523 | #define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */ |
524 | #define KEY_ZOOMRESET 0x1a4 /* AC Zoom */ | 524 | #define KEY_ZOOMRESET 0x1a4 /* AC Zoom */ |
525 | #define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */ | 525 | #define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */ |
526 | #define KEY_EDITOR 0x1a6 /* AL Text Editor */ | 526 | #define KEY_EDITOR 0x1a6 /* AL Text Editor */ |
527 | #define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */ | 527 | #define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */ |
528 | #define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */ | 528 | #define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */ |
529 | #define KEY_PRESENTATION 0x1a9 /* AL Presentation App */ | 529 | #define KEY_PRESENTATION 0x1a9 /* AL Presentation App */ |
530 | #define KEY_DATABASE 0x1aa /* AL Database App */ | 530 | #define KEY_DATABASE 0x1aa /* AL Database App */ |
531 | #define KEY_NEWS 0x1ab /* AL Newsreader */ | 531 | #define KEY_NEWS 0x1ab /* AL Newsreader */ |
532 | #define KEY_VOICEMAIL 0x1ac /* AL Voicemail */ | 532 | #define KEY_VOICEMAIL 0x1ac /* AL Voicemail */ |
533 | #define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ | 533 | #define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ |
534 | #define KEY_MESSENGER 0x1ae /* AL Instant Messaging */ | 534 | #define KEY_MESSENGER 0x1ae /* AL Instant Messaging */ |
535 | #define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ | 535 | #define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ |
536 | #define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ | 536 | #define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ |
537 | #define KEY_LOGOFF 0x1b1 /* AL Logoff */ | 537 | #define KEY_LOGOFF 0x1b1 /* AL Logoff */ |
538 | 538 | ||
539 | #define KEY_DOLLAR 0x1b2 | 539 | #define KEY_DOLLAR 0x1b2 |
540 | #define KEY_EURO 0x1b3 | 540 | #define KEY_EURO 0x1b3 |
541 | 541 | ||
542 | #define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */ | 542 | #define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */ |
543 | #define KEY_FRAMEFORWARD 0x1b5 | 543 | #define KEY_FRAMEFORWARD 0x1b5 |
544 | #define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ | 544 | #define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ |
545 | #define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ | 545 | #define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ |
546 | 546 | ||
547 | #define KEY_DEL_EOL 0x1c0 | 547 | #define KEY_DEL_EOL 0x1c0 |
548 | #define KEY_DEL_EOS 0x1c1 | 548 | #define KEY_DEL_EOS 0x1c1 |
549 | #define KEY_INS_LINE 0x1c2 | 549 | #define KEY_INS_LINE 0x1c2 |
550 | #define KEY_DEL_LINE 0x1c3 | 550 | #define KEY_DEL_LINE 0x1c3 |
551 | 551 | ||
552 | #define KEY_FN 0x1d0 | 552 | #define KEY_FN 0x1d0 |
553 | #define KEY_FN_ESC 0x1d1 | 553 | #define KEY_FN_ESC 0x1d1 |
554 | #define KEY_FN_F1 0x1d2 | 554 | #define KEY_FN_F1 0x1d2 |
555 | #define KEY_FN_F2 0x1d3 | 555 | #define KEY_FN_F2 0x1d3 |
556 | #define KEY_FN_F3 0x1d4 | 556 | #define KEY_FN_F3 0x1d4 |
557 | #define KEY_FN_F4 0x1d5 | 557 | #define KEY_FN_F4 0x1d5 |
558 | #define KEY_FN_F5 0x1d6 | 558 | #define KEY_FN_F5 0x1d6 |
559 | #define KEY_FN_F6 0x1d7 | 559 | #define KEY_FN_F6 0x1d7 |
560 | #define KEY_FN_F7 0x1d8 | 560 | #define KEY_FN_F7 0x1d8 |
561 | #define KEY_FN_F8 0x1d9 | 561 | #define KEY_FN_F8 0x1d9 |
562 | #define KEY_FN_F9 0x1da | 562 | #define KEY_FN_F9 0x1da |
563 | #define KEY_FN_F10 0x1db | 563 | #define KEY_FN_F10 0x1db |
564 | #define KEY_FN_F11 0x1dc | 564 | #define KEY_FN_F11 0x1dc |
565 | #define KEY_FN_F12 0x1dd | 565 | #define KEY_FN_F12 0x1dd |
566 | #define KEY_FN_1 0x1de | 566 | #define KEY_FN_1 0x1de |
567 | #define KEY_FN_2 0x1df | 567 | #define KEY_FN_2 0x1df |
568 | #define KEY_FN_D 0x1e0 | 568 | #define KEY_FN_D 0x1e0 |
569 | #define KEY_FN_E 0x1e1 | 569 | #define KEY_FN_E 0x1e1 |
570 | #define KEY_FN_F 0x1e2 | 570 | #define KEY_FN_F 0x1e2 |
571 | #define KEY_FN_S 0x1e3 | 571 | #define KEY_FN_S 0x1e3 |
572 | #define KEY_FN_B 0x1e4 | 572 | #define KEY_FN_B 0x1e4 |
573 | 573 | ||
574 | #define KEY_BRL_DOT1 0x1f1 | 574 | #define KEY_BRL_DOT1 0x1f1 |
575 | #define KEY_BRL_DOT2 0x1f2 | 575 | #define KEY_BRL_DOT2 0x1f2 |
576 | #define KEY_BRL_DOT3 0x1f3 | 576 | #define KEY_BRL_DOT3 0x1f3 |
577 | #define KEY_BRL_DOT4 0x1f4 | 577 | #define KEY_BRL_DOT4 0x1f4 |
578 | #define KEY_BRL_DOT5 0x1f5 | 578 | #define KEY_BRL_DOT5 0x1f5 |
579 | #define KEY_BRL_DOT6 0x1f6 | 579 | #define KEY_BRL_DOT6 0x1f6 |
580 | #define KEY_BRL_DOT7 0x1f7 | 580 | #define KEY_BRL_DOT7 0x1f7 |
581 | #define KEY_BRL_DOT8 0x1f8 | 581 | #define KEY_BRL_DOT8 0x1f8 |
582 | #define KEY_BRL_DOT9 0x1f9 | 582 | #define KEY_BRL_DOT9 0x1f9 |
583 | #define KEY_BRL_DOT10 0x1fa | 583 | #define KEY_BRL_DOT10 0x1fa |
584 | 584 | ||
585 | #define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */ | 585 | #define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */ |
586 | #define KEY_NUMERIC_1 0x201 /* and other keypads */ | 586 | #define KEY_NUMERIC_1 0x201 /* and other keypads */ |
587 | #define KEY_NUMERIC_2 0x202 | 587 | #define KEY_NUMERIC_2 0x202 |
588 | #define KEY_NUMERIC_3 0x203 | 588 | #define KEY_NUMERIC_3 0x203 |
589 | #define KEY_NUMERIC_4 0x204 | 589 | #define KEY_NUMERIC_4 0x204 |
590 | #define KEY_NUMERIC_5 0x205 | 590 | #define KEY_NUMERIC_5 0x205 |
591 | #define KEY_NUMERIC_6 0x206 | 591 | #define KEY_NUMERIC_6 0x206 |
592 | #define KEY_NUMERIC_7 0x207 | 592 | #define KEY_NUMERIC_7 0x207 |
593 | #define KEY_NUMERIC_8 0x208 | 593 | #define KEY_NUMERIC_8 0x208 |
594 | #define KEY_NUMERIC_9 0x209 | 594 | #define KEY_NUMERIC_9 0x209 |
595 | #define KEY_NUMERIC_STAR 0x20a | 595 | #define KEY_NUMERIC_STAR 0x20a |
596 | #define KEY_NUMERIC_POUND 0x20b | 596 | #define KEY_NUMERIC_POUND 0x20b |
597 | 597 | ||
598 | /* We avoid low common keys in module aliases so they don't get huge. */ | 598 | /* We avoid low common keys in module aliases so they don't get huge. */ |
599 | #define KEY_MIN_INTERESTING KEY_MUTE | 599 | #define KEY_MIN_INTERESTING KEY_MUTE |
600 | #define KEY_MAX 0x2ff | 600 | #define KEY_MAX 0x2ff |
601 | #define KEY_CNT (KEY_MAX+1) | 601 | #define KEY_CNT (KEY_MAX+1) |
602 | 602 | ||
603 | /* | 603 | /* |
604 | * Relative axes | 604 | * Relative axes |
605 | */ | 605 | */ |
606 | 606 | ||
607 | #define REL_X 0x00 | 607 | #define REL_X 0x00 |
608 | #define REL_Y 0x01 | 608 | #define REL_Y 0x01 |
609 | #define REL_Z 0x02 | 609 | #define REL_Z 0x02 |
610 | #define REL_RX 0x03 | 610 | #define REL_RX 0x03 |
611 | #define REL_RY 0x04 | 611 | #define REL_RY 0x04 |
612 | #define REL_RZ 0x05 | 612 | #define REL_RZ 0x05 |
613 | #define REL_HWHEEL 0x06 | 613 | #define REL_HWHEEL 0x06 |
614 | #define REL_DIAL 0x07 | 614 | #define REL_DIAL 0x07 |
615 | #define REL_WHEEL 0x08 | 615 | #define REL_WHEEL 0x08 |
616 | #define REL_MISC 0x09 | 616 | #define REL_MISC 0x09 |
617 | #define REL_MAX 0x0f | 617 | #define REL_MAX 0x0f |
618 | #define REL_CNT (REL_MAX+1) | 618 | #define REL_CNT (REL_MAX+1) |
619 | 619 | ||
620 | /* | 620 | /* |
621 | * Absolute axes | 621 | * Absolute axes |
622 | */ | 622 | */ |
623 | 623 | ||
624 | #define ABS_X 0x00 | 624 | #define ABS_X 0x00 |
625 | #define ABS_Y 0x01 | 625 | #define ABS_Y 0x01 |
626 | #define ABS_Z 0x02 | 626 | #define ABS_Z 0x02 |
627 | #define ABS_RX 0x03 | 627 | #define ABS_RX 0x03 |
628 | #define ABS_RY 0x04 | 628 | #define ABS_RY 0x04 |
629 | #define ABS_RZ 0x05 | 629 | #define ABS_RZ 0x05 |
630 | #define ABS_THROTTLE 0x06 | 630 | #define ABS_THROTTLE 0x06 |
631 | #define ABS_RUDDER 0x07 | 631 | #define ABS_RUDDER 0x07 |
632 | #define ABS_WHEEL 0x08 | 632 | #define ABS_WHEEL 0x08 |
633 | #define ABS_GAS 0x09 | 633 | #define ABS_GAS 0x09 |
634 | #define ABS_BRAKE 0x0a | 634 | #define ABS_BRAKE 0x0a |
635 | #define ABS_HAT0X 0x10 | 635 | #define ABS_HAT0X 0x10 |
636 | #define ABS_HAT0Y 0x11 | 636 | #define ABS_HAT0Y 0x11 |
637 | #define ABS_HAT1X 0x12 | 637 | #define ABS_HAT1X 0x12 |
638 | #define ABS_HAT1Y 0x13 | 638 | #define ABS_HAT1Y 0x13 |
639 | #define ABS_HAT2X 0x14 | 639 | #define ABS_HAT2X 0x14 |
640 | #define ABS_HAT2Y 0x15 | 640 | #define ABS_HAT2Y 0x15 |
641 | #define ABS_HAT3X 0x16 | 641 | #define ABS_HAT3X 0x16 |
642 | #define ABS_HAT3Y 0x17 | 642 | #define ABS_HAT3Y 0x17 |
643 | #define ABS_PRESSURE 0x18 | 643 | #define ABS_PRESSURE 0x18 |
644 | #define ABS_DISTANCE 0x19 | 644 | #define ABS_DISTANCE 0x19 |
645 | #define ABS_TILT_X 0x1a | 645 | #define ABS_TILT_X 0x1a |
646 | #define ABS_TILT_Y 0x1b | 646 | #define ABS_TILT_Y 0x1b |
647 | #define ABS_TOOL_WIDTH 0x1c | 647 | #define ABS_TOOL_WIDTH 0x1c |
648 | #define ABS_VOLUME 0x20 | 648 | #define ABS_VOLUME 0x20 |
649 | #define ABS_MISC 0x28 | 649 | #define ABS_MISC 0x28 |
650 | 650 | ||
651 | #define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ | 651 | #define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ |
652 | #define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ | 652 | #define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ |
653 | #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ | 653 | #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ |
654 | #define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ | 654 | #define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ |
655 | #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ | 655 | #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ |
656 | #define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */ | 656 | #define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */ |
657 | #define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */ | 657 | #define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */ |
658 | #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ | 658 | #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ |
659 | #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ | 659 | #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ |
660 | #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ | 660 | #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ |
661 | 661 | ||
662 | #define ABS_MAX 0x3f | 662 | #define ABS_MAX 0x3f |
663 | #define ABS_CNT (ABS_MAX+1) | 663 | #define ABS_CNT (ABS_MAX+1) |
664 | 664 | ||
665 | /* | 665 | /* |
666 | * Switch events | 666 | * Switch events |
667 | */ | 667 | */ |
668 | 668 | ||
669 | #define SW_LID 0x00 /* set = lid shut */ | 669 | #define SW_LID 0x00 /* set = lid shut */ |
670 | #define SW_TABLET_MODE 0x01 /* set = tablet mode */ | 670 | #define SW_TABLET_MODE 0x01 /* set = tablet mode */ |
671 | #define SW_HEADPHONE_INSERT 0x02 /* set = inserted */ | 671 | #define SW_HEADPHONE_INSERT 0x02 /* set = inserted */ |
672 | #define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" | 672 | #define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" |
673 | set = radio enabled */ | 673 | set = radio enabled */ |
674 | #define SW_RADIO SW_RFKILL_ALL /* deprecated */ | 674 | #define SW_RADIO SW_RFKILL_ALL /* deprecated */ |
675 | #define SW_MICROPHONE_INSERT 0x04 /* set = inserted */ | 675 | #define SW_MICROPHONE_INSERT 0x04 /* set = inserted */ |
676 | #define SW_DOCK 0x05 /* set = plugged into dock */ | 676 | #define SW_DOCK 0x05 /* set = plugged into dock */ |
677 | #define SW_LINEOUT_INSERT 0x06 /* set = inserted */ | 677 | #define SW_LINEOUT_INSERT 0x06 /* set = inserted */ |
678 | #define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */ | 678 | #define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */ |
679 | #define SW_VIDEOOUT_INSERT 0x08 /* set = inserted */ | 679 | #define SW_VIDEOOUT_INSERT 0x08 /* set = inserted */ |
680 | #define SW_MAX 0x0f | 680 | #define SW_MAX 0x0f |
681 | #define SW_CNT (SW_MAX+1) | 681 | #define SW_CNT (SW_MAX+1) |
682 | 682 | ||
683 | /* | 683 | /* |
684 | * Misc events | 684 | * Misc events |
685 | */ | 685 | */ |
686 | 686 | ||
687 | #define MSC_SERIAL 0x00 | 687 | #define MSC_SERIAL 0x00 |
688 | #define MSC_PULSELED 0x01 | 688 | #define MSC_PULSELED 0x01 |
689 | #define MSC_GESTURE 0x02 | 689 | #define MSC_GESTURE 0x02 |
690 | #define MSC_RAW 0x03 | 690 | #define MSC_RAW 0x03 |
691 | #define MSC_SCAN 0x04 | 691 | #define MSC_SCAN 0x04 |
692 | #define MSC_MAX 0x07 | 692 | #define MSC_MAX 0x07 |
693 | #define MSC_CNT (MSC_MAX+1) | 693 | #define MSC_CNT (MSC_MAX+1) |
694 | 694 | ||
695 | /* | 695 | /* |
696 | * LEDs | 696 | * LEDs |
697 | */ | 697 | */ |
698 | 698 | ||
699 | #define LED_NUML 0x00 | 699 | #define LED_NUML 0x00 |
700 | #define LED_CAPSL 0x01 | 700 | #define LED_CAPSL 0x01 |
701 | #define LED_SCROLLL 0x02 | 701 | #define LED_SCROLLL 0x02 |
702 | #define LED_COMPOSE 0x03 | 702 | #define LED_COMPOSE 0x03 |
703 | #define LED_KANA 0x04 | 703 | #define LED_KANA 0x04 |
704 | #define LED_SLEEP 0x05 | 704 | #define LED_SLEEP 0x05 |
705 | #define LED_SUSPEND 0x06 | 705 | #define LED_SUSPEND 0x06 |
706 | #define LED_MUTE 0x07 | 706 | #define LED_MUTE 0x07 |
707 | #define LED_MISC 0x08 | 707 | #define LED_MISC 0x08 |
708 | #define LED_MAIL 0x09 | 708 | #define LED_MAIL 0x09 |
709 | #define LED_CHARGING 0x0a | 709 | #define LED_CHARGING 0x0a |
710 | #define LED_MAX 0x0f | 710 | #define LED_MAX 0x0f |
711 | #define LED_CNT (LED_MAX+1) | 711 | #define LED_CNT (LED_MAX+1) |
712 | 712 | ||
713 | /* | 713 | /* |
714 | * Autorepeat values | 714 | * Autorepeat values |
715 | */ | 715 | */ |
716 | 716 | ||
717 | #define REP_DELAY 0x00 | 717 | #define REP_DELAY 0x00 |
718 | #define REP_PERIOD 0x01 | 718 | #define REP_PERIOD 0x01 |
719 | #define REP_MAX 0x01 | 719 | #define REP_MAX 0x01 |
720 | 720 | ||
721 | /* | 721 | /* |
722 | * Sounds | 722 | * Sounds |
723 | */ | 723 | */ |
724 | 724 | ||
725 | #define SND_CLICK 0x00 | 725 | #define SND_CLICK 0x00 |
726 | #define SND_BELL 0x01 | 726 | #define SND_BELL 0x01 |
727 | #define SND_TONE 0x02 | 727 | #define SND_TONE 0x02 |
728 | #define SND_MAX 0x07 | 728 | #define SND_MAX 0x07 |
729 | #define SND_CNT (SND_MAX+1) | 729 | #define SND_CNT (SND_MAX+1) |
730 | 730 | ||
731 | /* | 731 | /* |
732 | * IDs. | 732 | * IDs. |
733 | */ | 733 | */ |
734 | 734 | ||
735 | #define ID_BUS 0 | 735 | #define ID_BUS 0 |
736 | #define ID_VENDOR 1 | 736 | #define ID_VENDOR 1 |
737 | #define ID_PRODUCT 2 | 737 | #define ID_PRODUCT 2 |
738 | #define ID_VERSION 3 | 738 | #define ID_VERSION 3 |
739 | 739 | ||
740 | #define BUS_PCI 0x01 | 740 | #define BUS_PCI 0x01 |
741 | #define BUS_ISAPNP 0x02 | 741 | #define BUS_ISAPNP 0x02 |
742 | #define BUS_USB 0x03 | 742 | #define BUS_USB 0x03 |
743 | #define BUS_HIL 0x04 | 743 | #define BUS_HIL 0x04 |
744 | #define BUS_BLUETOOTH 0x05 | 744 | #define BUS_BLUETOOTH 0x05 |
745 | #define BUS_VIRTUAL 0x06 | 745 | #define BUS_VIRTUAL 0x06 |
746 | 746 | ||
747 | #define BUS_ISA 0x10 | 747 | #define BUS_ISA 0x10 |
748 | #define BUS_I8042 0x11 | 748 | #define BUS_I8042 0x11 |
749 | #define BUS_XTKBD 0x12 | 749 | #define BUS_XTKBD 0x12 |
750 | #define BUS_RS232 0x13 | 750 | #define BUS_RS232 0x13 |
751 | #define BUS_GAMEPORT 0x14 | 751 | #define BUS_GAMEPORT 0x14 |
752 | #define BUS_PARPORT 0x15 | 752 | #define BUS_PARPORT 0x15 |
753 | #define BUS_AMIGA 0x16 | 753 | #define BUS_AMIGA 0x16 |
754 | #define BUS_ADB 0x17 | 754 | #define BUS_ADB 0x17 |
755 | #define BUS_I2C 0x18 | 755 | #define BUS_I2C 0x18 |
756 | #define BUS_HOST 0x19 | 756 | #define BUS_HOST 0x19 |
757 | #define BUS_GSC 0x1A | 757 | #define BUS_GSC 0x1A |
758 | #define BUS_ATARI 0x1B | 758 | #define BUS_ATARI 0x1B |
759 | 759 | ||
760 | /* | 760 | /* |
761 | * MT_TOOL types | 761 | * MT_TOOL types |
762 | */ | 762 | */ |
763 | #define MT_TOOL_FINGER 0 | 763 | #define MT_TOOL_FINGER 0 |
764 | #define MT_TOOL_PEN 1 | 764 | #define MT_TOOL_PEN 1 |
765 | 765 | ||
766 | /* | 766 | /* |
767 | * Values describing the status of a force-feedback effect | 767 | * Values describing the status of a force-feedback effect |
768 | */ | 768 | */ |
769 | #define FF_STATUS_STOPPED 0x00 | 769 | #define FF_STATUS_STOPPED 0x00 |
770 | #define FF_STATUS_PLAYING 0x01 | 770 | #define FF_STATUS_PLAYING 0x01 |
771 | #define FF_STATUS_MAX 0x01 | 771 | #define FF_STATUS_MAX 0x01 |
772 | 772 | ||
773 | /* | 773 | /* |
774 | * Structures used in ioctls to upload effects to a device | 774 | * Structures used in ioctls to upload effects to a device |
775 | * They are pieces of a bigger structure (called ff_effect) | 775 | * They are pieces of a bigger structure (called ff_effect) |
776 | */ | 776 | */ |
777 | 777 | ||
778 | /* | 778 | /* |
779 | * All duration values are expressed in ms. Values above 32767 ms (0x7fff) | 779 | * All duration values are expressed in ms. Values above 32767 ms (0x7fff) |
780 | * should not be used and have unspecified results. | 780 | * should not be used and have unspecified results. |
781 | */ | 781 | */ |
782 | 782 | ||
783 | /** | 783 | /** |
784 | * struct ff_replay - defines scheduling of the force-feedback effect | 784 | * struct ff_replay - defines scheduling of the force-feedback effect |
785 | * @length: duration of the effect | 785 | * @length: duration of the effect |
786 | * @delay: delay before effect should start playing | 786 | * @delay: delay before effect should start playing |
787 | */ | 787 | */ |
788 | struct ff_replay { | 788 | struct ff_replay { |
789 | __u16 length; | 789 | __u16 length; |
790 | __u16 delay; | 790 | __u16 delay; |
791 | }; | 791 | }; |
792 | 792 | ||
793 | /** | 793 | /** |
794 | * struct ff_trigger - defines what triggers the force-feedback effect | 794 | * struct ff_trigger - defines what triggers the force-feedback effect |
795 | * @button: number of the button triggering the effect | 795 | * @button: number of the button triggering the effect |
796 | * @interval: controls how soon the effect can be re-triggered | 796 | * @interval: controls how soon the effect can be re-triggered |
797 | */ | 797 | */ |
798 | struct ff_trigger { | 798 | struct ff_trigger { |
799 | __u16 button; | 799 | __u16 button; |
800 | __u16 interval; | 800 | __u16 interval; |
801 | }; | 801 | }; |
802 | 802 | ||
803 | /** | 803 | /** |
804 | * struct ff_envelope - generic force-feedback effect envelope | 804 | * struct ff_envelope - generic force-feedback effect envelope |
805 | * @attack_length: duration of the attack (ms) | 805 | * @attack_length: duration of the attack (ms) |
806 | * @attack_level: level at the beginning of the attack | 806 | * @attack_level: level at the beginning of the attack |
807 | * @fade_length: duration of fade (ms) | 807 | * @fade_length: duration of fade (ms) |
808 | * @fade_level: level at the end of fade | 808 | * @fade_level: level at the end of fade |
809 | * | 809 | * |
810 | * The @attack_level and @fade_level are absolute values; when applying | 810 | * The @attack_level and @fade_level are absolute values; when applying |
811 | * envelope force-feedback core will convert to positive/negative | 811 | * envelope force-feedback core will convert to positive/negative |
812 | * value based on polarity of the default level of the effect. | 812 | * value based on polarity of the default level of the effect. |
813 | * Valid range for the attack and fade levels is 0x0000 - 0x7fff | 813 | * Valid range for the attack and fade levels is 0x0000 - 0x7fff |
814 | */ | 814 | */ |
815 | struct ff_envelope { | 815 | struct ff_envelope { |
816 | __u16 attack_length; | 816 | __u16 attack_length; |
817 | __u16 attack_level; | 817 | __u16 attack_level; |
818 | __u16 fade_length; | 818 | __u16 fade_length; |
819 | __u16 fade_level; | 819 | __u16 fade_level; |
820 | }; | 820 | }; |
821 | 821 | ||
822 | /** | 822 | /** |
823 | * struct ff_constant_effect - defines parameters of a constant force-feedback effect | 823 | * struct ff_constant_effect - defines parameters of a constant force-feedback effect |
824 | * @level: strength of the effect; may be negative | 824 | * @level: strength of the effect; may be negative |
825 | * @envelope: envelope data | 825 | * @envelope: envelope data |
826 | */ | 826 | */ |
827 | struct ff_constant_effect { | 827 | struct ff_constant_effect { |
828 | __s16 level; | 828 | __s16 level; |
829 | struct ff_envelope envelope; | 829 | struct ff_envelope envelope; |
830 | }; | 830 | }; |
831 | 831 | ||
832 | /** | 832 | /** |
833 | * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect | 833 | * struct ff_ramp_effect - defines parameters of a ramp force-feedback effect |
834 | * @start_level: beginning strength of the effect; may be negative | 834 | * @start_level: beginning strength of the effect; may be negative |
835 | * @end_level: final strength of the effect; may be negative | 835 | * @end_level: final strength of the effect; may be negative |
836 | * @envelope: envelope data | 836 | * @envelope: envelope data |
837 | */ | 837 | */ |
838 | struct ff_ramp_effect { | 838 | struct ff_ramp_effect { |
839 | __s16 start_level; | 839 | __s16 start_level; |
840 | __s16 end_level; | 840 | __s16 end_level; |
841 | struct ff_envelope envelope; | 841 | struct ff_envelope envelope; |
842 | }; | 842 | }; |
843 | 843 | ||
844 | /** | 844 | /** |
845 | * struct ff_condition_effect - defines a spring or friction force-feedback effect | 845 | * struct ff_condition_effect - defines a spring or friction force-feedback effect |
846 | * @right_saturation: maximum level when joystick moved all way to the right | 846 | * @right_saturation: maximum level when joystick moved all way to the right |
847 | * @left_saturation: same for the left side | 847 | * @left_saturation: same for the left side |
848 | * @right_coeff: controls how fast the force grows when the joystick moves | 848 | * @right_coeff: controls how fast the force grows when the joystick moves |
849 | * to the right | 849 | * to the right |
850 | * @left_coeff: same for the left side | 850 | * @left_coeff: same for the left side |
851 | * @deadband: size of the dead zone, where no force is produced | 851 | * @deadband: size of the dead zone, where no force is produced |
852 | * @center: position of the dead zone | 852 | * @center: position of the dead zone |
853 | */ | 853 | */ |
854 | struct ff_condition_effect { | 854 | struct ff_condition_effect { |
855 | __u16 right_saturation; | 855 | __u16 right_saturation; |
856 | __u16 left_saturation; | 856 | __u16 left_saturation; |
857 | 857 | ||
858 | __s16 right_coeff; | 858 | __s16 right_coeff; |
859 | __s16 left_coeff; | 859 | __s16 left_coeff; |
860 | 860 | ||
861 | __u16 deadband; | 861 | __u16 deadband; |
862 | __s16 center; | 862 | __s16 center; |
863 | }; | 863 | }; |
864 | 864 | ||
865 | /** | 865 | /** |
866 | * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect | 866 | * struct ff_periodic_effect - defines parameters of a periodic force-feedback effect |
867 | * @waveform: kind of the effect (wave) | 867 | * @waveform: kind of the effect (wave) |
868 | * @period: period of the wave (ms) | 868 | * @period: period of the wave (ms) |
869 | * @magnitude: peak value | 869 | * @magnitude: peak value |
870 | * @offset: mean value of the wave (roughly) | 870 | * @offset: mean value of the wave (roughly) |
871 | * @phase: 'horizontal' shift | 871 | * @phase: 'horizontal' shift |
872 | * @envelope: envelope data | 872 | * @envelope: envelope data |
873 | * @custom_len: number of samples (FF_CUSTOM only) | 873 | * @custom_len: number of samples (FF_CUSTOM only) |
874 | * @custom_data: buffer of samples (FF_CUSTOM only) | 874 | * @custom_data: buffer of samples (FF_CUSTOM only) |
875 | * | 875 | * |
876 | * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP, | 876 | * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP, |
877 | * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined | 877 | * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined |
878 | * for the time being as no driver supports it yet. | 878 | * for the time being as no driver supports it yet. |
879 | * | 879 | * |
880 | * Note: the data pointed by custom_data is copied by the driver. | 880 | * Note: the data pointed by custom_data is copied by the driver. |
881 | * You can therefore dispose of the memory after the upload/update. | 881 | * You can therefore dispose of the memory after the upload/update. |
882 | */ | 882 | */ |
883 | struct ff_periodic_effect { | 883 | struct ff_periodic_effect { |
884 | __u16 waveform; | 884 | __u16 waveform; |
885 | __u16 period; | 885 | __u16 period; |
886 | __s16 magnitude; | 886 | __s16 magnitude; |
887 | __s16 offset; | 887 | __s16 offset; |
888 | __u16 phase; | 888 | __u16 phase; |
889 | 889 | ||
890 | struct ff_envelope envelope; | 890 | struct ff_envelope envelope; |
891 | 891 | ||
892 | __u32 custom_len; | 892 | __u32 custom_len; |
893 | __s16 *custom_data; | 893 | __s16 *custom_data; |
894 | }; | 894 | }; |
895 | 895 | ||
896 | /** | 896 | /** |
897 | * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect | 897 | * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect |
898 | * @strong_magnitude: magnitude of the heavy motor | 898 | * @strong_magnitude: magnitude of the heavy motor |
899 | * @weak_magnitude: magnitude of the light one | 899 | * @weak_magnitude: magnitude of the light one |
900 | * | 900 | * |
901 | * Some rumble pads have two motors of different weight. Strong_magnitude | 901 | * Some rumble pads have two motors of different weight. Strong_magnitude |
902 | * represents the magnitude of the vibration generated by the heavy one. | 902 | * represents the magnitude of the vibration generated by the heavy one. |
903 | */ | 903 | */ |
904 | struct ff_rumble_effect { | 904 | struct ff_rumble_effect { |
905 | __u16 strong_magnitude; | 905 | __u16 strong_magnitude; |
906 | __u16 weak_magnitude; | 906 | __u16 weak_magnitude; |
907 | }; | 907 | }; |
908 | 908 | ||
909 | /** | 909 | /** |
910 | * struct ff_effect - defines force feedback effect | 910 | * struct ff_effect - defines force feedback effect |
911 | * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, | 911 | * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, |
912 | * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM) | 912 | * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM) |
913 | * @id: an unique id assigned to an effect | 913 | * @id: an unique id assigned to an effect |
914 | * @direction: direction of the effect | 914 | * @direction: direction of the effect |
915 | * @trigger: trigger conditions (struct ff_trigger) | 915 | * @trigger: trigger conditions (struct ff_trigger) |
916 | * @replay: scheduling of the effect (struct ff_replay) | 916 | * @replay: scheduling of the effect (struct ff_replay) |
917 | * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect, | 917 | * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect, |
918 | * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further | 918 | * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further |
919 | * defining effect parameters | 919 | * defining effect parameters |
920 | * | 920 | * |
921 | * This structure is sent through ioctl from the application to the driver. | 921 | * This structure is sent through ioctl from the application to the driver. |
922 | * To create a new effect application should set its @id to -1; the kernel | 922 | * To create a new effect application should set its @id to -1; the kernel |
923 | * will return assigned @id which can later be used to update or delete | 923 | * will return assigned @id which can later be used to update or delete |
924 | * this effect. | 924 | * this effect. |
925 | * | 925 | * |
926 | * Direction of the effect is encoded as follows: | 926 | * Direction of the effect is encoded as follows: |
927 | * 0 deg -> 0x0000 (down) | 927 | * 0 deg -> 0x0000 (down) |
928 | * 90 deg -> 0x4000 (left) | 928 | * 90 deg -> 0x4000 (left) |
929 | * 180 deg -> 0x8000 (up) | 929 | * 180 deg -> 0x8000 (up) |
930 | * 270 deg -> 0xC000 (right) | 930 | * 270 deg -> 0xC000 (right) |
931 | */ | 931 | */ |
932 | struct ff_effect { | 932 | struct ff_effect { |
933 | __u16 type; | 933 | __u16 type; |
934 | __s16 id; | 934 | __s16 id; |
935 | __u16 direction; | 935 | __u16 direction; |
936 | struct ff_trigger trigger; | 936 | struct ff_trigger trigger; |
937 | struct ff_replay replay; | 937 | struct ff_replay replay; |
938 | 938 | ||
939 | union { | 939 | union { |
940 | struct ff_constant_effect constant; | 940 | struct ff_constant_effect constant; |
941 | struct ff_ramp_effect ramp; | 941 | struct ff_ramp_effect ramp; |
942 | struct ff_periodic_effect periodic; | 942 | struct ff_periodic_effect periodic; |
943 | struct ff_condition_effect condition[2]; /* One for each axis */ | 943 | struct ff_condition_effect condition[2]; /* One for each axis */ |
944 | struct ff_rumble_effect rumble; | 944 | struct ff_rumble_effect rumble; |
945 | } u; | 945 | } u; |
946 | }; | 946 | }; |
947 | 947 | ||
948 | /* | 948 | /* |
949 | * Force feedback effect types | 949 | * Force feedback effect types |
950 | */ | 950 | */ |
951 | 951 | ||
952 | #define FF_RUMBLE 0x50 | 952 | #define FF_RUMBLE 0x50 |
953 | #define FF_PERIODIC 0x51 | 953 | #define FF_PERIODIC 0x51 |
954 | #define FF_CONSTANT 0x52 | 954 | #define FF_CONSTANT 0x52 |
955 | #define FF_SPRING 0x53 | 955 | #define FF_SPRING 0x53 |
956 | #define FF_FRICTION 0x54 | 956 | #define FF_FRICTION 0x54 |
957 | #define FF_DAMPER 0x55 | 957 | #define FF_DAMPER 0x55 |
958 | #define FF_INERTIA 0x56 | 958 | #define FF_INERTIA 0x56 |
959 | #define FF_RAMP 0x57 | 959 | #define FF_RAMP 0x57 |
960 | 960 | ||
961 | #define FF_EFFECT_MIN FF_RUMBLE | 961 | #define FF_EFFECT_MIN FF_RUMBLE |
962 | #define FF_EFFECT_MAX FF_RAMP | 962 | #define FF_EFFECT_MAX FF_RAMP |
963 | 963 | ||
964 | /* | 964 | /* |
965 | * Force feedback periodic effect types | 965 | * Force feedback periodic effect types |
966 | */ | 966 | */ |
967 | 967 | ||
968 | #define FF_SQUARE 0x58 | 968 | #define FF_SQUARE 0x58 |
969 | #define FF_TRIANGLE 0x59 | 969 | #define FF_TRIANGLE 0x59 |
970 | #define FF_SINE 0x5a | 970 | #define FF_SINE 0x5a |
971 | #define FF_SAW_UP 0x5b | 971 | #define FF_SAW_UP 0x5b |
972 | #define FF_SAW_DOWN 0x5c | 972 | #define FF_SAW_DOWN 0x5c |
973 | #define FF_CUSTOM 0x5d | 973 | #define FF_CUSTOM 0x5d |
974 | 974 | ||
975 | #define FF_WAVEFORM_MIN FF_SQUARE | 975 | #define FF_WAVEFORM_MIN FF_SQUARE |
976 | #define FF_WAVEFORM_MAX FF_CUSTOM | 976 | #define FF_WAVEFORM_MAX FF_CUSTOM |
977 | 977 | ||
978 | /* | 978 | /* |
979 | * Set ff device properties | 979 | * Set ff device properties |
980 | */ | 980 | */ |
981 | 981 | ||
982 | #define FF_GAIN 0x60 | 982 | #define FF_GAIN 0x60 |
983 | #define FF_AUTOCENTER 0x61 | 983 | #define FF_AUTOCENTER 0x61 |
984 | 984 | ||
985 | #define FF_MAX 0x7f | 985 | #define FF_MAX 0x7f |
986 | #define FF_CNT (FF_MAX+1) | 986 | #define FF_CNT (FF_MAX+1) |
987 | 987 | ||
988 | #ifdef __KERNEL__ | 988 | #ifdef __KERNEL__ |
989 | 989 | ||
990 | /* | 990 | /* |
991 | * In-kernel definitions. | 991 | * In-kernel definitions. |
992 | */ | 992 | */ |
993 | 993 | ||
994 | #include <linux/device.h> | 994 | #include <linux/device.h> |
995 | #include <linux/fs.h> | 995 | #include <linux/fs.h> |
996 | #include <linux/timer.h> | 996 | #include <linux/timer.h> |
997 | #include <linux/mod_devicetable.h> | 997 | #include <linux/mod_devicetable.h> |
998 | 998 | ||
999 | /** | 999 | /** |
1000 | * struct input_dev - represents an input device | 1000 | * struct input_dev - represents an input device |
1001 | * @name: name of the device | 1001 | * @name: name of the device |
1002 | * @phys: physical path to the device in the system hierarchy | 1002 | * @phys: physical path to the device in the system hierarchy |
1003 | * @uniq: unique identification code for the device (if device has it) | 1003 | * @uniq: unique identification code for the device (if device has it) |
1004 | * @id: id of the device (struct input_id) | 1004 | * @id: id of the device (struct input_id) |
1005 | * @evbit: bitmap of types of events supported by the device (EV_KEY, | 1005 | * @evbit: bitmap of types of events supported by the device (EV_KEY, |
1006 | * EV_REL, etc.) | 1006 | * EV_REL, etc.) |
1007 | * @keybit: bitmap of keys/buttons this device has | 1007 | * @keybit: bitmap of keys/buttons this device has |
1008 | * @relbit: bitmap of relative axes for the device | 1008 | * @relbit: bitmap of relative axes for the device |
1009 | * @absbit: bitmap of absolute axes for the device | 1009 | * @absbit: bitmap of absolute axes for the device |
1010 | * @mscbit: bitmap of miscellaneous events supported by the device | 1010 | * @mscbit: bitmap of miscellaneous events supported by the device |
1011 | * @ledbit: bitmap of leds present on the device | 1011 | * @ledbit: bitmap of leds present on the device |
1012 | * @sndbit: bitmap of sound effects supported by the device | 1012 | * @sndbit: bitmap of sound effects supported by the device |
1013 | * @ffbit: bitmap of force feedback effects supported by the device | 1013 | * @ffbit: bitmap of force feedback effects supported by the device |
1014 | * @swbit: bitmap of switches present on the device | 1014 | * @swbit: bitmap of switches present on the device |
1015 | * @keycodemax: size of keycode table | 1015 | * @keycodemax: size of keycode table |
1016 | * @keycodesize: size of elements in keycode table | 1016 | * @keycodesize: size of elements in keycode table |
1017 | * @keycode: map of scancodes to keycodes for this device | 1017 | * @keycode: map of scancodes to keycodes for this device |
1018 | * @setkeycode: optional method to alter current keymap, used to implement | 1018 | * @setkeycode: optional method to alter current keymap, used to implement |
1019 | * sparse keymaps. If not supplied default mechanism will be used | 1019 | * sparse keymaps. If not supplied default mechanism will be used |
1020 | * @getkeycode: optional method to retrieve current keymap. If not supplied | 1020 | * @getkeycode: optional method to retrieve current keymap. If not supplied |
1021 | * default mechanism will be used | 1021 | * default mechanism will be used |
1022 | * @ff: force feedback structure associated with the device if device | 1022 | * @ff: force feedback structure associated with the device if device |
1023 | * supports force feedback effects | 1023 | * supports force feedback effects |
1024 | * @repeat_key: stores key code of the last key pressed; used to implement | 1024 | * @repeat_key: stores key code of the last key pressed; used to implement |
1025 | * software autorepeat | 1025 | * software autorepeat |
1026 | * @timer: timer for software autorepeat | 1026 | * @timer: timer for software autorepeat |
1027 | * @sync: set to 1 when there were no new events since last EV_SYNC | 1027 | * @sync: set to 1 when there were no new events since last EV_SYNC |
1028 | * @abs: current values for reports from absolute axes | 1028 | * @abs: current values for reports from absolute axes |
1029 | * @rep: current values for autorepeat parameters (delay, rate) | 1029 | * @rep: current values for autorepeat parameters (delay, rate) |
1030 | * @key: reflects current state of device's keys/buttons | 1030 | * @key: reflects current state of device's keys/buttons |
1031 | * @led: reflects current state of device's LEDs | 1031 | * @led: reflects current state of device's LEDs |
1032 | * @snd: reflects current state of sound effects | 1032 | * @snd: reflects current state of sound effects |
1033 | * @sw: reflects current state of device's switches | 1033 | * @sw: reflects current state of device's switches |
1034 | * @absmax: maximum values for events coming from absolute axes | 1034 | * @absmax: maximum values for events coming from absolute axes |
1035 | * @absmin: minimum values for events coming from absolute axes | 1035 | * @absmin: minimum values for events coming from absolute axes |
1036 | * @absfuzz: describes noisiness for axes | 1036 | * @absfuzz: describes noisiness for axes |
1037 | * @absflat: size of the center flat position (used by joydev) | 1037 | * @absflat: size of the center flat position (used by joydev) |
1038 | * @open: this method is called when the very first user calls | 1038 | * @open: this method is called when the very first user calls |
1039 | * input_open_device(). The driver must prepare the device | 1039 | * input_open_device(). The driver must prepare the device |
1040 | * to start generating events (start polling thread, | 1040 | * to start generating events (start polling thread, |
1041 | * request an IRQ, submit URB, etc.) | 1041 | * request an IRQ, submit URB, etc.) |
1042 | * @close: this method is called when the very last user calls | 1042 | * @close: this method is called when the very last user calls |
1043 | * input_close_device(). | 1043 | * input_close_device(). |
1044 | * @flush: purges the device. Most commonly used to get rid of force | 1044 | * @flush: purges the device. Most commonly used to get rid of force |
1045 | * feedback effects loaded into the device when disconnecting | 1045 | * feedback effects loaded into the device when disconnecting |
1046 | * from it | 1046 | * from it |
1047 | * @event: event handler for events sent _to_ the device, like EV_LED | 1047 | * @event: event handler for events sent _to_ the device, like EV_LED |
1048 | * or EV_SND. The device is expected to carry out the requested | 1048 | * or EV_SND. The device is expected to carry out the requested |
1049 | * action (turn on a LED, play sound, etc.) The call is protected | 1049 | * action (turn on a LED, play sound, etc.) The call is protected |
1050 | * by @event_lock and must not sleep | 1050 | * by @event_lock and must not sleep |
1051 | * @grab: input handle that currently has the device grabbed (via | 1051 | * @grab: input handle that currently has the device grabbed (via |
1052 | * EVIOCGRAB ioctl). When a handle grabs a device it becomes sole | 1052 | * EVIOCGRAB ioctl). When a handle grabs a device it becomes sole |
1053 | * recipient for all input events coming from the device | 1053 | * recipient for all input events coming from the device |
1054 | * @event_lock: this spinlock is is taken when input core receives | 1054 | * @event_lock: this spinlock is is taken when input core receives |
1055 | * and processes a new event for the device (in input_event()). | 1055 | * and processes a new event for the device (in input_event()). |
1056 | * Code that accesses and/or modifies parameters of a device | 1056 | * Code that accesses and/or modifies parameters of a device |
1057 | * (such as keymap or absmin, absmax, absfuzz, etc.) after device | 1057 | * (such as keymap or absmin, absmax, absfuzz, etc.) after device |
1058 | * has been registered with input core must take this lock. | 1058 | * has been registered with input core must take this lock. |
1059 | * @mutex: serializes calls to open(), close() and flush() methods | 1059 | * @mutex: serializes calls to open(), close() and flush() methods |
1060 | * @users: stores number of users (input handlers) that opened this | 1060 | * @users: stores number of users (input handlers) that opened this |
1061 | * device. It is used by input_open_device() and input_close_device() | 1061 | * device. It is used by input_open_device() and input_close_device() |
1062 | * to make sure that dev->open() is only called when the first | 1062 | * to make sure that dev->open() is only called when the first |
1063 | * user opens device and dev->close() is called when the very | 1063 | * user opens device and dev->close() is called when the very |
1064 | * last user closes the device | 1064 | * last user closes the device |
1065 | * @going_away: marks devices that are in a middle of unregistering and | 1065 | * @going_away: marks devices that are in a middle of unregistering and |
1066 | * causes input_open_device*() fail with -ENODEV. | 1066 | * causes input_open_device*() fail with -ENODEV. |
1067 | * @dev: driver model's view of this device | 1067 | * @dev: driver model's view of this device |
1068 | * @h_list: list of input handles associated with the device. When | 1068 | * @h_list: list of input handles associated with the device. When |
1069 | * accessing the list dev->mutex must be held | 1069 | * accessing the list dev->mutex must be held |
1070 | * @node: used to place the device onto input_dev_list | 1070 | * @node: used to place the device onto input_dev_list |
1071 | */ | 1071 | */ |
1072 | struct input_dev { | 1072 | struct input_dev { |
1073 | const char *name; | 1073 | const char *name; |
1074 | const char *phys; | 1074 | const char *phys; |
1075 | const char *uniq; | 1075 | const char *uniq; |
1076 | struct input_id id; | 1076 | struct input_id id; |
1077 | 1077 | ||
1078 | unsigned long evbit[BITS_TO_LONGS(EV_CNT)]; | 1078 | unsigned long evbit[BITS_TO_LONGS(EV_CNT)]; |
1079 | unsigned long keybit[BITS_TO_LONGS(KEY_CNT)]; | 1079 | unsigned long keybit[BITS_TO_LONGS(KEY_CNT)]; |
1080 | unsigned long relbit[BITS_TO_LONGS(REL_CNT)]; | 1080 | unsigned long relbit[BITS_TO_LONGS(REL_CNT)]; |
1081 | unsigned long absbit[BITS_TO_LONGS(ABS_CNT)]; | 1081 | unsigned long absbit[BITS_TO_LONGS(ABS_CNT)]; |
1082 | unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)]; | 1082 | unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)]; |
1083 | unsigned long ledbit[BITS_TO_LONGS(LED_CNT)]; | 1083 | unsigned long ledbit[BITS_TO_LONGS(LED_CNT)]; |
1084 | unsigned long sndbit[BITS_TO_LONGS(SND_CNT)]; | 1084 | unsigned long sndbit[BITS_TO_LONGS(SND_CNT)]; |
1085 | unsigned long ffbit[BITS_TO_LONGS(FF_CNT)]; | 1085 | unsigned long ffbit[BITS_TO_LONGS(FF_CNT)]; |
1086 | unsigned long swbit[BITS_TO_LONGS(SW_CNT)]; | 1086 | unsigned long swbit[BITS_TO_LONGS(SW_CNT)]; |
1087 | 1087 | ||
1088 | unsigned int keycodemax; | 1088 | unsigned int keycodemax; |
1089 | unsigned int keycodesize; | 1089 | unsigned int keycodesize; |
1090 | void *keycode; | 1090 | void *keycode; |
1091 | int (*setkeycode)(struct input_dev *dev, int scancode, int keycode); | 1091 | int (*setkeycode)(struct input_dev *dev, int scancode, int keycode); |
1092 | int (*getkeycode)(struct input_dev *dev, int scancode, int *keycode); | 1092 | int (*getkeycode)(struct input_dev *dev, int scancode, int *keycode); |
1093 | 1093 | ||
1094 | struct ff_device *ff; | 1094 | struct ff_device *ff; |
1095 | 1095 | ||
1096 | unsigned int repeat_key; | 1096 | unsigned int repeat_key; |
1097 | struct timer_list timer; | 1097 | struct timer_list timer; |
1098 | 1098 | ||
1099 | int sync; | 1099 | int sync; |
1100 | 1100 | ||
1101 | int abs[ABS_MAX + 1]; | 1101 | int abs[ABS_MAX + 1]; |
1102 | int rep[REP_MAX + 1]; | 1102 | int rep[REP_MAX + 1]; |
1103 | 1103 | ||
1104 | unsigned long key[BITS_TO_LONGS(KEY_CNT)]; | 1104 | unsigned long key[BITS_TO_LONGS(KEY_CNT)]; |
1105 | unsigned long led[BITS_TO_LONGS(LED_CNT)]; | 1105 | unsigned long led[BITS_TO_LONGS(LED_CNT)]; |
1106 | unsigned long snd[BITS_TO_LONGS(SND_CNT)]; | 1106 | unsigned long snd[BITS_TO_LONGS(SND_CNT)]; |
1107 | unsigned long sw[BITS_TO_LONGS(SW_CNT)]; | 1107 | unsigned long sw[BITS_TO_LONGS(SW_CNT)]; |
1108 | 1108 | ||
1109 | int absmax[ABS_MAX + 1]; | 1109 | int absmax[ABS_MAX + 1]; |
1110 | int absmin[ABS_MAX + 1]; | 1110 | int absmin[ABS_MAX + 1]; |
1111 | int absfuzz[ABS_MAX + 1]; | 1111 | int absfuzz[ABS_MAX + 1]; |
1112 | int absflat[ABS_MAX + 1]; | 1112 | int absflat[ABS_MAX + 1]; |
1113 | int absres[ABS_MAX + 1]; | 1113 | int absres[ABS_MAX + 1]; |
1114 | 1114 | ||
1115 | int (*open)(struct input_dev *dev); | 1115 | int (*open)(struct input_dev *dev); |
1116 | void (*close)(struct input_dev *dev); | 1116 | void (*close)(struct input_dev *dev); |
1117 | int (*flush)(struct input_dev *dev, struct file *file); | 1117 | int (*flush)(struct input_dev *dev, struct file *file); |
1118 | int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); | 1118 | int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); |
1119 | 1119 | ||
1120 | struct input_handle *grab; | 1120 | struct input_handle *grab; |
1121 | 1121 | ||
1122 | spinlock_t event_lock; | 1122 | spinlock_t event_lock; |
1123 | struct mutex mutex; | 1123 | struct mutex mutex; |
1124 | 1124 | ||
1125 | unsigned int users; | 1125 | unsigned int users; |
1126 | bool going_away; | 1126 | bool going_away; |
1127 | 1127 | ||
1128 | struct device dev; | 1128 | struct device dev; |
1129 | 1129 | ||
1130 | struct list_head h_list; | 1130 | struct list_head h_list; |
1131 | struct list_head node; | 1131 | struct list_head node; |
1132 | }; | 1132 | }; |
1133 | #define to_input_dev(d) container_of(d, struct input_dev, dev) | 1133 | #define to_input_dev(d) container_of(d, struct input_dev, dev) |
1134 | 1134 | ||
1135 | /* | 1135 | /* |
1136 | * Verify that we are in sync with input_device_id mod_devicetable.h #defines | 1136 | * Verify that we are in sync with input_device_id mod_devicetable.h #defines |
1137 | */ | 1137 | */ |
1138 | 1138 | ||
1139 | #if EV_MAX != INPUT_DEVICE_ID_EV_MAX | 1139 | #if EV_MAX != INPUT_DEVICE_ID_EV_MAX |
1140 | #error "EV_MAX and INPUT_DEVICE_ID_EV_MAX do not match" | 1140 | #error "EV_MAX and INPUT_DEVICE_ID_EV_MAX do not match" |
1141 | #endif | 1141 | #endif |
1142 | 1142 | ||
1143 | #if KEY_MIN_INTERESTING != INPUT_DEVICE_ID_KEY_MIN_INTERESTING | 1143 | #if KEY_MIN_INTERESTING != INPUT_DEVICE_ID_KEY_MIN_INTERESTING |
1144 | #error "KEY_MIN_INTERESTING and INPUT_DEVICE_ID_KEY_MIN_INTERESTING do not match" | 1144 | #error "KEY_MIN_INTERESTING and INPUT_DEVICE_ID_KEY_MIN_INTERESTING do not match" |
1145 | #endif | 1145 | #endif |
1146 | 1146 | ||
1147 | #if KEY_MAX != INPUT_DEVICE_ID_KEY_MAX | 1147 | #if KEY_MAX != INPUT_DEVICE_ID_KEY_MAX |
1148 | #error "KEY_MAX and INPUT_DEVICE_ID_KEY_MAX do not match" | 1148 | #error "KEY_MAX and INPUT_DEVICE_ID_KEY_MAX do not match" |
1149 | #endif | 1149 | #endif |
1150 | 1150 | ||
1151 | #if REL_MAX != INPUT_DEVICE_ID_REL_MAX | 1151 | #if REL_MAX != INPUT_DEVICE_ID_REL_MAX |
1152 | #error "REL_MAX and INPUT_DEVICE_ID_REL_MAX do not match" | 1152 | #error "REL_MAX and INPUT_DEVICE_ID_REL_MAX do not match" |
1153 | #endif | 1153 | #endif |
1154 | 1154 | ||
1155 | #if ABS_MAX != INPUT_DEVICE_ID_ABS_MAX | 1155 | #if ABS_MAX != INPUT_DEVICE_ID_ABS_MAX |
1156 | #error "ABS_MAX and INPUT_DEVICE_ID_ABS_MAX do not match" | 1156 | #error "ABS_MAX and INPUT_DEVICE_ID_ABS_MAX do not match" |
1157 | #endif | 1157 | #endif |
1158 | 1158 | ||
1159 | #if MSC_MAX != INPUT_DEVICE_ID_MSC_MAX | 1159 | #if MSC_MAX != INPUT_DEVICE_ID_MSC_MAX |
1160 | #error "MSC_MAX and INPUT_DEVICE_ID_MSC_MAX do not match" | 1160 | #error "MSC_MAX and INPUT_DEVICE_ID_MSC_MAX do not match" |
1161 | #endif | 1161 | #endif |
1162 | 1162 | ||
1163 | #if LED_MAX != INPUT_DEVICE_ID_LED_MAX | 1163 | #if LED_MAX != INPUT_DEVICE_ID_LED_MAX |
1164 | #error "LED_MAX and INPUT_DEVICE_ID_LED_MAX do not match" | 1164 | #error "LED_MAX and INPUT_DEVICE_ID_LED_MAX do not match" |
1165 | #endif | 1165 | #endif |
1166 | 1166 | ||
1167 | #if SND_MAX != INPUT_DEVICE_ID_SND_MAX | 1167 | #if SND_MAX != INPUT_DEVICE_ID_SND_MAX |
1168 | #error "SND_MAX and INPUT_DEVICE_ID_SND_MAX do not match" | 1168 | #error "SND_MAX and INPUT_DEVICE_ID_SND_MAX do not match" |
1169 | #endif | 1169 | #endif |
1170 | 1170 | ||
1171 | #if FF_MAX != INPUT_DEVICE_ID_FF_MAX | 1171 | #if FF_MAX != INPUT_DEVICE_ID_FF_MAX |
1172 | #error "FF_MAX and INPUT_DEVICE_ID_FF_MAX do not match" | 1172 | #error "FF_MAX and INPUT_DEVICE_ID_FF_MAX do not match" |
1173 | #endif | 1173 | #endif |
1174 | 1174 | ||
1175 | #if SW_MAX != INPUT_DEVICE_ID_SW_MAX | 1175 | #if SW_MAX != INPUT_DEVICE_ID_SW_MAX |
1176 | #error "SW_MAX and INPUT_DEVICE_ID_SW_MAX do not match" | 1176 | #error "SW_MAX and INPUT_DEVICE_ID_SW_MAX do not match" |
1177 | #endif | 1177 | #endif |
1178 | 1178 | ||
1179 | #define INPUT_DEVICE_ID_MATCH_DEVICE \ | 1179 | #define INPUT_DEVICE_ID_MATCH_DEVICE \ |
1180 | (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT) | 1180 | (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT) |
1181 | #define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION \ | 1181 | #define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION \ |
1182 | (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION) | 1182 | (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION) |
1183 | 1183 | ||
1184 | struct input_handle; | 1184 | struct input_handle; |
1185 | 1185 | ||
1186 | /** | 1186 | /** |
1187 | * struct input_handler - implements one of interfaces for input devices | 1187 | * struct input_handler - implements one of interfaces for input devices |
1188 | * @private: driver-specific data | 1188 | * @private: driver-specific data |
1189 | * @event: event handler. This method is being called by input core with | 1189 | * @event: event handler. This method is being called by input core with |
1190 | * interrupts disabled and dev->event_lock spinlock held and so | 1190 | * interrupts disabled and dev->event_lock spinlock held and so |
1191 | * it may not sleep | 1191 | * it may not sleep |
1192 | * @connect: called when attaching a handler to an input device | 1192 | * @connect: called when attaching a handler to an input device |
1193 | * @disconnect: disconnects a handler from input device | 1193 | * @disconnect: disconnects a handler from input device |
1194 | * @start: starts handler for given handle. This function is called by | 1194 | * @start: starts handler for given handle. This function is called by |
1195 | * input core right after connect() method and also when a process | 1195 | * input core right after connect() method and also when a process |
1196 | * that "grabbed" a device releases it | 1196 | * that "grabbed" a device releases it |
1197 | * @fops: file operations this driver implements | 1197 | * @fops: file operations this driver implements |
1198 | * @minor: beginning of range of 32 minors for devices this driver | 1198 | * @minor: beginning of range of 32 minors for devices this driver |
1199 | * can provide | 1199 | * can provide |
1200 | * @name: name of the handler, to be shown in /proc/bus/input/handlers | 1200 | * @name: name of the handler, to be shown in /proc/bus/input/handlers |
1201 | * @id_table: pointer to a table of input_device_ids this driver can | 1201 | * @id_table: pointer to a table of input_device_ids this driver can |
1202 | * handle | 1202 | * handle |
1203 | * @blacklist: pointer to a table of input_device_ids this driver should | 1203 | * @blacklist: pointer to a table of input_device_ids this driver should |
1204 | * ignore even if they match @id_table | 1204 | * ignore even if they match @id_table |
1205 | * @h_list: list of input handles associated with the handler | 1205 | * @h_list: list of input handles associated with the handler |
1206 | * @node: for placing the driver onto input_handler_list | 1206 | * @node: for placing the driver onto input_handler_list |
1207 | * | 1207 | * |
1208 | * Input handlers attach to input devices and create input handles. There | 1208 | * Input handlers attach to input devices and create input handles. There |
1209 | * are likely several handlers attached to any given input device at the | 1209 | * are likely several handlers attached to any given input device at the |
1210 | * same time. All of them will get their copy of input event generated by | 1210 | * same time. All of them will get their copy of input event generated by |
1211 | * the device. | 1211 | * the device. |
1212 | * | 1212 | * |
1213 | * Note that input core serializes calls to connect() and disconnect() | 1213 | * Note that input core serializes calls to connect() and disconnect() |
1214 | * methods. | 1214 | * methods. |
1215 | */ | 1215 | */ |
1216 | struct input_handler { | 1216 | struct input_handler { |
1217 | 1217 | ||
1218 | void *private; | 1218 | void *private; |
1219 | 1219 | ||
1220 | void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); | 1220 | void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); |
1221 | int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id); | 1221 | int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id); |
1222 | void (*disconnect)(struct input_handle *handle); | 1222 | void (*disconnect)(struct input_handle *handle); |
1223 | void (*start)(struct input_handle *handle); | 1223 | void (*start)(struct input_handle *handle); |
1224 | 1224 | ||
1225 | const struct file_operations *fops; | 1225 | const struct file_operations *fops; |
1226 | int minor; | 1226 | int minor; |
1227 | const char *name; | 1227 | const char *name; |
1228 | 1228 | ||
1229 | const struct input_device_id *id_table; | 1229 | const struct input_device_id *id_table; |
1230 | const struct input_device_id *blacklist; | 1230 | const struct input_device_id *blacklist; |
1231 | 1231 | ||
1232 | struct list_head h_list; | 1232 | struct list_head h_list; |
1233 | struct list_head node; | 1233 | struct list_head node; |
1234 | }; | 1234 | }; |
1235 | 1235 | ||
1236 | /** | 1236 | /** |
1237 | * struct input_handle - links input device with an input handler | 1237 | * struct input_handle - links input device with an input handler |
1238 | * @private: handler-specific data | 1238 | * @private: handler-specific data |
1239 | * @open: counter showing whether the handle is 'open', i.e. should deliver | 1239 | * @open: counter showing whether the handle is 'open', i.e. should deliver |
1240 | * events from its device | 1240 | * events from its device |
1241 | * @name: name given to the handle by handler that created it | 1241 | * @name: name given to the handle by handler that created it |
1242 | * @dev: input device the handle is attached to | 1242 | * @dev: input device the handle is attached to |
1243 | * @handler: handler that works with the device through this handle | 1243 | * @handler: handler that works with the device through this handle |
1244 | * @d_node: used to put the handle on device's list of attached handles | 1244 | * @d_node: used to put the handle on device's list of attached handles |
1245 | * @h_node: used to put the handle on handler's list of handles from which | 1245 | * @h_node: used to put the handle on handler's list of handles from which |
1246 | * it gets events | 1246 | * it gets events |
1247 | */ | 1247 | */ |
1248 | struct input_handle { | 1248 | struct input_handle { |
1249 | 1249 | ||
1250 | void *private; | 1250 | void *private; |
1251 | 1251 | ||
1252 | int open; | 1252 | int open; |
1253 | const char *name; | 1253 | const char *name; |
1254 | 1254 | ||
1255 | struct input_dev *dev; | 1255 | struct input_dev *dev; |
1256 | struct input_handler *handler; | 1256 | struct input_handler *handler; |
1257 | 1257 | ||
1258 | struct list_head d_node; | 1258 | struct list_head d_node; |
1259 | struct list_head h_node; | 1259 | struct list_head h_node; |
1260 | }; | 1260 | }; |
1261 | 1261 | ||
1262 | struct input_dev *input_allocate_device(void); | 1262 | struct input_dev *input_allocate_device(void); |
1263 | void input_free_device(struct input_dev *dev); | 1263 | void input_free_device(struct input_dev *dev); |
1264 | 1264 | ||
1265 | static inline struct input_dev *input_get_device(struct input_dev *dev) | 1265 | static inline struct input_dev *input_get_device(struct input_dev *dev) |
1266 | { | 1266 | { |
1267 | return dev ? to_input_dev(get_device(&dev->dev)) : NULL; | 1267 | return dev ? to_input_dev(get_device(&dev->dev)) : NULL; |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | static inline void input_put_device(struct input_dev *dev) | 1270 | static inline void input_put_device(struct input_dev *dev) |
1271 | { | 1271 | { |
1272 | if (dev) | 1272 | if (dev) |
1273 | put_device(&dev->dev); | 1273 | put_device(&dev->dev); |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | static inline void *input_get_drvdata(struct input_dev *dev) | 1276 | static inline void *input_get_drvdata(struct input_dev *dev) |
1277 | { | 1277 | { |
1278 | return dev_get_drvdata(&dev->dev); | 1278 | return dev_get_drvdata(&dev->dev); |
1279 | } | 1279 | } |
1280 | 1280 | ||
1281 | static inline void input_set_drvdata(struct input_dev *dev, void *data) | 1281 | static inline void input_set_drvdata(struct input_dev *dev, void *data) |
1282 | { | 1282 | { |
1283 | dev_set_drvdata(&dev->dev, data); | 1283 | dev_set_drvdata(&dev->dev, data); |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | int __must_check input_register_device(struct input_dev *); | 1286 | int __must_check input_register_device(struct input_dev *); |
1287 | void input_unregister_device(struct input_dev *); | 1287 | void input_unregister_device(struct input_dev *); |
1288 | 1288 | ||
1289 | int __must_check input_register_handler(struct input_handler *); | 1289 | int __must_check input_register_handler(struct input_handler *); |
1290 | void input_unregister_handler(struct input_handler *); | 1290 | void input_unregister_handler(struct input_handler *); |
1291 | 1291 | ||
1292 | int input_register_handle(struct input_handle *); | 1292 | int input_register_handle(struct input_handle *); |
1293 | void input_unregister_handle(struct input_handle *); | 1293 | void input_unregister_handle(struct input_handle *); |
1294 | 1294 | ||
1295 | int input_grab_device(struct input_handle *); | 1295 | int input_grab_device(struct input_handle *); |
1296 | void input_release_device(struct input_handle *); | 1296 | void input_release_device(struct input_handle *); |
1297 | 1297 | ||
1298 | int input_open_device(struct input_handle *); | 1298 | int input_open_device(struct input_handle *); |
1299 | void input_close_device(struct input_handle *); | 1299 | void input_close_device(struct input_handle *); |
1300 | 1300 | ||
1301 | int input_flush_device(struct input_handle* handle, struct file* file); | 1301 | int input_flush_device(struct input_handle* handle, struct file* file); |
1302 | 1302 | ||
1303 | void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); | 1303 | void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); |
1304 | void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value); | 1304 | void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value); |
1305 | 1305 | ||
1306 | static inline void input_report_key(struct input_dev *dev, unsigned int code, int value) | 1306 | static inline void input_report_key(struct input_dev *dev, unsigned int code, int value) |
1307 | { | 1307 | { |
1308 | input_event(dev, EV_KEY, code, !!value); | 1308 | input_event(dev, EV_KEY, code, !!value); |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value) | 1311 | static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value) |
1312 | { | 1312 | { |
1313 | input_event(dev, EV_REL, code, value); | 1313 | input_event(dev, EV_REL, code, value); |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value) | 1316 | static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value) |
1317 | { | 1317 | { |
1318 | input_event(dev, EV_ABS, code, value); | 1318 | input_event(dev, EV_ABS, code, value); |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value) | 1321 | static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value) |
1322 | { | 1322 | { |
1323 | input_event(dev, EV_FF_STATUS, code, value); | 1323 | input_event(dev, EV_FF_STATUS, code, value); |
1324 | } | 1324 | } |
1325 | 1325 | ||
1326 | static inline void input_report_switch(struct input_dev *dev, unsigned int code, int value) | 1326 | static inline void input_report_switch(struct input_dev *dev, unsigned int code, int value) |
1327 | { | 1327 | { |
1328 | input_event(dev, EV_SW, code, !!value); | 1328 | input_event(dev, EV_SW, code, !!value); |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | static inline void input_sync(struct input_dev *dev) | 1331 | static inline void input_sync(struct input_dev *dev) |
1332 | { | 1332 | { |
1333 | input_event(dev, EV_SYN, SYN_REPORT, 0); | 1333 | input_event(dev, EV_SYN, SYN_REPORT, 0); |
1334 | } | 1334 | } |
1335 | 1335 | ||
1336 | static inline void input_mt_sync(struct input_dev *dev) | 1336 | static inline void input_mt_sync(struct input_dev *dev) |
1337 | { | 1337 | { |
1338 | input_event(dev, EV_SYN, SYN_MT_REPORT, 0); | 1338 | input_event(dev, EV_SYN, SYN_MT_REPORT, 0); |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code); | 1341 | void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code); |
1342 | 1342 | ||
1343 | static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) | 1343 | static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) |
1344 | { | 1344 | { |
1345 | dev->absmin[axis] = min; | 1345 | dev->absmin[axis] = min; |
1346 | dev->absmax[axis] = max; | 1346 | dev->absmax[axis] = max; |
1347 | dev->absfuzz[axis] = fuzz; | 1347 | dev->absfuzz[axis] = fuzz; |
1348 | dev->absflat[axis] = flat; | 1348 | dev->absflat[axis] = flat; |
1349 | 1349 | ||
1350 | dev->absbit[BIT_WORD(axis)] |= BIT_MASK(axis); | 1350 | dev->absbit[BIT_WORD(axis)] |= BIT_MASK(axis); |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | int input_get_keycode(struct input_dev *dev, int scancode, int *keycode); | 1353 | int input_get_keycode(struct input_dev *dev, int scancode, int *keycode); |
1354 | int input_set_keycode(struct input_dev *dev, int scancode, int keycode); | 1354 | int input_set_keycode(struct input_dev *dev, int scancode, int keycode); |
1355 | 1355 | ||
1356 | extern struct class input_class; | 1356 | extern struct class input_class; |
1357 | 1357 | ||
1358 | /** | 1358 | /** |
1359 | * struct ff_device - force-feedback part of an input device | 1359 | * struct ff_device - force-feedback part of an input device |
1360 | * @upload: Called to upload an new effect into device | 1360 | * @upload: Called to upload an new effect into device |
1361 | * @erase: Called to erase an effect from device | 1361 | * @erase: Called to erase an effect from device |
1362 | * @playback: Called to request device to start playing specified effect | 1362 | * @playback: Called to request device to start playing specified effect |
1363 | * @set_gain: Called to set specified gain | 1363 | * @set_gain: Called to set specified gain |
1364 | * @set_autocenter: Called to auto-center device | 1364 | * @set_autocenter: Called to auto-center device |
1365 | * @destroy: called by input core when parent input device is being | 1365 | * @destroy: called by input core when parent input device is being |
1366 | * destroyed | 1366 | * destroyed |
1367 | * @private: driver-specific data, will be freed automatically | 1367 | * @private: driver-specific data, will be freed automatically |
1368 | * @ffbit: bitmap of force feedback capabilities truly supported by | 1368 | * @ffbit: bitmap of force feedback capabilities truly supported by |
1369 | * device (not emulated like ones in input_dev->ffbit) | 1369 | * device (not emulated like ones in input_dev->ffbit) |
1370 | * @mutex: mutex for serializing access to the device | 1370 | * @mutex: mutex for serializing access to the device |
1371 | * @max_effects: maximum number of effects supported by device | 1371 | * @max_effects: maximum number of effects supported by device |
1372 | * @effects: pointer to an array of effects currently loaded into device | 1372 | * @effects: pointer to an array of effects currently loaded into device |
1373 | * @effect_owners: array of effect owners; when file handle owning | 1373 | * @effect_owners: array of effect owners; when file handle owning |
1374 | * an effect gets closed the effect is automatically erased | 1374 | * an effect gets closed the effect is automatically erased |
1375 | * | 1375 | * |
1376 | * Every force-feedback device must implement upload() and playback() | 1376 | * Every force-feedback device must implement upload() and playback() |
1377 | * methods; erase() is optional. set_gain() and set_autocenter() need | 1377 | * methods; erase() is optional. set_gain() and set_autocenter() need |
1378 | * only be implemented if driver sets up FF_GAIN and FF_AUTOCENTER | 1378 | * only be implemented if driver sets up FF_GAIN and FF_AUTOCENTER |
1379 | * bits. | 1379 | * bits. |
1380 | * | ||
1381 | * Note that playback(), set_gain() and set_autocenter() are called with | ||
1382 | * dev->event_lock spinlock held and interrupts off and thus may not | ||
1383 | * sleep. | ||
1380 | */ | 1384 | */ |
1381 | struct ff_device { | 1385 | struct ff_device { |
1382 | int (*upload)(struct input_dev *dev, struct ff_effect *effect, | 1386 | int (*upload)(struct input_dev *dev, struct ff_effect *effect, |
1383 | struct ff_effect *old); | 1387 | struct ff_effect *old); |
1384 | int (*erase)(struct input_dev *dev, int effect_id); | 1388 | int (*erase)(struct input_dev *dev, int effect_id); |
1385 | 1389 | ||
1386 | int (*playback)(struct input_dev *dev, int effect_id, int value); | 1390 | int (*playback)(struct input_dev *dev, int effect_id, int value); |
1387 | void (*set_gain)(struct input_dev *dev, u16 gain); | 1391 | void (*set_gain)(struct input_dev *dev, u16 gain); |
1388 | void (*set_autocenter)(struct input_dev *dev, u16 magnitude); | 1392 | void (*set_autocenter)(struct input_dev *dev, u16 magnitude); |
1389 | 1393 | ||
1390 | void (*destroy)(struct ff_device *); | 1394 | void (*destroy)(struct ff_device *); |
1391 | 1395 | ||
1392 | void *private; | 1396 | void *private; |
1393 | 1397 | ||
1394 | unsigned long ffbit[BITS_TO_LONGS(FF_CNT)]; | 1398 | unsigned long ffbit[BITS_TO_LONGS(FF_CNT)]; |
1395 | 1399 | ||
1396 | struct mutex mutex; | 1400 | struct mutex mutex; |
1397 | 1401 | ||
1398 | int max_effects; | 1402 | int max_effects; |
1399 | struct ff_effect *effects; | 1403 | struct ff_effect *effects; |
1400 | struct file *effect_owners[]; | 1404 | struct file *effect_owners[]; |
1401 | }; | 1405 | }; |
1402 | 1406 | ||
1403 | int input_ff_create(struct input_dev *dev, int max_effects); | 1407 | int input_ff_create(struct input_dev *dev, int max_effects); |
1404 | void input_ff_destroy(struct input_dev *dev); | 1408 | void input_ff_destroy(struct input_dev *dev); |
1405 | 1409 | ||
1406 | int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); | 1410 | int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); |
1407 | 1411 | ||
1408 | int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, struct file *file); | 1412 | int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, struct file *file); |
1409 | int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file); | 1413 | int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file); |
1410 | 1414 | ||
1411 | int input_ff_create_memless(struct input_dev *dev, void *data, | 1415 | int input_ff_create_memless(struct input_dev *dev, void *data, |
1412 | int (*play_effect)(struct input_dev *, void *, struct ff_effect *)); | 1416 | int (*play_effect)(struct input_dev *, void *, struct ff_effect *)); |
1413 | 1417 | ||
1414 | #endif | 1418 | #endif |
1415 | #endif | 1419 | #endif |
1416 | 1420 |