• Home
  • Raw
  • Download

Lines Matching refs:joydev

35 struct joydev {  struct
64 struct joydev *joydev; argument
91 struct joydev *joydev = client->joydev; in joydev_pass_event() local
100 if (client->startup == joydev->nabs + joydev->nkey) { in joydev_pass_event()
115 struct joydev *joydev = handle->private; in joydev_event() local
125 event.number = joydev->keymap[code - BTN_MISC]; in joydev_event()
131 event.number = joydev->absmap[code]; in joydev_event()
133 &joydev->corr[event.number]); in joydev_event()
134 if (event.value == joydev->abs[event.number]) in joydev_event()
136 joydev->abs[event.number] = event.value; in joydev_event()
146 list_for_each_entry_rcu(client, &joydev->client_list, node) in joydev_event()
150 wake_up_interruptible(&joydev->wait); in joydev_event()
162 struct joydev *joydev = container_of(dev, struct joydev, dev); in joydev_free() local
164 input_put_device(joydev->handle.dev); in joydev_free()
165 kfree(joydev); in joydev_free()
168 static void joydev_attach_client(struct joydev *joydev, in joydev_attach_client() argument
171 spin_lock(&joydev->client_lock); in joydev_attach_client()
172 list_add_tail_rcu(&client->node, &joydev->client_list); in joydev_attach_client()
173 spin_unlock(&joydev->client_lock); in joydev_attach_client()
176 static void joydev_detach_client(struct joydev *joydev, in joydev_detach_client() argument
179 spin_lock(&joydev->client_lock); in joydev_detach_client()
181 spin_unlock(&joydev->client_lock); in joydev_detach_client()
185 static void joydev_refresh_state(struct joydev *joydev) in joydev_refresh_state() argument
187 struct input_dev *dev = joydev->handle.dev; in joydev_refresh_state()
190 for (i = 0; i < joydev->nabs; i++) { in joydev_refresh_state()
191 val = input_abs_get_val(dev, joydev->abspam[i]); in joydev_refresh_state()
192 joydev->abs[i] = joydev_correct(val, &joydev->corr[i]); in joydev_refresh_state()
196 static int joydev_open_device(struct joydev *joydev) in joydev_open_device() argument
200 retval = mutex_lock_interruptible(&joydev->mutex); in joydev_open_device()
204 if (!joydev->exist) in joydev_open_device()
206 else if (!joydev->open++) { in joydev_open_device()
207 retval = input_open_device(&joydev->handle); in joydev_open_device()
209 joydev->open--; in joydev_open_device()
211 joydev_refresh_state(joydev); in joydev_open_device()
214 mutex_unlock(&joydev->mutex); in joydev_open_device()
218 static void joydev_close_device(struct joydev *joydev) in joydev_close_device() argument
220 mutex_lock(&joydev->mutex); in joydev_close_device()
222 if (joydev->exist && !--joydev->open) in joydev_close_device()
223 input_close_device(&joydev->handle); in joydev_close_device()
225 mutex_unlock(&joydev->mutex); in joydev_close_device()
232 static void joydev_hangup(struct joydev *joydev) in joydev_hangup() argument
236 spin_lock(&joydev->client_lock); in joydev_hangup()
237 list_for_each_entry(client, &joydev->client_list, node) in joydev_hangup()
239 spin_unlock(&joydev->client_lock); in joydev_hangup()
241 wake_up_interruptible(&joydev->wait); in joydev_hangup()
247 struct joydev *joydev = client->joydev; in joydev_release() local
249 joydev_detach_client(joydev, client); in joydev_release()
252 joydev_close_device(joydev); in joydev_release()
259 struct joydev *joydev = in joydev_open() local
260 container_of(inode->i_cdev, struct joydev, cdev); in joydev_open()
269 client->joydev = joydev; in joydev_open()
270 joydev_attach_client(joydev, client); in joydev_open()
272 error = joydev_open_device(joydev); in joydev_open()
282 joydev_detach_client(joydev, client); in joydev_open()
291 struct joydev *joydev = client->joydev; in joydev_generate_startup_event() local
296 have_event = client->startup < joydev->nabs + joydev->nkey; in joydev_generate_startup_event()
301 if (client->startup < joydev->nkey) { in joydev_generate_startup_event()
304 event->value = !!test_bit(joydev->keypam[event->number], in joydev_generate_startup_event()
308 event->number = client->startup - joydev->nkey; in joydev_generate_startup_event()
309 event->value = joydev->abs[event->number]; in joydev_generate_startup_event()
344 struct joydev *joydev = client->joydev; in joydev_0x_read() local
353 for (data.buttons = i = 0; i < 32 && i < joydev->nkey; i++) in joydev_0x_read()
355 test_bit(joydev->keypam[i], input->key) ? (1 << i) : 0; in joydev_0x_read()
356 data.x = (joydev->abs[0] / 256 + 128) >> joydev->glue.JS_CORR.x; in joydev_0x_read()
357 data.y = (joydev->abs[1] / 256 + 128) >> joydev->glue.JS_CORR.y; in joydev_0x_read()
377 struct joydev *joydev = client->joydev; in joydev_data_pending() local
379 return client->startup < joydev->nabs + joydev->nkey || in joydev_data_pending()
387 struct joydev *joydev = client->joydev; in joydev_read() local
388 struct input_dev *input = joydev->handle.dev; in joydev_read()
392 if (!joydev->exist) in joydev_read()
404 retval = wait_event_interruptible(joydev->wait, in joydev_read()
405 !joydev->exist || joydev_data_pending(client)); in joydev_read()
409 if (!joydev->exist) in joydev_read()
437 struct joydev *joydev = client->joydev; in joydev_poll() local
439 poll_wait(file, &joydev->wait, wait); in joydev_poll()
441 (joydev->exist ? 0 : (EPOLLHUP | EPOLLERR)); in joydev_poll()
444 static int joydev_handle_JSIOCSAXMAP(struct joydev *joydev, in joydev_handle_JSIOCSAXMAP() argument
451 len = min(len, sizeof(joydev->abspam)); in joydev_handle_JSIOCSAXMAP()
458 for (i = 0; i < len && i < joydev->nabs; i++) { in joydev_handle_JSIOCSAXMAP()
465 memcpy(joydev->abspam, abspam, len); in joydev_handle_JSIOCSAXMAP()
467 for (i = 0; i < joydev->nabs; i++) in joydev_handle_JSIOCSAXMAP()
468 joydev->absmap[joydev->abspam[i]] = i; in joydev_handle_JSIOCSAXMAP()
475 static int joydev_handle_JSIOCSBTNMAP(struct joydev *joydev, in joydev_handle_JSIOCSBTNMAP() argument
485 len = min(len, sizeof(joydev->keypam)); in joydev_handle_JSIOCSBTNMAP()
492 for (i = 0; i < (len / 2) && i < joydev->nkey; i++) { in joydev_handle_JSIOCSBTNMAP()
499 memcpy(joydev->keypam, keypam, len); in joydev_handle_JSIOCSBTNMAP()
501 for (i = 0; i < joydev->nkey; i++) in joydev_handle_JSIOCSBTNMAP()
502 joydev->keymap[joydev->keypam[i] - BTN_MISC] = i; in joydev_handle_JSIOCSBTNMAP()
510 static int joydev_ioctl_common(struct joydev *joydev, in joydev_ioctl_common() argument
513 struct input_dev *dev = joydev->handle.dev; in joydev_ioctl_common()
522 return copy_from_user(&joydev->glue.JS_CORR, argp, in joydev_ioctl_common()
523 sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; in joydev_ioctl_common()
526 return copy_to_user(argp, &joydev->glue.JS_CORR, in joydev_ioctl_common()
527 sizeof(joydev->glue.JS_CORR)) ? -EFAULT : 0; in joydev_ioctl_common()
530 return get_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); in joydev_ioctl_common()
533 return put_user(joydev->glue.JS_TIMEOUT, (s32 __user *) argp); in joydev_ioctl_common()
539 return put_user(joydev->nabs, (__u8 __user *) argp); in joydev_ioctl_common()
542 return put_user(joydev->nkey, (__u8 __user *) argp); in joydev_ioctl_common()
545 if (copy_from_user(joydev->corr, argp, in joydev_ioctl_common()
546 sizeof(joydev->corr[0]) * joydev->nabs)) in joydev_ioctl_common()
549 for (i = 0; i < joydev->nabs; i++) { in joydev_ioctl_common()
550 int val = input_abs_get_val(dev, joydev->abspam[i]); in joydev_ioctl_common()
551 joydev->abs[i] = joydev_correct(val, &joydev->corr[i]); in joydev_ioctl_common()
556 return copy_to_user(argp, joydev->corr, in joydev_ioctl_common()
557 sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0; in joydev_ioctl_common()
569 return joydev_handle_JSIOCSAXMAP(joydev, argp, _IOC_SIZE(cmd)); in joydev_ioctl_common()
572 len = min_t(size_t, _IOC_SIZE(cmd), sizeof(joydev->abspam)); in joydev_ioctl_common()
573 return copy_to_user(argp, joydev->abspam, len) ? -EFAULT : len; in joydev_ioctl_common()
576 return joydev_handle_JSIOCSBTNMAP(joydev, argp, _IOC_SIZE(cmd)); in joydev_ioctl_common()
579 len = min_t(size_t, _IOC_SIZE(cmd), sizeof(joydev->keypam)); in joydev_ioctl_common()
580 return copy_to_user(argp, joydev->keypam, len) ? -EFAULT : len; in joydev_ioctl_common()
599 struct joydev *joydev = client->joydev; in joydev_compat_ioctl() local
605 retval = mutex_lock_interruptible(&joydev->mutex); in joydev_compat_ioctl()
609 if (!joydev->exist) { in joydev_compat_ioctl()
619 joydev->glue.JS_TIMELIMIT = tmp32; in joydev_compat_ioctl()
623 tmp32 = joydev->glue.JS_TIMELIMIT; in joydev_compat_ioctl()
631 joydev->glue.JS_TIMEOUT = ds32.JS_TIMEOUT; in joydev_compat_ioctl()
632 joydev->glue.BUSY = ds32.BUSY; in joydev_compat_ioctl()
633 joydev->glue.JS_EXPIRETIME = ds32.JS_EXPIRETIME; in joydev_compat_ioctl()
634 joydev->glue.JS_TIMELIMIT = ds32.JS_TIMELIMIT; in joydev_compat_ioctl()
635 joydev->glue.JS_SAVE = ds32.JS_SAVE; in joydev_compat_ioctl()
636 joydev->glue.JS_CORR = ds32.JS_CORR; in joydev_compat_ioctl()
641 ds32.JS_TIMEOUT = joydev->glue.JS_TIMEOUT; in joydev_compat_ioctl()
642 ds32.BUSY = joydev->glue.BUSY; in joydev_compat_ioctl()
643 ds32.JS_EXPIRETIME = joydev->glue.JS_EXPIRETIME; in joydev_compat_ioctl()
644 ds32.JS_TIMELIMIT = joydev->glue.JS_TIMELIMIT; in joydev_compat_ioctl()
645 ds32.JS_SAVE = joydev->glue.JS_SAVE; in joydev_compat_ioctl()
646 ds32.JS_CORR = joydev->glue.JS_CORR; in joydev_compat_ioctl()
652 retval = joydev_ioctl_common(joydev, cmd, argp); in joydev_compat_ioctl()
657 mutex_unlock(&joydev->mutex); in joydev_compat_ioctl()
666 struct joydev *joydev = client->joydev; in joydev_ioctl() local
670 retval = mutex_lock_interruptible(&joydev->mutex); in joydev_ioctl()
674 if (!joydev->exist) { in joydev_ioctl()
682 retval = get_user(joydev->glue.JS_TIMELIMIT, in joydev_ioctl()
687 retval = put_user(joydev->glue.JS_TIMELIMIT, in joydev_ioctl()
692 retval = copy_from_user(&joydev->glue, argp, in joydev_ioctl()
693 sizeof(joydev->glue)) ? -EFAULT : 0; in joydev_ioctl()
697 retval = copy_to_user(argp, &joydev->glue, in joydev_ioctl()
698 sizeof(joydev->glue)) ? -EFAULT : 0; in joydev_ioctl()
702 retval = joydev_ioctl_common(joydev, cmd, argp); in joydev_ioctl()
706 mutex_unlock(&joydev->mutex); in joydev_ioctl()
729 static void joydev_mark_dead(struct joydev *joydev) in joydev_mark_dead() argument
731 mutex_lock(&joydev->mutex); in joydev_mark_dead()
732 joydev->exist = false; in joydev_mark_dead()
733 mutex_unlock(&joydev->mutex); in joydev_mark_dead()
736 static void joydev_cleanup(struct joydev *joydev) in joydev_cleanup() argument
738 struct input_handle *handle = &joydev->handle; in joydev_cleanup()
740 joydev_mark_dead(joydev); in joydev_cleanup()
741 joydev_hangup(joydev); in joydev_cleanup()
744 if (joydev->open) in joydev_cleanup()
904 struct joydev *joydev; in joydev_connect() local
915 joydev = kzalloc(sizeof(struct joydev), GFP_KERNEL); in joydev_connect()
916 if (!joydev) { in joydev_connect()
921 INIT_LIST_HEAD(&joydev->client_list); in joydev_connect()
922 spin_lock_init(&joydev->client_lock); in joydev_connect()
923 mutex_init(&joydev->mutex); in joydev_connect()
924 init_waitqueue_head(&joydev->wait); in joydev_connect()
925 joydev->exist = true; in joydev_connect()
931 dev_set_name(&joydev->dev, "js%d", dev_no); in joydev_connect()
933 joydev->handle.dev = input_get_device(dev); in joydev_connect()
934 joydev->handle.name = dev_name(&joydev->dev); in joydev_connect()
935 joydev->handle.handler = handler; in joydev_connect()
936 joydev->handle.private = joydev; in joydev_connect()
939 joydev->absmap[i] = joydev->nabs; in joydev_connect()
940 joydev->abspam[joydev->nabs] = i; in joydev_connect()
941 joydev->nabs++; in joydev_connect()
946 joydev->keymap[i] = joydev->nkey; in joydev_connect()
947 joydev->keypam[joydev->nkey] = i + BTN_MISC; in joydev_connect()
948 joydev->nkey++; in joydev_connect()
953 joydev->keymap[i] = joydev->nkey; in joydev_connect()
954 joydev->keypam[joydev->nkey] = i + BTN_MISC; in joydev_connect()
955 joydev->nkey++; in joydev_connect()
958 for (i = 0; i < joydev->nabs; i++) { in joydev_connect()
959 j = joydev->abspam[i]; in joydev_connect()
961 joydev->corr[i].type = JS_CORR_NONE; in joydev_connect()
964 joydev->corr[i].type = JS_CORR_BROKEN; in joydev_connect()
965 joydev->corr[i].prec = input_abs_get_fuzz(dev, j); in joydev_connect()
968 joydev->corr[i].coef[0] = t - input_abs_get_flat(dev, j); in joydev_connect()
969 joydev->corr[i].coef[1] = t + input_abs_get_flat(dev, j); in joydev_connect()
974 joydev->corr[i].coef[2] = (1 << 29) / t; in joydev_connect()
975 joydev->corr[i].coef[3] = (1 << 29) / t; in joydev_connect()
979 joydev->dev.devt = MKDEV(INPUT_MAJOR, minor); in joydev_connect()
980 joydev->dev.class = &input_class; in joydev_connect()
981 joydev->dev.parent = &dev->dev; in joydev_connect()
982 joydev->dev.release = joydev_free; in joydev_connect()
983 device_initialize(&joydev->dev); in joydev_connect()
985 error = input_register_handle(&joydev->handle); in joydev_connect()
989 cdev_init(&joydev->cdev, &joydev_fops); in joydev_connect()
991 error = cdev_device_add(&joydev->cdev, &joydev->dev); in joydev_connect()
998 joydev_cleanup(joydev); in joydev_connect()
999 input_unregister_handle(&joydev->handle); in joydev_connect()
1001 put_device(&joydev->dev); in joydev_connect()
1009 struct joydev *joydev = handle->private; in joydev_disconnect() local
1011 cdev_device_del(&joydev->cdev, &joydev->dev); in joydev_disconnect()
1012 joydev_cleanup(joydev); in joydev_disconnect()
1013 input_free_minor(MINOR(joydev->dev.devt)); in joydev_disconnect()
1015 put_device(&joydev->dev); in joydev_disconnect()