Commit 80b4895a authored by Jeff Brown's avatar Jeff Brown Committed by Dmitry Torokhov

Input: estimate number of events per packet

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: default avatarJeff Brown <jeffbrown@android.com>
Reviewed-by: default avatarHenrik Rydberg <rydberg@euromail.se>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 9fb0f14e
...@@ -1746,6 +1746,42 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int ...@@ -1746,6 +1746,42 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
} }
EXPORT_SYMBOL(input_set_capability); EXPORT_SYMBOL(input_set_capability);
static unsigned int input_estimate_events_per_packet(struct input_dev *dev)
{
int mt_slots;
int i;
unsigned int events;
if (dev->mtsize) {
mt_slots = dev->mtsize;
} else if (test_bit(ABS_MT_TRACKING_ID, dev->absbit)) {
mt_slots = dev->absinfo[ABS_MT_TRACKING_ID].maximum -
dev->absinfo[ABS_MT_TRACKING_ID].minimum + 1,
clamp(mt_slots, 2, 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 (input_is_mt_axis(i))
events += mt_slots;
else
events++;
}
}
for (i = 0; i < REL_CNT; i++)
if (test_bit(i, dev->relbit))
events++;
return events;
}
#define INPUT_CLEANSE_BITMASK(dev, type, bits) \ #define INPUT_CLEANSE_BITMASK(dev, type, bits) \
do { \ do { \
if (!test_bit(EV_##type, dev->evbit)) \ if (!test_bit(EV_##type, dev->evbit)) \
...@@ -1793,6 +1829,10 @@ int input_register_device(struct input_dev *dev) ...@@ -1793,6 +1829,10 @@ int input_register_device(struct input_dev *dev)
/* Make sure that bitmasks not mentioned in dev->evbit are clean. */ /* Make sure that bitmasks not mentioned in dev->evbit are clean. */
input_cleanse_bitmasks(dev); input_cleanse_bitmasks(dev);
if (!dev->hint_events_per_packet)
dev->hint_events_per_packet =
input_estimate_events_per_packet(dev);
/* /*
* If delay and period are pre-set by the driver, then autorepeating * If delay and period are pre-set by the driver, then autorepeating
* is handled by the driver itself and we don't do it in input.c. * is handled by the driver itself and we don't do it in input.c.
......
...@@ -48,6 +48,12 @@ static inline void input_mt_slot(struct input_dev *dev, int slot) ...@@ -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); input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
} }
static inline bool input_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, void input_mt_report_slot_state(struct input_dev *dev,
unsigned int tool_type, bool active); unsigned int tool_type, bool active);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment