Skip to contentSkip to conversation

Input: of_touchscreen / generic bindings - Add support for touchscreen-min-x|y

PATCH In review Hans de Goede 2 participants 4 messages May 29, 2018 – Jun 1, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: of_touchscreen / generic bindings - Add support for touchscreen-min-x|y

Some touchscreens, depending on the firmware and/or the digitizer report coordinates which never reach 0 along one or both of their axis.

This has been seen for example on the Silead touchscreens on a Onda V891w and a Point of View mobii TAB-P800w(v2.0).

This commit adds support for touchscreen-min-x and touchscreen-min-y device-properties which can be set to communicate the actual start coordinates (rather then 0,0) to userspace.

When set this fixes e.g. not being able to click things in the GNOME3 top-bar on the 2 example tablets.

---
 .../input/touchscreen/touchscreen.txt         |  6 ++--
 drivers/input/touchscreen/of_touchscreen.c    | 36 ++++++++++++++-----
 2 files changed, 32 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +4 -2
index 537643e86f61..8aff9551259f 100644
@@ -1,10 +1,12 @@
 General Touchscreen Properties:
 
 Optional properties for Touchscreens:
+ - touchscreen-min-x		: minimum x coordinate reported (0 if not set)
+ - touchscreen-min-y		: minimum y coordinate reported (0 if not set)
  - touchscreen-size-x		: horizontal resolution of touchscreen
-				  (in pixels)
+				  (maximum x coordinate reported + 1)
  - touchscreen-size-y		: vertical resolution of touchscreen
-				  (in pixels)
+				  (maximum y coordinate reported + 1)
  - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
 				  dependent on the controller)
  - touchscreen-fuzz-x		: horizontal noise value of the absolute input
drivers/input/touchscreen/of_touchscreen.c +28 -8
index 9642f103b726..6d241d45e312 100644
@@ -35,7 +35,7 @@ static bool touchscreen_get_prop_u32(struct device *dev,
 
 static void touchscreen_set_params(struct input_dev *dev,
 				   unsigned long axis,
-				   int max, int fuzz)
+				   int min, int max, int fuzz)
 {
 	struct input_absinfo *absinfo;
 
@@ -47,6 +47,7 @@ static void touchscreen_set_params(struct input_dev *dev,
 	}
 
 	absinfo = &dev->absinfo[axis];
+	absinfo->minimum = min;
 	absinfo->maximum = max;
 	absinfo->fuzz = fuzz;
 }
@@ -68,8 +69,9 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
 				  struct touchscreen_properties *prop)
 {
 	struct device *dev = input->dev.parent;
+	struct input_absinfo *absinfo;
 	unsigned int axis;
-	unsigned int maximum, fuzz;
+	unsigned int minimum, maximum, fuzz;
 	bool data_present;
 
 	input_alloc_absinfo(input);
@@ -77,7 +79,10 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
 		return;
 
 	axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
-	data_present = touchscreen_get_prop_u32(dev, "touchscreen-size-x",
+	data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x",
+						input_abs_get_min(input, axis),
+						&minimum) |
+		       touchscreen_get_prop_u32(dev, "touchscreen-size-x",
 						input_abs_get_max(input,
 								  axis) + 1,
 						&maximum) |
@@ -85,10 +90,13 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
 						input_abs_get_fuzz(input, axis),
 						&fuzz);
 	if (data_present)
-		touchscreen_set_params(input, axis, maximum - 1, fuzz);
+		touchscreen_set_params(input, axis, minimum, maximum - 1, fuzz);
 
 	axis = multitouch ? ABS_MT_POSITION_Y : ABS_Y;
-	data_present = touchscreen_get_prop_u32(dev, "touchscreen-size-y",
+	data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-y",
+						input_abs_get_min(input, axis),
+						&minimum) |
+		       touchscreen_get_prop_u32(dev, "touchscreen-size-y",
 						input_abs_get_max(input,
 								  axis) + 1,
 						&maximum) |
@@ -96,7 +104,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
 						input_abs_get_fuzz(input, axis),
 						&fuzz);
 	if (data_present)
-		touchscreen_set_params(input, axis, maximum - 1, fuzz);
+		touchscreen_set_params(input, axis, minimum, maximum - 1, fuzz);
 
 	axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE;
 	data_present = touchscreen_get_prop_u32(dev,
@@ -108,7 +116,7 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
 						input_abs_get_fuzz(input, axis),
 						&fuzz);
 	if (data_present)
