All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] input: touchscreen: Add generic touchscreen softbutton support
@ 2016-07-31 15:23 ` Hans de Goede
  0 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-07-31 15:23 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: Maxime Ripard, Chen-Yu Tsai, linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree

Hi Dmitry,

Some touchscreens extend over the display they cover and have a number
of capacative softbuttons outside of the display the cover.

With some hardware these softbuttons simply report touches with
coordinates outside of the normal coordinate space for touches on the
display.

This patch-series adds some generic helper code for supporting such
setups, including support for triggering a led as visual feedback that
a softbutton has been touched.

It also uses the generic helpers to add softbutton support to the
edt-ft5x06 driver.

Can you please review patches 1-3 and if they are to your liking merge
them ?

Note patch 4 is included mostly as illustration how this all can be used,
I will submit that to the sunxi dt maintainers once the input bits have
been merged.

Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 0/4] input: touchscreen: Add generic touchscreen softbutton support
@ 2016-07-31 15:23 ` Hans de Goede
  0 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-07-31 15:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Dmitry,

Some touchscreens extend over the display they cover and have a number
of capacative softbuttons outside of the display the cover.

With some hardware these softbuttons simply report touches with
coordinates outside of the normal coordinate space for touches on the
display.

This patch-series adds some generic helper code for supporting such
setups, including support for triggering a led as visual feedback that
a softbutton has been touched.

It also uses the generic helpers to add softbutton support to the
edt-ft5x06 driver.

Can you please review patches 1-3 and if they are to your liking merge
them ?

Note patch 4 is included mostly as illustration how this all can be used,
I will submit that to the sunxi dt maintainers once the input bits have
been merged.

Regards,

Hans

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
  2016-07-31 15:23 ` Hans de Goede
@ 2016-07-31 15:23   ` Hans de Goede
  -1 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-07-31 15:23 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: Maxime Ripard, Chen-Yu Tsai, linux-input, linux-arm-kernel,
	devicetree, Hans de Goede

Some touchscreens extend over the display they cover and have a number
of capacative softbuttons outside of the display the cover.

With some hardware these softbuttons simply report touches with
coordinates outside of the normal coordinate space for touches on the
display.

This commit adds a devicetree binding for describing such buttons in
devicetree and a bunch of helper functions to easily add support for
these to existing touchscreen drivers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
 drivers/input/touchscreen/Makefile                 |   2 +-
 drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
 include/linux/input/touchscreen.h                  |   9 ++
 4 files changed, 213 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
 create mode 100644 drivers/input/touchscreen/softbuttons.c

diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
new file mode 100644
index 0000000..3eb6f4c
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
@@ -0,0 +1,58 @@
+General Touchscreen Softbutton Properties:
+
+Some touchscreens extend over the display they cover and have a number
+of capacative softbuttons outside of the display the cover.
+
+Some of these softbuttons simply report touches with coordinates outside of
+the normal coordinate space for touches on the display. This binding is for
+describing such buttons in devicetree.
+
+Each softkey is represented as a sub-node of the touchscreen node.
+
+Required subnode-properties:
+ - label			: Descriptive name of the key.
+ - linux,code			: Keycode to emit.
+ - softbutton-min-x		: X start of the area the softbutton area covers
+ - softbutton-max-x		: X end of the area the softbutton area covers
+ - softbutton-min-y		: Y start of the area the softbutton area covers
+ - softbutton-max-y		: Y end of the area the softbutton area covers
+
+Example:
+
+#include <dt-bindings/input/input.h>
+
+&i2c2 {
+	ft5406ee8: touchscreen@38 {
+		compatible = "edt,edt-ft5406";
+		reg = <0x38>;
+		touchscreen-size-x = <1024>;
+		touchscreen-size-y = <768>;
+
+		button@0 {
+			label = "Esc";
+			linux,code = <KEY_ESC>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <0>;
+			softbutton-max-y = <49>;
+		};
+
+		button@1 {
+			label = "Home";
+			linux,code = <KEY_HOMEPAGE>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <50>;
+			softbutton-max-y = <99>;
+		};
+
+		button@2 {
+			label = "Menu";
+			linux,code = <KEY_MENU>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <100>;
+			softbutton-max-y = <149>;
+		};
+	};
+};
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 4166747..a4b00d0 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -6,7 +6,7 @@
 
 wm97xx-ts-y := wm97xx-core.o
 
-obj-$(CONFIG_TOUCHSCREEN_PROPERTIES)	+= of_touchscreen.o
+obj-$(CONFIG_TOUCHSCREEN_PROPERTIES)	+= of_touchscreen.o softbuttons.o
 obj-$(CONFIG_TOUCHSCREEN_88PM860X)	+= 88pm860x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_AD7877)	+= ad7877.o
 obj-$(CONFIG_TOUCHSCREEN_AD7879)	+= ad7879.o
diff --git a/drivers/input/touchscreen/softbuttons.c b/drivers/input/touchscreen/softbuttons.c
new file mode 100644
index 0000000..47aea18
--- /dev/null
+++ b/drivers/input/touchscreen/softbuttons.c
@@ -0,0 +1,145 @@
+/*
+ * touchscreen softbutton helper functions
+ *
+ * Copyright (c) 2016 Hans de Goede <hdegoede@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/input.h>
+#include <linux/input/touchscreen.h>
+#include <linux/of.h>
+
+struct touchscreen_softbutton {
+	u32 min_x;
+	u32 max_x;
+	u32 min_y;
+	u32 max_y;
+	u32 keycode;
+};
+
+struct touchscreen_softbutton_info {
+	struct input_dev *input;
+	struct touchscreen_softbutton *buttons;
+	int button_count;
+};
+
+/**
+ * devm_touchscreen_alloc_softbuttons - allocate softbuttons
+ * @input: touchscreen input device for which softbuttons should be allocated
+ *
+ * This function parses touschcreen softbutton DT properties for touchscreens
+ * and allocates and fill a touchscreen_softbutton_info struct if any
+ * softbuttons are found.
+ *
+ * Returns prepared struct touchscreen_softbutton_info on success,
+ * %NULL if no softbuttons were found (this is not an error) or a ERR_PTR
+ * in case of an error.
+ *
+ * Note as this is a devm function the returned pointer does not need to
+ * be freed.
+ */
+struct touchscreen_softbutton_info *devm_touchscreen_alloc_softbuttons(
+					struct input_dev *input)
+{
+	struct device *dev = input->dev.parent;
+	struct device_node *np, *pp;
+	struct touchscreen_softbutton_info *info;
+	int i, err, button_count;
+
+	np = dev->of_node;
+	if (!np)
+		return NULL;
+
+	button_count = of_get_child_count(np);
+	if (button_count == 0)
+		return NULL;
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return ERR_PTR(-ENOMEM);
+
+	info->input = input;
+	info->button_count = button_count;
+	info->buttons = devm_kzalloc(dev, button_count * sizeof(*info->buttons),
+				     GFP_KERNEL);
+	if (!info->buttons)
+		return ERR_PTR(-ENOMEM);
+
+	for (pp = of_get_next_child(np, NULL), i = 0;
+	     pp != NULL;
+	     pp = of_get_next_child(np, pp), i++) {
+		struct touchscreen_softbutton *btn = &info->buttons[i];
+
+		err = of_property_read_u32(pp, "linux,code", &btn->keycode);
+		if (err) {
+			dev_err(dev, "%s: Inval linux,code prop\n", pp->name);
+			return ERR_PTR(-EINVAL);
+		}
+
+		err = of_property_read_u32(pp, "softbutton-min-x", &btn->min_x);
+		if (err) {
+			dev_err(dev, "%s: Inval min-x prop\n", pp->name);
+			return ERR_PTR(-EINVAL);
+		}
+
+		err = of_property_read_u32(pp, "softbutton-max-x", &btn->max_x);
+		if (err) {
+			dev_err(dev, "%s: Inval max-x prop\n", pp->name);
+			return ERR_PTR(-EINVAL);
+		}
+
+		err = of_property_read_u32(pp, "softbutton-min-y", &btn->min_y);
+		if (err) {
+			dev_err(dev, "%s: Inval min-y prop\n", pp->name);
+			return ERR_PTR(-EINVAL);
+		}
+
+		err = of_property_read_u32(pp, "softbutton-max-y", &btn->max_y);
+		if (err) {
+			dev_err(dev, "%s: Inval max-y prop\n", pp->name);
+			return ERR_PTR(-EINVAL);
+		}
+	}
+
+	__set_bit(EV_KEY, input->evbit);
+	for (i = 0; i < info->button_count; i++)
+		__set_bit(info->buttons[i].keycode, input->keybit);
+
+	return info;
+}
+
+/**
+ * touchscreen_handle_softbuttons - check for softbutton press
+ * @info: softbutton info retured by devm_touchscreen_alloc_softbuttons.
+ *
+ * This function checks if the passed in coordinates match any softbutton,
+ * and when they do reports a key press / release for the softbutton.
+ *
+ * Returns true if the coordinates match a softbutton and a key press / release
+ * was reported, false otherwise.
+ */
+bool touchscreen_handle_softbuttons(struct touchscreen_softbutton_info *info,
+				    unsigned int x, unsigned int y, bool down)
+{
+	int i;
+
+	if (info == NULL)
+		return false;
+
+	for (i = 0; i < info->button_count; i++) {
+		if (x >= info->buttons[i].min_x &&
+		    x <= info->buttons[i].max_x &&
+		    y >= info->buttons[i].min_y &&
+		    y <= info->buttons[i].max_y) {
+			input_report_key(info->input,
+					 info->buttons[i].keycode, down);
+			return true;
+		}
+	}
+
+	return false;
+}
diff --git a/include/linux/input/touchscreen.h b/include/linux/input/touchscreen.h
index 09d22cc..0b9d4ee 100644
--- a/include/linux/input/touchscreen.h
+++ b/include/linux/input/touchscreen.h
@@ -9,8 +9,11 @@
 #ifndef _TOUCHSCREEN_H
 #define _TOUCHSCREEN_H
 
