projects/linux·commit c6cfaf4f

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

c6cfaf4f · Linus Torvalds <[email protected]> · 2019-09-19 14:10:54 -07:00

Pull input updates from Dmitry Torokhov:

 - input core allows hardware drivers to specify a [more precise]
   timestamp (normally taken in top half) to better track velocity of
   contacts

 - input_dev instances now support "polling" mode so that drivers could
   use the same object for polled and interrupt-driven operation. The
   plan is to convert existing drivers and retire input_polled_dev API

 - a new driver for the FlySky FS-iA6B RC receiver

 - a refresh of BU21013 touchpad driver

 - w90x900 keyboard and touchpad drivers are removed as the platform is
   gone

 - assorted fixes

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (45 commits)
  Input: sidewinder - make array seq static const, makes object smaller
  Input: reset device timestamp on sync
  Input: bu21013_ts - switch to using standard touchscreen properties
  Input: bu21013_ts - switch to using MT-B (slotted) protocol
  Input: bu21013_ts - fix suspend when wake source
  Input: bu21013_ts - use interrupt from I2C client
  Input: bu21013_ts - remove support for platform data
  Input: bu21013_ts - convert to using managed resources
  Input: bu21013_ts - remove useless comments
  Input: bu21013_ts - annotate supend/resume methods as __maybe_unused
  Input: bu21013_ts - rename some variables
  Input: bu21013_ts - convert to use GPIO descriptors
  ARM: ux500: improve BU21013 touchpad bindings
  Input: i8042 - enable wakeup on a stable struct device
  Input: soc_button_array - use platform_device_register_resndata()
  Input: psmouse - drop all unneeded functions from mouse headers
  Input: add support for polling to input devices
  Input: wacom_w8001 - allocate additional space for 'phys'
  Input: cros_ec_keyb - add back missing mask for event_type
  Input: remove dev_err() usage after platform_get_irq()
  ...
Commit
c6cfaf4f86d9d15e5541adb3bb899d0b80f89ec7
Parents
a9f8b38a · 08987822

Merge commit. Changes below are compared with the first parent: a9f8b38a.

Changes

92 files changed · +1236 −1551

