diff mbox

[PATCHv3,1/5] Input: add common DT binding for touchscreens

Message ID 1398470179-20880-2-git-send-email-sre@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sebastian Reichel April 25, 2014, 11:56 p.m. UTC
Add common DT binding documentation for touchscreen devices and
implement input_parse_touchscreen_of_params, which parses the common
properties and configures the input device accordingly.

The method currently does not interpret the axis inversion properties,
since there is no matching flag in the generic linux input device.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 .../bindings/input/touchscreen/touchscreen.txt     | 27 +++++++++++++++++
 drivers/input/input.c                              | 34 ++++++++++++++++++++++
 include/linux/input.h                              |  8 +++++
 3 files changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt

Comments

Pavel Machek April 29, 2014, 9:23 a.m. UTC | #1
On Sat 2014-04-26 01:56:15, Sebastian Reichel wrote:
> Add common DT binding documentation for touchscreen devices and
> implement input_parse_touchscreen_of_params, which parses the common
> properties and configures the input device accordingly.
> 
> The method currently does not interpret the axis inversion properties,
> since there is no matching flag in the generic linux input device.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>

Reviewed-by: Pavel Machek <pavel@ucw.cz>
Tony Lindgren May 5, 2014, 7:41 p.m. UTC | #2
* Sebastian Reichel <sre@kernel.org> [140425 16:56]:
> Add common DT binding documentation for touchscreen devices and
> implement input_parse_touchscreen_of_params, which parses the common
> properties and configures the input device accordingly.
> 
> The method currently does not interpret the axis inversion properties,
> since there is no matching flag in the generic linux input device.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>  .../bindings/input/touchscreen/touchscreen.txt     | 27 +++++++++++++++++
>  drivers/input/input.c                              | 34 ++++++++++++++++++++++
>  include/linux/input.h                              |  8 +++++
>  3 files changed, 69 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> new file mode 100644
> index 0000000..d8e0616
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> @@ -0,0 +1,27 @@
> +General Touchscreen Properties:
> +
> +Optional properties for Touchscreens:
> + - touchscreen-size-x		: horizontal resolution of touchscreen
> +				  (in pixels)
> + - touchscreen-size-y		: vertical resolution of touchscreen
> +				  (in pixels)
> + - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
> +				  dependent on the controller)
> + - touchscreen-fuzz-x		: horizontal noise value of the absolute input
> +				  device (in pixels)
> + - touchscreen-fuzz-y		: vertical noise value of the absolute input
> +				  device (in pixels)
> + - touchscreen-fuzz-pressure	: pressure noise value of the absolute input
> +				  device (arbitrary range dependent on the
> +				  controller)
> + - touchscreen-inverted-x	: X axis is inverted (boolean)
> + - touchscreen-inverted-y	: Y axis is inverted (boolean)

We probably also need something to swap x and y depending on the
display orientation in addition to the touchscreen-inverted-x and y.
Just swapping x and y is not enough depending if we rotate by 270
degrees instead of 90 degrees.

Naturally that part can be added later.

Regards,

That 
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov May 5, 2014, 7:51 p.m. UTC | #3
On Mon, May 05, 2014 at 12:41:26PM -0700, Tony Lindgren wrote:
> * Sebastian Reichel <sre@kernel.org> [140425 16:56]:
> > Add common DT binding documentation for touchscreen devices and
> > implement input_parse_touchscreen_of_params, which parses the common
> > properties and configures the input device accordingly.
> > 
> > The method currently does not interpret the axis inversion properties,
> > since there is no matching flag in the generic linux input device.
> > 
> > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > ---
> >  .../bindings/input/touchscreen/touchscreen.txt     | 27 +++++++++++++++++
> >  drivers/input/input.c                              | 34 ++++++++++++++++++++++
> >  include/linux/input.h                              |  8 +++++
> >  3 files changed, 69 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > new file mode 100644
> > index 0000000..d8e0616
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > @@ -0,0 +1,27 @@
> > +General Touchscreen Properties:
> > +
> > +Optional properties for Touchscreens:
> > + - touchscreen-size-x		: horizontal resolution of touchscreen
> > +				  (in pixels)
> > + - touchscreen-size-y		: vertical resolution of touchscreen
> > +				  (in pixels)
> > + - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
> > +				  dependent on the controller)
> > + - touchscreen-fuzz-x		: horizontal noise value of the absolute input
> > +				  device (in pixels)
> > + - touchscreen-fuzz-y		: vertical noise value of the absolute input
> > +				  device (in pixels)
> > + - touchscreen-fuzz-pressure	: pressure noise value of the absolute input
> > +				  device (arbitrary range dependent on the
> > +				  controller)

