Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rydberg/input...
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 16 Dec 2010 17:17:48 +0000 (09:17 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 16 Dec 2010 17:17:48 +0000 (09:17 -0800)
Conflicts:
drivers/input/Makefile

1  2 
drivers/input/Makefile
drivers/input/input.c
include/linux/input.h

diff --combined drivers/input/Makefile
index 9fd1cf2b705e6a07460002ac5ac5d6593b92e954,569938b3cc040ab6ab7db4a52441041777b7b23a..09614ce74961bccded0b02ecd29815f3947533a1
@@@ -5,7 -5,7 +5,7 @@@
  # Each configuration option enables a list of files.
  
  obj-$(CONFIG_INPUT)           += input-core.o
- input-core-y := input.o input-compat.o ff-core.o
 -input-core-objs := input.o input-compat.o ff-core.o input-mt.o
++input-core-y := input.o input-compat.o input-mt.o ff-core.o
  
  obj-$(CONFIG_INPUT_FF_MEMLESS)        += ff-memless.o
  obj-$(CONFIG_INPUT_POLLDEV)   += input-polldev.o
diff --combined drivers/input/input.c
index c7a1e826c58093932ab709a988e3d9e861c06684,37708d1d86ec2e518f35959b64d42ff7a67411a8..3312e20016bfa84ef1d7bea4b26070c63f62807c
   * the Free Software Foundation.
   */
  
 +#define pr_fmt(fmt) KBUILD_BASENAME ": " fmt
 +
  #include <linux/init.h>
  #include <linux/types.h>
- #include <linux/input.h>
+ #include <linux/input/mt.h>
  #include <linux/module.h>
  #include <linux/slab.h>
  #include <linux/random.h>
@@@ -76,7 -74,6 +76,7 @@@ static int input_defuzz_abs_event(int v
   * dev->event_lock held and interrupts disabled.
   */
  static void input_pass_event(struct input_dev *dev,
 +                           struct input_handler *src_handler,
                             unsigned int type, unsigned int code, int value)
  {
        struct input_handler *handler;
                                continue;
  
                        handler = handle->handler;
 +
 +                      /*
 +                       * If this is the handler that injected this
 +                       * particular event we want to skip it to avoid
 +                       * filters firing again and again.
 +                       */
 +                      if (handler == src_handler)
 +                              continue;
 +
                        if (!handler->filter) {
                                if (filtered)
                                        break;
@@@ -133,7 -121,7 +133,7 @@@ static void input_repeat_key(unsigned l
        if (test_bit(dev->repeat_key, dev->key) &&
            is_event_supported(dev->repeat_key, dev->keybit, KEY_MAX)) {
  
 -              input_pass_event(dev, EV_KEY, dev->repeat_key, 2);
 +              input_pass_event(dev, NULL, EV_KEY, dev->repeat_key, 2);
  
                if (dev->sync) {
                        /*
                         * Otherwise assume that the driver will send
                         * SYN_REPORT once it's done.
                         */
 -                      input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
 +                      input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1);
                }
  
                if (dev->rep[REP_PERIOD])
@@@ -175,7 -163,6 +175,7 @@@ static void input_stop_autorepeat(struc
  #define INPUT_PASS_TO_ALL     (INPUT_PASS_TO_HANDLERS | INPUT_PASS_TO_DEVICE)
  
  static int input_handle_abs_event(struct input_dev *dev,
 +                                struct input_handler *src_handler,
                                  unsigned int code, int *pval)
  {
        bool is_mt_event;
        /* Flush pending "slot" event */
        if (is_mt_event && dev->slot != input_abs_get_val(dev, ABS_MT_SLOT)) {
                input_abs_set_val(dev, ABS_MT_SLOT, dev->slot);
 -              input_pass_event(dev, EV_ABS, ABS_MT_SLOT, dev->slot);
 +              input_pass_event(dev, src_handler,
 +                               EV_ABS, ABS_MT_SLOT, dev->slot);
        }
  
        return INPUT_PASS_TO_HANDLERS;
  }
  
  static void input_handle_event(struct input_dev *dev,
 +                             struct input_handler *src_handler,
                               unsigned int type, unsigned int code, int value)
  {
        int disposition = INPUT_IGNORE_EVENT;
  
        case EV_ABS:
                if (is_event_supported(code, dev->absbit, ABS_MAX))
 -                      disposition = input_handle_abs_event(dev, code, &value);
 +                      disposition = input_handle_abs_event(dev, src_handler,
 +                                                           code, &value);
  
                break;
  
                dev->event(dev, type, code, value);
  
        if (disposition & INPUT_PASS_TO_HANDLERS)
 -              input_pass_event(dev, type, code, value);
 +              input_pass_event(dev, src_handler, type, code, value);
  }
  
  /**
@@@ -368,7 -352,7 +368,7 @@@ void input_event(struct input_dev *dev
  
                spin_lock_irqsave(&dev->event_lock, flags);
                add_input_randomness(type, code, value);
 -              input_handle_event(dev, type, code, value);
 +              input_handle_event(dev, NULL, type, code, value);
                spin_unlock_irqrestore(&dev->event_lock, flags);
        }
  }
@@@ -398,8 -382,7 +398,8 @@@ void input_inject_event(struct input_ha
                rcu_read_lock();
                grab = rcu_dereference(dev->grab);
                if (!grab || grab == handle)
 -                      input_handle_event(dev, type, code, value);
 +                      input_handle_event(dev, handle->handler,
 +                                         type, code, value);
                rcu_read_unlock();
  
                spin_unlock_irqrestore(&dev->event_lock, flags);
@@@ -612,10 -595,10 +612,10 @@@ static void input_dev_release_keys(stru
                for (code = 0; code <= KEY_MAX; code++) {
                        if (is_event_supported(code, dev->keybit, KEY_MAX) &&
                            __test_and_clear_bit(code, dev->key)) {
 -                              input_pass_event(dev, EV_KEY, code, 0);
 +                              input_pass_event(dev, NULL, EV_KEY, code, 0);
                        }
                }
 -              input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
 +              input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1);
        }
  }
  
@@@ -890,9 -873,9 +890,9 @@@ int input_set_keycode(struct input_dev 
            !is_event_supported(old_keycode, dev->keybit, KEY_MAX) &&
            __test_and_clear_bit(old_keycode, dev->key)) {
  
 -              input_pass_event(dev, EV_KEY, old_keycode, 0);
 +              input_pass_event(dev, NULL, EV_KEY, old_keycode, 0);
                if (dev->sync)
 -                      input_pass_event(dev, EV_SYN, SYN_REPORT, 1);
 +                      input_pass_event(dev, NULL, EV_SYN, SYN_REPORT, 1);
        }
  
   out:
@@@ -961,8 -944,10 +961,8 @@@ static int input_attach_handler(struct 
  
        error = handler->connect(handler, dev, id);
        if (error && error != -ENODEV)
 -              printk(KERN_ERR
 -                      "input: failed to attach handler %s to device %s, "
 -                      "error: %d\n",
 -                      handler->name, kobject_name(&dev->dev.kobj), error);
 +              pr_err("failed to attach handler %s to device %s, error: %d\n",
 +                     handler->name, kobject_name(&dev->dev.kobj), error);
  
        return error;
  }
@@@ -1580,7 -1565,8 +1580,7 @@@ static int input_dev_uevent(struct devi
                }                                                       \
        } while (0)
  
 -#ifdef CONFIG_PM
 -static void input_dev_reset(struct input_dev *dev, bool activate)
 +static void input_dev_toggle(struct input_dev *dev, bool activate)
  {
        if (!dev->event)
                return;
        }
  }
  
 +/**
 + * input_reset_device() - reset/restore the state of input device
 + * @dev: input device whose state needs to be reset
 + *
 + * This function tries to reset the state of an opened input device and
 + * bring internal state and state if the hardware in sync with each other.
 + * We mark all keys as released, restore LED state, repeat rate, etc.
 + */
 +void input_reset_device(struct input_dev *dev)
 +{
 +      mutex_lock(&dev->mutex);
 +
 +      if (dev->users) {
 +              input_dev_toggle(dev, true);
 +
 +              /*
 +               * Keys that have been pressed at suspend time are unlikely
 +               * to be still pressed when we resume.
 +               */
 +              spin_lock_irq(&dev->event_lock);
 +              input_dev_release_keys(dev);
 +              spin_unlock_irq(&dev->event_lock);
 +      }
 +
 +      mutex_unlock(&dev->mutex);
 +}
 +EXPORT_SYMBOL(input_reset_device);
 +
 +#ifdef CONFIG_PM
  static int input_dev_suspend(struct device *dev)
  {
        struct input_dev *input_dev = to_input_dev(dev);
  
        mutex_lock(&input_dev->mutex);
 -      input_dev_reset(input_dev, false);
 +
 +      if (input_dev->users)
 +              input_dev_toggle(input_dev, false);
 +
        mutex_unlock(&input_dev->mutex);
  
        return 0;
@@@ -1641,7 -1595,18 +1641,7 @@@ static int input_dev_resume(struct devi
  {
        struct input_dev *input_dev = to_input_dev(dev);
  
 -      mutex_lock(&input_dev->mutex);
 -      input_dev_reset(input_dev, true);
 -
 -      /*
 -       * Keys that have been pressed at suspend time are unlikely
 -       * to be still pressed when we resume.
 -       */
 -      spin_lock_irq(&input_dev->event_lock);
 -      input_dev_release_keys(input_dev);
 -      spin_unlock_irq(&input_dev->event_lock);
 -
 -      mutex_unlock(&input_dev->mutex);
 +      input_reset_device(input_dev);
  
        return 0;
  }
@@@ -1725,52 -1690,6 +1725,6 @@@ void input_free_device(struct input_de
  }
  EXPORT_SYMBOL(input_free_device);
  
- /**
-  * input_mt_create_slots() - create MT input slots
-  * @dev: input device supporting MT events and finger tracking
-  * @num_slots: number of slots used by the device
-  *
-  * This function allocates all necessary memory for MT slot handling in the
-  * input device, and adds ABS_MT_SLOT to the device capabilities. All slots
-  * are initially marked as unused by setting ABS_MT_TRACKING_ID to -1.
-  */
- int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
- {
-       int i;
-       if (!num_slots)
-               return 0;
-       dev->mt = kcalloc(num_slots, sizeof(struct input_mt_slot), GFP_KERNEL);
-       if (!dev->mt)
-               return -ENOMEM;
-       dev->mtsize = num_slots;
-       input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0);
-       /* Mark slots as 'unused' */
-       for (i = 0; i < num_slots; i++)
-               dev->mt[i].abs[ABS_MT_TRACKING_ID - ABS_MT_FIRST] = -1;
-       return 0;
- }
- EXPORT_SYMBOL(input_mt_create_slots);
- /**
-  * input_mt_destroy_slots() - frees the MT slots of the input device
-  * @dev: input device with allocated MT slots
-  *
-  * This function is only needed in error path as the input core will
-  * automatically free the MT slots when the device is destroyed.
-  */
- void input_mt_destroy_slots(struct input_dev *dev)
- {
-       kfree(dev->mt);
-       dev->mt = NULL;
-       dev->mtsize = 0;
- }
- EXPORT_SYMBOL(input_mt_destroy_slots);
  /**
   * input_set_capability - mark device as capable of a certain event
   * @dev: device that is capable of emitting or accepting event
@@@ -1820,8 -1739,9 +1774,8 @@@ void input_set_capability(struct input_
                break;
  
        default:
 -              printk(KERN_ERR
 -                      "input_set_capability: unknown type %u (code %u)\n",
 -                      type, code);
 +              pr_err("input_set_capability: unknown type %u (code %u)\n",
 +                     type, code);
                dump_stack();
                return;
        }
@@@ -1903,9 -1823,8 +1857,9 @@@ int input_register_device(struct input_
                return error;
  
        path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
 -      printk(KERN_INFO "input: %s as %s\n",
 -              dev->name ? dev->name : "Unspecified device", path ? path : "N/A");
 +      pr_info("%s as %s\n",
 +              dev->name ? dev->name : "Unspecified device",
 +              path ? path : "N/A");
        kfree(path);
  
        error = mutex_lock_interruptible(&input_mutex);
@@@ -2187,7 -2106,7 +2141,7 @@@ static int __init input_init(void
  
        err = class_register(&input_class);
        if (err) {
 -              printk(KERN_ERR "input: unable to register input_dev class\n");
 +              pr_err("unable to register input_dev class\n");
                return err;
        }
  
  
        err = register_chrdev(INPUT_MAJOR, "input", &input_fops);
        if (err) {
 -              printk(KERN_ERR "input: unable to register char major %d", INPUT_MAJOR);
 +              pr_err("unable to register char major %d", INPUT_MAJOR);
                goto fail2;
        }
  
diff --combined include/linux/input.h
index 6ef44465db8ddc31c41be1de00eeef38c53b5fa5,b3a1e02080c0ba041383145faf9869e1c433dc7a..53f873e8556cf9336fe5066fae133186238ae804
@@@ -733,11 -733,12 +733,12 @@@ struct input_keymap_entry 
  #define ABS_MT_BLOB_ID                0x38    /* Group a set of packets as a blob */
  #define ABS_MT_TRACKING_ID    0x39    /* Unique ID of initiated contact */
  #define ABS_MT_PRESSURE               0x3a    /* Pressure on contact area */
+ #define ABS_MT_DISTANCE               0x3b    /* Contact hover distance */
  
  #ifdef __KERNEL__
  /* Implementation details, userspace should not care about these */
  #define ABS_MT_FIRST          ABS_MT_TOUCH_MAJOR
- #define ABS_MT_LAST           ABS_MT_PRESSURE
+ #define ABS_MT_LAST           ABS_MT_DISTANCE
  #endif
  
  #define ABS_MAX                       0x3f
   */
  #define MT_TOOL_FINGER                0
  #define MT_TOOL_PEN           1
+ #define MT_TOOL_MAX           1
  
  /*
   * Values describing the status of a force-feedback effect
@@@ -1082,14 -1084,6 +1084,6 @@@ struct ff_effect 
  #include <linux/timer.h>
  #include <linux/mod_devicetable.h>
  
- /**
-  * struct input_mt_slot - represents the state of an input MT slot
-  * @abs: holds current values of ABS_MT axes for this slot
-  */
- struct input_mt_slot {
-       int abs[ABS_MT_LAST - ABS_MT_FIRST + 1];
- };
  /**
   * struct input_dev - represents an input device
   * @name: name of the device
   *    of tracked contacts
   * @mtsize: number of MT slots the device uses
   * @slot: MT slot currently being transmitted
+  * @trkid: stores MT tracking ID for the current contact
   * @absinfo: array of &struct absinfo elements holding information
   *    about absolute axes (current value, min, max, flat, fuzz,
   *    resolution)
@@@ -1214,6 -1209,7 +1209,7 @@@ struct input_dev 
        struct input_mt_slot *mt;
        int mtsize;
        int slot;
+       int trkid;
  
        struct input_absinfo *absinfo;
  
@@@ -1406,8 -1402,6 +1402,8 @@@ static inline void input_set_drvdata(st
  int __must_check input_register_device(struct input_dev *);
  void input_unregister_device(struct input_dev *);
  
 +void input_reset_device(struct input_dev *);
 +
  int __must_check input_register_handler(struct input_handler *);
  void input_unregister_handler(struct input_handler *);
  
@@@ -1423,7 -1417,7 +1419,7 @@@ void input_release_device(struct input_
  int input_open_device(struct input_handle *);
  void input_close_device(struct input_handle *);
  
 -int input_flush_device(struct input_handle* handle, struct file* file);
 +int input_flush_device(struct input_handle *handle, struct file *file);
  
  void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
  void input_inject_event(struct input_handle *handle, unsigned int type, unsigned int code, int value);
@@@ -1463,11 -1457,6 +1459,6 @@@ static inline void input_mt_sync(struc
        input_event(dev, EV_SYN, SYN_MT_REPORT, 0);
  }
  
- static inline void input_mt_slot(struct input_dev *dev, int slot)
- {
-       input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
- }
  void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code);
  
  /**
@@@ -1580,8 -1569,5 +1571,5 @@@ int input_ff_erase(struct input_dev *de
  int input_ff_create_memless(struct input_dev *dev, void *data,
                int (*play_effect)(struct input_dev *, void *, struct ff_effect *));
  
- int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots);
- void input_mt_destroy_slots(struct input_dev *dev);
  #endif
  #endif