FileStatusAddDelContent
Documentation/devicetree/bindings/input/touchscreen/ads7846.txtmodified+21−8View file
Documentation/devicetree/bindings/input/touchscreen/bu21013.txtmodified+21−6View file
MAINTAINERSmodified+6−0View file
drivers/input/Makefilemodified+1−1View file
drivers/input/evdev.cmodified+8−27View file
drivers/input/input-poller.cadded+213−0View file
drivers/input/input-poller.hadded+18−0View file
drivers/input/input.cmodified+76−7View file
drivers/input/joystick/Kconfigmodified+10−0View file
drivers/input/joystick/Makefilemodified+3−2View file
drivers/input/joystick/fsia6b.cadded+231−0View file
drivers/input/joystick/sidewinder.cmodified+1−1View file
drivers/input/keyboard/Kconfigmodified+0−11View file
drivers/input/keyboard/Makefilemodified+0−1View file
drivers/input/keyboard/applespi.cmodified+6−24View file
drivers/input/keyboard/bcm-keypad.cmodified+1−3View file
drivers/input/keyboard/cros_ec_keyb.cmodified+4−2View file
drivers/input/keyboard/davinci_keyscan.cmodified+0−1View file
drivers/input/keyboard/gpio_keys.cmodified+2−11View file
drivers/input/keyboard/imx_keypad.cmodified+1−3View file
drivers/input/keyboard/lpc32xx-keys.cmodified+1−3View file
drivers/input/keyboard/mpr121_touchkey.cmodified+1−2View file
drivers/input/keyboard/nomadik-ske-keypad.cmodified+1−3View file
drivers/input/keyboard/nspire-keypad.cmodified+1−3View file
drivers/input/keyboard/opencores-kbd.cmodified+1−3View file
drivers/input/keyboard/pmic8xxx-keypad.cmodified+2−6View file
drivers/input/keyboard/pxa27x_keypad.cmodified+1−3View file
drivers/input/keyboard/pxa930_rotary.cmodified+1−3View file
drivers/input/keyboard/sh_keysc.cmodified+1−3View file
drivers/input/keyboard/snvs_pwrkey.cmodified+1−3View file
drivers/input/keyboard/spear-keyboard.cmodified+1−3View file
drivers/input/keyboard/st-keyscan.cmodified+1−3View file
drivers/input/keyboard/tegra-kbc.cmodified+1−3View file
drivers/input/keyboard/w90p910_keypad.cdeleted+0−264View before deletion
drivers/input/matrix-keymap.cmodified+1−1View file
drivers/input/misc/88pm80x_onkey.cmodified+0−1View file
drivers/input/misc/88pm860x_onkey.cmodified+1−3View file
drivers/input/misc/Kconfigmodified+3−3View file
drivers/input/misc/ab8500-ponkey.cmodified+2−6View file
drivers/input/misc/axp20x-pek.cmodified+5−20View file
drivers/input/misc/da9055_onkey.cmodified+1−4View file
drivers/input/misc/da9063_onkey.cmodified+2−5View file
drivers/input/misc/e3x0-button.cmodified+2−8View file
drivers/input/misc/hisi_powerkey.cmodified+2−6View file
drivers/input/misc/max8925_onkey.cmodified+2−6View file
drivers/input/misc/pm8941-pwrkey.cmodified+1−3View file
drivers/input/misc/rk805-pwrkey.cmodified+2−6View file
drivers/input/misc/soc_button_array.cmodified+101−26View file
drivers/input/misc/stpmic1_onkey.cmodified+2−8View file
drivers/input/misc/tps65218-pwrbutton.cmodified+1−3View file
drivers/input/misc/twl6040-vibra.cmodified+1−3View file
drivers/input/mouse/alps.hmodified+0−11View file
drivers/input/mouse/byd.hmodified+0−11View file
drivers/input/mouse/cyapa.cmodified+1−15View file
drivers/input/mouse/cypress_ps2.hmodified+0−11View file
drivers/input/mouse/elan_i2c_core.cmodified+2−18View file
drivers/input/mouse/elantech.hmodified+2−16View file
drivers/input/mouse/hgpk.hmodified+3−10View file
drivers/input/mouse/lifebook.hmodified+3−10View file
drivers/input/mouse/logips2pp.hmodified+0−7View file
drivers/input/mouse/pxa930_trkball.cmodified+1−3View file
drivers/input/mouse/sentelic.hmodified+0−11View file
drivers/input/mouse/synaptics.cmodified+1−1View file
drivers/input/mouse/touchkit_ps2.hmodified+0−8View file
drivers/input/mouse/trackpoint.hmodified+0−8View file
drivers/input/mouse/vmmouse.hmodified+0−11View file
drivers/input/rmi4/rmi_2d_sensor.cmodified+0−1View file
drivers/input/serio/arc_ps2.cmodified+1−3View file
drivers/input/serio/i8042.cmodified+14−11View file
drivers/input/serio/ps2-gpio.cmodified+0−2View file
drivers/input/touchscreen/88pm860x-ts.cmodified+1−3View file
drivers/input/touchscreen/Kconfigmodified+0−9View file
drivers/input/touchscreen/Makefilemodified+0−1View file
drivers/input/touchscreen/ads7846.cmodified+30−8View file
drivers/input/touchscreen/atmel_mxt_ts.cmodified+1−2View file
drivers/input/touchscreen/bcm_iproc_tsc.cmodified+1−3View file
drivers/input/touchscreen/bu21013_ts.cmodified+321−419View file
drivers/input/touchscreen/edt-ft5x06.cmodified+0−2View file
drivers/input/touchscreen/fsl-imx25-tcq.cmodified+2−6View file
drivers/input/touchscreen/hideep.cmodified+1−2View file
drivers/input/touchscreen/imx6ul_tsc.cmodified+2−6View file
drivers/input/touchscreen/lpc32xx_ts.cmodified+1−3View file
drivers/input/touchscreen/mxs-lradc-ts.cmodified+3−7View file
drivers/input/touchscreen/sun4i-ts.cmodified+1−2View file
drivers/input/touchscreen/ts4800-ts.cmodified+1−3View file
drivers/input/touchscreen/w90p910_ts.cdeleted+0−331View before deletion
drivers/input/touchscreen/wacom_w8001.cmodified+3−1View file
drivers/platform/x86/surfacepro3_button.cmodified+47−0View file
include/linux/input.hmodified+26−0View file
include/linux/input/bu21013.hdeleted+0−34View before deletion
include/linux/platform_data/keypad-w90p910.hdeleted+0−16View before deletion
include/uapi/linux/serio.hmodified+1−0View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/devicetree/bindings/input/touchscreen/ads7846.txt

