devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] input: touchscreen: stmpe: ext. features
@ 2019-05-27 16:07 Leif Middelschulte
  2019-05-27 16:07 ` [PATCH 01/10] dt-bindings: input: touchscreen: stmpe: add touch window configuration Leif Middelschulte
                   ` (5 more replies)
  0 siblings, 6 replies; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:07 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

This set of patches implements various features suppported by the STMPE811
touchscreen controller. It integrates certain properties to facilitate the
operation/integration with kernel provided interfaces/properties and userland
libraries, such as libinput.

Based on Linus' v5.2-rc2

Leif Middelschulte (10):
  dt-bindings: input: touchscreen: stmpe: add touch window configuration
  Input: stmpe-ts - implement touch window configuration support
  dt-bindings: input: touchscreen: stmpe: add resolution support
  Input: stmpe-ts - implement resolution support
  dt-bindings: input: touchscreen: stmpe: add XY mode
  Input: stmpe-ts - implement XY acquisition mode
  dt-bindings: input: touchscreen: stmpe: add axes inversion and swap
  Input: stmpe-ts - axes inversion and swapping
  dt-bindings: input: touchscreen: stmpe: add tracking index
  Input: stmpe-ts - implement tracking index

 .../bindings/input/touchscreen/stmpe.txt      |  35 ++++
 drivers/input/touchscreen/stmpe-ts.c          | 161 ++++++++++++++++--
 include/linux/mfd/stmpe.h                     |   1 +
 3 files changed, 185 insertions(+), 12 deletions(-)

-- 
2.21.0

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

* [PATCH 01/10] dt-bindings: input: touchscreen: stmpe: add touch window configuration
  2019-05-27 16:07 [PATCH 00/10] input: touchscreen: stmpe: ext. features Leif Middelschulte
@ 2019-05-27 16:07 ` Leif Middelschulte
  2019-06-14 19:48   ` Rob Herring
  2019-05-27 16:07 ` [PATCH 02/10] Input: stmpe-ts - implement touch window configuration support Leif Middelschulte
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:07 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

The STMPE811 is able to only monitor a subwindow of the
entire screen. Touches outside of this window are neglected.
This change adds the corresponding documentation.

Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
---
 .../devicetree/bindings/input/touchscreen/stmpe.txt      | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
index c549924603d2..04962e2e1ad0 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
@@ -33,6 +33,13 @@ Optional properties:
 - st,i-drive		: current limit value of the touchscreen drivers
 				0 -> 20 mA (typical 35mA max)
 				1 -> 50 mA (typical 80 mA max)
+- st,window-tracking	: An u12 array that allows to pre-set a sub-window in the touchscreen.
+				Any touch position that is outside the sub-window is discarded
+				(top-right x, top-right y, bottom-left x, bottom-left y).
+				The given window also affects the value range (limits) set
+				within the input subsystem which, in turn, affects
+				the input resolution calculation on both axes.
+
 
 Optional properties common with MFD (deprecated):
  - st,sample-time	: ADC conversion time in number of clock.
@@ -101,6 +108,8 @@ stmpe811@41 {
 		 * current limit value
 		 */
 		st,i-drive = <1>;
+		/* enable entire window */
+		st,window-tracking = /bits/ 16 <4095 4095 0 0>;
 	};
 	stmpe_adc {
 		compatible = "st,stmpe-adc";
-- 
2.21.0

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

* [PATCH 02/10] Input: stmpe-ts - implement touch window configuration support
  2019-05-27 16:07 [PATCH 00/10] input: touchscreen: stmpe: ext. features Leif Middelschulte
  2019-05-27 16:07 ` [PATCH 01/10] dt-bindings: input: touchscreen: stmpe: add touch window configuration Leif Middelschulte
@ 2019-05-27 16:07 ` Leif Middelschulte
  2019-05-27 16:07 ` [PATCH 03/10] dt-bindings: input: touchscreen: stmpe: add resolution support Leif Middelschulte
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:07 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

Touch window tracking allows to pre-set a sub-window in the
touchscreen area such that any touch position that is outside
the sub-window is discarded.

Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
---
 drivers/input/touchscreen/stmpe-ts.c | 96 +++++++++++++++++++++++++++-
 1 file changed, 94 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index cf9c9aa39f6e..6917237bd6c6 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -19,6 +19,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/input.h>
+#include <linux/input/touchscreen.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
@@ -35,6 +36,10 @@
 #define STMPE_REG_FIFO_TH		0x4A
 #define STMPE_REG_FIFO_STA		0x4B
 #define STMPE_REG_FIFO_SIZE		0x4C
+#define STMPE_REG_WDW_TR_X		0x42
+#define STMPE_REG_WDW_TR_Y		0x44
+#define STMPE_REG_WDW_BL_X		0x46
+#define STMPE_REG_WDW_BL_Y		0x48
 #define STMPE_REG_TSC_DATA_XYZ		0x52
 #define STMPE_REG_TSC_FRACTION_Z	0x56
 #define STMPE_REG_TSC_I_DRIVE		0x58
@@ -82,6 +87,22 @@ struct stmpe_touch {
 	u8 settling;
 	u8 fraction_z;
 	u8 i_drive;
+	struct {
+	struct {
+		u16 x;
+		u16 y;
+	} top_right;
+	struct {
+		u16 x;
+		u16 y;
+	} bottom_left;
+	} wdw;
+	bool wdw_from_dt;
+	struct touchscreen_properties props;
+	struct {
+		u32 x;
+		u32 y;
+	}	min;
 };
 
 static int __stmpe_reset_fifo(struct stmpe *stmpe)
@@ -128,6 +149,27 @@ static void stmpe_work(struct work_struct *work)
 	input_sync(ts->idev);
 }
 
+static void stmpe_update_range_values(struct stmpe_touch *ts)
+{
+	u8 data_set[2];
+	/*
+	 * Calculate max_x and max_y based on window size configuration read
+	 * from touchscreen controller
+	 */
+	stmpe_block_read(ts->stmpe, STMPE_REG_WDW_TR_X, 2, data_set);
+	ts->wdw.top_right.x = (data_set[0] << 8) | (data_set[1]);
+	stmpe_block_read(ts->stmpe, STMPE_REG_WDW_TR_Y, 2, data_set);
+	ts->wdw.top_right.y = (data_set[0] << 8) | (data_set[1]);
+	stmpe_block_read(ts->stmpe, STMPE_REG_WDW_BL_X, 2, data_set);
+	ts->wdw.bottom_left.x = (data_set[0] << 8) | (data_set[1]);
+	stmpe_block_read(ts->stmpe, STMPE_REG_WDW_BL_Y, 2, data_set);
+	ts->wdw.bottom_left.y = (data_set[0] << 8) | (data_set[1]);
+	ts->min.x = ts->wdw.bottom_left.x;
+	ts->min.y = ts->wdw.bottom_left.y;
+	ts->props.max_x = ts->wdw.top_right.x;
+	ts->props.max_y = ts->wdw.top_right.y;
+}
+
 static irqreturn_t stmpe_ts_handler(int irq, void *data)
 {
 	u8 data_set[4];
@@ -212,6 +254,44 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
 		return ret;
 	}
 
