diff mbox

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

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

Commit Message

Sebastian Reichel April 5, 2014, 10:26 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.

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

Comments

Rob Herring April 7, 2014, 4:38 p.m. UTC | #1
On Sat, Apr 5, 2014 at 5:26 PM, Sebastian Reichel <sre@kernel.org> 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.

Good.

>
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>  .../bindings/input/touchscreen/touchscreen.txt     |  9 ++++++
>  drivers/input/input.c                              | 34 ++++++++++++++++++++++
>  include/linux/input.h                              |  8 +++++
>  3 files changed, 51 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..a2ff0a0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> @@ -0,0 +1,9 @@
> +General Touchscreen Properties:
> +
> +Optional properties for Touchscreens:
> + - touchscreen-size-x          : horizontal resolution of touchscreen
> + - touchscreen-size-y          : vertical resolution of touchscreen

While I like the consistency, x-size and y-size are already commonly
used. Perhaps the common binding should have both and x-size/y-size be
marked deprecated.

> + - touchscreen-max-pressure    : maximum reported pressure
> + - touchscreen-fuzz-x          : horizontal noise value of the absolute input device
> + - touchscreen-fuzz-y          : vertical noise value of the absolute input device
> + - touchscreen-fuzz-pressure   : pressure noise value of the absolute input device

What are the units or are they just an arbitrary range dependent on
the controller? Several existing bindings appear to be in pixels, but
that seems wrong to me.

There's also these various properties that should have common versions created:

ti,x-plate-resistance and ti,x-plate-ohms (tsc2007)
- rohm,flip-x             : Flip touch coordinates on the X axis
 - rohm,flip-y             : Flip touch coordinates on the Y axis
- x-invert: invert X axis
- y-invert: invert Y axis
- contact-threshold:
- moving-threshold:

Rob
--
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 April 7, 2014, 8 p.m. UTC | #2
On Mon, Apr 07, 2014 at 11:38:01AM -0500, Rob Herring wrote:
> On Sat, Apr 5, 2014 at 5:26 PM, Sebastian Reichel <sre@kernel.org> 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.
> 
> Good.
> 
> [...]
> > +Optional properties for Touchscreens:
> > + - touchscreen-size-x          : horizontal resolution of touchscreen
> > + - touchscreen-size-y          : vertical resolution of touchscreen
> 
> While I like the consistency, x-size and y-size are already commonly
> used. Perhaps the common binding should have both and x-size/y-size be
> marked deprecated.

So you want me to add something like the following?

- x-size : deprecated name for touchscreen-size-x
- y-size : deprecated name for touchscreen-size-y

> > + - touchscreen-max-pressure    : maximum reported pressure
> > + - touchscreen-fuzz-x          : horizontal noise value of the absolute input device
> > + - touchscreen-fuzz-y          : vertical noise value of the absolute input device
> > + - touchscreen-fuzz-pressure   : pressure noise value of the absolute input device
> 
> What are the units or are they just an arbitrary range dependent on
> the controller? Several existing bindings appear to be in pixels, but
> that seems wrong to me.

x/y related properties: pixels
pressure related properties: arbitrary range dependent on the controller

> There's also these various properties that should have common versions created:
> 
> ti,x-plate-resistance and ti,x-plate-ohms (tsc2007)

I think this is ti specific. But I should probably name the tsc2005
property "ti,x-plate-ohms", so that its in sync with tsc2007.

> - rohm,flip-x             : Flip touch coordinates on the X axis
> - rohm,flip-y             : Flip touch coordinates on the Y axis
> - x-invert: invert X axis
> - y-invert: invert Y axis

like this?

- touchscreen-inverted-x: X axis is inverted
- touchscreen-inverted-y: Y axis is inverted
- x-invert: deprecated name for touchscreen-inverted-x
- y-invert: deprecated name for touchscreen-inverted-y

Inverting is currently not supported by the input system, though. So
adding support for it to input_parse_touchscreen_of_params() is not
trivial :/

> - contact-threshold:
> - moving-threshold:

I think those are hardware specific. The properties are currently
used by one driver, which writes them directly into some registers.
The DT binding does not give more information about them.

I think those should have been vendor-prefixed.

-- Sebastian
Rob Herring April 8, 2014, 2:53 a.m. UTC | #3
On Mon, Apr 7, 2014 at 3:00 PM, Sebastian Reichel <sre@kernel.org> wrote:
> On Mon, Apr 07, 2014 at 11:38:01AM -0500, Rob Herring wrote:
>> On Sat, Apr 5, 2014 at 5:26 PM, Sebastian Reichel <sre@kernel.org> 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.
>>
>> Good.
>>
>> [...]
>> > +Optional properties for Touchscreens:
>> > + - touchscreen-size-x          : horizontal resolution of touchscreen
>> > + - touchscreen-size-y          : vertical resolution of touchscreen
>>
>> While I like the consistency, x-size and y-size are already commonly
>> used. Perhaps the common binding should have both and x-size/y-size be
>> marked deprecated.
>
> So you want me to add something like the following?
>
> - x-size : deprecated name for touchscreen-size-x
> - y-size : deprecated name for touchscreen-size-y

Yes.

>
>> > + - touchscreen-max-pressure    : maximum reported pressure
>> > + - touchscreen-fuzz-x          : horizontal noise value of the absolute input device
>> > + - touchscreen-fuzz-y          : vertical noise value of the absolute input device
>> > + - touchscreen-fuzz-pressure   : pressure noise value of the absolute input device
>>
>> What are the units or are they just an arbitrary range dependent on
>> the controller? Several existing bindings appear to be in pixels, but
>> that seems wrong to me.
>
> x/y related properties: pixels
> pressure related properties: arbitrary range dependent on the controller

Please make this clear in the binding description.

>> There's also these various properties that should have common versions created:
>>
>> ti,x-plate-resistance and ti,x-plate-ohms (tsc2007)
>
> I think this is ti specific. But I should probably name the tsc2005
> property "ti,x-plate-ohms", so that its in sync with tsc2007.
>
>> - rohm,flip-x             : Flip touch coordinates on the X axis
>> - rohm,flip-y             : Flip touch coordinates on the Y axis
>> - x-invert: invert X axis
>> - y-invert: invert Y axis
>
> like this?
>
> - touchscreen-inverted-x: X axis is inverted
> - touchscreen-inverted-y: Y axis is inverted
> - x-invert: deprecated name for touchscreen-inverted-x
> - y-invert: deprecated name for touchscreen-inverted-y
>
> Inverting is currently not supported by the input system, though. So
> adding support for it to input_parse_touchscreen_of_params() is not
> trivial :/

Does not matter. I'm only asking you to define the property. Linux
does not have to use it currently.

>> - contact-threshold:
>> - moving-threshold:
>
> I think those are hardware specific. The properties are currently
> used by one driver, which writes them directly into some registers.
> The DT binding does not give more information about them.

moving-threshold is probably the same as fuzz. contact-threshold is
sounds like min pressure. I remember having to tune the minimum
pressure on a touchscreen I worked on long ago. So think think is
definitely not an uncommon property.

Rob
--
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
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..a2ff0a0
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
@@ -0,0 +1,9 @@ 
+General Touchscreen Properties:
+
+Optional properties for Touchscreens:
+ - touchscreen-size-x		: horizontal resolution of touchscreen
+ - touchscreen-size-y		: vertical resolution of touchscreen
+ - touchscreen-max-pressure	: maximum reported pressure
+ - touchscreen-fuzz-x		: horizontal noise value of the absolute input device
+ - touchscreen-fuzz-y		: vertical noise value of the absolute input device
+ - touchscreen-fuzz-pressure	: pressure noise value of the absolute input device
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