View file
diff --git a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
index 04413da..81f6bda 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
@@ -32,7 +32,6 @@ Optional properties:
(ADS7846).
ti,keep-vref-on set to keep vref on for differential
measurements as well
- ti,swap-xy swap x and y axis
ti,settle-delay-usec Settling time of the analog signals;
a function of Vcc and the capacitance
on the X/Y drivers. If set to non-zero,
@@ -51,13 +50,6 @@ Optional properties:
in Ohms (u16).
ti,x-min Minimum value on the X axis (u16).
ti,y-min Minimum value on the Y axis (u16).
- ti,x-max Maximum value on the X axis (u16).
- ti,y-max Minimum value on the Y axis (u16).
- ti,pressure-min Minimum reported pressure value
- (threshold) - u16.
- ti,pressure-max Maximum reported pressure value (u16).
- ti,debounce-max Max number of additional readings per
- sample (u16).
ti,debounce-tol Tolerance used for filtering (u16).
ti,debounce-rep Additional consecutive good readings
required after the first two (u16).
@@ -67,7 +59,28 @@ Optional properties:
line is connected to.
wakeup-source use any event on touchscreen as wakeup event.
(Legacy property support: "linux,wakeup")
+ touchscreen-size-x General touchscreen binding, see [1].
+ touchscreen-size-y General touchscreen binding, see [1].
+ touchscreen-max-pressure General touchscreen binding, see [1].
+ touchscreen-min-pressure General touchscreen binding, see [1].
+ touchscreen-average-samples General touchscreen binding, see [1].
+ touchscreen-inverted-x General touchscreen binding, see [1].
+ touchscreen-inverted-y General touchscreen binding, see [1].
+ touchscreen-swapped-x-y General touchscreen binding, see [1].
+
+[1] All general touchscreen properties are described in
+ Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt.
+Deprecated properties:
+
+ ti,swap-xy swap x and y axis
+ ti,x-max Maximum value on the X axis (u16).
+ ti,y-max Maximum value on the Y axis (u16).
+ ti,pressure-min Minimum reported pressure value
+ (threshold) - u16.
+ ti,pressure-max Maximum reported pressure value (u16).
+ ti,debounce-max Max number of additional readings per
+ sample (u16).
Example for a TSC2046 chip connected to an McSPI controller of an OMAP SoC::

Documentation/devicetree/bindings/input/touchscreen/bu21013.txt

