aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorAnssi Hannula <anssi.hannula@gmail.com>2006-07-19 01:41:09 -0400
committerDmitry Torokhov <dtor@insightbb.com>2006-07-19 01:41:09 -0400
commitff462551235d8d7d843a005950bc90924fcedede (patch)
tree638ca70b8d1572b6f3738cfcb87355e34d006317 /drivers/input/misc
parentdc76c912145febae8b62746d6f93e5edae342c9d (diff)
Input: uinput - switch to the new FF interface
The userspace interface of the force feedback part is changed and documentation in uinput.h is updated accordingly. MODULE_VERSION is also incremented to reflect the revision. Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/uinput.c67
1 files changed, 51 insertions, 16 deletions
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index d723e9ad7c41..9516439b7c78 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -20,6 +20,9 @@
20 * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org> 20 * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
21 * 21 *
22 * Changes/Revisions: 22 * Changes/Revisions:
23 * 0.3 09/04/2006 (Anssi Hannula <anssi.hannula@gmail.com>)
24 * - updated ff support for the changes in kernel interface
25 * - added MODULE_VERSION
23 * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>) 26 * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>)
24 * - added force feedback support 27 * - added force feedback support
25 * - added UI_SET_PHYS 28 * - added UI_SET_PHYS
@@ -107,18 +110,31 @@ static int uinput_request_submit(struct input_dev *dev, struct uinput_request *r
107 return request->retval; 110 return request->retval;
108} 111}
109 112
110static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect) 113static void uinput_dev_set_gain(struct input_dev *dev, u16 gain)
114{
115 uinput_dev_event(dev, EV_FF, FF_GAIN, gain);
116}
117
118static void uinput_dev_set_autocenter(struct input_dev *dev, u16 magnitude)
119{
120 uinput_dev_event(dev, EV_FF, FF_AUTOCENTER, magnitude);
121}
122
123static int uinput_dev_playback(struct input_dev *dev, int effect_id, int value)
124{
125 return uinput_dev_event(dev, EV_FF, effect_id, value);
126}
127
128static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect, struct ff_effect *old)
111{ 129{
112 struct uinput_request request; 130 struct uinput_request request;
113 int retval; 131 int retval;
114 132
115 if (!test_bit(EV_FF, dev->evbit))
116 return -ENOSYS;
117
118 request.id = -1; 133 request.id = -1;
119 init_completion(&request.done); 134 init_completion(&request.done);
120 request.code = UI_FF_UPLOAD; 135 request.code = UI_FF_UPLOAD;
121 request.u.effect = effect; 136 request.u.upload.effect = effect;
137 request.u.upload.old = old;
122 138
123 retval = uinput_request_reserve_slot(dev->private, &request); 139 retval = uinput_request_reserve_slot(dev->private, &request);
124 if (!retval) 140 if (!retval)
@@ -168,6 +184,7 @@ static void uinput_destroy_device(struct uinput_device *udev)
168 184
169static int uinput_create_device(struct uinput_device *udev) 185static int uinput_create_device(struct uinput_device *udev)
170{ 186{
187 struct input_dev *dev = udev->dev;
171 int error; 188 int error;
172 189
173 if (udev->state != UIST_SETUP_COMPLETE) { 190 if (udev->state != UIST_SETUP_COMPLETE) {
@@ -175,15 +192,29 @@ static int uinput_create_device(struct uinput_device *udev)
175 return -EINVAL; 192 return -EINVAL;
176 } 193 }
177 194
178 error = input_register_device(udev->dev); 195 if (udev->ff_effects_max) {
179 if (error) { 196 error = input_ff_create(dev, udev->ff_effects_max);
180 uinput_destroy_device(udev); 197 if (error)
181 return error; 198 goto fail1;
199
200 dev->ff->upload = uinput_dev_upload_effect;
201 dev->ff->erase = uinput_dev_erase_effect;
202 dev->ff->playback = uinput_dev_playback;
203 dev->ff->set_gain = uinput_dev_set_gain;
204 dev->ff->set_autocenter = uinput_dev_set_autocenter;
182 } 205 }
183 206
207 error = input_register_device(udev->dev);
208 if (error)
209 goto fail2;
210
184 udev->state = UIST_CREATED; 211 udev->state = UIST_CREATED;
185 212
186 return 0; 213 return 0;
214
215 fail2: input_ff_destroy(dev);
216 fail1: uinput_destroy_device(udev);
217 return error;
187} 218}
188 219
189static int uinput_open(struct inode *inode, struct file *file) 220static int uinput_open(struct inode *inode, struct file *file)
@@ -243,8 +274,6 @@ static int uinput_allocate_device(struct uinput_device *udev)
243 return -ENOMEM; 274 return -ENOMEM;
244 275
245 udev->dev->event = uinput_dev_event; 276 udev->dev->event = uinput_dev_event;
246 udev->dev->upload_effect = uinput_dev_upload_effect;
247 udev->dev->erase_effect = uinput_dev_erase_effect;
248 udev->dev->private = udev; 277 udev->dev->private = udev;
249 278
250 return 0; 279 return 0;
@@ -278,6 +307,8 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
278 goto exit; 307 goto exit;
279 } 308 }
280 309
310 udev->ff_effects_max = user_dev->ff_effects_max;
311
281 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1; 312 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1;
282 if (!size) { 313 if (!size) {
283 retval = -EINVAL; 314 retval = -EINVAL;
@@ -296,7 +327,6 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
296 dev->id.vendor = user_dev->id.vendor; 327 dev->id.vendor = user_dev->id.vendor;
297 dev->id.product = user_dev->id.product; 328 dev->id.product = user_dev->id.product;
298 dev->id.version = user_dev->id.version; 329 dev->id.version = user_dev->id.version;
299 dev->ff_effects_max = user_dev->ff_effects_max;
300 330
301 size = sizeof(int) * (ABS_MAX + 1); 331 size = sizeof(int) * (ABS_MAX + 1);
302 memcpy(dev->absmax, user_dev->absmax, size); 332 memcpy(dev->absmax, user_dev->absmax, size);
@@ -525,12 +555,17 @@ static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
525 break; 555 break;
526 } 556 }
527 req = uinput_request_find(udev, ff_up.request_id); 557 req = uinput_request_find(udev, ff_up.request_id);
528 if (!(req && req->code == UI_FF_UPLOAD && req->u.effect)) { 558 if (!(req && req->code == UI_FF_UPLOAD && req->u.upload.effect)) {
529 retval = -EINVAL; 559 retval = -EINVAL;
530 break; 560 break;
531 } 561 }
532 ff_up.retval = 0; 562 ff_up.retval = 0;
533 memcpy(&ff_up.effect, req->u.effect, sizeof(struct ff_effect)); 563 memcpy(&ff_up.effect, req->u.upload.effect, sizeof(struct ff_effect));
564 if (req->u.upload.old)
565 memcpy(&ff_up.old, req->u.upload.old, sizeof(struct ff_effect));
566 else
567 memset(&ff_up.old, 0, sizeof(struct ff_effect));
568
534 if (copy_to_user(p, &ff_up, sizeof(ff_up))) { 569 if (copy_to_user(p, &ff_up, sizeof(ff_up))) {
535 retval = -EFAULT; 570 retval = -EFAULT;
536 break; 571 break;
@@ -561,12 +596,11 @@ static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
561 break; 596 break;
562 } 597 }
563 req = uinput_request_find(udev, ff_up.request_id); 598 req = uinput_request_find(udev, ff_up.request_id);
564 if (!(req && req->code == UI_FF_UPLOAD && req->u.effect)) { 599 if (!(req && req->code == UI_FF_UPLOAD && req->u.upload.effect)) {
565 retval = -EINVAL; 600 retval = -EINVAL;
566 break; 601 break;
567 } 602 }
568 req->retval = ff_up.retval; 603 req->retval = ff_up.retval;
569 memcpy(req->u.effect, &ff_up.effect, sizeof(struct ff_effect));
570 uinput_request_done(udev, req); 604 uinput_request_done(udev, req);
571 break; 605 break;
572 606
@@ -622,6 +656,7 @@ static void __exit uinput_exit(void)
622MODULE_AUTHOR("Aristeu Sergio Rozanski Filho"); 656MODULE_AUTHOR("Aristeu Sergio Rozanski Filho");
623MODULE_DESCRIPTION("User level driver support for input subsystem"); 657MODULE_DESCRIPTION("User level driver support for input subsystem");
624MODULE_LICENSE("GPL"); 658MODULE_LICENSE("GPL");
659MODULE_VERSION("0.3");
625 660
626module_init(uinput_init); 661module_init(uinput_init);
627module_exit(uinput_exit); 662module_exit(uinput_exit);