+#include <linux/types.h>
+
 struct input_dev;
 struct input_mt_pos;
+struct touchscreen_softbutton_info;
 
 struct touchscreen_properties {
 	unsigned int max_x;
@@ -32,4 +35,10 @@ void touchscreen_report_pos(struct input_dev *input,
 			    unsigned int x, unsigned int y,
 			    bool multitouch);
 
+struct touchscreen_softbutton_info *devm_touchscreen_alloc_softbuttons(
+					struct input_dev *input);
+
+bool touchscreen_handle_softbuttons(struct touchscreen_softbutton_info *info,
+				    unsigned int x, unsigned int y, bool down);
+
 #endif
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
@ 2016-07-31 15:23   ` Hans de Goede
  0 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-07-31 15:23 UTC (permalink / raw)
  To: linux-arm-kernel

Some touchscreens extend over the display they cover and have a number
of capacative softbuttons outside of the display the cover.

With some hardware these softbuttons simply report touches with
coordinates outside of the normal coordinate space for touches on the
display.

This commit adds a devicetree binding for describing such buttons in
devicetree and a bunch of helper functions to easily add support for
these to existing touchscreen drivers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
 drivers/input/touchscreen/Makefile                 |   2 +-
 drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
 include/linux/input/touchscreen.h                  |   9 ++
 4 files changed, 213 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
 create mode 100644 drivers/input/touchscreen/softbuttons.c

diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
new file mode 100644
index 0000000..3eb6f4c
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
@@ -0,0 +1,58 @@
+General Touchscreen Softbutton Properties:
+
+Some touchscreens extend over the display they cover and have a number
+of capacative softbuttons outside of the display the cover.
+
+Some of these softbuttons simply report touches with coordinates outside of
+the normal coordinate space for touches on the display. This binding is for
+describing such buttons in devicetree.
+
+Each softkey is represented as a sub-node of the touchscreen node.
+
+Required subnode-properties:
+ - label			: Descriptive name of the key.
+ - linux,code			: Keycode to emit.
+ - softbutton-min-x		: X start of the area the softbutton area covers
+ - softbutton-max-x		: X end of the area the softbutton area covers
+ - softbutton-min-y		: Y start of the area the softbutton area covers
+ - softbutton-max-y		: Y end of the area the softbutton area covers
+
+Example:
+
+#include <dt-bindings/input/input.h>
+
+&i2c2 {
+	ft5406ee8: touchscreen at 38 {
+		compatible = "edt,edt-ft5406";
+		reg = <0x38>;
+		touchscreen-size-x = <1024>;
+		touchscreen-size-y = <768>;
+
+		button at 0 {
+			label = "Esc";
+			linux,code = <KEY_ESC>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <0>;
+			softbutton-max-y = <49>;
+		};
+
+		button at 1 {
+			label = "Home";
+			linux,code = <KEY_HOMEPAGE>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <50>;
+			softbutton-max-y = <99>;
+		};
+
+		button at 2 {
+			label = "Menu";
+			linux,code = <KEY_MENU>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <100>;
+			softbutton-max-y = <149>;
+		};
+	};
+};
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 4166747..a4b00d0 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -6,7 +6,7 @@
 
 wm97xx-ts-y := wm97xx-core.o
 
-obj-$(CONFIG_TOUCHSCREEN_PROPERTIES)	+= of_touchscreen.o
+obj-$(CONFIG_TOUCHSCREEN_PROPERTIES)	+= of_touchscreen.o softbuttons.o
 obj-$(CONFIG_TOUCHSCREEN_88PM860X)	+= 88pm860x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_AD7877)	+= ad7877.o
 obj-$(CONFIG_TOUCHSCREEN_AD7879)	+= ad7879.o
diff --git a/drivers/input/touchscreen/softbuttons.c b/drivers/input/touchscreen/softbuttons.c
new file mode 100644
index 0000000..47aea18
--- /dev/null
+++ b/drivers/input/touchscreen/softbuttons.c
@@ -0,0 +1,145 @@
+/*
+ * touchscreen softbutton helper functions
+ *
+ * Copyright (c) 2016 Hans de Goede <hdegoede@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/input.h>
+#include <linux/input/touchscreen.h>
+#include <linux/of.h>
+
+struct touchscreen_softbutton {
+	u32 min_x;
+	u32 max_x;
+	u32 min_y;
+	u32 max_y;
+	u32 keycode;
+};
+
+struct touchscreen_softbutton_info {
+	struct input_dev *input;
+	struct touchscreen_softbutton *buttons;
+	int button_count;
+};
+
+/**
+ * devm_touchscreen_alloc_softbuttons - allocate softbuttons
+ * @input: touchscreen input device for which softbuttons should be allocated
+ *
+ * This function parses touschcreen softbutton DT properties for touchscreens
+ * and allocates and fill a touchscreen_softbutton_info struct if any
+ * softbuttons are found.
+ *
+ * Returns prepared struct touchscreen_softbutton_info on success,
+ * %NULL if no softbuttons were found (this is not an error) or a ERR_PTR
+ * in case of an error.
+ *
+ * Note as this is a devm function the returned pointer does not need to
+ * be freed.
+ */
+struct touchscreen_softbutton_info *devm_touchscreen_alloc_softbuttons(
+					struct input_dev *input)
+{
+	struct device *dev = input->dev.parent;
+	struct device_node *np, *pp;
+	struct touchscreen_softbutton_info *info;
+	int i, err, button_count;
+
+	np = dev->of_node;
+	if (!np)
+		return NULL;
+
+	button_count = of_get_child_count(np);
+	if (button_count == 0)
+		return NULL;
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return ERR_PTR(-ENOMEM);
+
+	info->input = input;
+	info->button_count = button_count;
+	info->buttons = devm_kzalloc(dev, button_count * sizeof(*info->buttons),
+				     GFP_KERNEL);
+	if (!info->buttons)
+		return ERR_PTR(-ENOMEM);
+
+	for (pp = of_get_next_child(np, NULL), i = 0;
+	     pp != NULL;
+	     pp = of_get_next_child(np, pp), i++) {
+		struct touchscreen_softbutton *btn = &info->buttons[i];
+
+		err = of_property_read_u32(pp, "linux,code", &btn->keycode);
+		if (err) {
+			dev_err(dev, "%s: Inval linux,code prop\n", pp->name);
+			return ERR_PTR(-EINVAL);
+		}
+
+		err = of_property_read_u32(pp, "softbutton-min-x", &btn->min_x);
+		if (err) {
+			dev_err(dev, "%s: Inval min-x prop\n", pp->name);
+			return ERR_PTR(-EINVAL);
+		}
+
+		err = of_property_read_u32(pp, "softbutton-max-x", &btn->max_x);
+		if (err) {
+			dev_err(dev, "%s: Inval max-x prop\n", pp->name);
+			return ERR_PTR(-EINVAL);
+		}
+
+		err = of_property_read_u32(pp, "softbutton-min-y", &btn->min_y);
+		if (err) {
+			dev_err(dev, "%s: Inval min-y prop\n", pp->name);
+			return ERR_PTR(-EINVAL);
+		}
+
+		err = of_property_read_u32(pp, "softbutton-max-y", &btn->max_y);
+		if (err) {
+			dev_err(dev, "%s: Inval max-y prop\n", pp->name);
+			return ERR_PTR(-EINVAL);
+		}
+	}
+
+	__set_bit(EV_KEY, input->evbit);
+	for (i = 0; i < info->button_count; i++)
+		__set_bit(info->buttons[i].keycode, input->keybit);
+
+	return info;
+}
+
+/**
+ * touchscreen_handle_softbuttons - check for softbutton press
+ * @info: softbutton info retured by devm_touchscreen_alloc_softbuttons.
+ *
+ * This function checks if the passed in coordinates match any softbutton,
+ * and when they do reports a key press / release for the softbutton.
+ *
+ * Returns true if the coordinates match a softbutton and a key press / release
+ * was reported, false otherwise.
+ */
+bool touchscreen_handle_softbuttons(struct touchscreen_softbutton_info *info,
+				    unsigned int x, unsigned int y, bool down)
+{
+	int i;
+
+	if (info == NULL)
+		return false;
+
+	for (i = 0; i < info->button_count; i++) {
+		if (x >= info->buttons[i].min_x &&
+		    x <= info->buttons[i].max_x &&
+		    y >= info->buttons[i].min_y &&
+		    y <= info->buttons[i].max_y) {
+			input_report_key(info->input,
+					 info->buttons[i].keycode, down);
+			return true;
+		}
+	}
+
+	return false;
+}
diff --git a/include/linux/input/touchscreen.h b/include/linux/input/touchscreen.h
index 09d22cc..0b9d4ee 100644
--- a/include/linux/input/touchscreen.h
+++ b/include/linux/input/touchscreen.h
@@ -9,8 +9,11 @@
 #ifndef _TOUCHSCREEN_H
 #define _TOUCHSCREEN_H
 
+#include <linux/types.h>
+
 struct input_dev;
 struct input_mt_pos;
+struct touchscreen_softbutton_info;
 
 struct touchscreen_properties {
 	unsigned int max_x;
@@ -32,4 +35,10 @@ void touchscreen_report_pos(struct input_dev *input,
 			    unsigned int x, unsigned int y,
 			    bool multitouch);
 
+struct touchscreen_softbutton_info *devm_touchscreen_alloc_softbuttons(
+					struct input_dev *input);
+
+bool touchscreen_handle_softbuttons(struct touchscreen_softbutton_info *info,
+				    unsigned int x, unsigned int y, bool down);
+
 #endif
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/4] input: touchscreen: Add LED trigger support to the softbutton code
  2016-07-31 15:23 ` Hans de Goede
@ 2016-07-31 15:23     ` Hans de Goede
  -1 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-07-31 15:23 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: Maxime Ripard, Chen-Yu Tsai, linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
	Hans de Goede

In some hardware there are 1 or more LEDs behind the touchscreen
softbuttons, which are intended to provide visual feedback to the
user that the softbutton has been pressed, this commit adds support
for this.

Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 .../bindings/input/touchscreen/softbuttons.txt     |  4 ++
 drivers/input/touchscreen/softbuttons.c            | 49 +++++++++++++++++++++-
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
index 3eb6f4c..b425b95 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
@@ -17,6 +17,10 @@ Required subnode-properties:
  - softbutton-min-y		: Y start of the area the softbutton area covers
  - softbutton-max-y		: Y end of the area the softbutton area covers
 
+Optional subnode-properties:
+- linux,led-trigger		: String for a LED trigger for providing visual
+				  feedback that the softbutton has been pressed
+
 Example:
 
 #include <dt-bindings/input/input.h>
diff --git a/drivers/input/touchscreen/softbuttons.c b/drivers/input/touchscreen/softbuttons.c
index 47aea18..9a3fbfa 100644
--- a/drivers/input/touchscreen/softbuttons.c
+++ b/drivers/input/touchscreen/softbuttons.c
@@ -11,6 +11,7 @@
 
 #include <linux/input.h>
 #include <linux/input/touchscreen.h>
+#include <linux/leds.h>
 #include <linux/of.h>
 
 struct touchscreen_softbutton {
@@ -19,6 +20,8 @@ struct touchscreen_softbutton {
 	u32 min_y;
 	u32 max_y;
 	u32 keycode;
+	const char *ledtrigger_name;
+	struct led_trigger *ledtrigger;
 };
 
 struct touchscreen_softbutton_info {
@@ -48,7 +51,7 @@ struct touchscreen_softbutton_info *devm_touchscreen_alloc_softbuttons(
 	struct device *dev = input->dev.parent;
 	struct device_node *np, *pp;
 	struct touchscreen_softbutton_info *info;
-	int i, err, button_count;
+	int i, j, err, button_count;
 
 	np = dev->of_node;
 	if (!np)
@@ -103,6 +106,36 @@ struct touchscreen_softbutton_info *devm_touchscreen_alloc_softbuttons(
 			dev_err(dev, "%s: Inval max-y prop\n", pp->name);
 			return ERR_PTR(-EINVAL);
 		}
+
+		err = of_property_read_string(pp, "linux,led-trigger",
+					      &btn->ledtrigger_name);
+		if (err)
+			continue; /* The LED trigger is optional */
+
+		/* Check if another softbutton uses the same trigger */
+		for (j = 0; j < i; j++) {
+			if (info->buttons[j].ledtrigger_name &&
+			    strcmp(info->buttons[j].ledtrigger_name,
+				   btn->ledtrigger_name) == 0) {
+				btn->ledtrigger = info->buttons[j].ledtrigger;
+				break;
+			}
+		}
+		if (!btn->ledtrigger) {
+			btn->ledtrigger =
+				devm_kzalloc(dev, sizeof(*btn->ledtrigger),
+					     GFP_KERNEL);
+			if (!btn->ledtrigger)
+				return ERR_PTR(-ENOMEM);
+
+			btn->ledtrigger->name = btn->ledtrigger_name;
+			err = devm_led_trigger_register(dev, btn->ledtrigger);
+			if (err) {
+				dev_err(dev, "%s: Ledtrigger register error\n",
+					pp->name);
+				return ERR_PTR(err);
+			}
+		}
 	}
 
 	__set_bit(EV_KEY, input->evbit);
@@ -126,6 +159,7 @@ bool touchscreen_handle_softbuttons(struct touchscreen_softbutton_info *info,
 				    unsigned int x, unsigned int y, bool down)
 {
 	int i;
+	unsigned long led_delay = 1000; /* Keep the led on 1s after release */
 
 	if (info == NULL)
 		return false;
@@ -137,6 +171,19 @@ bool touchscreen_handle_softbuttons(struct touchscreen_softbutton_info *info,
 		    y <= info->buttons[i].max_y) {
 			input_report_key(info->input,
 					 info->buttons[i].keycode, down);
+
+			if (info->buttons[i].ledtrigger && down) {
+				led_trigger_event(info->buttons[i].ledtrigger,
+						  LED_FULL);
+			} else if (info->buttons[i].ledtrigger && !down) {
+				/* Led must be off before calling blink */
+				led_trigger_event(info->buttons[i].ledtrigger,
+						  LED_OFF);
+				led_trigger_blink_oneshot(
+					info->buttons[i].ledtrigger,
+					&led_delay, &led_delay, 0);
+			}
+
 			return true;
 		}
 	}
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/4] input: touchscreen: Add LED trigger support to the softbutton code
@ 2016-07-31 15:23     ` Hans de Goede
  0 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-07-31 15:23 UTC (permalink / raw)
  To: linux-arm-kernel

In some hardware there are 1 or more LEDs behind the touchscreen
softbuttons, which are intended to provide visual feedback to the
user that the softbutton has been pressed, this commit adds support
for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 .../bindings/input/touchscreen/softbuttons.txt     |  4 ++
 drivers/input/touchscreen/softbuttons.c            | 49 +++++++++++++++++++++-
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
index 3eb6f4c..b425b95 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
@@ -17,6 +17,10 @@ Required subnode-properties:
  - softbutton-min-y		: Y start of the area the softbutton area covers
  - softbutton-max-y		: Y end of the area the softbutton area covers
 
+Optional subnode-properties:
+- linux,led-trigger		: String for a LED trigger for providing visual
+				  feedback that the softbutton has been pressed
+
 Example:
 
 #include <dt-bindings/input/input.h>
diff --git a/drivers/input/touchscreen/softbuttons.c b/drivers/input/touchscreen/softbuttons.c
index 47aea18..9a3fbfa 100644
--- a/drivers/input/touchscreen/softbuttons.c
+++ b/drivers/input/touchscreen/softbuttons.c
@@ -11,6 +11,7 @@
 
 #include <linux/input.h>
 #include <linux/input/touchscreen.h>
+#include <linux/leds.h>
 #include <linux/of.h>
 
 struct touchscreen_softbutton {
@@ -19,6 +20,8 @@ struct touchscreen_softbutton {
 	u32 min_y;
 	u32 max_y;
 	u32 keycode;
+	const char *ledtrigger_name;
+	struct led_trigger *ledtrigger;
 };
 
 struct touchscreen_softbutton_info {
@@ -48,7 +51,7 @@ struct touchscreen_softbutton_info *devm_touchscreen_alloc_softbuttons(
 	struct device *dev = input->dev.parent;
 	struct device_node *np, *pp;
 	struct touchscreen_softbutton_info *info;
-	int i, err, button_count;
+	int i, j, err, button_count;
 
 	np = dev->of_node;
 	if (!np)
@@ -103,6 +106,36 @@ struct touchscreen_softbutton_info *devm_touchscreen_alloc_softbuttons(
 			dev_err(dev, "%s: Inval max-y prop\n", pp->name);
 			return ERR_PTR(-EINVAL);
 		}
+
+		err = of_property_read_string(pp, "linux,led-trigger",
+					      &btn->ledtrigger_name);
+		if (err)
+			continue; /* The LED trigger is optional */
+
+		/* Check if another softbutton uses the same trigger */
+		for (j = 0; j < i; j++) {
+			if (info->buttons[j].ledtrigger_name &&
+			    strcmp(info->buttons[j].ledtrigger_name,
+				   btn->ledtrigger_name) == 0) {
+				btn->ledtrigger = info->buttons[j].ledtrigger;
+				break;
+			}
+		}
+		if (!btn->ledtrigger) {
+			btn->ledtrigger =
+				devm_kzalloc(dev, sizeof(*btn->ledtrigger),
+					     GFP_KERNEL);
+			if (!btn->ledtrigger)
+				return ERR_PTR(-ENOMEM);
+
+			btn->ledtrigger->name = btn->ledtrigger_name;
+			err = devm_led_trigger_register(dev, btn->ledtrigger);
+			if (err) {
+				dev_err(dev, "%s: Ledtrigger register error\n",
+					pp->name);
+				return ERR_PTR(err);
+			}
+		}
 	}
 
 	__set_bit(EV_KEY, input->evbit);
@@ -126,6 +159,7 @@ bool touchscreen_handle_softbuttons(struct touchscreen_softbutton_info *info,
 				    unsigned int x, unsigned int y, bool down)
 {
 	int i;
+	unsigned long led_delay = 1000; /* Keep the led on 1s after release */
 
 	if (info == NULL)
 		return false;
@@ -137,6 +171,19 @@ bool touchscreen_handle_softbuttons(struct touchscreen_softbutton_info *info,
 		    y <= info->buttons[i].max_y) {
 			input_report_key(info->input,
 					 info->buttons[i].keycode, down);
+
+			if (info->buttons[i].ledtrigger && down) {
+				led_trigger_event(info->buttons[i].ledtrigger,
+						  LED_FULL);
+			} else if (info->buttons[i].ledtrigger && !down) {
+				/* Led must be off before calling blink */
+				led_trigger_event(info->buttons[i].ledtrigger,
+						  LED_OFF);
+				led_trigger_blink_oneshot(
+					info->buttons[i].ledtrigger,
+					&led_delay, &led_delay, 0);
+			}
+
 			return true;
 		}
 	}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/4] input: touchscreen: edt-ft5x06: Add support for softbuttons
  2016-07-31 15:23 ` Hans de Goede
@ 2016-07-31 15:23     ` Hans de Goede
  -1 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-07-31 15:23 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: Maxime Ripard, Chen-Yu Tsai, linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
	Hans de Goede

Add support for softbuttons to the edt-ft5x06 driver.

Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 drivers/input/touchscreen/edt-ft5x06.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 703e295..d19bf45 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -86,6 +86,7 @@ struct edt_reg_addr {
 struct edt_ft5x06_ts_data {
 	struct i2c_client *client;
 	struct input_dev *input;
+	struct touchscreen_softbutton_info *buttons;
 	struct touchscreen_properties prop;
 	u16 num_x;
 	u16 num_y;
@@ -241,6 +242,9 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
 		id = (buf[2] >> 4) & 0x0f;
 		down = type != TOUCH_EVENT_UP;
 
+		if (touchscreen_handle_softbuttons(tsdata->buttons, x, y, down))
+			continue;
+
 		input_mt_slot(tsdata->input, id);
 		input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, down);
 
@@ -975,6 +979,10 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 
 	touchscreen_parse_properties(input, true, &tsdata->prop);
 
+	tsdata->buttons = devm_touchscreen_alloc_softbuttons(input);
+	if (IS_ERR(tsdata->buttons))
+		return PTR_ERR(tsdata->buttons);
+
 	error = input_mt_init_slots(input, tsdata->max_support_points,
 				INPUT_MT_DIRECT);
 	if (error) {
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/4] input: touchscreen: edt-ft5x06: Add support for softbuttons
@ 2016-07-31 15:23     ` Hans de Goede
  0 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-07-31 15:23 UTC (permalink / raw)
  To: linux-arm-kernel

Add support for softbuttons to the edt-ft5x06 driver.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/input/touchscreen/edt-ft5x06.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 703e295..d19bf45 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -86,6 +86,7 @@ struct edt_reg_addr {
 struct edt_ft5x06_ts_data {
 	struct i2c_client *client;
 	struct input_dev *input;
+	struct touchscreen_softbutton_info *buttons;
 	struct touchscreen_properties prop;
 	u16 num_x;
 	u16 num_y;
@@ -241,6 +242,9 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
 		id = (buf[2] >> 4) & 0x0f;
 		down = type != TOUCH_EVENT_UP;
 
+		if (touchscreen_handle_softbuttons(tsdata->buttons, x, y, down))
+			continue;
+
 		input_mt_slot(tsdata->input, id);
 		input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, down);
 
@@ -975,6 +979,10 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
 
 	touchscreen_parse_properties(input, true, &tsdata->prop);
 
+	tsdata->buttons = devm_touchscreen_alloc_softbuttons(input);
+	if (IS_ERR(tsdata->buttons))
+		return PTR_ERR(tsdata->buttons);
+
 	error = input_mt_init_slots(input, tsdata->max_support_points,
 				INPUT_MT_DIRECT);
 	if (error) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/4] ARM: dts: sun4i: Describe softbuttons in dserve-dsrv9703c touchscreen node
  2016-07-31 15:23 ` Hans de Goede
@ 2016-07-31 15:23   ` Hans de Goede
  -1 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-07-31 15:23 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: Maxime Ripard, Chen-Yu Tsai, linux-input, linux-arm-kernel,
	devicetree, Hans de Goede

The dserve-dsrv9703c touchscreen has 3 softbuttons, describe these
in the dts.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dts | 49 ++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dts b/arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dts
index 893497e..92e15e4 100644
--- a/arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dts
+++ b/arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dts
@@ -78,6 +78,18 @@
 		max-microvolt = <3000000>;
 	};
 
+	leds {
+		compatible = "gpio-leds";
+		pinctrl-names = "default";
+		pinctrl-0 = <&led_pins>;
+
+		touchscreen_softbuttons_led {
+			label = "dsrv9703c:white:touschscreen-softbuttons";
+			gpios = <&pio 0 5 GPIO_ACTIVE_HIGH>; /* PA5 */
+			linux,default-trigger = "touschscreen-softbuttons";
+		};
+	};
+
 	reg_motor: reg_motor {
 		compatible = "regulator-fixed";
 		pinctrl-names = "default";
@@ -140,6 +152,36 @@
 		reset-gpios = <&pio 1 13 GPIO_ACTIVE_LOW>;
 		touchscreen-size-x = <1024>;
 		touchscreen-size-y = <768>;
+
+		button@0 {
+			label = "Esc";
+			linux,code = <KEY_ESC>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <0>;
+			softbutton-max-y = <49>;
+			linux,led-trigger = "touschscreen-softbuttons";
+		};
+
+		button@1 {
+			label = "Home";
+			linux,code = <KEY_HOMEPAGE>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <50>;
+			softbutton-max-y = <99>;
+			linux,led-trigger = "touschscreen-softbuttons";
+		};
+
+		button@2 {
+			label = "Menu";
+			linux,code = <KEY_MENU>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <100>;
+			softbutton-max-y = <149>;
+			linux,led-trigger = "touschscreen-softbuttons";
+		};
 	};
 };
 
@@ -191,6 +233,13 @@
 		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 	};
 
+	led_pins: led_pins@0 {
+		allwinner,pins = "PA5";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+	};
+
 	motor_pins: motor_pins@0 {
 		allwinner,pins = "PB3";
 		allwinner,function = "gpio_out";
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/4] ARM: dts: sun4i: Describe softbuttons in dserve-dsrv9703c touchscreen node
@ 2016-07-31 15:23   ` Hans de Goede
  0 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-07-31 15:23 UTC (permalink / raw)
  To: linux-arm-kernel

The dserve-dsrv9703c touchscreen has 3 softbuttons, describe these
in the dts.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dts | 49 ++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dts b/arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dts
index 893497e..92e15e4 100644
--- a/arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dts
+++ b/arch/arm/boot/dts/sun4i-a10-dserve-dsrv9703c.dts
@@ -78,6 +78,18 @@
 		max-microvolt = <3000000>;
 	};
 
+	leds {
+		compatible = "gpio-leds";
+		pinctrl-names = "default";
+		pinctrl-0 = <&led_pins>;
+
+		touchscreen_softbuttons_led {
+			label = "dsrv9703c:white:touschscreen-softbuttons";
+			gpios = <&pio 0 5 GPIO_ACTIVE_HIGH>; /* PA5 */
+			linux,default-trigger = "touschscreen-softbuttons";
+		};
+	};
+
 	reg_motor: reg_motor {
 		compatible = "regulator-fixed";
 		pinctrl-names = "default";
@@ -140,6 +152,36 @@
 		reset-gpios = <&pio 1 13 GPIO_ACTIVE_LOW>;
 		touchscreen-size-x = <1024>;
 		touchscreen-size-y = <768>;
+
+		button at 0 {
+			label = "Esc";
+			linux,code = <KEY_ESC>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <0>;
+			softbutton-max-y = <49>;
+			linux,led-trigger = "touschscreen-softbuttons";
+		};
+
+		button at 1 {
+			label = "Home";
+			linux,code = <KEY_HOMEPAGE>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <50>;
+			softbutton-max-y = <99>;
+			linux,led-trigger = "touschscreen-softbuttons";
+		};
+
+		button at 2 {
+			label = "Menu";
+			linux,code = <KEY_MENU>;
+			softbutton-min-x = <1084>;
+			softbutton-max-x = <1098>;
+			softbutton-min-y = <100>;
+			softbutton-max-y = <149>;
+			linux,led-trigger = "touschscreen-softbuttons";
+		};
 	};
 };
 
@@ -191,6 +233,13 @@
 		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 	};
 