+	if (ts->wdw_from_dt) {
+		u8 data_set[2];
+
+		data_set[0] = ts->wdw.top_right.x >> 8;
+		data_set[1] = ts->wdw.top_right.x;
+		ret = stmpe_block_write(ts->stmpe,
+			STMPE_REG_WDW_TR_X, 2, data_set);
+		if (ret) {
+			dev_err(dev, "Could not configure touchscreen window's top right x value\n");
+			return ret;
+		}
+		data_set[0] = ts->wdw.top_right.y >> 8;
+		data_set[1] = ts->wdw.top_right.y;
+		ret = stmpe_block_write(ts->stmpe,
+			STMPE_REG_WDW_TR_Y, 2, data_set);
+		if (ret) {
+			dev_err(dev, "Could not configure touchscreen window's top right y value\n");
+			return ret;
+		}
+		data_set[0] = ts->wdw.bottom_left.x >> 8;
+		data_set[1] = ts->wdw.bottom_left.x;
+		ret = stmpe_block_write(ts->stmpe,
+			STMPE_REG_WDW_BL_X, 2, data_set);
+		if (ret) {
+			dev_err(dev, "Could not configure touchscreen window's bottom left x value\n");
+			return ret;
+		}
+		data_set[0] = ts->wdw.bottom_left.y >> 8;
+		data_set[1] = ts->wdw.bottom_left.y;
+		ret = stmpe_block_write(ts->stmpe,
+			STMPE_REG_WDW_BL_Y, 2, data_set);
+		if (ret) {
+			dev_err(dev, "Could not configure touchscreen window's bottom left y value\n");
+			return ret;
+		}
+	}
+	stmpe_update_range_values(ts);
+
 	ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_I_DRIVE,
 			STMPE_I_DRIVE(0xff), STMPE_I_DRIVE(ts->i_drive));
 	if (ret) {
@@ -264,6 +344,7 @@ static void stmpe_ts_get_platform_info(struct platform_device *pdev,
 {
 	struct device_node *np = pdev->dev.of_node;
 	u32 val;
+	u16 wdw[4];
 
 	if (np) {
 		if (!of_property_read_u32(np, "st,sample-time", &val))
@@ -284,6 +365,15 @@ static void stmpe_ts_get_platform_info(struct platform_device *pdev,
 			ts->fraction_z = val;
 		if (!of_property_read_u32(np, "st,i-drive", &val))
 			ts->i_drive = val;
+		if (!of_property_read_u16_array(np, "st,window-tracking",
+			wdw, 4)) {
+			ts->wdw.top_right.x = wdw[0] & XY_MASK;
+			ts->wdw.top_right.y = wdw[1] & XY_MASK;
+			ts->wdw.bottom_left.x = wdw[2] & XY_MASK;
+			ts->wdw.bottom_left.y = wdw[3] & XY_MASK;
+			ts->wdw_from_dt = true;
+		}
+		touchscreen_parse_properties(ts->idev, false, &ts->props);
 	}
 }
 
@@ -338,8 +428,10 @@ static int stmpe_input_probe(struct platform_device *pdev)
 	input_set_drvdata(idev, ts);
 
 	input_set_capability(idev, EV_KEY, BTN_TOUCH);
-	input_set_abs_params(idev, ABS_X, 0, XY_MASK, 0, 0);
-	input_set_abs_params(idev, ABS_Y, 0, XY_MASK, 0, 0);
+	input_set_abs_params(idev,
+		ABS_X, ts->min.x, ts->props.max_x, 0, 0);
+	input_set_abs_params(idev,
+		ABS_Y, ts->min.y, ts->props.max_y, 0, 0);
 	input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0);
 
 	error = input_register_device(idev);
-- 
2.21.0

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

* [PATCH 03/10] dt-bindings: input: touchscreen: stmpe: add resolution support
  2019-05-27 16:07 [PATCH 00/10] input: touchscreen: stmpe: ext. features Leif Middelschulte
  2019-05-27 16:07 ` [PATCH 01/10] dt-bindings: input: touchscreen: stmpe: add touch window configuration Leif Middelschulte
  2019-05-27 16:07 ` [PATCH 02/10] Input: stmpe-ts - implement touch window configuration support Leif Middelschulte
@ 2019-05-27 16:07 ` Leif Middelschulte
  2019-06-14 19:55   ` Rob Herring
  2019-05-27 16:07 ` [PATCH 04/10] Input: stmpe-ts - implement " Leif Middelschulte
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:07 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

This documents the support for specifying the screen size in milimeter
and its impact on resolution calculation.

Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
---
 Documentation/devicetree/bindings/input/touchscreen/stmpe.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
index 04962e2e1ad0..d20dc5a7d8ad 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
@@ -39,6 +39,10 @@ Optional properties:
 				The given window also affects the value range (limits) set
 				within the input subsystem which, in turn, affects
 				the input resolution calculation on both axes.
+- touchscreen-x-mm	: horizontal length in mm of the touchscreen. It affects
+				the input resolution calculation on the horizontal axis.
+- touchscreen-y-mm	: vertical length in mm of the touchscreen. It affects
+				the input resolution calculation on the vertical axis.
 
 
 Optional properties common with MFD (deprecated):
-- 
2.21.0

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

* [PATCH 04/10] Input: stmpe-ts - implement resolution support
  2019-05-27 16:07 [PATCH 00/10] input: touchscreen: stmpe: ext. features Leif Middelschulte
                   ` (2 preceding siblings ...)
  2019-05-27 16:07 ` [PATCH 03/10] dt-bindings: input: touchscreen: stmpe: add resolution support Leif Middelschulte
@ 2019-05-27 16:07 ` Leif Middelschulte
  2019-05-27 16:19 ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Leif Middelschulte
  2019-05-27 16:22 ` [PATCH 10/10] Input: stmpe-ts - implement tracking index Leif Middelschulte
  5 siblings, 0 replies; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:07 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

The resolution is calculated based on the devicetree property
`touchscreen-{x,y}-mm`. It matches the prosa definition given in
uapi/linux/input.h.

Beware that the resolution is affected, if window-tracking
parameters are applied.

Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
---
 drivers/input/touchscreen/stmpe-ts.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index 6917237bd6c6..1f11043a04df 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -102,7 +102,7 @@ struct stmpe_touch {
 	struct {
 		u32 x;
 		u32 y;
-	}	min;
+	}	size_in_mm, min;
 };
 
 static int __stmpe_reset_fifo(struct stmpe *stmpe)
@@ -346,6 +346,10 @@ static void stmpe_ts_get_platform_info(struct platform_device *pdev,
 	u32 val;
 	u16 wdw[4];
 
+	// use sensible (with regards to calculations) default values
+	ts->size_in_mm.x = 1;
+	ts->size_in_mm.y = 1;
+
 	if (np) {
 		if (!of_property_read_u32(np, "st,sample-time", &val))
 			ts->stmpe->sample_time = val;
@@ -373,6 +377,10 @@ static void stmpe_ts_get_platform_info(struct platform_device *pdev,
 			ts->wdw.bottom_left.y = wdw[3] & XY_MASK;
 			ts->wdw_from_dt = true;
 		}
+		if (!of_property_read_u32(np, "touchscreen-x-mm", &val))
+			ts->size_in_mm.x = val;
+		if (!of_property_read_u32(np, "touchscreen-y-mm", &val))
+			ts->size_in_mm.y = val;
 		touchscreen_parse_properties(ts->idev, false, &ts->props);
 	}
 }
@@ -384,6 +392,7 @@ static int stmpe_input_probe(struct platform_device *pdev)
 	struct input_dev *idev;
 	int error;
 	int ts_irq;
+	int resolution;
 
 	ts_irq = platform_get_irq_byname(pdev, "FIFO_TH");
 	if (ts_irq < 0)
@@ -430,8 +439,12 @@ static int stmpe_input_probe(struct platform_device *pdev)
 	input_set_capability(idev, EV_KEY, BTN_TOUCH);
 	input_set_abs_params(idev,
 		ABS_X, ts->min.x, ts->props.max_x, 0, 0);
+	resolution = (ts->props.max_x - ts->min.x) / ts->size_in_mm.x;
+	input_abs_set_res(idev, ABS_X, resolution);
 	input_set_abs_params(idev,
 		ABS_Y, ts->min.y, ts->props.max_y, 0, 0);
+	resolution = (ts->props.max_y - ts->min.y) / ts->size_in_mm.y;
+	input_abs_set_res(idev, ABS_Y, resolution);
 	input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0);
 
 	error = input_register_device(idev);
-- 
2.21.0

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

* [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode
  2019-05-27 16:07 [PATCH 00/10] input: touchscreen: stmpe: ext. features Leif Middelschulte
                   ` (3 preceding siblings ...)
  2019-05-27 16:07 ` [PATCH 04/10] Input: stmpe-ts - implement " Leif Middelschulte
@ 2019-05-27 16:19 ` Leif Middelschulte
  2019-05-27 16:19   ` [PATCH 06/10] Input: stmpe-ts - implement XY acquisition mode Leif Middelschulte
                     ` (4 more replies)
  2019-05-27 16:22 ` [PATCH 10/10] Input: stmpe-ts - implement tracking index Leif Middelschulte
  5 siblings, 5 replies; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:19 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

This change documents the support of another input data
acquisition mode (XY). This mode is mostly relevant in
the context of/combination with the tracking index.

Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
---
 Documentation/devicetree/bindings/input/touchscreen/stmpe.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
index d20dc5a7d8ad..aee1abf06ddb 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
@@ -28,6 +28,9 @@ Optional properties:
 				5 -> 10 ms
 				6 -> 50 ms
 				7 -> 100 ms
+- st,op-mod		: Axis information acquisition operating mode (Default is 0)
+				0 -> XYZ
+				1 -> XY
 - st,fraction-z		: Length of the fractional part in z (recommended is 7)
 			  (fraction-z ([0..7]) = Count of the fractional part)
 - st,i-drive		: current limit value of the touchscreen drivers
-- 
2.21.0

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

* [PATCH 06/10] Input: stmpe-ts - implement XY acquisition mode
  2019-05-27 16:19 ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Leif Middelschulte
@ 2019-05-27 16:19   ` Leif Middelschulte
  2019-05-27 16:19   ` [PATCH 07/10] dt-bindings: input: touchscreen: stmpe: add axes inversion and swap Leif Middelschulte
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:19 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

While the default acquisition covers the pressure (z) too,
the XY mode is only concerend with the horizontal and vertical
input position acquisition.
It uses dedicated registers for each axes to do so, while the
XYZ acquisition packs the read values more densely.

Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
---
 drivers/input/touchscreen/stmpe-ts.c | 45 ++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 9 deletions(-)

diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index 1f11043a04df..152aac8b3ab7 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -40,11 +40,14 @@
 #define STMPE_REG_WDW_TR_Y		0x44
 #define STMPE_REG_WDW_BL_X		0x46
 #define STMPE_REG_WDW_BL_Y		0x48
+#define STMPE_REG_TSC_DATA_X		0x4D
+#define STMPE_REG_TSC_DATA_Y		0x4F
 #define STMPE_REG_TSC_DATA_XYZ		0x52
 #define STMPE_REG_TSC_FRACTION_Z	0x56
 #define STMPE_REG_TSC_I_DRIVE		0x58
 
 #define OP_MOD_XYZ			0
+#define OP_MOD_XY			1
 
 #define STMPE_TSC_CTRL_TSC_EN		(1<<0)
 
@@ -87,6 +90,7 @@ struct stmpe_touch {
 	u8 settling;
 	u8 fraction_z;
 	u8 i_drive;
+	u8 op_mod;
 	struct {
 	struct {
 		u16 x;
@@ -174,6 +178,7 @@ static irqreturn_t stmpe_ts_handler(int irq, void *data)
 {
 	u8 data_set[4];
 	int x, y, z;
+	bool report_pressure = false;
 	struct stmpe_touch *ts = data;
 
 	/*
@@ -191,18 +196,35 @@ static irqreturn_t stmpe_ts_handler(int irq, void *data)
 	stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL,
 				STMPE_TSC_CTRL_TSC_EN, 0);
 
-	stmpe_block_read(ts->stmpe, STMPE_REG_TSC_DATA_XYZ, 4, data_set);
-
-	x = (data_set[0] << 4) | (data_set[1] >> 4);
-	y = ((data_set[1] & 0xf) << 8) | data_set[2];
-	z = data_set[3];
+	switch (ts->op_mod) {
+	case OP_MOD_XYZ:
+		stmpe_block_read(ts->stmpe,
+			STMPE_REG_TSC_DATA_XYZ, 4, data_set);
+		x = (data_set[0] << 4) | (data_set[1] >> 4);
+		y = ((data_set[1] & 0xf) << 8) | data_set[2];
+		z = data_set[3];
+		report_pressure = true;
+		break;
+	case OP_MOD_XY:
+		stmpe_block_read(ts->stmpe,
+			STMPE_REG_TSC_DATA_X, 2, data_set);
+		x = (data_set[0] << 8) | (data_set[1]);
+		stmpe_block_read(ts->stmpe,
+			STMPE_REG_TSC_DATA_Y, 2, data_set);
+		y = (data_set[0] << 8) | (data_set[1]);
+		break;
+	default:
+		goto _skip_input_events;
+	}
 
 	input_report_abs(ts->idev, ABS_X, x);
 	input_report_abs(ts->idev, ABS_Y, y);
-	input_report_abs(ts->idev, ABS_PRESSURE, z);
+	if (report_pressure)
+		input_report_abs(ts->idev, ABS_PRESSURE, z);
 	input_report_key(ts->idev, BTN_TOUCH, 1);
 	input_sync(ts->idev);
 
+_skip_input_events:
        /* flush the FIFO after we have read out our values. */
 	__stmpe_reset_fifo(ts->stmpe);
 
@@ -219,7 +241,7 @@ static irqreturn_t stmpe_ts_handler(int irq, void *data)
 static int stmpe_init_hw(struct stmpe_touch *ts)
 {
 	int ret;
-	u8 tsc_cfg, tsc_cfg_mask;
+	u8 tsc_cfg, tsc_cfg_mask, tsc_ctrl, tsc_ctrl_mask;
 	struct stmpe *stmpe = ts->stmpe;
 	struct device *dev = ts->dev;
 
@@ -306,10 +328,13 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
 		return ret;
 	}
 
+	tsc_ctrl = STMPE_OP_MODE(ts->op_mod);
+	tsc_ctrl_mask = STMPE_OP_MODE(0xff);
+
 	ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CTRL,
-			STMPE_OP_MODE(0xff), STMPE_OP_MODE(OP_MOD_XYZ));
+			tsc_ctrl_mask, tsc_ctrl);
 	if (ret) {
-		dev_err(dev, "Could not set mode\n");
+		dev_err(dev, "Could not set control registers\n");
 		return ret;
 	}
 
@@ -357,6 +382,8 @@ static void stmpe_ts_get_platform_info(struct platform_device *pdev,
 			ts->stmpe->mod_12b = val;
 		if (!of_property_read_u32(np, "st,ref-sel", &val))
 			ts->stmpe->ref_sel = val;
+		if (!of_property_read_u32(np, "st,op-mod", &val))
+			ts->op_mod = val;
 		if (!of_property_read_u32(np, "st,adc-freq", &val))
 			ts->stmpe->adc_freq = val;
 		if (!of_property_read_u32(np, "st,ave-ctrl", &val))
-- 
2.21.0

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

* [PATCH 07/10] dt-bindings: input: touchscreen: stmpe: add axes inversion and swap
  2019-05-27 16:19 ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Leif Middelschulte
  2019-05-27 16:19   ` [PATCH 06/10] Input: stmpe-ts - implement XY acquisition mode Leif Middelschulte
@ 2019-05-27 16:19   ` Leif Middelschulte
  2019-06-14 19:56     ` Rob Herring
  2019-05-27 16:19   ` [PATCH 08/10] Input: stmpe-ts - axes inversion and swapping Leif Middelschulte
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:19 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

This driver too supports coordinate inversion on X,Y axes and
axes swapping via the common properties defined in touchscreen.txt

Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
---
 Documentation/devicetree/bindings/input/touchscreen/stmpe.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
index aee1abf06ddb..09d2d4f288cc 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
@@ -42,6 +42,10 @@ Optional properties:
 				The given window also affects the value range (limits) set
 				within the input subsystem which, in turn, affects
 				the input resolution calculation on both axes.
+- touchscreen-inverted-x: X axis is inverted (boolean)
+- touchscreen-inverted-y: Y axis is inverted (boolean)
+- touchscreen-swapped-x-y: X and Y axis are swapped (boolean)
+				Swapping is done after inverting the axis
 - touchscreen-x-mm	: horizontal length in mm of the touchscreen. It affects
 				the input resolution calculation on the horizontal axis.
 - touchscreen-y-mm	: vertical length in mm of the touchscreen. It affects
-- 
2.21.0

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

* [PATCH 08/10] Input: stmpe-ts - axes inversion and swapping
  2019-05-27 16:19 ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Leif Middelschulte
  2019-05-27 16:19   ` [PATCH 06/10] Input: stmpe-ts - implement XY acquisition mode Leif Middelschulte
  2019-05-27 16:19   ` [PATCH 07/10] dt-bindings: input: touchscreen: stmpe: add axes inversion and swap Leif Middelschulte
@ 2019-05-27 16:19   ` Leif Middelschulte
  2019-05-27 16:19   ` [PATCH 09/10] dt-bindings: input: touchscreen: stmpe: add tracking index Leif Middelschulte
  2019-06-14 19:55   ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Rob Herring
  4 siblings, 0 replies; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:19 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

This implements inversion and swapping of the reported X and Y input
values, configurable via the corresponding devicetree properties binding.

Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
---
 drivers/input/touchscreen/stmpe-ts.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index 152aac8b3ab7..1d114278e7e9 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -217,8 +217,12 @@ static irqreturn_t stmpe_ts_handler(int irq, void *data)
 		goto _skip_input_events;
 	}
 
-	input_report_abs(ts->idev, ABS_X, x);
-	input_report_abs(ts->idev, ABS_Y, y);
+	if (ts->props.invert_x)
+		x -= ts->min.x;
+	if (ts->props.invert_y)
+		y -= ts->min.y;
+
+	touchscreen_report_pos(ts->idev, &ts->props, x, y, false);
 	if (report_pressure)
 		input_report_abs(ts->idev, ABS_PRESSURE, z);
 	input_report_key(ts->idev, BTN_TOUCH, 1);
-- 
2.21.0

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

* [PATCH 09/10] dt-bindings: input: touchscreen: stmpe: add tracking index
  2019-05-27 16:19 ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Leif Middelschulte
                     ` (2 preceding siblings ...)
  2019-05-27 16:19   ` [PATCH 08/10] Input: stmpe-ts - axes inversion and swapping Leif Middelschulte
@ 2019-05-27 16:19   ` Leif Middelschulte
  2019-06-14 19:58     ` Rob Herring
  2019-06-14 19:55   ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Rob Herring
  4 siblings, 1 reply; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:19 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

The tracking index is a "minimum" distance two touch
points need to have in order for the second to be valid.
This adds the corresponding binding property documentation.

Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
---
 .../bindings/input/touchscreen/stmpe.txt          | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
index 09d2d4f288cc..8696af35a7b8 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
@@ -42,6 +42,21 @@ Optional properties:
 				The given window also affects the value range (limits) set
 				within the input subsystem which, in turn, affects
 				the input resolution calculation on both axes.
+- st,tracking-index	: Minimal distance between the current touch position and the previous
+				touch position. If the distance is shorter than the tracking
+				index, it is discarded. The tracking is calculated by summation
+				of the horizontal and vertical movement.
+				If pressure reporting is enabled (X/Y/Z), an increase in pressure
+				override the movement tracking and report the new data set, even
+				if X/Y is within the previous tracking index.
+				0 -> disabled
+				1 -> 4
+				4 -> 8
+				3 -> 16
+				4 -> 32
+				5 -> 64
+				6 -> 92
+				7 -> 127
 - touchscreen-inverted-x: X axis is inverted (boolean)
 - touchscreen-inverted-y: Y axis is inverted (boolean)
 - touchscreen-swapped-x-y: X and Y axis are swapped (boolean)
-- 
2.21.0

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

* [PATCH 10/10] Input: stmpe-ts - implement tracking index
  2019-05-27 16:07 [PATCH 00/10] input: touchscreen: stmpe: ext. features Leif Middelschulte
                   ` (4 preceding siblings ...)
  2019-05-27 16:19 ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Leif Middelschulte
@ 2019-05-27 16:22 ` Leif Middelschulte
  5 siblings, 0 replies; 23+ messages in thread
From: Leif Middelschulte @ 2019-05-27 16:22 UTC (permalink / raw)
  To: dmitry.torokhov, devicetree
  Cc: linux-input, robh+dt, mark.rutland, Leif Middelschulte

The tracking index specifies an minimum distance between
two touchpoints so that the latter will be discarded, if
the distance falls short of the configured value.
Beware: When using the XYZ acquisition mode, an increase
in pressure leads to a position report anyway.

Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
---
 drivers/input/touchscreen/stmpe-ts.c | 5 +++--
 include/linux/mfd/stmpe.h            | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index 1d114278e7e9..ec1bbc19562e 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -91,6 +91,7 @@ struct stmpe_touch {
 	u8 fraction_z;
 	u8 i_drive;
 	u8 op_mod;
+	u8 tracking_index;
 	struct {
 	struct {
 		u16 x;
@@ -332,8 +333,8 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
 		return ret;
 	}
 
-	tsc_ctrl = STMPE_OP_MODE(ts->op_mod);
-	tsc_ctrl_mask = STMPE_OP_MODE(0xff);
+	tsc_ctrl = STMPE_TRACK(ts->tracking_index) | STMPE_OP_MODE(ts->op_mod);
+	tsc_ctrl_mask = STMPE_TRACK(0xff) | STMPE_OP_MODE(0xff);
 
 	ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CTRL,
 			tsc_ctrl_mask, tsc_ctrl);
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 07f55aac9390..4e3217b0237a 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -16,6 +16,7 @@
 #define STMPE_ADC_FREQ(x)	(x & 0x3)
 #define STMPE_AVE_CTRL(x)	((x & 0x3) << 6)
 #define STMPE_DET_DELAY(x)	((x & 0x7) << 3)
+#define STMPE_TRACK(x)	((x & 0x7) << 4)
 #define STMPE_SETTLING(x)	(x & 0x7)
 #define STMPE_FRACTION_Z(x)	(x & 0x7)
 #define STMPE_I_DRIVE(x)	(x & 0x1)
-- 
2.21.0

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

* Re: [PATCH 01/10] dt-bindings: input: touchscreen: stmpe: add touch window configuration
  2019-05-27 16:07 ` [PATCH 01/10] dt-bindings: input: touchscreen: stmpe: add touch window configuration Leif Middelschulte
@ 2019-06-14 19:48   ` Rob Herring
  2019-06-19 11:55     ` Middelschulte, Leif
  0 siblings, 1 reply; 23+ messages in thread
From: Rob Herring @ 2019-06-14 19:48 UTC (permalink / raw)
  To: Leif Middelschulte; +Cc: dmitry.torokhov, devicetree, linux-input, mark.rutland

On Mon, May 27, 2019 at 06:07:27PM +0200, Leif Middelschulte wrote:
> The STMPE811 is able to only monitor a subwindow of the
> entire screen. Touches outside of this window are neglected.
> This change adds the corresponding documentation.

Unless you are trying to just filter out the edge values which I think 
we already have properties for, wouldn't this be something the user 
may want to adjust/move at runtime?

> 
> Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
> ---
>  .../devicetree/bindings/input/touchscreen/stmpe.txt      | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> index c549924603d2..04962e2e1ad0 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> @@ -33,6 +33,13 @@ Optional properties:
>  - st,i-drive		: current limit value of the touchscreen drivers
>  				0 -> 20 mA (typical 35mA max)
>  				1 -> 50 mA (typical 80 mA max)
> +- st,window-tracking	: An u12 array that allows to pre-set a sub-window in the touchscreen.

u16?

> +				Any touch position that is outside the sub-window is discarded
> +				(top-right x, top-right y, bottom-left x, bottom-left y).
> +				The given window also affects the value range (limits) set
> +				within the input subsystem which, in turn, affects
> +				the input resolution calculation on both axes.
> +
>  
>  Optional properties common with MFD (deprecated):
>   - st,sample-time	: ADC conversion time in number of clock.
> @@ -101,6 +108,8 @@ stmpe811@41 {
>  		 * current limit value
>  		 */
>  		st,i-drive = <1>;
> +		/* enable entire window */
> +		st,window-tracking = /bits/ 16 <4095 4095 0 0>;
>  	};
>  	stmpe_adc {
>  		compatible = "st,stmpe-adc";
> -- 
> 2.21.0
> 

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

* Re: [PATCH 03/10] dt-bindings: input: touchscreen: stmpe: add resolution support
  2019-05-27 16:07 ` [PATCH 03/10] dt-bindings: input: touchscreen: stmpe: add resolution support Leif Middelschulte
@ 2019-06-14 19:55   ` Rob Herring
  2019-06-19 12:33     ` Middelschulte, Leif
  0 siblings, 1 reply; 23+ messages in thread
From: Rob Herring @ 2019-06-14 19:55 UTC (permalink / raw)
  To: Leif Middelschulte; +Cc: dmitry.torokhov, devicetree, linux-input, mark.rutland

On Mon, May 27, 2019 at 06:07:29PM +0200, Leif Middelschulte wrote:
> This documents the support for specifying the screen size in milimeter
> and its impact on resolution calculation.
> 
> Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
> ---
>  Documentation/devicetree/bindings/input/touchscreen/stmpe.txt | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> index 04962e2e1ad0..d20dc5a7d8ad 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> @@ -39,6 +39,10 @@ Optional properties:
>  				The given window also affects the value range (limits) set
>  				within the input subsystem which, in turn, affects
>  				the input resolution calculation on both axes.
> +- touchscreen-x-mm	: horizontal length in mm of the touchscreen. It affects
> +				the input resolution calculation on the horizontal axis.
> +- touchscreen-y-mm	: vertical length in mm of the touchscreen. It affects
> +				the input resolution calculation on the vertical axis.

No need to define this again. Just reference the common definition. If 
you have any additional constraints, then add them.

Rob

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

* Re: [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode
  2019-05-27 16:19 ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Leif Middelschulte
                     ` (3 preceding siblings ...)
  2019-05-27 16:19   ` [PATCH 09/10] dt-bindings: input: touchscreen: stmpe: add tracking index Leif Middelschulte
@ 2019-06-14 19:55   ` Rob Herring
  4 siblings, 0 replies; 23+ messages in thread
From: Rob Herring @ 2019-06-14 19:55 UTC (permalink / raw)
  To: Leif Middelschulte
  Cc: dmitry.torokhov, devicetree, linux-input, robh+dt, mark.rutland

On Mon, 27 May 2019 18:19:33 +0200, Leif Middelschulte wrote:
> This change documents the support of another input data
> acquisition mode (XY). This mode is mostly relevant in
> the context of/combination with the tracking index.
> 
> Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
> ---
>  Documentation/devicetree/bindings/input/touchscreen/stmpe.txt | 3 +++
>  1 file changed, 3 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH 07/10] dt-bindings: input: touchscreen: stmpe: add axes inversion and swap
  2019-05-27 16:19   ` [PATCH 07/10] dt-bindings: input: touchscreen: stmpe: add axes inversion and swap Leif Middelschulte
@ 2019-06-14 19:56     ` Rob Herring
  0 siblings, 0 replies; 23+ messages in thread
From: Rob Herring @ 2019-06-14 19:56 UTC (permalink / raw)
  To: Leif Middelschulte; +Cc: dmitry.torokhov, devicetree, linux-input, mark.rutland

On Mon, May 27, 2019 at 06:19:35PM +0200, Leif Middelschulte wrote:
> This driver too supports coordinate inversion on X,Y axes and
> axes swapping via the common properties defined in touchscreen.txt
> 
> Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
> ---
>  Documentation/devicetree/bindings/input/touchscreen/stmpe.txt | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> index aee1abf06ddb..09d2d4f288cc 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> @@ -42,6 +42,10 @@ Optional properties:
>  				The given window also affects the value range (limits) set
>  				within the input subsystem which, in turn, affects
>  				the input resolution calculation on both axes.
> +- touchscreen-inverted-x: X axis is inverted (boolean)
> +- touchscreen-inverted-y: Y axis is inverted (boolean)
> +- touchscreen-swapped-x-y: X and Y axis are swapped (boolean)
> +				Swapping is done after inverting the axis

Just reference common definition.

>  - touchscreen-x-mm	: horizontal length in mm of the touchscreen. It affects
>  				the input resolution calculation on the horizontal axis.
>  - touchscreen-y-mm	: vertical length in mm of the touchscreen. It affects
> -- 
> 2.21.0
> 

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

* Re: [PATCH 09/10] dt-bindings: input: touchscreen: stmpe: add tracking index
  2019-05-27 16:19   ` [PATCH 09/10] dt-bindings: input: touchscreen: stmpe: add tracking index Leif Middelschulte
@ 2019-06-14 19:58     ` Rob Herring
  2019-06-19 12:47       ` Middelschulte, Leif
  0 siblings, 1 reply; 23+ messages in thread
From: Rob Herring @ 2019-06-14 19:58 UTC (permalink / raw)
  To: Leif Middelschulte; +Cc: dmitry.torokhov, devicetree, linux-input, mark.rutland

On Mon, May 27, 2019 at 06:19:37PM +0200, Leif Middelschulte wrote:
> The tracking index is a "minimum" distance two touch
> points need to have in order for the second to be valid.
> This adds the corresponding binding property documentation.
> 
> Signed-off-by: Leif Middelschulte <leif.middelschulte@klsmartin.com>
> ---
>  .../bindings/input/touchscreen/stmpe.txt          | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> index 09d2d4f288cc..8696af35a7b8 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> @@ -42,6 +42,21 @@ Optional properties:
>  				The given window also affects the value range (limits) set
>  				within the input subsystem which, in turn, affects
>  				the input resolution calculation on both axes.
> +- st,tracking-index	: Minimal distance between the current touch position and the previous
> +				touch position. If the distance is shorter than the tracking
> +				index, it is discarded. The tracking is calculated by summation
> +				of the horizontal and vertical movement.
> +				If pressure reporting is enabled (X/Y/Z), an increase in pressure
> +				override the movement tracking and report the new data set, even
> +				if X/Y is within the previous tracking index.
> +				0 -> disabled
> +				1 -> 4
> +				4 -> 8
> +				3 -> 16
> +				4 -> 32
> +				5 -> 64
> +				6 -> 92
> +				7 -> 127

This is what touchscreen-fuzz-x/y is for.

>  - touchscreen-inverted-x: X axis is inverted (boolean)
>  - touchscreen-inverted-y: Y axis is inverted (boolean)
>  - touchscreen-swapped-x-y: X and Y axis are swapped (boolean)
> -- 
> 2.21.0
> 

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

* Re: [PATCH 01/10] dt-bindings: input: touchscreen: stmpe: add touch window configuration
  2019-06-14 19:48   ` Rob Herring
@ 2019-06-19 11:55     ` Middelschulte, Leif
  2019-06-19 13:51       ` Rob Herring
  0 siblings, 1 reply; 23+ messages in thread
From: Middelschulte, Leif @ 2019-06-19 11:55 UTC (permalink / raw)
  To: robh@kernel.org
  Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, mark.rutland@arm.com

Am Freitag, den 14.06.2019, 13:48 -0600 schrieb Rob Herring:
> On Mon, May 27, 2019 at 06:07:27PM +0200, Leif Middelschulte wrote:
> > The STMPE811 is able to only monitor a subwindow of the
> > entire screen. Touches outside of this window are neglected.
> > This change adds the corresponding documentation.
> 
> Unless you are trying to just filter out the edge values 
I'm trying to "just filter out the edge values" by filtering the values
right on the smpte microcontroller. It is a device specific feature, that is
why I implemented and documented the support.

But sure, one could leave that to a corresponding entry in the hwdb that
would manipulate absinfo to gain calibrated input [1].

> which I think we already have properties for,
While there [0] is "touchscreen-min-{x,y}", I could not spot a corresponding
"touchscreen-max-{x,y}". Could you point me to the right property?

> wouldn't this be something the user may want to adjust/move at runtime?
It is adjustable at runtime via the hwdb or calling ioctl on the evdev device directly.


[0] https://www.kernel.org/doc/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
[1] https://who-t.blogspot.com/2018/08/how-60-evdevhwdb-works.html
> 
> > Signed-off-by: Leif Middelschulte <
> > leif.middelschulte@klsmartin.com
> > >
> > ---
> >  .../devicetree/bindings/input/touchscreen/stmpe.txt      | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > index c549924603d2..04962e2e1ad0 100644
> > --- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > @@ -33,6 +33,13 @@ Optional properties:
> >  - st,i-drive		: current limit value of the touchscreen drivers
> >  				0 -> 20 mA (typical 35mA max)
> >  				1 -> 50 mA (typical 80 mA max)
> > +- st,window-tracking	: An u12 array that allows to pre-set a sub-window in the touchscreen.
> 
> u16?
> 
> > +				Any touch position that is outside the sub-window is discarded
> > +				(top-right x, top-right y, bottom-left x, bottom-left y).
> > +				The given window also affects the value range (limits) set
> > +				within the input subsystem which, in turn, affects
> > +				the input resolution calculation on both axes.
> > +
> >  
> >  Optional properties common with MFD (deprecated):
> >   - st,sample-time	: ADC conversion time in number of clock.
> > @@ -101,6 +108,8 @@ stmpe811@41 {
> >  		 * current limit value
> >  		 */
> >  		st,i-drive = <1>;
> > +		/* enable entire window */
> > +		st,window-tracking = /bits/ 16 <4095 4095 0 0>;
> >  	};
> >  	stmpe_adc {
> >  		compatible = "st,stmpe-adc";
> > -- 
> > 2.21.0
> > 

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

* Re: [PATCH 03/10] dt-bindings: input: touchscreen: stmpe: add resolution support
  2019-06-14 19:55   ` Rob Herring
@ 2019-06-19 12:33     ` Middelschulte, Leif
  0 siblings, 0 replies; 23+ messages in thread
From: Middelschulte, Leif @ 2019-06-19 12:33 UTC (permalink / raw)
  To: robh@kernel.org
  Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, mark.rutland@arm.com

Am Freitag, den 14.06.2019, 13:55 -0600 schrieb Rob Herring:
> On Mon, May 27, 2019 at 06:07:29PM +0200, Leif Middelschulte wrote:
> > This documents the support for specifying the screen size in milimeter
> > and its impact on resolution calculation.
> > 
> > Signed-off-by: Leif Middelschulte <
> > leif.middelschulte@klsmartin.com
> > >
> > ---
> >  Documentation/devicetree/bindings/input/touchscreen/stmpe.txt | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > index 04962e2e1ad0..d20dc5a7d8ad 100644
> > --- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > @@ -39,6 +39,10 @@ Optional properties:
> >  				The given window also affects the value range (limits) set
> >  				within the input subsystem which, in turn, affects
> >  				the input resolution calculation on both axes.
> > +- touchscreen-x-mm	: horizontal length in mm of the touchscreen. It affects
> > +				the input resolution calculation on the horizontal axis.
> > +- touchscreen-y-mm	: vertical length in mm of the touchscreen. It affects
> > +				the input resolution calculation on the vertical axis.
> 
> No need to define this again. Just reference the common definition. If 
> you have any additional constraints, then add them.

I assumed it should not be redefined. I merely wanted to document the implication
this value has on the automatically configured resolution within `abs_info`.
Other drivers might not use it in that way, as the general documentation[0] does not
document such a behavior.

[0] https://www.kernel.org/doc/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt

> Rob

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

* Re: [PATCH 09/10] dt-bindings: input: touchscreen: stmpe: add tracking index
  2019-06-14 19:58     ` Rob Herring
@ 2019-06-19 12:47       ` Middelschulte, Leif
  2019-06-19 13:46         ` Rob Herring
  0 siblings, 1 reply; 23+ messages in thread
From: Middelschulte, Leif @ 2019-06-19 12:47 UTC (permalink / raw)
  To: robh@kernel.org
  Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, mark.rutland@arm.com

Am Freitag, den 14.06.2019, 13:58 -0600 schrieb Rob Herring:
> On Mon, May 27, 2019 at 06:19:37PM +0200, Leif Middelschulte wrote:
> > The tracking index is a "minimum" distance two touch
> > points need to have in order for the second to be valid.
> > This adds the corresponding binding property documentation.
> > 
> > Signed-off-by: Leif Middelschulte <
> > leif.middelschulte@klsmartin.com
> > >
> > ---
> >  .../bindings/input/touchscreen/stmpe.txt          | 15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > index 09d2d4f288cc..8696af35a7b8 100644
> > --- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > @@ -42,6 +42,21 @@ Optional properties:
> >  				The given window also affects the value range (limits) set
> >  				within the input subsystem which, in turn, affects
> >  				the input resolution calculation on both axes.
> > +- st,tracking-index	: Minimal distance between the current touch position and the previous
> > +				touch position. If the distance is shorter than the tracking
> > +				index, it is discarded. The tracking is calculated by summation
> > +				of the horizontal and vertical movement.
> > +				If pressure reporting is enabled (X/Y/Z), an increase in pressure
> > +				override the movement tracking and report the new data set, even
> > +				if X/Y is within the previous tracking index.
> > +				0 -> disabled
> > +				1 -> 4
> > +				4 -> 8
> > +				3 -> 16
> > +				4 -> 32
> > +				5 -> 64
> > +				6 -> 92
> > +				7 -> 127
> 
> This is what touchscreen-fuzz-x/y is for.

The stmpe touchcontroller does not support handling each axis separately.
Also it is not to be mistaken in its specific behavior (i.e. override)
for the general `fuzz` parameter. However, should I rename it to `st,fuzz-x-y` or similar?

AFAICS there[0] is no generic combined devicetree property, is there?

[0]https://www.kernel.org/doc/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt

> 
> >  - touchscreen-inverted-x: X axis is inverted (boolean)
> >  - touchscreen-inverted-y: Y axis is inverted (boolean)
> >  - touchscreen-swapped-x-y: X and Y axis are swapped (boolean)
> > -- 
> > 2.21.0
> > 

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

* Re: [PATCH 09/10] dt-bindings: input: touchscreen: stmpe: add tracking index
  2019-06-19 12:47       ` Middelschulte, Leif
@ 2019-06-19 13:46         ` Rob Herring
  2019-06-24 11:44           ` Middelschulte, Leif
  0 siblings, 1 reply; 23+ messages in thread
From: Rob Herring @ 2019-06-19 13:46 UTC (permalink / raw)
  To: Middelschulte, Leif
  Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, mark.rutland@arm.com

On Wed, Jun 19, 2019 at 6:47 AM Middelschulte, Leif
<Leif.Middelschulte@klsmartin.com> wrote:
>
> Am Freitag, den 14.06.2019, 13:58 -0600 schrieb Rob Herring:
> > On Mon, May 27, 2019 at 06:19:37PM +0200, Leif Middelschulte wrote:
> > > The tracking index is a "minimum" distance two touch
> > > points need to have in order for the second to be valid.
> > > This adds the corresponding binding property documentation.
> > >
> > > Signed-off-by: Leif Middelschulte <
> > > leif.middelschulte@klsmartin.com
> > > >
> > > ---
> > >  .../bindings/input/touchscreen/stmpe.txt          | 15 +++++++++++++++
> > >  1 file changed, 15 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > > index 09d2d4f288cc..8696af35a7b8 100644
> > > --- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > > +++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > > @@ -42,6 +42,21 @@ Optional properties:
> > >                             The given window also affects the value range (limits) set
> > >                             within the input subsystem which, in turn, affects
> > >                             the input resolution calculation on both axes.
> > > +- st,tracking-index        : Minimal distance between the current touch position and the previous
> > > +                           touch position. If the distance is shorter than the tracking
> > > +                           index, it is discarded. The tracking is calculated by summation
> > > +                           of the horizontal and vertical movement.
> > > +                           If pressure reporting is enabled (X/Y/Z), an increase in pressure
> > > +                           override the movement tracking and report the new data set, even
> > > +                           if X/Y is within the previous tracking index.
> > > +                           0 -> disabled
> > > +                           1 -> 4
> > > +                           4 -> 8
> > > +                           3 -> 16
> > > +                           4 -> 32
> > > +                           5 -> 64
> > > +                           6 -> 92
> > > +                           7 -> 127
> >
> > This is what touchscreen-fuzz-x/y is for.
>
> The stmpe touchcontroller does not support handling each axis separately.
> Also it is not to be mistaken in its specific behavior (i.e. override)
> for the general `fuzz` parameter. However, should I rename it to `st,fuzz-x-y` or similar?
>
> AFAICS there[0] is no generic combined devicetree property, is there?

Can't you set both properties and require them to be the same value?

Rob

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

* Re: [PATCH 01/10] dt-bindings: input: touchscreen: stmpe: add touch window configuration
  2019-06-19 11:55     ` Middelschulte, Leif
@ 2019-06-19 13:51       ` Rob Herring
  2019-06-24 10:33         ` Middelschulte, Leif
  0 siblings, 1 reply; 23+ messages in thread
From: Rob Herring @ 2019-06-19 13:51 UTC (permalink / raw)
  To: Middelschulte, Leif
  Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, mark.rutland@arm.com

On Wed, Jun 19, 2019 at 5:56 AM Middelschulte, Leif
<Leif.Middelschulte@klsmartin.com> wrote:
>
> Am Freitag, den 14.06.2019, 13:48 -0600 schrieb Rob Herring:
> > On Mon, May 27, 2019 at 06:07:27PM +0200, Leif Middelschulte wrote:
> > > The STMPE811 is able to only monitor a subwindow of the
> > > entire screen. Touches outside of this window are neglected.
> > > This change adds the corresponding documentation.
> >
> > Unless you are trying to just filter out the edge values
> I'm trying to "just filter out the edge values" by filtering the values
> right on the smpte microcontroller. It is a device specific feature, that is
> why I implemented and documented the support.
>
> But sure, one could leave that to a corresponding entry in the hwdb that
> would manipulate absinfo to gain calibrated input [1].
>
> > which I think we already have properties for,
> While there [0] is "touchscreen-min-{x,y}", I could not spot a corresponding
> "touchscreen-max-{x,y}". Could you point me to the right property?

Perhaps add them. If we have min, adding a max seems logical.

Rob

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

* Re: [PATCH 01/10] dt-bindings: input: touchscreen: stmpe: add touch window configuration
  2019-06-19 13:51       ` Rob Herring
@ 2019-06-24 10:33         ` Middelschulte, Leif
  0 siblings, 0 replies; 23+ messages in thread
From: Middelschulte, Leif @ 2019-06-24 10:33 UTC (permalink / raw)
  To: robh@kernel.org
  Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, mark.rutland@arm.com

Am Mittwoch, den 19.06.2019, 07:51 -0600 schrieb Rob Herring:
> On Wed, Jun 19, 2019 at 5:56 AM Middelschulte, Leif
> <
> Leif.Middelschulte@klsmartin.com
> > wrote:
> > Am Freitag, den 14.06.2019, 13:48 -0600 schrieb Rob Herring:
> > > On Mon, May 27, 2019 at 06:07:27PM +0200, Leif Middelschulte wrote:
> > > > The STMPE811 is able to only monitor a subwindow of the
> > > > entire screen. Touches outside of this window are neglected.
> > > > This change adds the corresponding documentation.
> > > 
> > > Unless you are trying to just filter out the edge values
> > 
> > I'm trying to "just filter out the edge values" by filtering the values
> > right on the smpte microcontroller. It is a device specific feature, that is
> > why I implemented and documented the support.
> > 
> > But sure, one could leave that to a corresponding entry in the hwdb that
> > would manipulate absinfo to gain calibrated input [1].
> > 
> > > which I think we already have properties for,
> > 
> > While there [0] is "touchscreen-min-{x,y}", I could not spot a corresponding
> > "touchscreen-max-{x,y}". Could you point me to the right property?
> 
> Perhaps add them. If we have min, adding a max seems logical.
There are `touchscreen-size-x` and `touchscreen-size-y`, which are described[0] as
"horizontal resolution of touchscreen (maximum x coordinate reported + 1)"

The potentially misleading property name aside, the general
implementation in of_touchscreen.c[1] applies it as maximum value.
It is not applied as resolution as in the context of input devices[2].

So here are the options:
 A) I go with `touchscreen-min-{x,y}` for minimum values and
    `touchscreen-size-{x,y}` for maximum values.
 B) Deprecate `touchscreen-size-{x,y}` for named reasons and
    introduce `touchscreen-max-{x,y}`.

In my case, I do need to set the resolution too though.

So, another question would be how to go about handling the resolution:
 I) Introducing an explicit resolution tuple? This would be bad
    because of multiple invalid constelations.
 II) Implicitly applying a resolution if a corrsponding
     `touchscreen-{x,y}-mm` is provided too. This approach would change
     behavior though.


[0] https://www.kernel.org/doc/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/input/touchscreen/of_touchscreen.c?h=v5.2-rc6#n81
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/input.h#n95

Leif

> 
> Rob
> 

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

* Re: [PATCH 09/10] dt-bindings: input: touchscreen: stmpe: add tracking index
  2019-06-19 13:46         ` Rob Herring
@ 2019-06-24 11:44           ` Middelschulte, Leif
  0 siblings, 0 replies; 23+ messages in thread
From: Middelschulte, Leif @ 2019-06-24 11:44 UTC (permalink / raw)
  To: robh@kernel.org
  Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, mark.rutland@arm.com

Am Mittwoch, den 19.06.2019, 07:46 -0600 schrieb Rob Herring:
> On Wed, Jun 19, 2019 at 6:47 AM Middelschulte, Leif
> <
> Leif.Middelschulte@klsmartin.com
> > wrote:
> > Am Freitag, den 14.06.2019, 13:58 -0600 schrieb Rob Herring:
> > > On Mon, May 27, 2019 at 06:19:37PM +0200, Leif Middelschulte wrote:
> > > > The tracking index is a "minimum" distance two touch
> > > > points need to have in order for the second to be valid.
> > > > This adds the corresponding binding property documentation.
> > > > 
> > > > Signed-off-by: Leif Middelschulte <
> > > > leif.middelschulte@klsmartin.com
> > > > 
> > > > 
> > > > ---
> > > >  .../bindings/input/touchscreen/stmpe.txt          | 15 +++++++++++++++
> > > >  1 file changed, 15 insertions(+)
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > > > index 09d2d4f288cc..8696af35a7b8 100644
> > > > --- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > > > +++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
> > > > @@ -42,6 +42,21 @@ Optional properties:
> > > >                             The given window also affects the value range (limits) set
> > > >                             within the input subsystem which, in turn, affects
> > > >                             the input resolution calculation on both axes.
> > > > +- st,tracking-index        : Minimal distance between the current touch position and the previous
> > > > +                           touch position. If the distance is shorter than the tracking
> > > > +                           index, it is discarded. The tracking is calculated by summation
> > > > +                           of the horizontal and vertical movement.
> > > > +                           If pressure reporting is enabled (X/Y/Z), an increase in pressure
> > > > +                           override the movement tracking and report the new data set, even
> > > > +                           if X/Y is within the previous tracking index.
> > > > +                           0 -> disabled
> > > > +                           1 -> 4
> > > > +                           4 -> 8
> > > > +                           3 -> 16
> > > > +                           4 -> 32
> > > > +                           5 -> 64
> > > > +                           6 -> 92
> > > > +                           7 -> 127
> > > 
> > > This is what touchscreen-fuzz-x/y is for.
> > 
> > The stmpe touchcontroller does not support handling each axis separately.
> > Also it is not to be mistaken in its specific behavior (i.e. override)
> > for the general `fuzz` parameter. However, should I rename it to `st,fuzz-x-y` or similar?
> > 
> > AFAICS there[0] is no generic combined devicetree property, is there?
> 
> Can't you set both properties and require them to be the same value?
The documentation would have to mention the (deviating) behavior possibly like follows:
``` This snippet is adapted from eeti.txt[0]
The following optional properties described in touchscreen.txt are
also supported:

- touchscreen-fuzz-x: This value needs to be the same as touchscreen-fuzz-y.
                      It is futhermore ignored, if the Z-axis is acquired too and an increase in pressure is detected.
      
The given value is a sum of the distances of both axis.
- touchscreen-fuzz-y: This value needs to be the same as touchscreen-fuzz-x.
                      It is futhermore ignored, if the Z-axis is acquired too and an increase in pressure is detected.
                      The given value is a sum of the distances of both axis.
```
Seems a bit odd to imagine. How would you suggest to it to look like?


It seems, to me, that either a general combined value should be introduced or this should be left stmpe specific (especially when considering the override behavior).

[0] https://www.kernel.org/doc/Documentation/devicetree/bindings/input/touchscreen/eeti.txt

Leif

> 
> Rob
> 

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

end of thread, other threads:[~2019-06-24 11:44 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-27 16:07 [PATCH 00/10] input: touchscreen: stmpe: ext. features Leif Middelschulte
2019-05-27 16:07 ` [PATCH 01/10] dt-bindings: input: touchscreen: stmpe: add touch window configuration Leif Middelschulte
2019-06-14 19:48   ` Rob Herring
2019-06-19 11:55     ` Middelschulte, Leif
2019-06-19 13:51       ` Rob Herring
2019-06-24 10:33         ` Middelschulte, Leif
2019-05-27 16:07 ` [PATCH 02/10] Input: stmpe-ts - implement touch window configuration support Leif Middelschulte
2019-05-27 16:07 ` [PATCH 03/10] dt-bindings: input: touchscreen: stmpe: add resolution support Leif Middelschulte
2019-06-14 19:55   ` Rob Herring
2019-06-19 12:33     ` Middelschulte, Leif
2019-05-27 16:07 ` [PATCH 04/10] Input: stmpe-ts - implement " Leif Middelschulte
2019-05-27 16:19 ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Leif Middelschulte
2019-05-27 16:19   ` [PATCH 06/10] Input: stmpe-ts - implement XY acquisition mode Leif Middelschulte
2019-05-27 16:19   ` [PATCH 07/10] dt-bindings: input: touchscreen: stmpe: add axes inversion and swap Leif Middelschulte
2019-06-14 19:56     ` Rob Herring
2019-05-27 16:19   ` [PATCH 08/10] Input: stmpe-ts - axes inversion and swapping Leif Middelschulte
2019-05-27 16:19   ` [PATCH 09/10] dt-bindings: input: touchscreen: stmpe: add tracking index Leif Middelschulte
2019-06-14 19:58     ` Rob Herring
2019-06-19 12:47       ` Middelschulte, Leif
2019-06-19 13:46         ` Rob Herring
2019-06-24 11:44           ` Middelschulte, Leif
2019-06-14 19:55   ` [PATCH 05/10] dt-bindings: input: touchscreen: stmpe: add XY mode Rob Herring
2019-05-27 16:22 ` [PATCH 10/10] Input: stmpe-ts - implement tracking index Leif Middelschulte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).