diff options
Diffstat (limited to 'drivers/input/joydev.c')
-rw-r--r-- | drivers/input/joydev.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index 63834585c283..d85bd8a7967d 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -530,7 +530,7 @@ static int joydev_ioctl_common(struct joydev *joydev, | |||
530 | { | 530 | { |
531 | struct input_dev *dev = joydev->handle.dev; | 531 | struct input_dev *dev = joydev->handle.dev; |
532 | size_t len; | 532 | size_t len; |
533 | int i, j; | 533 | int i; |
534 | const char *name; | 534 | const char *name; |
535 | 535 | ||
536 | /* Process fixed-sized commands. */ | 536 | /* Process fixed-sized commands. */ |
@@ -562,12 +562,11 @@ static int joydev_ioctl_common(struct joydev *joydev, | |||
562 | case JSIOCSCORR: | 562 | case JSIOCSCORR: |
563 | if (copy_from_user(joydev->corr, argp, | 563 | if (copy_from_user(joydev->corr, argp, |
564 | sizeof(joydev->corr[0]) * joydev->nabs)) | 564 | sizeof(joydev->corr[0]) * joydev->nabs)) |
565 | return -EFAULT; | 565 | return -EFAULT; |
566 | 566 | ||
567 | for (i = 0; i < joydev->nabs; i++) { | 567 | for (i = 0; i < joydev->nabs; i++) { |
568 | j = joydev->abspam[i]; | 568 | int val = input_abs_get_val(dev, joydev->abspam[i]); |
569 | joydev->abs[i] = joydev_correct(dev->abs[j], | 569 | joydev->abs[i] = joydev_correct(val, &joydev->corr[i]); |
570 | &joydev->corr[i]); | ||
571 | } | 570 | } |
572 | return 0; | 571 | return 0; |
573 | 572 | ||
@@ -848,25 +847,27 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, | |||
848 | 847 | ||
849 | for (i = 0; i < joydev->nabs; i++) { | 848 | for (i = 0; i < joydev->nabs; i++) { |
850 | j = joydev->abspam[i]; | 849 | j = joydev->abspam[i]; |
851 | if (dev->absmax[j] == dev->absmin[j]) { | 850 | if (input_abs_get_max(dev, j) == input_abs_get_min(dev, j)) { |
852 | joydev->corr[i].type = JS_CORR_NONE; | 851 | joydev->corr[i].type = JS_CORR_NONE; |
853 | joydev->abs[i] = dev->abs[j]; | 852 | joydev->abs[i] = input_abs_get_val(dev, j); |
854 | continue; | 853 | continue; |
855 | } | 854 | } |
856 | joydev->corr[i].type = JS_CORR_BROKEN; | 855 | joydev->corr[i].type = JS_CORR_BROKEN; |
857 | joydev->corr[i].prec = dev->absfuzz[j]; | 856 | joydev->corr[i].prec = input_abs_get_fuzz(dev, j); |
858 | joydev->corr[i].coef[0] = | 857 | |
859 | (dev->absmax[j] + dev->absmin[j]) / 2 - dev->absflat[j]; | 858 | t = (input_abs_get_max(dev, j) + input_abs_get_min(dev, j)) / 2; |
860 | joydev->corr[i].coef[1] = | 859 | joydev->corr[i].coef[0] = t - input_abs_get_flat(dev, j); |
861 | (dev->absmax[j] + dev->absmin[j]) / 2 + dev->absflat[j]; | 860 | joydev->corr[i].coef[1] = t + input_abs_get_flat(dev, j); |
862 | 861 | ||
863 | t = (dev->absmax[j] - dev->absmin[j]) / 2 - 2 * dev->absflat[j]; | 862 | t = (input_abs_get_max(dev, j) - input_abs_get_min(dev, j)) / 2 |
863 | - 2 * input_abs_get_flat(dev, j); | ||
864 | if (t) { | 864 | if (t) { |
865 | joydev->corr[i].coef[2] = (1 << 29) / t; | 865 | joydev->corr[i].coef[2] = (1 << 29) / t; |
866 | joydev->corr[i].coef[3] = (1 << 29) / t; | 866 | joydev->corr[i].coef[3] = (1 << 29) / t; |
867 | 867 | ||
868 | joydev->abs[i] = joydev_correct(dev->abs[j], | 868 | joydev->abs[i] = |
869 | joydev->corr + i); | 869 | joydev_correct(input_abs_get_val(dev, j), |
870 | joydev->corr + i); | ||
870 | } | 871 | } |
871 | } | 872 | } |
872 | 873 | ||