aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2012-03-09 13:56:35 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-03-09 13:56:35 -0500
commit05b7b842fa1798c4775997602d42f3d6373e7ef3 (patch)
treea0942796d362b68c893ec1d92c106a6f04010545
parentb675b3667f6729dcd1036a2a129b35445947f905 (diff)
parent7491f3dffd99fadf1239011c0ab5346925618dae (diff)
Merge branch 'for-next' of github.com:rydberg/linux into next
-rw-r--r--drivers/input/evdev.c27
-rw-r--r--drivers/input/input.c2
-rw-r--r--drivers/input/mouse/bcm5974.c1
-rw-r--r--include/linux/input.h25
-rw-r--r--include/linux/input/mt.h8
5 files changed, 59 insertions, 4 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 3626b1ce4609..cfe78597eb68 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -20,7 +20,7 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/input.h> 23#include <linux/input/mt.h>
24#include <linux/major.h> 24#include <linux/major.h>
25#include <linux/device.h> 25#include <linux/device.h>
26#include "input-compat.h" 26#include "input-compat.h"
@@ -632,6 +632,28 @@ static int evdev_handle_set_keycode_v2(struct input_dev *dev, void __user *p)
632 return input_set_keycode(dev, &ke); 632 return input_set_keycode(dev, &ke);
633} 633}
634 634
635static int evdev_handle_mt_request(struct input_dev *dev,
636 unsigned int size,
637 int __user *ip)
638{
639 const struct input_mt_slot *mt = dev->mt;
640 unsigned int code;
641 int max_slots;
642 int i;
643
644 if (get_user(code, &ip[0]))
645 return -EFAULT;
646 if (!input_is_mt_value(code))
647 return -EINVAL;
648
649 max_slots = (size - sizeof(__u32)) / sizeof(__s32);
650 for (i = 0; i < dev->mtsize && i < max_slots; i++)
651 if (put_user(input_mt_get_value(&mt[i], code), &ip[1 + i]))
652 return -EFAULT;
653
654 return 0;
655}
656
635static long evdev_do_ioctl(struct file *file, unsigned int cmd, 657static long evdev_do_ioctl(struct file *file, unsigned int cmd,
636 void __user *p, int compat_mode) 658 void __user *p, int compat_mode)
637{ 659{
@@ -725,6 +747,9 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
725 return bits_to_user(dev->propbit, INPUT_PROP_MAX, 747 return bits_to_user(dev->propbit, INPUT_PROP_MAX,
726 size, p, compat_mode); 748 size, p, compat_mode);
727 749
750 case EVIOCGMTSLOTS(0):
751 return evdev_handle_mt_request(dev, size, ip);
752
728 case EVIOCGKEY(0): 753 case EVIOCGKEY(0):
729 return bits_to_user(dev->key, KEY_MAX, size, p, compat_mode); 754 return bits_to_user(dev->key, KEY_MAX, size, p, compat_mode);
730 755
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 1f78c957a75a..8921c6180c51 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -180,7 +180,7 @@ static int input_handle_abs_event(struct input_dev *dev,
180 return INPUT_IGNORE_EVENT; 180 return INPUT_IGNORE_EVENT;
181 } 181 }
182 182
183 is_mt_event = code >= ABS_MT_FIRST && code <= ABS_MT_LAST; 183 is_mt_event = input_is_mt_value(code);
184 184
185 if (!is_mt_event) { 185 if (!is_mt_event) {
186 pold = &dev->absinfo[code].value; 186 pold = &dev->absinfo[code].value;
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index 927e479c2649..f9e2758b9f46 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -433,6 +433,7 @@ static void setup_events_to_report(struct input_dev *input_dev,
433 __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit); 433 __set_bit(BTN_TOOL_QUADTAP, input_dev->keybit);
434 __set_bit(BTN_LEFT, input_dev->keybit); 434 __set_bit(BTN_LEFT, input_dev->keybit);
435 435
436 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
436 if (cfg->caps & HAS_INTEGRATED_BUTTON) 437 if (cfg->caps & HAS_INTEGRATED_BUTTON)
437 __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit); 438 __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
438 439
diff --git a/include/linux/input.h b/include/linux/input.h
index 177261ea6f52..a81671453575 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -114,6 +114,31 @@ struct input_keymap_entry {
114#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */ 114#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */
115#define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len) /* get device properties */ 115#define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len) /* get device properties */
116 116
117/**
118 * EVIOCGMTSLOTS(len) - get MT slot values
119 *
120 * The ioctl buffer argument should be binary equivalent to
121 *
122 * struct input_mt_request_layout {
123 * __u32 code;
124 * __s32 values[num_slots];
125 * };
126 *
127 * where num_slots is the (arbitrary) number of MT slots to extract.
128 *
129 * The ioctl size argument (len) is the size of the buffer, which
130 * should satisfy len = (num_slots + 1) * sizeof(__s32). If len is
131 * too small to fit all available slots, the first num_slots are
132 * returned.
133 *
134 * Before the call, code is set to the wanted ABS_MT event type. On
135 * return, values[] is filled with the slot values for the specified
136 * ABS_MT code.
137 *
138 * If the request code is not an ABS_MT value, -EINVAL is returned.
139 */
140#define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len)
141
117#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */ 142#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */
118#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ 143#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */
119#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ 144#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
index 318bb82325a6..f86737586e19 100644
--- a/include/linux/input/mt.h
+++ b/include/linux/input/mt.h
@@ -48,10 +48,14 @@ static inline void input_mt_slot(struct input_dev *dev, int slot)
48 input_event(dev, EV_ABS, ABS_MT_SLOT, slot); 48 input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
49} 49}
50 50
51static inline bool input_is_mt_value(int axis)
52{
53 return axis >= ABS_MT_FIRST && axis <= ABS_MT_LAST;
54}
55
51static inline bool input_is_mt_axis(int axis) 56static inline bool input_is_mt_axis(int axis)
52{ 57{
53 return axis == ABS_MT_SLOT || 58 return axis == ABS_MT_SLOT || input_is_mt_value(axis);
54 (axis >= ABS_MT_FIRST && axis <= ABS_MT_LAST);
55} 59}
56 60
57void input_mt_report_slot_state(struct input_dev *dev, 61void input_mt_report_slot_state(struct input_dev *dev,