~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/input/input.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
218
218
{
219
219
        int disposition = INPUT_IGNORE_EVENT;
220
220
 
221
 
        trace_mark(input, input_event,
222
 
                   "type %u code %u value %d", type, code, value);
223
 
 
224
221
        switch (type) {
225
222
 
226
223
        case EV_SYN:
454
451
        }
455
452
 
456
453
        rcu_assign_pointer(dev->grab, handle);
457
 
        synchronize_rcu();
458
454
 
459
455
 out:
460
456
        mutex_unlock(&dev->mutex);
794
790
        int retval;
795
791
 
796
792
        spin_lock_irqsave(&dev->event_lock, flags);
797
 
 
798
 
        if (dev->getkeycode) {
799
 
                /*
800
 
                 * Support for legacy drivers, that don't implement the new
801
 
                 * ioctls
802
 
                 */
803
 
                u32 scancode = ke->index;
804
 
 
805
 
                memcpy(ke->scancode, &scancode, sizeof(scancode));
806
 
                ke->len = sizeof(scancode);
807
 
                retval = dev->getkeycode(dev, scancode, &ke->keycode);
808
 
        } else {
809
 
                retval = dev->getkeycode_new(dev, ke);
810
 
        }
811
 
 
 
793
        retval = dev->getkeycode(dev, ke);
812
794
        spin_unlock_irqrestore(&dev->event_lock, flags);
 
795
 
813
796
        return retval;
814
797
}
815
798
EXPORT_SYMBOL(input_get_keycode);
834
817
 
835
818
        spin_lock_irqsave(&dev->event_lock, flags);
836
819
 
837
 
        if (dev->setkeycode) {
838
 
                /*
839
 
                 * Support for legacy drivers, that don't implement the new
840
 
                 * ioctls
841
 
                 */
842
 
                unsigned int scancode;
843
 
 
844
 
                retval = input_scancode_to_scalar(ke, &scancode);
845
 
                if (retval)
846
 
                        goto out;
847
 
 
848
 
                /*
849
 
                 * We need to know the old scancode, in order to generate a
850
 
                 * keyup effect, if the set operation happens successfully
851
 
                 */
852
 
                if (!dev->getkeycode) {
853
 
                        retval = -EINVAL;
854
 
                        goto out;
855
 
                }
856
 
 
857
 
                retval = dev->getkeycode(dev, scancode, &old_keycode);
858
 
                if (retval)
859
 
                        goto out;
860
 
 
861
 
                retval = dev->setkeycode(dev, scancode, ke->keycode);
862
 
        } else {
863
 
                retval = dev->setkeycode_new(dev, ke, &old_keycode);
864
 
        }
865
 
 
 
820
        retval = dev->setkeycode(dev, ke, &old_keycode);
866
821
        if (retval)
867
822
                goto out;
868
823
 
1790
1745
}
1791
1746
EXPORT_SYMBOL(input_set_capability);
1792
1747
 
 
1748
static unsigned int input_estimate_events_per_packet(struct input_dev *dev)
 
1749
{
 
1750
        int mt_slots;
 
1751
        int i;
 
1752
        unsigned int events;
 
1753
 
 
1754
        if (dev->mtsize) {
 
1755
                mt_slots = dev->mtsize;
 
1756
        } else if (test_bit(ABS_MT_TRACKING_ID, dev->absbit)) {
 
1757
                mt_slots = dev->absinfo[ABS_MT_TRACKING_ID].maximum -
 
1758
                           dev->absinfo[ABS_MT_TRACKING_ID].minimum + 1,
 
1759
                mt_slots = clamp(mt_slots, 2, 32);
 
1760
        } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) {
 
1761
                mt_slots = 2;
 
1762
        } else {
 
1763
                mt_slots = 0;
 
1764
        }
 
1765
 
 
1766
        events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */
 
1767
 
 
1768
        for (i = 0; i < ABS_CNT; i++) {
 
1769
                if (test_bit(i, dev->absbit)) {
 
1770
                        if (input_is_mt_axis(i))
 
1771
                                events += mt_slots;
 
1772
                        else
 
1773
                                events++;
 
1774
                }
 
1775
        }
 
1776
 
 
1777
        for (i = 0; i < REL_CNT; i++)
 
1778
                if (test_bit(i, dev->relbit))
 
1779
                        events++;
 
1780
 
 
1781
        return events;
 
1782
}
 
1783
 
1793
1784
#define INPUT_CLEANSE_BITMASK(dev, type, bits)                          \
1794
1785
        do {                                                            \
1795
1786
                if (!test_bit(EV_##type, dev->evbit))                   \
1837
1828
        /* Make sure that bitmasks not mentioned in dev->evbit are clean. */
1838
1829
        input_cleanse_bitmasks(dev);
1839
1830
 
 
1831
        if (!dev->hint_events_per_packet)
 
1832
                dev->hint_events_per_packet =
 
1833
                                input_estimate_events_per_packet(dev);
 
1834
 
1840
1835
        /*
1841
1836
         * If delay and period are pre-set by the driver, then autorepeating
1842
1837
         * is handled by the driver itself and we don't do it in input.c.
1849
1844
                dev->rep[REP_PERIOD] = 33;
1850
1845
        }
1851
1846
 
1852
 
        if (!dev->getkeycode && !dev->getkeycode_new)
1853
 
                dev->getkeycode_new = input_default_getkeycode;
 
1847
        if (!dev->getkeycode)
 
1848
                dev->getkeycode = input_default_getkeycode;
1854
1849
 
1855
 
        if (!dev->setkeycode && !dev->setkeycode_new)
1856
 
                dev->setkeycode_new = input_default_setkeycode;
 
1850
        if (!dev->setkeycode)
 
1851
                dev->setkeycode = input_default_setkeycode;
1857
1852
 
1858
1853
        dev_set_name(&dev->dev, "input%ld",
1859
1854
                     (unsigned long) atomic_inc_return(&input_no) - 1);