diff options
Diffstat (limited to 'drivers/input/input.c')
| -rw-r--r-- | drivers/input/input.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index d6e8bd8a851c..ebbceedc92f4 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
| @@ -1746,6 +1746,42 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int | |||
| 1746 | } | 1746 | } |
| 1747 | EXPORT_SYMBOL(input_set_capability); | 1747 | EXPORT_SYMBOL(input_set_capability); |
| 1748 | 1748 | ||
| 1749 | static unsigned int input_estimate_events_per_packet(struct input_dev *dev) | ||
| 1750 | { | ||
| 1751 | int mt_slots; | ||
| 1752 | int i; | ||
| 1753 | unsigned int events; | ||
| 1754 | |||
| 1755 | if (dev->mtsize) { | ||
| 1756 | mt_slots = dev->mtsize; | ||
| 1757 | } else if (test_bit(ABS_MT_TRACKING_ID, dev->absbit)) { | ||
| 1758 | mt_slots = dev->absinfo[ABS_MT_TRACKING_ID].maximum - | ||
| 1759 | dev->absinfo[ABS_MT_TRACKING_ID].minimum + 1, | ||
| 1760 | clamp(mt_slots, 2, 32); | ||
| 1761 | } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) { | ||
| 1762 | mt_slots = 2; | ||
| 1763 | } else { | ||
| 1764 | mt_slots = 0; | ||
| 1765 | } | ||
| 1766 | |||
| 1767 | events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */ | ||
| 1768 | |||
| 1769 | for (i = 0; i < ABS_CNT; i++) { | ||
| 1770 | if (test_bit(i, dev->absbit)) { | ||
| 1771 | if (input_is_mt_axis(i)) | ||
| 1772 | events += mt_slots; | ||
| 1773 | else | ||
| 1774 | events++; | ||
| 1775 | } | ||
| 1776 | } | ||
| 1777 | |||
| 1778 | for (i = 0; i < REL_CNT; i++) | ||
| 1779 | if (test_bit(i, dev->relbit)) | ||
| 1780 | events++; | ||
| 1781 | |||
| 1782 | return events; | ||
| 1783 | } | ||
| 1784 | |||
| 1749 | #define INPUT_CLEANSE_BITMASK(dev, type, bits) \ | 1785 | #define INPUT_CLEANSE_BITMASK(dev, type, bits) \ |
| 1750 | do { \ | 1786 | do { \ |
| 1751 | if (!test_bit(EV_##type, dev->evbit)) \ | 1787 | if (!test_bit(EV_##type, dev->evbit)) \ |
| @@ -1793,6 +1829,10 @@ int input_register_device(struct input_dev *dev) | |||
| 1793 | /* Make sure that bitmasks not mentioned in dev->evbit are clean. */ | 1829 | /* Make sure that bitmasks not mentioned in dev->evbit are clean. */ |
| 1794 | input_cleanse_bitmasks(dev); | 1830 | input_cleanse_bitmasks(dev); |
| 1795 | 1831 | ||
| 1832 | if (!dev->hint_events_per_packet) | ||
| 1833 | dev->hint_events_per_packet = | ||
| 1834 | input_estimate_events_per_packet(dev); | ||
| 1835 | |||
| 1796 | /* | 1836 | /* |
| 1797 | * If delay and period are pre-set by the driver, then autorepeating | 1837 | * If delay and period are pre-set by the driver, then autorepeating |
| 1798 | * is handled by the driver itself and we don't do it in input.c. | 1838 | * is handled by the driver itself and we don't do it in input.c. |