Fuzz seems like linux-specific property, not generic one.


> > + - touchscreen-inverted-x	: X axis is inverted (boolean)
> > + - touchscreen-inverted-y	: Y axis is inverted (boolean)
> 
> We probably also need something to swap x and y depending on the
> display orientation in addition to the touchscreen-inverted-x and y.
> Just swapping x and y is not enough depending if we rotate by 270
> degrees instead of 90 degrees.
> 
> Naturally that part can be added later.

So far we've been relying on upper layers (such as tslib) to perform
such transformations rather than re-implementing it in every driver. Are
we saying that we need to implement this in input core?

Thanks.
Tony Lindgren May 5, 2014, 8:12 p.m. UTC | #4
* Dmitry Torokhov <dmitry.torokhov@gmail.com> [140505 12:52]:
> On Mon, May 05, 2014 at 12:41:26PM -0700, Tony Lindgren wrote:
> > * Sebastian Reichel <sre@kernel.org> [140425 16:56]:
> > > Add common DT binding documentation for touchscreen devices and
> > > implement input_parse_touchscreen_of_params, which parses the common
> > > properties and configures the input device accordingly.
> > > 
> > > The method currently does not interpret the axis inversion properties,
> > > since there is no matching flag in the generic linux input device.
> > > 
> > > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > > ---
> > >  .../bindings/input/touchscreen/touchscreen.txt     | 27 +++++++++++++++++
> > >  drivers/input/input.c                              | 34 ++++++++++++++++++++++
> > >  include/linux/input.h                              |  8 +++++
> > >  3 files changed, 69 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > 
> > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > new file mode 100644
> > > index 0000000..d8e0616
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > @@ -0,0 +1,27 @@
> > > +General Touchscreen Properties:
> > > +
> > > +Optional properties for Touchscreens:
> > > + - touchscreen-size-x		: horizontal resolution of touchscreen
> > > +				  (in pixels)
> > > + - touchscreen-size-y		: vertical resolution of touchscreen
> > > +				  (in pixels)
> > > + - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
> > > +				  dependent on the controller)
> > > + - touchscreen-fuzz-x		: horizontal noise value of the absolute input
> > > +				  device (in pixels)
> > > + - touchscreen-fuzz-y		: vertical noise value of the absolute input
> > > +				  device (in pixels)
> > > + - touchscreen-fuzz-pressure	: pressure noise value of the absolute input
> > > +				  device (arbitrary range dependent on the
> > > +				  controller)
> 
> Fuzz seems like linux-specific property, not generic one.
> 
> 
> > > + - touchscreen-inverted-x	: X axis is inverted (boolean)
> > > + - touchscreen-inverted-y	: Y axis is inverted (boolean)
> > 
> > We probably also need something to swap x and y depending on the
> > display orientation in addition to the touchscreen-inverted-x and y.
> > Just swapping x and y is not enough depending if we rotate by 270
> > degrees instead of 90 degrees.
> > 
> > Naturally that part can be added later.
> 
> So far we've been relying on upper layers (such as tslib) to perform
> such transformations rather than re-implementing it in every driver. Are
> we saying that we need to implement this in input core?

We seem to have that already partially implemented at least with
ti,swap-xy in Documentation/devicetree/bindings/input/ads7846.txt.

But that only works for the 90 degree rotation case as it's missing
something similar to touchscreen-inverted-x I just noticed few days
ago while trying to make some legacy code disappear :)