-		touchscreen_set_params(input, axis, maximum, fuzz);
+		touchscreen_set_params(input, axis, 0, maximum, fuzz);
 
 	if (!prop)
 		return;
@@ -117,13 +125,25 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
 
 	prop->max_x = input_abs_get_max(input, axis);
 	prop->max_y = input_abs_get_max(input, axis + 1);
+
 	prop->invert_x =
 		device_property_read_bool(dev, "touchscreen-inverted-x");
+	if (prop->invert_x) {
+		absinfo = &input->absinfo[axis];
+		absinfo->maximum -= absinfo->minimum;
+		absinfo->minimum = 0;
+	}
+
 	prop->invert_y =
 		device_property_read_bool(dev, "touchscreen-inverted-y");
+	if (prop->invert_y) {
+		absinfo = &input->absinfo[axis + 1];
+		absinfo->maximum -= absinfo->minimum;
+		absinfo->minimum = 0;
+	}
+
 	prop->swap_x_y =
 		device_property_read_bool(dev, "touchscreen-swapped-x-y");
-
 	if (prop->swap_x_y)
 		swap(input->absinfo[axis], input->absinfo[axis + 1]);
 }
Signature · 1 line
2.17.0
maintainer
#1 lore raw
Quoted 10 lines · Hans de Goede

Some touchscreens, depending on the firmware and/or the digitizer report coordinates which never reach 0 along one or both of their axis.

This has been seen for example on the Silead touchscreens on a Onda V891w and a Point of View mobii TAB-P800w(v2.0).

This commit adds support for touchscreen-min-x and touchscreen-min-y device-properties which can be set to communicate the actual start coordinates (rather then 0,0) to userspace.

Quoted 6 lines

When set this fixes e.g. not being able to click things in the GNOME3 top-bar on the 2 example tablets.

---
 .../input/touchscreen/touchscreen.txt         |  6 ++--

Please split bindings to separate patch.

Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 5

Quoted 13 lines
 drivers/input/touchscreen/of_touchscreen.c    | 36 ++++++++++++++-----
 2 files changed, 32 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +2 -0
index 537643e86f61..8aff9551259f 100644
@@ -1,10 +1,12 @@
 General Touchscreen Properties:
 
 Optional properties for Touchscreens:
+ - touchscreen-min-x		: minimum x coordinate reported (0 if not set)
+ - touchscreen-min-y		: minimum y coordinate reported (0 if not set)

Maybe a min-max range would be better if size (in pixels) is also needed?

Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 7

Quoted 3 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +1 -1
  - touchscreen-size-x		: horizontal resolution of touchscreen
-				  (in pixels)
+				  (maximum x coordinate reported + 1)

This is unrelated or at least not explained in the commit msg. I agree this probably makes sense as units are often not pixels unless the hw/fw is doing some scaling itself.

Quoted 6 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +1 -1
  - touchscreen-size-y		: vertical resolution of touchscreen
-				  (in pixels)
+				  (maximum y coordinate reported + 1)
  - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
 				  dependent on the controller)
  - touchscreen-fuzz-x		: horizontal noise value of the absolute input
#2 lore raw

Hi,

Quoted 11 lines · Rob Herring
Quoted 10 lines · Hans de Goede

Some touchscreens, depending on the firmware and/or the digitizer report coordinates which never reach 0 along one or both of their axis.

This has been seen for example on the Silead touchscreens on a Onda V891w and a Point of View mobii TAB-P800w(v2.0).

This commit adds support for touchscreen-min-x and touchscreen-min-y device-properties which can be set to communicate the actual start coordinates (rather then 0,0) to userspace.

Quoted 8 lines
Quoted 6 lines

When set this fixes e.g. not being able to click things in the GNOME3 top-bar on the 2 example tablets.

---
  .../input/touchscreen/touchscreen.txt         |  6 ++--

Please split bindings to separate patch.

Will do for v2.

Quoted 10 lines
Quoted 10 lines
  drivers/input/touchscreen/of_touchscreen.c    | 36 ++++++++++++++-----
  2 files changed, 32 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +0 -0