+	led_pins: led_pins at 0 {
+		allwinner,pins = "PA5";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+	};
+
 	motor_pins: motor_pins at 0 {
 		allwinner,pins = "PB3";
 		allwinner,function = "gpio_out";
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
  2016-07-31 15:23   ` Hans de Goede
@ 2016-08-01 16:54     ` Rob Herring
  -1 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2016-08-01 16:54 UTC (permalink / raw)
  To: Hans de Goede
  Cc: devicetree, Dmitry Torokhov, Chen-Yu Tsai, linux-input,
	Maxime Ripard, linux-arm-kernel

On Sun, Jul 31, 2016 at 05:23:07PM +0200, Hans de Goede wrote:
> Some touchscreens extend over the display they cover and have a number
> of capacative softbuttons outside of the display the cover.
> 
> With some hardware these softbuttons simply report touches with
> coordinates outside of the normal coordinate space for touches on the
> display.
> 
> This commit adds a devicetree binding for describing such buttons in
> devicetree and a bunch of helper functions to easily add support for
> these to existing touchscreen drivers.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
>  drivers/input/touchscreen/Makefile                 |   2 +-
>  drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
>  include/linux/input/touchscreen.h                  |   9 ++
>  4 files changed, 213 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>  create mode 100644 drivers/input/touchscreen/softbuttons.c
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
> new file mode 100644
> index 0000000..3eb6f4c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
> @@ -0,0 +1,58 @@
> +General Touchscreen Softbutton Properties:
> +
> +Some touchscreens extend over the display they cover and have a number
> +of capacative softbuttons outside of the display the cover.
> +
> +Some of these softbuttons simply report touches with coordinates outside of
> +the normal coordinate space for touches on the display. This binding is for
> +describing such buttons in devicetree.
> +
> +Each softkey is represented as a sub-node of the touchscreen node.
> +
> +Required subnode-properties:
> + - label			: Descriptive name of the key.
> + - linux,code			: Keycode to emit.
> + - softbutton-min-x		: X start of the area the softbutton area covers
> + - softbutton-max-x		: X end of the area the softbutton area covers
> + - softbutton-min-y		: Y start of the area the softbutton area covers
> + - softbutton-max-y		: Y end of the area the softbutton area covers

This generally looks fine to me, but I am wondering one thing. If the 
buttons are located at the origin of an axis, can we handle that case? I 
don't think you can unless you assume softbutton-max-? is 0 for the 
touchscreen. To put it another way, you have a gap from 1024 to 1084 
which you can't express for buttons at the origin unless you do negative 
numbers.

Rob

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
@ 2016-08-01 16:54     ` Rob Herring
  0 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2016-08-01 16:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Jul 31, 2016 at 05:23:07PM +0200, Hans de Goede wrote:
> Some touchscreens extend over the display they cover and have a number
> of capacative softbuttons outside of the display the cover.
> 
> With some hardware these softbuttons simply report touches with
> coordinates outside of the normal coordinate space for touches on the
> display.
> 
> This commit adds a devicetree binding for describing such buttons in
> devicetree and a bunch of helper functions to easily add support for
> these to existing touchscreen drivers.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
>  drivers/input/touchscreen/Makefile                 |   2 +-
>  drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
>  include/linux/input/touchscreen.h                  |   9 ++
>  4 files changed, 213 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>  create mode 100644 drivers/input/touchscreen/softbuttons.c
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
> new file mode 100644
> index 0000000..3eb6f4c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
> @@ -0,0 +1,58 @@
> +General Touchscreen Softbutton Properties:
> +
> +Some touchscreens extend over the display they cover and have a number
> +of capacative softbuttons outside of the display the cover.
> +
> +Some of these softbuttons simply report touches with coordinates outside of
> +the normal coordinate space for touches on the display. This binding is for
> +describing such buttons in devicetree.
> +
> +Each softkey is represented as a sub-node of the touchscreen node.
> +
> +Required subnode-properties:
> + - label			: Descriptive name of the key.
> + - linux,code			: Keycode to emit.
> + - softbutton-min-x		: X start of the area the softbutton area covers
> + - softbutton-max-x		: X end of the area the softbutton area covers
> + - softbutton-min-y		: Y start of the area the softbutton area covers
> + - softbutton-max-y		: Y end of the area the softbutton area covers

This generally looks fine to me, but I am wondering one thing. If the 
buttons are located at the origin of an axis, can we handle that case? I 
don't think you can unless you assume softbutton-max-? is 0 for the 
touchscreen. To put it another way, you have a gap from 1024 to 1084 
which you can't express for buttons at the origin unless you do negative 
numbers.

Rob

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
  2016-08-01 16:54     ` Rob Herring
@ 2016-08-01 17:41       ` Dmitry Torokhov
  -1 siblings, 0 replies; 20+ messages in thread
From: Dmitry Torokhov @ 2016-08-01 17:41 UTC (permalink / raw)
  To: Rob Herring
  Cc: Hans de Goede, Maxime Ripard, Chen-Yu Tsai,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree

On Mon, Aug 01, 2016 at 11:54:30AM -0500, Rob Herring wrote:
> On Sun, Jul 31, 2016 at 05:23:07PM +0200, Hans de Goede wrote:
> > Some touchscreens extend over the display they cover and have a number
> > of capacative softbuttons outside of the display the cover.
> > 
> > With some hardware these softbuttons simply report touches with
> > coordinates outside of the normal coordinate space for touches on the
> > display.
> > 
> > This commit adds a devicetree binding for describing such buttons in
> > devicetree and a bunch of helper functions to easily add support for
> > these to existing touchscreen drivers.
> > 
> > Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > ---
> >  .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
> >  drivers/input/touchscreen/Makefile                 |   2 +-
> >  drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
> >  include/linux/input/touchscreen.h                  |   9 ++
> >  4 files changed, 213 insertions(+), 1 deletion(-)
> >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
> >  create mode 100644 drivers/input/touchscreen/softbuttons.c
> > 
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
> > new file mode 100644
> > index 0000000..3eb6f4c
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
> > @@ -0,0 +1,58 @@
> > +General Touchscreen Softbutton Properties:
> > +
> > +Some touchscreens extend over the display they cover and have a number
> > +of capacative softbuttons outside of the display the cover.
> > +
> > +Some of these softbuttons simply report touches with coordinates outside of
> > +the normal coordinate space for touches on the display. This binding is for
> > +describing such buttons in devicetree.
> > +
> > +Each softkey is represented as a sub-node of the touchscreen node.
> > +
> > +Required subnode-properties:
> > + - label			: Descriptive name of the key.
> > + - linux,code			: Keycode to emit.
> > + - softbutton-min-x		: X start of the area the softbutton area covers
> > + - softbutton-max-x		: X end of the area the softbutton area covers
> > + - softbutton-min-y		: Y start of the area the softbutton area covers
> > + - softbutton-max-y		: Y end of the area the softbutton area covers
> 
> This generally looks fine to me, but I am wondering one thing. If the 
> buttons are located at the origin of an axis, can we handle that case? I 
> don't think you can unless you assume softbutton-max-? is 0 for the 
> touchscreen. To put it another way, you have a gap from 1024 to 1084 
> which you can't express for buttons at the origin unless you do negative 
> numbers.

I do not this this should be done in kernel: I do not see nay difference
in softbuttons or sliders or circular controls or... They are not
controller-specific and I think are better handled in userspace. We do
that for Synaptics touchpads with softbuttons, we can do that for other
controllers.

Also, what is or stance when there is no bezel and we sill want to have
the softbutons (i.e. all Nexus phones and tablets)?

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
@ 2016-08-01 17:41       ` Dmitry Torokhov
  0 siblings, 0 replies; 20+ messages in thread
From: Dmitry Torokhov @ 2016-08-01 17:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Aug 01, 2016 at 11:54:30AM -0500, Rob Herring wrote:
> On Sun, Jul 31, 2016 at 05:23:07PM +0200, Hans de Goede wrote:
> > Some touchscreens extend over the display they cover and have a number
> > of capacative softbuttons outside of the display the cover.
> > 
> > With some hardware these softbuttons simply report touches with
> > coordinates outside of the normal coordinate space for touches on the
> > display.
> > 
> > This commit adds a devicetree binding for describing such buttons in
> > devicetree and a bunch of helper functions to easily add support for
> > these to existing touchscreen drivers.
> > 
> > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > ---
> >  .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
> >  drivers/input/touchscreen/Makefile                 |   2 +-
> >  drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
> >  include/linux/input/touchscreen.h                  |   9 ++
> >  4 files changed, 213 insertions(+), 1 deletion(-)
> >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
> >  create mode 100644 drivers/input/touchscreen/softbuttons.c
> > 
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
> > new file mode 100644
> > index 0000000..3eb6f4c
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
> > @@ -0,0 +1,58 @@
> > +General Touchscreen Softbutton Properties:
> > +
> > +Some touchscreens extend over the display they cover and have a number
> > +of capacative softbuttons outside of the display the cover.
> > +
> > +Some of these softbuttons simply report touches with coordinates outside of
> > +the normal coordinate space for touches on the display. This binding is for
> > +describing such buttons in devicetree.
> > +
> > +Each softkey is represented as a sub-node of the touchscreen node.
> > +
> > +Required subnode-properties:
> > + - label			: Descriptive name of the key.
> > + - linux,code			: Keycode to emit.
> > + - softbutton-min-x		: X start of the area the softbutton area covers
> > + - softbutton-max-x		: X end of the area the softbutton area covers
> > + - softbutton-min-y		: Y start of the area the softbutton area covers
> > + - softbutton-max-y		: Y end of the area the softbutton area covers
> 
> This generally looks fine to me, but I am wondering one thing. If the 
> buttons are located at the origin of an axis, can we handle that case? I 
> don't think you can unless you assume softbutton-max-? is 0 for the 
> touchscreen. To put it another way, you have a gap from 1024 to 1084 
> which you can't express for buttons at the origin unless you do negative 
> numbers.

I do not this this should be done in kernel: I do not see nay difference
in softbuttons or sliders or circular controls or... They are not
controller-specific and I think are better handled in userspace. We do
that for Synaptics touchpads with softbuttons, we can do that for other
controllers.

Also, what is or stance when there is no bezel and we sill want to have
the softbutons (i.e. all Nexus phones and tablets)?

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
  2016-08-01 16:54     ` Rob Herring
@ 2016-08-02  8:19       ` Hans de Goede
  -1 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-08-02  8:19 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, Dmitry Torokhov, Chen-Yu Tsai, linux-input,
	Maxime Ripard, linux-arm-kernel

Hi Rob,

On 01-08-16 18:54, Rob Herring wrote:
> On Sun, Jul 31, 2016 at 05:23:07PM +0200, Hans de Goede wrote:
>> Some touchscreens extend over the display they cover and have a number
>> of capacative softbuttons outside of the display the cover.
>>
>> With some hardware these softbuttons simply report touches with
>> coordinates outside of the normal coordinate space for touches on the
>> display.
>>
>> This commit adds a devicetree binding for describing such buttons in
>> devicetree and a bunch of helper functions to easily add support for
>> these to existing touchscreen drivers.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>  .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
>>  drivers/input/touchscreen/Makefile                 |   2 +-
>>  drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
>>  include/linux/input/touchscreen.h                  |   9 ++
>>  4 files changed, 213 insertions(+), 1 deletion(-)
>>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>  create mode 100644 drivers/input/touchscreen/softbuttons.c
>>
>> diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>> new file mode 100644
>> index 0000000..3eb6f4c
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>> @@ -0,0 +1,58 @@
>> +General Touchscreen Softbutton Properties:
>> +
>> +Some touchscreens extend over the display they cover and have a number
>> +of capacative softbuttons outside of the display the cover.
>> +
>> +Some of these softbuttons simply report touches with coordinates outside of
>> +the normal coordinate space for touches on the display. This binding is for
>> +describing such buttons in devicetree.
>> +
>> +Each softkey is represented as a sub-node of the touchscreen node.
>> +
>> +Required subnode-properties:
>> + - label			: Descriptive name of the key.
>> + - linux,code			: Keycode to emit.
>> + - softbutton-min-x		: X start of the area the softbutton area covers
>> + - softbutton-max-x		: X end of the area the softbutton area covers
>> + - softbutton-min-y		: Y start of the area the softbutton area covers
>> + - softbutton-max-y		: Y end of the area the softbutton area covers
>
> This generally looks fine to me, but I am wondering one thing. If the
> buttons are located at the origin of an axis, can we handle that case? I
> don't think you can unless you assume softbutton-max-? is 0 for the
> touchscreen. To put it another way, you have a gap from 1024 to 1084
> which you can't express for buttons at the origin unless you do negative
> numbers.

Actually for the touchscreen I'm working on:

https://content.hwigroup.net/images/products_xl/157078/dserve-dsrv-9703c.jpg

The buttons are past the display edge which corresponds to x coordinate 0,
so they should logically send negative coordinates but the "firmware" (which
I believe is more config / calibration data) maps them to coordinates above
1024, so logically across the other edge. But I can envision some other
hardware doing this differently. I suggest we deal with this when we need too,
likely we just need to add a note that the dt min/max values should be interpreted
as a s32 rather then an u32, I can do that now if you want.

Regards,

Hans




>
> Rob
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
@ 2016-08-02  8:19       ` Hans de Goede
  0 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-08-02  8:19 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Rob,

On 01-08-16 18:54, Rob Herring wrote:
> On Sun, Jul 31, 2016 at 05:23:07PM +0200, Hans de Goede wrote:
>> Some touchscreens extend over the display they cover and have a number
>> of capacative softbuttons outside of the display the cover.
>>
>> With some hardware these softbuttons simply report touches with
>> coordinates outside of the normal coordinate space for touches on the
>> display.
>>
>> This commit adds a devicetree binding for describing such buttons in
>> devicetree and a bunch of helper functions to easily add support for
>> these to existing touchscreen drivers.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>  .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
>>  drivers/input/touchscreen/Makefile                 |   2 +-
>>  drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
>>  include/linux/input/touchscreen.h                  |   9 ++
>>  4 files changed, 213 insertions(+), 1 deletion(-)
>>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>  create mode 100644 drivers/input/touchscreen/softbuttons.c
>>
>> diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>> new file mode 100644
>> index 0000000..3eb6f4c
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>> @@ -0,0 +1,58 @@
>> +General Touchscreen Softbutton Properties:
>> +
>> +Some touchscreens extend over the display they cover and have a number
>> +of capacative softbuttons outside of the display the cover.
>> +
>> +Some of these softbuttons simply report touches with coordinates outside of
>> +the normal coordinate space for touches on the display. This binding is for
>> +describing such buttons in devicetree.
>> +
>> +Each softkey is represented as a sub-node of the touchscreen node.
>> +
>> +Required subnode-properties:
>> + - label			: Descriptive name of the key.
>> + - linux,code			: Keycode to emit.
>> + - softbutton-min-x		: X start of the area the softbutton area covers
>> + - softbutton-max-x		: X end of the area the softbutton area covers
>> + - softbutton-min-y		: Y start of the area the softbutton area covers
>> + - softbutton-max-y		: Y end of the area the softbutton area covers
>
> This generally looks fine to me, but I am wondering one thing. If the
> buttons are located at the origin of an axis, can we handle that case? I
> don't think you can unless you assume softbutton-max-? is 0 for the
> touchscreen. To put it another way, you have a gap from 1024 to 1084
> which you can't express for buttons at the origin unless you do negative
> numbers.

Actually for the touchscreen I'm working on:

https://content.hwigroup.net/images/products_xl/157078/dserve-dsrv-9703c.jpg

The buttons are past the display edge which corresponds to x coordinate 0,
so they should logically send negative coordinates but the "firmware" (which
I believe is more config / calibration data) maps them to coordinates above
1024, so logically across the other edge. But I can envision some other
hardware doing this differently. I suggest we deal with this when we need too,
likely we just need to add a note that the dt min/max values should be interpreted
as a s32 rather then an u32, I can do that now if you want.

Regards,

Hans




>
> Rob
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
  2016-08-01 17:41       ` Dmitry Torokhov
@ 2016-08-02  8:33         ` Hans de Goede
  -1 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-08-02  8:33 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: Maxime Ripard, Chen-Yu Tsai, linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree

Hi,

On 01-08-16 19:41, Dmitry Torokhov wrote:
> On Mon, Aug 01, 2016 at 11:54:30AM -0500, Rob Herring wrote:
>> On Sun, Jul 31, 2016 at 05:23:07PM +0200, Hans de Goede wrote:
>>> Some touchscreens extend over the display they cover and have a number
>>> of capacative softbuttons outside of the display the cover.
>>>
>>> With some hardware these softbuttons simply report touches with
>>> coordinates outside of the normal coordinate space for touches on the
>>> display.
>>>
>>> This commit adds a devicetree binding for describing such buttons in
>>> devicetree and a bunch of helper functions to easily add support for
>>> these to existing touchscreen drivers.
>>>
>>> Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>>> ---
>>>  .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
>>>  drivers/input/touchscreen/Makefile                 |   2 +-
>>>  drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
>>>  include/linux/input/touchscreen.h                  |   9 ++
>>>  4 files changed, 213 insertions(+), 1 deletion(-)
>>>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>>  create mode 100644 drivers/input/touchscreen/softbuttons.c
>>>
>>> diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>> new file mode 100644
>>> index 0000000..3eb6f4c
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>> @@ -0,0 +1,58 @@
>>> +General Touchscreen Softbutton Properties:
>>> +
>>> +Some touchscreens extend over the display they cover and have a number
>>> +of capacative softbuttons outside of the display the cover.
>>> +
>>> +Some of these softbuttons simply report touches with coordinates outside of
>>> +the normal coordinate space for touches on the display. This binding is for
>>> +describing such buttons in devicetree.
>>> +
>>> +Each softkey is represented as a sub-node of the touchscreen node.
>>> +
>>> +Required subnode-properties:
>>> + - label			: Descriptive name of the key.
>>> + - linux,code			: Keycode to emit.
>>> + - softbutton-min-x		: X start of the area the softbutton area covers
>>> + - softbutton-max-x		: X end of the area the softbutton area covers
>>> + - softbutton-min-y		: Y start of the area the softbutton area covers
>>> + - softbutton-max-y		: Y end of the area the softbutton area covers
>>
>> This generally looks fine to me, but I am wondering one thing. If the
>> buttons are located at the origin of an axis, can we handle that case? I
>> don't think you can unless you assume softbutton-max-? is 0 for the
>> touchscreen. To put it another way, you have a gap from 1024 to 1084
>> which you can't express for buttons at the origin unless you do negative
>> numbers.
>
> I do not this this should be done in kernel: I do not see nay difference
> in softbuttons or sliders or circular controls or... They are not
> controller-specific and I think are better handled in userspace. We do
> that for Synaptics touchpads with softbuttons, we can do that for other
> controllers.
>
> Also, what is or stance when there is no bezel and we sill want to have
> the softbutons (i.e. all Nexus phones and tablets)?

Maybe softbuttons is not the best name (I googled and it seemed to match),
so first lets make clear what I'm talking about here, I wrote this patch-set
for this tablet:

https://content.hwigroup.net/images/products_xl/157078/dserve-dsrv-9703c.jpg

I decided to make it generic, since it seemed to me that there will likely
be other hardware which is similar (but uses a different touch screen
controller) out there, so keeping this generic seemed best.

Now back to the kernelspace vs userspace solution question, if you look at
the picture you will see 3 clearly marked buttons on the front of the tablet,
outside of the display: menu, home and back. These are not buttons which get
generated / drawn on the display when you touch the bottom of the screen, these
are separate single-purpose buttons which happen to report presses via the
touchscreen controller then via a separate hw mechanism.

If these buttons used a separate capacative button controller as used in
e.g. capacitive numpads, say something like this:

http://www.ebay.com/itm/2PCS-TTP223-Capacitive-Touch-Switch-Button-Self-Lock-Module-for-Arduino-/131662428748

Then there would be no question that this belongs in the kernel. I do not
see how these are any different really. These cannot be runtime re-configured,
they are separate dedicated buttons which happens to report presses via
the touchscreen controllers.

There also is the question of hardware description, no matter where we
put support for this, we need some place were we describe the presence
of these buttons to the software bits which end up dealing with them.

And we already have a mechanism for describing "fixed" hardware for a
certain model machine / board in the form of devicetree. To me putting
the hardware description for this anywhere but in devicetree makes
no sense because then we start scattering the description of a single
device-type over multiple places which seems like a bad idea.

And once we decided to put the description in devicetree, then dealing
with this in the kernel becomes the logical thing to do.

Regards,

Hans


p.s.

One other example of buttons like these are those on the nexus one:

http://www.informatica.com.do/7BZ-PortalImageUpload/image/2010151059110.google-nexus-one-01.jpg

Note I'm not saying this binding will work for those, I've no idea how
they are hooked up, but they are the same in that they are really
4 dedicated separate buttons which happen to be part of the main digitizer.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
@ 2016-08-02  8:33         ` Hans de Goede
  0 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-08-02  8:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 01-08-16 19:41, Dmitry Torokhov wrote:
> On Mon, Aug 01, 2016 at 11:54:30AM -0500, Rob Herring wrote:
>> On Sun, Jul 31, 2016 at 05:23:07PM +0200, Hans de Goede wrote:
>>> Some touchscreens extend over the display they cover and have a number
>>> of capacative softbuttons outside of the display the cover.
>>>
>>> With some hardware these softbuttons simply report touches with
>>> coordinates outside of the normal coordinate space for touches on the
>>> display.
>>>
>>> This commit adds a devicetree binding for describing such buttons in
>>> devicetree and a bunch of helper functions to easily add support for
>>> these to existing touchscreen drivers.
>>>
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>> ---
>>>  .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
>>>  drivers/input/touchscreen/Makefile                 |   2 +-
>>>  drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
>>>  include/linux/input/touchscreen.h                  |   9 ++
>>>  4 files changed, 213 insertions(+), 1 deletion(-)
>>>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>>  create mode 100644 drivers/input/touchscreen/softbuttons.c
>>>
>>> diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>> new file mode 100644
>>> index 0000000..3eb6f4c
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>> @@ -0,0 +1,58 @@
>>> +General Touchscreen Softbutton Properties:
>>> +
>>> +Some touchscreens extend over the display they cover and have a number
>>> +of capacative softbuttons outside of the display the cover.
>>> +
>>> +Some of these softbuttons simply report touches with coordinates outside of
>>> +the normal coordinate space for touches on the display. This binding is for
>>> +describing such buttons in devicetree.
>>> +
>>> +Each softkey is represented as a sub-node of the touchscreen node.
>>> +
>>> +Required subnode-properties:
>>> + - label			: Descriptive name of the key.
>>> + - linux,code			: Keycode to emit.
>>> + - softbutton-min-x		: X start of the area the softbutton area covers
>>> + - softbutton-max-x		: X end of the area the softbutton area covers
>>> + - softbutton-min-y		: Y start of the area the softbutton area covers
>>> + - softbutton-max-y		: Y end of the area the softbutton area covers
>>
>> This generally looks fine to me, but I am wondering one thing. If the
>> buttons are located at the origin of an axis, can we handle that case? I
>> don't think you can unless you assume softbutton-max-? is 0 for the
>> touchscreen. To put it another way, you have a gap from 1024 to 1084
>> which you can't express for buttons at the origin unless you do negative
>> numbers.
>
> I do not this this should be done in kernel: I do not see nay difference
> in softbuttons or sliders or circular controls or... They are not
> controller-specific and I think are better handled in userspace. We do
> that for Synaptics touchpads with softbuttons, we can do that for other
> controllers.
>
> Also, what is or stance when there is no bezel and we sill want to have
> the softbutons (i.e. all Nexus phones and tablets)?

Maybe softbuttons is not the best name (I googled and it seemed to match),
so first lets make clear what I'm talking about here, I wrote this patch-set
for this tablet:

https://content.hwigroup.net/images/products_xl/157078/dserve-dsrv-9703c.jpg

I decided to make it generic, since it seemed to me that there will likely
be other hardware which is similar (but uses a different touch screen
controller) out there, so keeping this generic seemed best.

Now back to the kernelspace vs userspace solution question, if you look at
the picture you will see 3 clearly marked buttons on the front of the tablet,
outside of the display: menu, home and back. These are not buttons which get
generated / drawn on the display when you touch the bottom of the screen, these
are separate single-purpose buttons which happen to report presses via the
touchscreen controller then via a separate hw mechanism.

If these buttons used a separate capacative button controller as used in
e.g. capacitive numpads, say something like this:

http://www.ebay.com/itm/2PCS-TTP223-Capacitive-Touch-Switch-Button-Self-Lock-Module-for-Arduino-/131662428748

Then there would be no question that this belongs in the kernel. I do not
see how these are any different really. These cannot be runtime re-configured,
they are separate dedicated buttons which happens to report presses via
the touchscreen controllers.

There also is the question of hardware description, no matter where we
put support for this, we need some place were we describe the presence
of these buttons to the software bits which end up dealing with them.

And we already have a mechanism for describing "fixed" hardware for a
certain model machine / board in the form of devicetree. To me putting
the hardware description for this anywhere but in devicetree makes
no sense because then we start scattering the description of a single
device-type over multiple places which seems like a bad idea.

And once we decided to put the description in devicetree, then dealing
with this in the kernel becomes the logical thing to do.

Regards,

Hans


p.s.

One other example of buttons like these are those on the nexus one:

http://www.informatica.com.do/7BZ-PortalImageUpload/image/2010151059110.google-nexus-one-01.jpg

Note I'm not saying this binding will work for those, I've no idea how
they are hooked up, but they are the same in that they are really
4 dedicated separate buttons which happen to be part of the main digitizer.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
  2016-08-02  8:33         ` Hans de Goede
@ 2016-08-11  9:21           ` Hans de Goede
  -1 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-08-11  9:21 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring
  Cc: Maxime Ripard, Chen-Yu Tsai, linux-input, linux-arm-kernel, devicetree



On 02-08-16 10:33, Hans de Goede wrote:
> Hi,
>
> On 01-08-16 19:41, Dmitry Torokhov wrote:
>> On Mon, Aug 01, 2016 at 11:54:30AM -0500, Rob Herring wrote:
>>> On Sun, Jul 31, 2016 at 05:23:07PM +0200, Hans de Goede wrote:
>>>> Some touchscreens extend over the display they cover and have a number
>>>> of capacative softbuttons outside of the display the cover.
>>>>
>>>> With some hardware these softbuttons simply report touches with
>>>> coordinates outside of the normal coordinate space for touches on the
>>>> display.
>>>>
>>>> This commit adds a devicetree binding for describing such buttons in
>>>> devicetree and a bunch of helper functions to easily add support for
>>>> these to existing touchscreen drivers.
>>>>
>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>>> ---
>>>>  .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
>>>>  drivers/input/touchscreen/Makefile                 |   2 +-
>>>>  drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
>>>>  include/linux/input/touchscreen.h                  |   9 ++
>>>>  4 files changed, 213 insertions(+), 1 deletion(-)
>>>>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>>>  create mode 100644 drivers/input/touchscreen/softbuttons.c
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>>> new file mode 100644
>>>> index 0000000..3eb6f4c
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>>> @@ -0,0 +1,58 @@
>>>> +General Touchscreen Softbutton Properties:
>>>> +
>>>> +Some touchscreens extend over the display they cover and have a number
>>>> +of capacative softbuttons outside of the display the cover.
>>>> +
>>>> +Some of these softbuttons simply report touches with coordinates outside of
>>>> +the normal coordinate space for touches on the display. This binding is for
>>>> +describing such buttons in devicetree.
>>>> +
>>>> +Each softkey is represented as a sub-node of the touchscreen node.
>>>> +
>>>> +Required subnode-properties:
>>>> + - label            : Descriptive name of the key.
>>>> + - linux,code            : Keycode to emit.
>>>> + - softbutton-min-x        : X start of the area the softbutton area covers
>>>> + - softbutton-max-x        : X end of the area the softbutton area covers
>>>> + - softbutton-min-y        : Y start of the area the softbutton area covers
>>>> + - softbutton-max-y        : Y end of the area the softbutton area covers
>>>
>>> This generally looks fine to me, but I am wondering one thing. If the
>>> buttons are located at the origin of an axis, can we handle that case? I
>>> don't think you can unless you assume softbutton-max-? is 0 for the
>>> touchscreen. To put it another way, you have a gap from 1024 to 1084
>>> which you can't express for buttons at the origin unless you do negative
>>> numbers.
>>
>> I do not this this should be done in kernel: I do not see nay difference
>> in softbuttons or sliders or circular controls or... They are not
>> controller-specific and I think are better handled in userspace. We do
>> that for Synaptics touchpads with softbuttons, we can do that for other
>> controllers.
>>
>> Also, what is or stance when there is no bezel and we sill want to have
>> the softbutons (i.e. all Nexus phones and tablets)?
>
> Maybe softbuttons is not the best name (I googled and it seemed to match),
> so first lets make clear what I'm talking about here, I wrote this patch-set
> for this tablet:
>
> https://content.hwigroup.net/images/products_xl/157078/dserve-dsrv-9703c.jpg
>
> I decided to make it generic, since it seemed to me that there will likely
> be other hardware which is similar (but uses a different touch screen
> controller) out there, so keeping this generic seemed best.
>
> Now back to the kernelspace vs userspace solution question, if you look at
> the picture you will see 3 clearly marked buttons on the front of the tablet,
> outside of the display: menu, home and back. These are not buttons which get
> generated / drawn on the display when you touch the bottom of the screen, these
> are separate single-purpose buttons which happen to report presses via the
> touchscreen controller then via a separate hw mechanism.
>
> If these buttons used a separate capacative button controller as used in
> e.g. capacitive numpads, say something like this:
>
> http://www.ebay.com/itm/2PCS-TTP223-Capacitive-Touch-Switch-Button-Self-Lock-Module-for-Arduino-/131662428748
>
> Then there would be no question that this belongs in the kernel. I do not
> see how these are any different really. These cannot be runtime re-configured,
> they are separate dedicated buttons which happens to report presses via
> the touchscreen controllers.
>
> There also is the question of hardware description, no matter where we
> put support for this, we need some place were we describe the presence
> of these buttons to the software bits which end up dealing with them.
>
> And we already have a mechanism for describing "fixed" hardware for a
> certain model machine / board in the form of devicetree. To me putting
> the hardware description for this anywhere but in devicetree makes
> no sense because then we start scattering the description of a single
> device-type over multiple places which seems like a bad idea.
>
> And once we decided to put the description in devicetree, then dealing
> with this in the kernel becomes the logical thing to do.
>
> Regards,
>
> Hans
>
>
> p.s.
>
> One other example of buttons like these are those on the nexus one:
>
> http://www.informatica.com.do/7BZ-PortalImageUpload/image/2010151059110.google-nexus-one-01.jpg
>
> Note I'm not saying this binding will work for those, I've no idea how
> they are hooked up, but they are the same in that they are really
> 4 dedicated separate buttons which happen to be part of the main digitizer.

Dmitry, ping? Any reaction to the above ?

Regards,

Hans


p.s.

I've been thinking a bit more about this, trying to envision a reasonable
user-space solution and I do not really see any. IMHO this really belongs
in the kernel, and it is not a lot of code, the basic softbutton core is
quite small, and the actually needed touchscreen driver changer are
only a couple of line, so it is not like doing this in the kernel is
a hassle, where as doing this in userspace will be a hassle.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code
@ 2016-08-11  9:21           ` Hans de Goede
  0 siblings, 0 replies; 20+ messages in thread
From: Hans de Goede @ 2016-08-11  9:21 UTC (permalink / raw)
  To: linux-arm-kernel



On 02-08-16 10:33, Hans de Goede wrote:
> Hi,
>
> On 01-08-16 19:41, Dmitry Torokhov wrote:
>> On Mon, Aug 01, 2016 at 11:54:30AM -0500, Rob Herring wrote:
>>> On Sun, Jul 31, 2016 at 05:23:07PM +0200, Hans de Goede wrote:
>>>> Some touchscreens extend over the display they cover and have a number
>>>> of capacative softbuttons outside of the display the cover.
>>>>
>>>> With some hardware these softbuttons simply report touches with
>>>> coordinates outside of the normal coordinate space for touches on the
>>>> display.
>>>>
>>>> This commit adds a devicetree binding for describing such buttons in
>>>> devicetree and a bunch of helper functions to easily add support for
>>>> these to existing touchscreen drivers.
>>>>
>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>>> ---
>>>>  .../bindings/input/touchscreen/softbuttons.txt     |  58 +++++++++
>>>>  drivers/input/touchscreen/Makefile                 |   2 +-
>>>>  drivers/input/touchscreen/softbuttons.c            | 145 +++++++++++++++++++++
>>>>  include/linux/input/touchscreen.h                  |   9 ++
>>>>  4 files changed, 213 insertions(+), 1 deletion(-)
>>>>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>>>  create mode 100644 drivers/input/touchscreen/softbuttons.c
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>>> new file mode 100644
>>>> index 0000000..3eb6f4c
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/input/touchscreen/softbuttons.txt
>>>> @@ -0,0 +1,58 @@
>>>> +General Touchscreen Softbutton Properties:
>>>> +
>>>> +Some touchscreens extend over the display they cover and have a number
>>>> +of capacative softbuttons outside of the display the cover.
>>>> +
>>>> +Some of these softbuttons simply report touches with coordinates outside of
>>>> +the normal coordinate space for touches on the display. This binding is for
>>>> +describing such buttons in devicetree.
>>>> +
>>>> +Each softkey is represented as a sub-node of the touchscreen node.
>>>> +
>>>> +Required subnode-properties:
>>>> + - label            : Descriptive name of the key.
>>>> + - linux,code            : Keycode to emit.
>>>> + - softbutton-min-x        : X start of the area the softbutton area covers
>>>> + - softbutton-max-x        : X end of the area the softbutton area covers
>>>> + - softbutton-min-y        : Y start of the area the softbutton area covers
>>>> + - softbutton-max-y        : Y end of the area the softbutton area covers
>>>
>>> This generally looks fine to me, but I am wondering one thing. If the
>>> buttons are located at the origin of an axis, can we handle that case? I
>>> don't think you can unless you assume softbutton-max-? is 0 for the
>>> touchscreen. To put it another way, you have a gap from 1024 to 1084
>>> which you can't express for buttons at the origin unless you do negative
>>> numbers.
>>
>> I do not this this should be done in kernel: I do not see nay difference
>> in softbuttons or sliders or circular controls or... They are not
>> controller-specific and I think are better handled in userspace. We do
>> that for Synaptics touchpads with softbuttons, we can do that for other
>> controllers.
>>
>> Also, what is or stance when there is no bezel and we sill want to have
>> the softbutons (i.e. all Nexus phones and tablets)?
>
> Maybe softbuttons is not the best name (I googled and it seemed to match),
> so first lets make clear what I'm talking about here, I wrote this patch-set
> for this tablet:
>
> https://content.hwigroup.net/images/products_xl/157078/dserve-dsrv-9703c.jpg
>
> I decided to make it generic, since it seemed to me that there will likely
> be other hardware which is similar (but uses a different touch screen
> controller) out there, so keeping this generic seemed best.
>
> Now back to the kernelspace vs userspace solution question, if you look at
> the picture you will see 3 clearly marked buttons on the front of the tablet,
> outside of the display: menu, home and back. These are not buttons which get
> generated / drawn on the display when you touch the bottom of the screen, these
> are separate single-purpose buttons which happen to report presses via the
> touchscreen controller then via a separate hw mechanism.
>
> If these buttons used a separate capacative button controller as used in
> e.g. capacitive numpads, say something like this:
>
> http://www.ebay.com/itm/2PCS-TTP223-Capacitive-Touch-Switch-Button-Self-Lock-Module-for-Arduino-/131662428748
>
> Then there would be no question that this belongs in the kernel. I do not
> see how these are any different really. These cannot be runtime re-configured,
> they are separate dedicated buttons which happens to report presses via
> the touchscreen controllers.
>
> There also is the question of hardware description, no matter where we
> put support for this, we need some place were we describe the presence
> of these buttons to the software bits which end up dealing with them.
>
> And we already have a mechanism for describing "fixed" hardware for a
> certain model machine / board in the form of devicetree. To me putting
> the hardware description for this anywhere but in devicetree makes
> no sense because then we start scattering the description of a single
> device-type over multiple places which seems like a bad idea.
>
> And once we decided to put the description in devicetree, then dealing
> with this in the kernel becomes the logical thing to do.
>
> Regards,
>
> Hans
>
>
> p.s.
>
> One other example of buttons like these are those on the nexus one:
>
> http://www.informatica.com.do/7BZ-PortalImageUpload/image/2010151059110.google-nexus-one-01.jpg
>
> Note I'm not saying this binding will work for those, I've no idea how
> they are hooked up, but they are the same in that they are really
> 4 dedicated separate buttons which happen to be part of the main digitizer.

Dmitry, ping? Any reaction to the above ?

Regards,

Hans


p.s.

I've been thinking a bit more about this, trying to envision a reasonable
user-space solution and I do not really see any. IMHO this really belongs
in the kernel, and it is not a lot of code, the basic softbutton core is
quite small, and the actually needed touchscreen driver changer are
only a couple of line, so it is not like doing this in the kernel is
a hassle, where as doing this in userspace will be a hassle.

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-08-11  9:21 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-31 15:23 [PATCH 0/4] input: touchscreen: Add generic touchscreen softbutton support Hans de Goede
2016-07-31 15:23 ` Hans de Goede
2016-07-31 15:23 ` [PATCH 1/4] input: touchscreen: Add generic touchscreen softbutton handling code Hans de Goede
2016-07-31 15:23   ` Hans de Goede
2016-08-01 16:54   ` Rob Herring
2016-08-01 16:54     ` Rob Herring
2016-08-01 17:41     ` Dmitry Torokhov
2016-08-01 17:41       ` Dmitry Torokhov
2016-08-02  8:33       ` Hans de Goede
2016-08-02  8:33         ` Hans de Goede
2016-08-11  9:21         ` Hans de Goede
2016-08-11  9:21           ` Hans de Goede
2016-08-02  8:19     ` Hans de Goede
2016-08-02  8:19       ` Hans de Goede
     [not found] ` <1469978590-14081-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-07-31 15:23   ` [PATCH 2/4] input: touchscreen: Add LED trigger support to the softbutton code Hans de Goede
2016-07-31 15:23     ` Hans de Goede
2016-07-31 15:23   ` [PATCH 3/4] input: touchscreen: edt-ft5x06: Add support for softbuttons Hans de Goede
2016-07-31 15:23     ` Hans de Goede
2016-07-31 15:23 ` [PATCH 4/4] ARM: dts: sun4i: Describe softbuttons in dserve-dsrv9703c touchscreen node Hans de Goede
2016-07-31 15:23   ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.