No idea where rotation should be specified. But if the panel is
rotated based on the DT property or kernel cmdline, probably the
touchscreen should be too? In most cases touchscreens are integrated
together with the LCD panel, and they are not separate like other
input devices.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sebastian Reichel May 5, 2014, 11:04 p.m. UTC | #5
On Mon, May 05, 2014 at 12:51:39PM -0700, Dmitry Torokhov wrote:
> On Mon, May 05, 2014 at 12:41:26PM -0700, Tony Lindgren wrote:
> > * Sebastian Reichel <sre@kernel.org> [140425 16:56]:
> > > Add common DT binding documentation for touchscreen devices and
> > > implement input_parse_touchscreen_of_params, which parses the common
> > > properties and configures the input device accordingly.
> > > 
> > > The method currently does not interpret the axis inversion properties,
> > > since there is no matching flag in the generic linux input device.
> > > 
> > > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > > ---
> > >  .../bindings/input/touchscreen/touchscreen.txt     | 27 +++++++++++++++++
> > >  drivers/input/input.c                              | 34 ++++++++++++++++++++++
> > >  include/linux/input.h                              |  8 +++++
> > >  3 files changed, 69 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > 
> > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > new file mode 100644
> > > index 0000000..d8e0616
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > @@ -0,0 +1,27 @@
> > > +General Touchscreen Properties:
> > > +
> > > +Optional properties for Touchscreens:
> > > + - touchscreen-size-x		: horizontal resolution of touchscreen
> > > +				  (in pixels)
> > > + - touchscreen-size-y		: vertical resolution of touchscreen
> > > +				  (in pixels)
> > > + - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
> > > +				  dependent on the controller)
> > > + - touchscreen-fuzz-x		: horizontal noise value of the absolute input
> > > +				  device (in pixels)
> > > + - touchscreen-fuzz-y		: vertical noise value of the absolute input
> > > +				  device (in pixels)
> > > + - touchscreen-fuzz-pressure	: pressure noise value of the absolute input
> > > +				  device (arbitrary range dependent on the
> > > +				  controller)
> 
> Fuzz seems like linux-specific property, not generic one.

I don't know about the term "fuzz", but the idea is pretty generic
IMHO. It's similar to debouncing switches/buttons.

> > > + - touchscreen-inverted-x	: X axis is inverted (boolean)
> > > + - touchscreen-inverted-y	: Y axis is inverted (boolean)
> > 
> > We probably also need something to swap x and y depending on the
> > display orientation in addition to the touchscreen-inverted-x and y.
> > Just swapping x and y is not enough depending if we rotate by 270
> > degrees instead of 90 degrees.
> > 
> > Naturally that part can be added later.
> 
> So far we've been relying on upper layers (such as tslib) to perform
> such transformations rather than re-implementing it in every driver. Are
> we saying that we need to implement this in input core?

I would appreciate to add this later to move on with this patchset.
Having the N900's touchscreen working via DT in 3.16 would be nice
now that the display is working :)

-- Sebastian
Dmitry Torokhov May 19, 2014, 5:35 a.m. UTC | #6
On Tue, May 06, 2014 at 01:04:12AM +0200, Sebastian Reichel wrote:
> On Mon, May 05, 2014 at 12:51:39PM -0700, Dmitry Torokhov wrote:
> > On Mon, May 05, 2014 at 12:41:26PM -0700, Tony Lindgren wrote:
> > > * Sebastian Reichel <sre@kernel.org> [140425 16:56]:
> > > > Add common DT binding documentation for touchscreen devices and
> > > > implement input_parse_touchscreen_of_params, which parses the common
> > > > properties and configures the input device accordingly.
> > > > 
> > > > The method currently does not interpret the axis inversion properties,
> > > > since there is no matching flag in the generic linux input device.
> > > > 
> > > > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > > > ---
> > > >  .../bindings/input/touchscreen/touchscreen.txt     | 27 +++++++++++++++++
> > > >  drivers/input/input.c                              | 34 ++++++++++++++++++++++
> > > >  include/linux/input.h                              |  8 +++++
> > > >  3 files changed, 69 insertions(+)
> > > >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > > new file mode 100644
> > > > index 0000000..d8e0616
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > > @@ -0,0 +1,27 @@
> > > > +General Touchscreen Properties:
> > > > +
> > > > +Optional properties for Touchscreens:
> > > > + - touchscreen-size-x		: horizontal resolution of touchscreen
> > > > +				  (in pixels)
> > > > + - touchscreen-size-y		: vertical resolution of touchscreen
> > > > +				  (in pixels)
> > > > + - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
> > > > +				  dependent on the controller)
> > > > + - touchscreen-fuzz-x		: horizontal noise value of the absolute input
> > > > +				  device (in pixels)
> > > > + - touchscreen-fuzz-y		: vertical noise value of the absolute input
> > > > +				  device (in pixels)
> > > > + - touchscreen-fuzz-pressure	: pressure noise value of the absolute input
> > > > +				  device (arbitrary range dependent on the
> > > > +				  controller)
> > 
> > Fuzz seems like linux-specific property, not generic one.
> 
> I don't know about the term "fuzz", but the idea is pretty generic
> IMHO. It's similar to debouncing switches/buttons.

OK, fair enough.

