aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-11-27 03:16:48 -0500
committerHenrik Rydberg <rydberg@euromail.se>2010-12-16 04:39:57 -0500
commit47c78e891323513e9909729b44033e2c6649e2b7 (patch)
tree828e0da90418a890653ef2f0af3cf81714fe5c80 /drivers/input
parentc8ddb2713c624f432fa5fe3c7ecffcdda46ea0d4 (diff)
input: mt: Break out slots handling
In preparation for common code to handle a larger set of MT slots devices, move the slots handling over to a separate file. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/Makefile2
-rw-r--r--drivers/input/input-mt.c58
-rw-r--r--drivers/input/input.c48
-rw-r--r--drivers/input/misc/uinput.c1
-rw-r--r--drivers/input/tablet/wacom_wac.c1
-rw-r--r--drivers/input/touchscreen/wacom_w8001.c2
6 files changed, 63 insertions, 49 deletions
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
7obj-$(CONFIG_INPUT) += input-core.o 7obj-$(CONFIG_INPUT) += input-core.o
8input-core-objs := input.o input-compat.o ff-core.o 8input-core-objs := input.o input-compat.o ff-core.o input-mt.o
9 9
10obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o 10obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o
11obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o 11obj-$(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 */
23int 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}
43EXPORT_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 */
52void input_mt_destroy_slots(struct input_dev *dev)
53{
54 kfree(dev->mt);
55 dev->mt = NULL;
56 dev->mtsize = 0;
57}
58EXPORT_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)
1691EXPORT_SYMBOL(input_free_device); 1691EXPORT_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 */
1702int 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}
1722EXPORT_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 */
1731void input_mt_destroy_slots(struct input_dev *dev)
1732{
1733 kfree(dev->mt);
1734 dev->mt = NULL;
1735 dev->mtsize = 0;
1736}
1737EXPORT_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
42static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 43static 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
18static int wacom_penpartner_irq(struct wacom_wac *wacom) 19static 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>