linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] input: Set default events per packet.
@ 2011-04-02  6:54 Jeff Brown
  2011-04-02  6:54 ` [PATCH v2 2/4] hid: hid-input: Remove obsolete default events per packet setting Jeff Brown
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Jeff Brown @ 2011-04-02  6:54 UTC (permalink / raw)
  To: dmitry.torokhov, rydberg, djkurtz
  Cc: linux-input, linux-kernel, Jeff Brown, jeffbrown

From: Jeff Brown <jeffbrown@google.com>

Calculate a default based on the number of ABS axes, REL axes,
and MT slots for the device during input device registration.

Signed-off-by: jeffbrown@android.com
---
 drivers/input/input.c    |   40 ++++++++++++++++++++++++++++++++++++++++
 include/linux/input/mt.h |    6 ++++++
 2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index d6e8bd8..53fccee 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1746,6 +1746,43 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
 }
 EXPORT_SYMBOL(input_set_capability);
 
+static void input_set_default_events_per_packet(struct input_dev *dev)
+{
+	int mt_slots;
+	int i;
+	int events;
+
+	if (dev->hint_events_per_packet)
+		return;
+
+	if (dev->mtsize)
+		mt_slots = dev->mtsize;
+	else if (test_bit(ABS_MT_TRACKING_ID, dev->absbit))
+		mt_slots = min(dev->absinfo[ABS_MT_TRACKING_ID].maximum -
+			dev->absinfo[ABS_MT_TRACKING_ID].minimum + 1, 32);
+	else if (test_bit(ABS_MT_POSITION_X, dev->absbit))
+		mt_slots = 2;
+	else
+		mt_slots = 0;
+
+	events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */
+
+	for (i = 0; i < ABS_CNT; i++) {
+		if (test_bit(i, dev->absbit)) {
+			if (is_mt_axis(i))
+				events += mt_slots;
+			else
+				events++;
+		}
+	}
+
+	for (i = 0; i < REL_CNT; i++)
+		if (test_bit(i, dev->relbit))
+			events++;
+
+	input_set_events_per_packet(dev, events);
+}
+
 #define INPUT_CLEANSE_BITMASK(dev, type, bits)				\
 	do {								\
 		if (!test_bit(EV_##type, dev->evbit))			\
@@ -1784,6 +1821,9 @@ int input_register_device(struct input_dev *dev)
 	const char *path;
 	int error;
 
+	/* Use a larger default input buffer for MT devices */
+	input_set_default_events_per_packet(dev);
+
 	/* Every input device generates EV_SYN/SYN_REPORT events. */
 	__set_bit(EV_SYN, dev->evbit);
 
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
index b3ac06a..0ef2f87 100644
--- a/include/linux/input/mt.h
+++ b/include/linux/input/mt.h
@@ -48,6 +48,12 @@ static inline void input_mt_slot(struct input_dev *dev, int slot)
 	input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
 }
 
+static inline bool is_mt_axis(int axis)
+{
+	return axis == ABS_MT_SLOT ||
+		(axis >= ABS_MT_FIRST && axis <= ABS_MT_LAST);
+}
+
 void input_mt_report_slot_state(struct input_dev *dev,
 				unsigned int tool_type, bool active);
 
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-04-11 20:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-02  6:54 [PATCH v2 1/4] input: Set default events per packet Jeff Brown
2011-04-02  6:54 ` [PATCH v2 2/4] hid: hid-input: Remove obsolete default events per packet setting Jeff Brown
2011-04-05 12:20   ` Henrik Rydberg
2011-04-02  6:54 ` [PATCH v2 3/4] input: evdev: Indicate buffer overrun with SYN_DROPPED Jeff Brown
2011-04-04 21:33   ` Dmitry Torokhov
2011-04-04 21:52     ` Jeffrey Brown
2011-04-05 11:41     ` Henrik Rydberg
2011-04-02  6:54 ` [PATCH v2 4/4] input: evdev: Make device readable only when it contains a complete packet Jeff Brown
2011-04-04 21:36   ` Dmitry Torokhov
2011-04-04 22:16     ` Jeffrey Brown
2011-04-04 22:46       ` Dmitry Torokhov
2011-04-05  0:34         ` Jeffrey Brown
2011-04-05 12:03           ` Henrik Rydberg
2011-04-05 16:32             ` Dmitry Torokhov
2011-04-05 16:38           ` Dmitry Torokhov
2011-04-11 20:15             ` Jeffrey Brown
2011-04-05 12:16 ` [PATCH v2 1/4] input: Set default events per packet Henrik Rydberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).