> 
> > > > + - touchscreen-inverted-x	: X axis is inverted (boolean)
> > > > + - touchscreen-inverted-y	: Y axis is inverted (boolean)
> > > 
> > > We probably also need something to swap x and y depending on the
> > > display orientation in addition to the touchscreen-inverted-x and y.
> > > Just swapping x and y is not enough depending if we rotate by 270
> > > degrees instead of 90 degrees.
> > > 
> > > Naturally that part can be added later.
> > 
> > So far we've been relying on upper layers (such as tslib) to perform
> > such transformations rather than re-implementing it in every driver. Are
> > we saying that we need to implement this in input core?
> 
> I would appreciate to add this later to move on with this patchset.
> Having the N900's touchscreen working via DT in 3.16 would be nice
> now that the display is working :)
> 

Please remove the "inverted" bits and move touchscreen OF parsing into a
separate file/module, similarly to support for sparse and matrix keymaps
that we have - it does not really belong to input core.

Thanks.
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
new file mode 100644
index 0000000..d8e0616
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
@@ -0,0 +1,27 @@ 
+General Touchscreen Properties:
+
+Optional properties for Touchscreens:
+ - touchscreen-size-x		: horizontal resolution of touchscreen
+				  (in pixels)
+ - touchscreen-size-y		: vertical resolution of touchscreen
+				  (in pixels)
+ - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
+				  dependent on the controller)
+ - touchscreen-fuzz-x		: horizontal noise value of the absolute input
+				  device (in pixels)
+ - touchscreen-fuzz-y		: vertical noise value of the absolute input
+				  device (in pixels)
+ - touchscreen-fuzz-pressure	: pressure noise value of the absolute input
+				  device (arbitrary range dependent on the
+				  controller)
+ - touchscreen-inverted-x	: X axis is inverted (boolean)
+ - touchscreen-inverted-y	: Y axis is inverted (boolean)
+
+Deprecated properties for Touchscreens:
+ - x-size			: deprecated name for touchscreen-size-x
+ - y-size			: deprecated name for touchscreen-size-y
+ - moving-threshold		: deprecated name for a combination of
+				  touchscreen-fuzz-x and touchscreen-fuzz-y
+ - contact-threshold		: deprecated name for touchscreen-fuzz-pressure
+ - x-invert			: deprecated name for touchscreen-inverted-x
+ - y-invert			: deprecated name for touchscreen-inverted-y
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 1c4c0db..97966d93 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -27,6 +27,7 @@ 
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/rcupdate.h>
+#include <linux/of.h>
 #include "input-compat.h"
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
@@ -2398,6 +2399,39 @@  void input_free_minor(unsigned int minor)
 }
 EXPORT_SYMBOL(input_free_minor);
 
+#if defined(CONFIG_OF)
+/**
+ * input_parse_touchscreen_of_params - parse common touchscreen DT properties
+ * @dev: device that should be parsed
+ *
+ * This function parses common DT properties for touchscreens and setups the
+ * input device accordingly. The function keeps previously setuped default
+ * values if no value is specified via DT.
+ */
+void input_parse_touchscreen_of_params(struct input_dev *dev)
+{
+	struct device_node *np = dev->dev.parent->of_node;
+	struct input_absinfo *absinfo;
+
+	input_alloc_absinfo(dev);
+	if (!dev->absinfo)
+		return;
+
+	absinfo = &dev->absinfo[ABS_X];
+	of_property_read_u32(np, "touchscreen-size-x", &absinfo->maximum);
+	of_property_read_u32(np, "touchscreen-fuzz-x", &absinfo->fuzz);
+
+	absinfo = &dev->absinfo[ABS_Y];
+	of_property_read_u32(np, "touchscreen-size-y", &absinfo->maximum);
+	of_property_read_u32(np, "touchscreen-fuzz-y", &absinfo->fuzz);
+
+	absinfo = &dev->absinfo[ABS_PRESSURE];
+	of_property_read_u32(np, "touchscreen-max-pressure", &absinfo->maximum);
+	of_property_read_u32(np, "touchscreen-fuzz-pressure", &absinfo->fuzz);
+}
+EXPORT_SYMBOL(input_parse_touchscreen_of_params);
+#endif
+
 static int __init input_init(void)
 {
 	int err;
diff --git a/include/linux/input.h b/include/linux/input.h
index 82ce323..3dc3b1e 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -531,4 +531,12 @@  int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file);
 int input_ff_create_memless(struct input_dev *dev, void *data,
 		int (*play_effect)(struct input_dev *, void *, struct ff_effect *));
 
+#if defined(CONFIG_OF)
+void input_parse_touchscreen_of_params(struct input_dev *dev);
+#else
+static inline void input_parse_touchscreen_of_params(struct input_dev *dev) {
+	return;
+}
+#endif
+
 #endif