View file
diff --git a/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt b/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt
index 56d8352..da4c9d8 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt
@@ -2,11 +2,24 @@
Required properties:
- compatible : "rohm,bu21013_tp"
- - reg : I2C device address
+ - reg : I2C device address
+ - reset-gpios : GPIO pin enabling (selecting) chip (CS)
+ - interrupt-parent : the phandle for the gpio controller
+ - interrupts : (gpio) interrupt to which the chip is connected
Optional properties:
- - touch-gpio : GPIO pin registering a touch event
+ - touch-gpios : GPIO pin registering a touch event
- <supply_name>-supply : Phandle to a regulator supply
+ - touchscreen-size-x : General touchscreen binding, see [1].
+ - touchscreen-size-y : General touchscreen binding, see [1].
+ - touchscreen-inverted-x : General touchscreen binding, see [1].
+ - touchscreen-inverted-y : General touchscreen binding, see [1].
+ - touchscreen-swapped-x-y : General touchscreen binding, see [1].
+
+[1] All general touchscreen properties are described in
+ Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt.
+
+Deprecated properties:
- rohm,touch-max-x : Maximum outward permitted limit in the X axis
- rohm,touch-max-y : Maximum outward permitted limit in the Y axis
- rohm,flip-x : Flip touch coordinates on the X axis
@@ -18,11 +31,13 @@ Example:
bu21013_tp@5c {
compatible = "rohm,bu21013_tp";
reg = <0x5c>;
- touch-gpio = <&gpio2 20 0x4>;
+ interrupt-parent = <&gpio2>;
+ interrupts <&20 IRQ_TYPE_LEVEL_LOW>;
+ touch-gpio = <&gpio2 20 GPIO_ACTIVE_LOW>;
avdd-supply = <&ab8500_ldo_aux1_reg>;
- rohm,touch-max-x = <384>;
- rohm,touch-max-y = <704>;
- rohm,flip-y;
+ touchscreen-size-x = <384>;
+ touchscreen-size-y = <704>;
+ touchscreen-inverted-y;
};
};

MAINTAINERS

View file
diff --git a/MAINTAINERS b/MAINTAINERS
index a6ae125..3e449fa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12742,6 +12742,12 @@ S: Maintained
F: Documentation/input/devices/pxrc.rst
F: drivers/input/joystick/pxrc.c
+FLYSKY FSIA6B RC RECEIVER
+M: Markus Koch <[email protected]>
+S: Maintained
+F: drivers/input/joystick/fsia6b.c
+
PHONET PROTOCOL
M: Remi Denis-Courmont <[email protected]>
S: Supported

drivers/input/Makefile

View file
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 40de6a7..e356509 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -6,7 +6,7 @@
# Each configuration option enables a list of files.
obj-$(CONFIG_INPUT) += input-core.o
-input-core-y := input.o input-compat.o input-mt.o ff-core.o
+input-core-y := input.o input-compat.o input-mt.o input-poller.o ff-core.o
obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o
obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o

drivers/input/evdev.c

