diff options
-rw-r--r-- | drivers/hid/hid-3m-pct.c | 1 | ||||
-rw-r--r-- | drivers/input/Makefile | 2 | ||||
-rw-r--r-- | drivers/input/input-mt.c | 58 | ||||
-rw-r--r-- | drivers/input/input.c | 48 | ||||
-rw-r--r-- | drivers/input/misc/uinput.c | 1 | ||||
-rw-r--r-- | drivers/input/tablet/wacom_wac.c | 1 | ||||
-rw-r--r-- | drivers/input/touchscreen/wacom_w8001.c | 2 | ||||
-rw-r--r-- | include/linux/input.h | 16 | ||||
-rw-r--r-- | include/linux/input/mt.h | 44 |
9 files changed, 108 insertions, 65 deletions
diff --git a/drivers/hid/hid-3m-pct.c b/drivers/hid/hid-3m-pct.c index 02d8cd3b1b1b..18575a4e0d63 100644 --- a/drivers/hid/hid-3m-pct.c +++ b/drivers/hid/hid-3m-pct.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/usb.h> | 21 | #include <linux/usb.h> |
22 | #include <linux/input/mt.h> | ||
22 | 23 | ||
23 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); | 24 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); |
24 | MODULE_DESCRIPTION("3M PCT multitouch panels"); | 25 | MODULE_DESCRIPTION("3M PCT multitouch panels"); |
diff --git a/drivers/input/Makefile b/drivers/input/Makefile index 7ad212d31f99..569938b3cc04 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | # Each configuration option enables a list of files. | 5 | # Each configuration option enables a list of files. |
6 | 6 | ||
7 | obj-$(CONFIG_INPUT) += input-core.o | 7 | obj-$(CONFIG_INPUT) += input-core.o |
8 | input-core-objs := input.o input-compat.o ff-core.o | 8 | input-core-objs := input.o input-compat.o ff-core.o input-mt.o |
9 | 9 | ||
10 | obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o | 10 | obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o |
11 | obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o | 11 | obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o |
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c new file mode 100644 index 000000000000..463a4d7d54f2 --- /dev/null +++ b/drivers/input/input-mt.c | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * Input Multitouch Library | ||
3 | * | ||
4 | * Copyright (c) 2008-2010 Henrik Rydberg | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License version 2 as published by | ||
8 | * the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/input/mt.h> | ||
12 | #include <linux/slab.h> | ||
13 | |||
14 | /** | ||
15 | * input_mt_create_slots() - create MT input slots | ||
16 | * @dev: input device supporting MT events and finger tracking | ||
17 | * @num_slots: number of slots used by the device | ||
18 | * | ||
19 | * This function allocates all necessary memory for MT slot handling in the | ||
20 | * input device, and adds ABS_MT_SLOT to the device capabilities. All slots | ||
21 | * are initially marked as unused by setting ABS_MT_TRACKING_ID to -1. | ||
22 | */ | ||
23 | int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots) | ||
24 | { | ||
25 | int i; | ||
26 | |||
27 | if (!num_slots) | ||
28 | return 0; | ||
29 | |||
30 | dev->mt = kcalloc(num_slots, sizeof(struct input_mt_slot), GFP_KERNEL); | ||
31 | if (!dev->mt) | ||
32 | return -ENOMEM; | ||
33 | |||
34 | dev->mtsize = num_slots; | ||
35 | input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0); | ||
36 | |||
37 | /* Mark slots as 'unused' */ | ||
38 | for (i = 0; i < num_slots; i++) | ||
39 | input_mt_set_value(&dev->mt[i], ABS_MT_TRACKING_ID, -1); | ||
40 | |||
41 | return 0; | ||
42 | } | ||
43 | EXPORT_SYMBOL(input_mt_create_slots); | ||
44 | |||
45 | /** | ||
46 | * input_mt_destroy_slots() - frees the MT slots of the input device | ||
47 | * @dev: input device with allocated MT slots | ||
48 | * | ||
49 | * This function is only needed in error path as the input core will | ||
50 | * automatically free the MT slots when the device is destroyed. | ||
51 | */ | ||
52 | void input_mt_destroy_slots(struct input_dev *dev) | ||
53 | { | ||
54 | kfree(dev->mt); | ||
55 | dev->mt = NULL; | ||
56 | dev->mtsize = 0; | ||
57 | } | ||
58 | EXPORT_SYMBOL(input_mt_destroy_slots); | ||
diff --git a/drivers/input/input.c b/drivers/input/input.c index d092ef9291da..37708d1d86ec 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -12,7 +12,7 @@ | |||
12 | 12 | ||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | #include <linux/input.h> | 15 | #include <linux/input/mt.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/random.h> | 18 | #include <linux/random.h> |
@@ -1691,52 +1691,6 @@ void input_free_device(struct input_dev *dev) | |||
1691 | EXPORT_SYMBOL(input_free_device); | 1691 | EXPORT_SYMBOL(input_free_device); |
1692 | 1692 | ||
1693 | /** | 1693 | /** |
1694 | * input_mt_create_slots() - create MT input slots | ||
1695 | * @dev: input device supporting MT events and finger tracking | ||
1696 | * @num_slots: number of slots used by the device | ||
1697 | * | ||
1698 | * This function allocates all necessary memory for MT slot handling in the | ||
1699 | * input device, and adds ABS_MT_SLOT to the device capabilities. All slots | ||
1700 | * are initially marked as unused by setting ABS_MT_TRACKING_ID to -1. | ||
1701 | */ | ||
1702 | int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots) | ||
1703 | { | ||
1704 | int i; | ||
1705 | |||
1706 | if (!num_slots) | ||
1707 | return 0; | ||
1708 | |||
1709 | dev->mt = kcalloc(num_slots, sizeof(struct input_mt_slot), GFP_KERNEL); | ||
1710 | if (!dev->mt) | ||
1711 | return -ENOMEM; | ||
1712 | |||
1713 | dev->mtsize = num_slots; | ||
1714 | input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0); | ||
1715 | |||
1716 | /* Mark slots as 'unused' */ | ||
1717 | for (i = 0; i < num_slots; i++) | ||
1718 | dev->mt[i].abs[ABS_MT_TRACKING_ID - ABS_MT_FIRST] = -1; | ||
1719 | |||
1720 | return 0; | ||
1721 | } | ||
1722 | EXPORT_SYMBOL(input_mt_create_slots); | ||
1723 | |||
1724 | /** | ||
1725 | * input_mt_destroy_slots() - frees the MT slots of the input device | ||
1726 | * @dev: input device with allocated MT slots | ||
1727 | * | ||
1728 | * This function is only needed in error path as the input core will | ||
1729 | * automatically free the MT slots when the device is destroyed. | ||
1730 | */ | ||
1731 | void input_mt_destroy_slots(struct input_dev *dev) | ||
1732 | { | ||
1733 | kfree(dev->mt); | ||
1734 | dev->mt = NULL; | ||
1735 | dev->mtsize = 0; | ||
1736 | } | ||
1737 | EXPORT_SYMBOL(input_mt_destroy_slots); | ||
1738 | |||
1739 | /** | ||
1740 | * input_set_capability - mark device as capable of a certain event | 1694 | * input_set_capability - mark device as capable of a certain event |
1741 | * @dev: device that is capable of emitting or accepting event | 1695 | * @dev: device that is capable of emitting or accepting event |
1742 | * @type: type of the event (EV_KEY, EV_REL, etc...) | 1696 | * @type: type of the event (EV_KEY, EV_REL, etc...) |
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index b9410784e6a1..8f374143190e 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/fs.h> | 37 | #include <linux/fs.h> |
38 | #include <linux/miscdevice.h> | 38 | #include <linux/miscdevice.h> |
39 | #include <linux/uinput.h> | 39 | #include <linux/uinput.h> |
40 | #include <linux/input/mt.h> | ||
40 | #include "../input-compat.h" | 41 | #include "../input-compat.h" |
41 | 42 | ||
42 | static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 43 | static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index b3252ef1e279..bde612c6d36d 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | #include "wacom_wac.h" | 15 | #include "wacom_wac.h" |
16 | #include "wacom.h" | 16 | #include "wacom.h" |
17 | #include <linux/input/mt.h> | ||
17 | 18 | ||
18 | static int wacom_penpartner_irq(struct wacom_wac *wacom) | 19 | static int wacom_penpartner_irq(struct wacom_wac *wacom) |
19 | { | 20 | { |
diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index 9ae4c7b16ba7..5d4f50e52a28 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/input.h> | 18 | #include <linux/input/mt.h> |
19 | #include <linux/serio.h> | 19 | #include <linux/serio.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/ctype.h> | 21 | #include <linux/ctype.h> |
diff --git a/include/linux/input.h b/include/linux/input.h index 51af441f3a21..99e2a52c0509 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
@@ -1083,14 +1083,6 @@ struct ff_effect { | |||
1083 | #include <linux/mod_devicetable.h> | 1083 | #include <linux/mod_devicetable.h> |
1084 | 1084 | ||
1085 | /** | 1085 | /** |
1086 | * struct input_mt_slot - represents the state of an input MT slot | ||
1087 | * @abs: holds current values of ABS_MT axes for this slot | ||
1088 | */ | ||
1089 | struct input_mt_slot { | ||
1090 | int abs[ABS_MT_LAST - ABS_MT_FIRST + 1]; | ||
1091 | }; | ||
1092 | |||
1093 | /** | ||
1094 | * struct input_dev - represents an input device | 1086 | * struct input_dev - represents an input device |
1095 | * @name: name of the device | 1087 | * @name: name of the device |
1096 | * @phys: physical path to the device in the system hierarchy | 1088 | * @phys: physical path to the device in the system hierarchy |
@@ -1461,11 +1453,6 @@ static inline void input_mt_sync(struct input_dev *dev) | |||
1461 | input_event(dev, EV_SYN, SYN_MT_REPORT, 0); | 1453 | input_event(dev, EV_SYN, SYN_MT_REPORT, 0); |
1462 | } | 1454 | } |
1463 | 1455 | ||
1464 | static inline void input_mt_slot(struct input_dev *dev, int slot) | ||
1465 | { | ||
1466 | input_event(dev, EV_ABS, ABS_MT_SLOT, slot); | ||
1467 | } | ||
1468 | |||
1469 | void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code); | 1456 | void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code); |
1470 | 1457 | ||
1471 | /** | 1458 | /** |
@@ -1578,8 +1565,5 @@ int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file); | |||
1578 | int input_ff_create_memless(struct input_dev *dev, void *data, | 1565 | int input_ff_create_memless(struct input_dev *dev, void *data, |
1579 | int (*play_effect)(struct input_dev *, void *, struct ff_effect *)); | 1566 | int (*play_effect)(struct input_dev *, void *, struct ff_effect *)); |
1580 | 1567 | ||
1581 | int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots); | ||
1582 | void input_mt_destroy_slots(struct input_dev *dev); | ||
1583 | |||
1584 | #endif | 1568 | #endif |
1585 | #endif | 1569 | #endif |
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h new file mode 100644 index 000000000000..4f5e9d0e2eae --- /dev/null +++ b/include/linux/input/mt.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef _INPUT_MT_H | ||
2 | #define _INPUT_MT_H | ||
3 | |||
4 | /* | ||
5 | * Input Multitouch Library | ||
6 | * | ||
7 | * Copyright (c) 2010 Henrik Rydberg | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License version 2 as published by | ||
11 | * the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/input.h> | ||
15 | |||
16 | /** | ||
17 | * struct input_mt_slot - represents the state of an input MT slot | ||
18 | * @abs: holds current values of ABS_MT axes for this slot | ||
19 | */ | ||
20 | struct input_mt_slot { | ||
21 | int abs[ABS_MT_LAST - ABS_MT_FIRST + 1]; | ||
22 | }; | ||
23 | |||
24 | static inline void input_mt_set_value(struct input_mt_slot *slot, | ||
25 | unsigned code, int value) | ||
26 | { | ||
27 | slot->abs[code - ABS_MT_FIRST] = value; | ||
28 | } | ||
29 | |||
30 | static inline int input_mt_get_value(const struct input_mt_slot *slot, | ||
31 | unsigned code) | ||
32 | { | ||
33 | return slot->abs[code - ABS_MT_FIRST]; | ||
34 | } | ||
35 | |||
36 | int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots); | ||
37 | void input_mt_destroy_slots(struct input_dev *dev); | ||
38 | |||
39 | static inline void input_mt_slot(struct input_dev *dev, int slot) | ||
40 | { | ||
41 | input_event(dev, EV_ABS, ABS_MT_SLOT, slot); | ||
42 | } | ||
43 | |||
44 | #endif | ||