index 537643e86f61..8aff9551259f 100644
@@ -1,10 +1,12 @@
  General Touchscreen Properties:
 
Quoted 6 lines

Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 5

Quoted 3 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +2 -0
  Optional properties for Touchscreens:
+ - touchscreen-min-x		: minimum x coordinate reported (0 if not set)
+ - touchscreen-min-y		: minimum y coordinate reported (0 if not set)

Maybe a min-max range would be better if size (in pixels) is also needed?

Size in pixels is never needed. The touchscreen-size-x / touchscreen-size-y have always been the max x/y coordinate reported + 1 and may or may not have anything to do with pixels. I've noticed on some ARM tablets that the firmware in the touchscreen controller was programmed to send coordinates in the same range as the display resolution, but then the manufacturer would turn around, put in a higher res display and keep the same touchscreen range (or the otherway around). So it seems that there has been a 1:1 mapping on some devices, but that has not been true for a long time now.

Quoted 7 lines

Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 7

Quoted 3 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +1 -1
   - touchscreen-size-x		: horizontal resolution of touchscreen
-				  (in pixels)
+				  (maximum x coordinate reported + 1)

This is unrelated or at least not explained in the commit msg. I agree this probably makes sense as units are often not pixels unless the hw/fw is doing some scaling itself.

Right I added this fix to make clear that we are indeed specifying a min-max range, with the oddity that instead of max we specify max + 1 for historical reasons.

Do you want me to split this out into a separate patch?

Regards,

Hans

Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +1 -1
   - touchscreen-size-y		: vertical resolution of touchscreen
-				  (in pixels)
+				  (maximum y coordinate reported + 1)
   - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
  				  dependent on the controller)
   - touchscreen-fuzz-x		: horizontal noise value of the absolute input
maintainer
#3 lore raw
Quoted 71 lines · Hans de Goede

Hi,

Quoted 16 lines · Rob Herring
Quoted 14 lines · Hans de Goede

Some touchscreens, depending on the firmware and/or the digitizer report coordinates which never reach 0 along one or both of their axis.

This has been seen for example on the Silead touchscreens on a Onda V891w and a Point of View mobii TAB-P800w(v2.0).

This commit adds support for touchscreen-min-x and touchscreen-min-y device-properties which can be set to communicate the actual start coordinates (rather then 0,0) to userspace.

When set this fixes e.g. not being able to click things in the GNOME3 top-bar on the 2 example tablets.

Quoted 6 lines
Quoted 3 lines
---
  .../input/touchscreen/touchscreen.txt         |  6 ++--

Please split bindings to separate patch.

Will do for v2.

Quoted 12 lines
Quoted 12 lines
  drivers/input/touchscreen/of_touchscreen.c    | 36 ++++++++++++++-----
  2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt index 537643e86f61..8aff9551259f 100644

Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +0 -0
@@ -1,10 +1,12 @@
  General Touchscreen Properties:
    Optional properties for Touchscreens:
Quoted 8 lines

Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 6

Quoted 4 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +2 -0
+ - touchscreen-min-x           : minimum x coordinate reported (0 if not
 set)
+ - touchscreen-min-y           : minimum y coordinate reported (0 if not
 set)

Maybe a min-max range would be better if size (in pixels) is also needed?

Size in pixels is never needed. The touchscreen-size-x / touchscreen-size-y have always been the max x/y coordinate reported + 1 and may or may not have anything to do with pixels. I've noticed on some ARM tablets that the firmware in the touchscreen controller was programmed to send coordinates in the same range as the display resolution, but then the manufacturer would turn around, put in a higher res display and keep the same touchscreen range (or the otherway around). So it seems that there has been a 1:1 mapping on some devices, but that has not been true for a long time now.

Quoted 8 lines

Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt line 7

Quoted 3 lines
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt +1 -1
   - touchscreen-size-x         : horizontal resolution of touchscreen
-                                 (in pixels)
+                                 (maximum x coordinate reported + 1)

This is unrelated or at least not explained in the commit msg. I agree this probably makes sense as units are often not pixels unless the hw/fw is doing some scaling itself.

Quoted 5 lines

Right I added this fix to make clear that we are indeed specifying a min-max range, with the oddity that instead of max we specify max + 1 for historical reasons.

Do you want me to split this out into a separate patch?

No, just some explanation in this one is fine.

Rob