View file
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 867c2cf..d7dd6fc 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -25,13 +25,6 @@
#include <linux/cdev.h>
#include "input-compat.h"
-enum evdev_clock_type {
- EV_CLK_REAL = 0,
- EV_CLK_MONO,
- EV_CLK_BOOT,
- EV_CLK_MAX
-};
-
struct evdev {
int open;
struct input_handle handle;
@@ -53,7 +46,7 @@ struct evdev_client {
struct fasync_struct *fasync;
struct evdev *evdev;
struct list_head node;
- unsigned int clk_type;
+ enum input_clock_type clk_type;
bool revoked;
unsigned long *evmasks[EV_CNT];
unsigned int bufsize;
@@ -149,17 +142,10 @@ static void __evdev_flush_queue(struct evdev_client *client, unsigned int type)
static void __evdev_queue_syn_dropped(struct evdev_client *client)
{
+ ktime_t *ev_time = input_get_timestamp(client->evdev->handle.dev);
+ struct timespec64 ts = ktime_to_timespec64(ev_time[client->clk_type]);
struct input_event ev;
- ktime_t time;
- struct timespec64 ts;
- time = client->clk_type == EV_CLK_REAL ?
- ktime_get_real() :
- client->clk_type == EV_CLK_MONO ?
- ktime_get() :
- ktime_get_boottime();
-
- ts = ktime_to_timespec64(time);
ev.input_event_sec = ts.tv_sec;
ev.input_event_usec = ts.tv_nsec / NSEC_PER_USEC;
ev.type = EV_SYN;
@@ -188,18 +174,18 @@ static void evdev_queue_syn_dropped(struct evdev_client *client)
static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
{
unsigned long flags;
- unsigned int clk_type;
+ enum input_clock_type clk_type;
switch (clkid) {
case CLOCK_REALTIME:
- clk_type = EV_CLK_REAL;
+ clk_type = INPUT_CLK_REAL;
break;
case CLOCK_MONOTONIC:
- clk_type = EV_CLK_MONO;
+ clk_type = INPUT_CLK_MONO;
break;
case CLOCK_BOOTTIME:
- clk_type = EV_CLK_BOOT;
+ clk_type = INPUT_CLK_BOOT;
break;
default:
return -EINVAL;
@@ -307,12 +293,7 @@ static void evdev_events(struct input_handle *handle,
{
struct evdev *evdev = handle->private;
struct evdev_client *client;
- ktime_t ev_time[EV_CLK_MAX];
-
- ev_time[EV_CLK_MONO] = ktime_get();
- ev_time[EV_CLK_REAL] = ktime_mono_to_real(ev_time[EV_CLK_MONO]);
- ev_time[EV_CLK_BOOT] = ktime_mono_to_any(ev_time[EV_CLK_MONO],
- TK_OFFS_BOOT);
+ ktime_t *ev_time = input_get_timestamp(handle->dev);
rcu_read_lock();

drivers/input/input-poller.c

View file
diff --git a/drivers/input/input-poller.c b/drivers/input/input-poller.c
new file mode 100644
index 0000000..1b3d289
--- /dev/null
+++ b/drivers/input/input-poller.c
@@ -0,0 +1,213 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Support for polling mode for input devices.
+ */
+
+#include <linux/device.h>
+#include <linux/input.h>
+#include <linux/jiffies.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/workqueue.h>
+#include "input-poller.h"
+
+struct input_dev_poller {
+ void (*poll)(struct input_dev *dev);
+
+ unsigned int poll_interval; /* msec */
+ unsigned int poll_interval_max; /* msec */
+ unsigned int poll_interval_min; /* msec */
+
+ struct input_dev *input;
+ struct delayed_work work;
+};
+
+static void input_dev_poller_queue_work(struct input_dev_poller *poller)
+{
+ unsigned long delay;
+
+ delay = msecs_to_jiffies(poller->poll_interval);
+ if (delay >= HZ)
+ delay = round_jiffies_relative(delay);
+
+ queue_delayed_work(system_freezable_wq, &poller->work, delay);
+}
+
+static void input_dev_poller_work(struct work_struct *work)
+{
+ struct input_dev_poller *poller =
+ container_of(work, struct input_dev_poller, work.work);
+
+ poller->poll(poller->input);
+ input_dev_poller_queue_work(poller);
+}
+
+void input_dev_poller_finalize(struct input_dev_poller *poller)
+{
+ if (!poller->poll_interval)
+ poller->poll_interval = 500;
+ if (!poller->poll_interval_max)
+ poller->poll_interval_max = poller->poll_interval;
+}
+
+void input_dev_poller_start(struct input_dev_poller *poller)
+{
+ /* Only start polling if polling is enabled */
+ if (poller->poll_interval > 0) {
+ poller->poll(poller->input);
+ input_dev_poller_queue_work(poller);
+ }
+}
+
+void input_dev_poller_stop(struct input_dev_poller *poller)
+{
+ cancel_delayed_work_sync(&poller->work);
+}
+
+int input_setup_polling(struct input_dev *dev,
+ void (*poll_fn)(struct input_dev *dev))
+{
+ struct input_dev_poller *poller;
+
+ poller = kzalloc(sizeof(*poller), GFP_KERNEL);
+ if (!poller) {
+ /*
+ * We want to show message even though kzalloc() may have
+ * printed backtrace as knowing what instance of input
+ * device we were dealing with is helpful.
+ */
+ dev_err(dev->dev.parent ?: &dev->dev,
+ "%s: unable to allocate poller structure\n", __func__);
+ return -ENOMEM;
+ }
+
+ INIT_DELAYED_WORK(&poller->work, input_dev_poller_work);
+ poller->input = dev;
+ poller->poll = poll_fn;
+
+ dev->poller = poller;
+ return 0;
+}
+EXPORT_SYMBOL(input_setup_polling);
+
+static bool input_dev_ensure_poller(struct input_dev *dev)
+{
+ if (!dev->poller) {
+ dev_err(dev->dev.parent ?: &dev->dev,
+ "poller structure has not been set up\n");
+ return false;
+ }
+
+ return true;
+}
+
+void input_set_poll_interval(struct input_dev *dev, unsigned int interval)
+{
+ if (input_dev_ensure_poller(dev))
+ dev->poller->poll_interval = interval;
+}
+EXPORT_SYMBOL(input_set_poll_interval);
+
+void input_set_min_poll_interval(struct input_dev *dev, unsigned int interval)
+{
+ if (input_dev_ensure_poller(dev))
+ dev->poller->poll_interval_min = interval;
+}
+EXPORT_SYMBOL(input_set_min_poll_interval);
+
+void input_set_max_poll_interval(struct input_dev *dev, unsigned int interval)
+{
+ if (input_dev_ensure_poller(dev))
+ dev->poller->poll_interval_max = interval;
+}
+EXPORT_SYMBOL(input_set_max_poll_interval);
+
+/* SYSFS interface */
+
+static ssize_t input_dev_get_poll_interval(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct input_dev *input = to_input_dev(dev);
+
+ return sprintf(buf, "%d\n", input->poller->poll_interval);
+}
+
+static ssize_t input_dev_set_poll_interval(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct input_dev *input = to_input_dev(dev);
+ struct input_dev_poller *poller = input->poller;
+ unsigned int interval;
+ int err;
+
+ err = kstrtouint(buf, 0, &interval);
+ if (err)
+ return err;
+
+ if (interval < poller->poll_interval_min)
+ return -EINVAL;
+
+ if (interval > poller->poll_interval_max)
+ return -EINVAL;
+
+ mutex_lock(&input->mutex);
+
+ poller->poll_interval = interval;
+
+ if (input->users) {
+ cancel_delayed_work_sync(&poller->work);
+ if (poller->poll_interval > 0)
+ input_dev_poller_queue_work(poller);
+ }
+
+ mutex_unlock(&input->mutex);
+
+ return count;
+}
+
+static DEVICE_ATTR(poll, 0644,
+ input_dev_get_poll_interval, input_dev_set_poll_interval);
+
+static ssize_t input_dev_get_poll_max(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct input_dev *input = to_input_dev(dev);
+
+ return sprintf(buf, "%d\n", input->poller->poll_interval_max);
+}
+
+static DEVICE_ATTR(max, 0444, input_dev_get_poll_max, NULL);
+
+static ssize_t input_dev_get_poll_min(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct input_dev *input = to_input_dev(dev);
+
+ return sprintf(buf, "%d\n", input->poller->poll_interval_min);
+}
+
+static DEVICE_ATTR(min, 0444, input_dev_get_poll_min, NULL);
+
+static umode_t input_poller_attrs_visible(struct kobject *kobj,
+ struct attribute *attr, int n)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct input_dev *input = to_input_dev(dev);
+
+ return input->poller ? attr->mode : 0;
+}
+
+static struct attribute *input_poller_attrs[] = {
+ &dev_attr_poll.attr,
+ &dev_attr_max.attr,
+ &dev_attr_min.attr,
+ NULL
+};
+
+struct attribute_group input_poller_attribute_group = {
+ .is_visible = input_poller_attrs_visible,
+ .attrs = input_poller_attrs,
+};

drivers/input/input-poller.h

View file
diff --git a/drivers/input/input-poller.h b/drivers/input/input-poller.h
new file mode 100644
index 0000000..e3fca0b
--- /dev/null
+++ b/drivers/input/input-poller.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _INPUT_POLLER_H
+#define _INPUT_POLLER_H
+
+/*
+ * Support for polling mode for input devices.
+ */
+#include <linux/sysfs.h>
+
+struct input_dev_poller;
+
+void input_dev_poller_finalize(struct input_dev_poller *poller);
+void input_dev_poller_start(struct input_dev_poller *poller);
+void input_dev_poller_stop(struct input_dev_poller *poller);
+
+extern struct attribute_group input_poller_attribute_group;
+
+#endif /* _INPUT_POLLER_H */

drivers/input/input.c

View file
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 7f3c5fc..5508627 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -24,6 +24,7 @@
#include <linux/mutex.h>
#include <linux/rcupdate.h>
#include "input-compat.h"
+#include "input-poller.h"
MODULE_AUTHOR("Vojtech Pavlik <[email protected]>");
MODULE_DESCRIPTION("Input core");
@@ -396,6 +397,13 @@ static void input_handle_event(struct input_dev *dev,
if (dev->num_vals >= 2)
input_pass_values(dev, dev->vals, dev->num_vals);
dev->num_vals = 0;
+ /*
+ * Reset the timestamp on flush so we won't end up
+ * with a stale one. Note we only need to reset the
+ * monolithic one as we use its presence when deciding
+ * whether to generate a synthetic timestamp.
+ */
+ dev->timestamp[INPUT_CLK_MONO] = ktime_set(0, 0);
} else if (dev->num_vals >= dev->max_vals - 2) {
dev->vals[dev->num_vals++] = input_value_sync;
input_pass_values(dev, dev->vals, dev->num_vals);
@@ -603,20 +611,31 @@ int input_open_device(struct input_handle *handle)
handle->open++;
- if (!dev->users++ && dev->open)
- retval = dev->open(dev);
+ if (dev->users++) {
+ /*
+ * Device is already opened, so we can exit immediately and
+ * report success.
+ */
+ goto out;
+ }
- if (retval) {
- dev->users--;
- if (!--handle->open) {
+ if (dev->open) {
+ retval = dev->open(dev);
+ if (retval) {
+ dev->users--;
+ handle->open--;
/*
* Make sure we are not delivering any more events
* through this handle
*/
synchronize_rcu();
+ goto out;
}
}
+ if (dev->poller)
+ input_dev_poller_start(dev->poller);
+
out:
mutex_unlock(&dev->mutex);
return retval;
@@ -655,8 +674,13 @@ void input_close_device(struct input_handle *handle)
__input_release_device(handle);
- if (!--dev->users && dev->close)
- dev->close(dev);
+ if (!--dev->users) {
+ if (dev->poller)
+ input_dev_poller_stop(dev->poller);
+
+ if (dev->close)
+ dev->close(dev);
+ }
if (!--handle->open) {
/*
@@ -1502,6 +1526,7 @@ static const struct attribute_group *input_dev_attr_groups[] = {
&input_dev_attr_group,
&input_dev_id_attr_group,
&input_dev_caps_attr_group,
+ &input_poller_attribute_group,
NULL
};
@@ -1511,6 +1536,7 @@ static void input_dev_release(struct device *device)
input_ff_destroy(dev);
input_mt_destroy_slots(dev);
+ kfree(dev->poller);
kfree(dev->absinfo);
kfree(dev->vals);
kfree(dev);
@@ -1895,6 +1921,46 @@ void input_free_device(struct input_dev *dev)
EXPORT_SYMBOL(input_free_device);
/**
+ * input_set_timestamp - set timestamp for input events
+ * @dev: input device to set timestamp for
+ * @timestamp: the time at which the event has occurred
+ * in CLOCK_MONOTONIC
+ *
+ * This function is intended to provide to the input system a more
+ * accurate time of when an event actually occurred. The driver should
+ * call this function as soon as a timestamp is acquired ensuring
+ * clock conversions in input_set_timestamp are done correctly.
+ *
+ * The system entering suspend state between timestamp acquisition and
+ * calling input_set_timestamp can result in inaccurate conversions.
+ */
+void input_set_timestamp(struct input_dev *dev, ktime_t timestamp)
+{
+ dev->timestamp[INPUT_CLK_MONO] = timestamp;
+ dev->timestamp[INPUT_CLK_REAL] = ktime_mono_to_real(timestamp);
+ dev->timestamp[INPUT_CLK_BOOT] = ktime_mono_to_any(timestamp,
+ TK_OFFS_BOOT);
+}
+EXPORT_SYMBOL(input_set_timestamp);
+
+/**
+ * input_get_timestamp - get timestamp for input events
+ * @dev: input device to get timestamp from
+ *
+ * A valid timestamp is a timestamp of non-zero value.
+ */
+ktime_t *input_get_timestamp(struct input_dev *dev)
+{
+ const ktime_t invalid_timestamp = ktime_set(0, 0);
+
+ if (!ktime_compare(dev->timestamp[INPUT_CLK_MONO], invalid_timestamp))
+ input_set_timestamp(dev, ktime_get());
+
+ return dev->timestamp;
+}
+EXPORT_SYMBOL(input_get_timestamp);
+
+/**

This diff is incomplete. Download the complete patch.

drivers/input/joystick/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/input/joystick/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/input/joystick/fsia6b.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/joystick/sidewinder.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/applespi.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/bcm-keypad.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/cros_ec_keyb.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/davinci_keyscan.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/gpio_keys.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/imx_keypad.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/lpc32xx-keys.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/mpr121_touchkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/nomadik-ske-keypad.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/nspire-keypad.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/opencores-kbd.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/pmic8xxx-keypad.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/pxa27x_keypad.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/pxa930_rotary.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/sh_keysc.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/snvs_pwrkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/spear-keyboard.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/st-keyscan.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/tegra-kbc.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/keyboard/w90p910_keypad.c

View before deletion

This diff is incomplete. Download the complete patch.

drivers/input/matrix-keymap.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/88pm80x_onkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/88pm860x_onkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/ab8500-ponkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/axp20x-pek.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/da9055_onkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/da9063_onkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/e3x0-button.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/hisi_powerkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/max8925_onkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/pm8941-pwrkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/rk805-pwrkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/soc_button_array.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/stpmic1_onkey.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/tps65218-pwrbutton.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/misc/twl6040-vibra.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/alps.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/byd.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/cyapa.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/cypress_ps2.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/elan_i2c_core.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/elantech.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/hgpk.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/lifebook.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/logips2pp.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/pxa930_trkball.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/sentelic.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/synaptics.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/touchkit_ps2.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/trackpoint.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/mouse/vmmouse.h

View file

This diff is incomplete. Download the complete patch.

drivers/input/rmi4/rmi_2d_sensor.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/serio/arc_ps2.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/serio/i8042.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/serio/ps2-gpio.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/88pm860x-ts.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/Kconfig

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/Makefile

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/ads7846.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/atmel_mxt_ts.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/bcm_iproc_tsc.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/bu21013_ts.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/edt-ft5x06.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/fsl-imx25-tcq.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/hideep.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/imx6ul_tsc.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/lpc32xx_ts.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/mxs-lradc-ts.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/sun4i-ts.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/ts4800-ts.c

View file

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/w90p910_ts.c

View before deletion

This diff is incomplete. Download the complete patch.

drivers/input/touchscreen/wacom_w8001.c

View file

This diff is incomplete. Download the complete patch.

drivers/platform/x86/surfacepro3_button.c

View file

This diff is incomplete. Download the complete patch.

include/linux/input.h

View file

This diff is incomplete. Download the complete patch.

include/linux/input/bu21013.h

View before deletion

This diff is incomplete. Download the complete patch.

include/linux/platform_data/keypad-w90p910.h

View before deletion

This diff is incomplete. Download the complete patch.

include/uapi/linux/serio.h

View file

This diff is incomplete. Download the complete patch.