All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] input: tsc2007: Extend for pre-calibration, flipping and rotation
@ 2014-09-30 20:17 ` Marek Belisko
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Belisko @ 2014-09-30 20:17 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	bcousson, tony, linux, dmitry.torokhov
  Cc: hns, devicetree, linux-kernel, linux-omap, linux-arm-kernel,
	linux-input, Marek Belisko

Following series add support to tsc2007 touchscreen driver for pre-calibration,
flipping and rotation. Added bindings are documented and used in gta04 device tree.

Marek Belisko (3):
  input: tsc2007: Add pre-calibration, flipping and rotation
  Documentation: dt: input: tsc2007: Document new parameters
  arm: dts: omap3-gta04: Extend touchscreen configs

 .../bindings/input/touchscreen/tsc2007.txt         | 17 ++++-
 arch/arm/boot/dts/omap3-gta04.dtsi                 |  6 ++
 drivers/input/touchscreen/tsc2007.c                | 89 +++++++++++++++++++++-
 include/linux/i2c/tsc2007.h                        |  6 ++
 4 files changed, 111 insertions(+), 7 deletions(-)

-- 
1.9.3


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

* [PATCH 0/3] input: tsc2007: Extend for pre-calibration, flipping and rotation
@ 2014-09-30 20:17 ` Marek Belisko
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Belisko @ 2014-09-30 20:17 UTC (permalink / raw)
  To: linux-arm-kernel

Following series add support to tsc2007 touchscreen driver for pre-calibration,
flipping and rotation. Added bindings are documented and used in gta04 device tree.

Marek Belisko (3):
  input: tsc2007: Add pre-calibration, flipping and rotation
  Documentation: dt: input: tsc2007: Document new parameters
  arm: dts: omap3-gta04: Extend touchscreen configs

 .../bindings/input/touchscreen/tsc2007.txt         | 17 ++++-
 arch/arm/boot/dts/omap3-gta04.dtsi                 |  6 ++
 drivers/input/touchscreen/tsc2007.c                | 89 +++++++++++++++++++++-
 include/linux/i2c/tsc2007.h                        |  6 ++
 4 files changed, 111 insertions(+), 7 deletions(-)

-- 
1.9.3

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

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
  2014-09-30 20:17 ` Marek Belisko
  (?)
@ 2014-09-30 20:17   ` Marek Belisko
  -1 siblings, 0 replies; 36+ messages in thread
From: Marek Belisko @ 2014-09-30 20:17 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	bcousson, tony, linux, dmitry.torokhov
  Cc: hns, devicetree, linux-kernel, linux-omap, linux-arm-kernel,
	linux-input, Marek Belisko

This patch adds new parameters that allow to address typical hardware
design differences: touch screens may be wired or oriented differently
(portrait or landscape). And usually the active area of the touch is a
little larger than the active area of the LCD. This results in the touch
coordinates that have some significant deviation from LCD coordinates.
Usually this is addressed in user space by a calibration tool (e.g. tslib
or xinput-calibrator) but some systems don't have these tools or require
that the screen is already roughly calibrated (e.g. Replicant) to operate
the device until a better calibration can be done. And, some systems
react very strangely if the touch event stream reports coordinates
outside of the active area.

This makes it necessry to be able to configure:
1. swapping x and y wires (coordinate values)
2. flipping of x (left - right) or y (top - bottom) or even both
3. define an active area so that an uncalibrated screen already
roughly matches the LCD to be useful.
4. clip reported coordinates to the active area.

If none of the new parameters is defined (in DT) or set in a board file,
the driver behaves the same as without this patch.

Author (1&2): H. Nikolaus Schaller <hns@goldelico.com>
Author (3&4): Paul Kocialkowski <contact@paulk.fr>

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/input/touchscreen/tsc2007.c | 89 +++++++++++++++++++++++++++++++++++--
 include/linux/i2c/tsc2007.h         |  6 +++
 2 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 1bf9906..cc0cc3c 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -74,6 +74,12 @@ struct tsc2007 {
 
 	u16			model;
 	u16			x_plate_ohms;
+	bool			swap_xy;	/* swap x and y axis */
+	u16			min_x;
+	u16			min_y;
+	u16			min_rt;
+	u16			max_x;
+	u16			max_y;
 	u16			max_rt;
 	unsigned long		poll_period;
 	int			fuzzx;
@@ -193,11 +199,50 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
 			break;
 		}
 
-		if (rt <= ts->max_rt) {
+		if (rt <= max(ts->min_rt, ts->max_rt)) {
 			dev_dbg(&ts->client->dev,
 				"DOWN point(%4d,%4d), pressure (%4u)\n",
 				tc.x, tc.y, rt);
 
+			if (ts->swap_xy) {
+				/* swap before applying the range limits */
+				u16 h = tc.x;
+
+				tc.x = tc.y;
+				tc.y = h;
+			}
+
+			/* flip and/or clip X */
+			if (ts->max_x < ts->min_x)
+				tc.x = (ts->min_x - tc.x) + ts->max_x;
+
+			if (tc.x > max(ts->min_x, ts->max_x))
+				tc.x = max(ts->min_x, ts->max_x);
+			else if (tc.x < min(ts->min_x, ts->max_x))
+				tc.x = min(ts->min_x, ts->max_x);
+
+			/* flip and/or clip Y */
+			if (ts->max_y < ts->min_y)
+				tc.y = (ts->min_y - tc.y) + ts->max_y;
+
+			if (tc.y > max(ts->min_y, ts->max_y))
+				tc.y = max(ts->min_y, ts->max_y);
+			else if (tc.y < min(ts->min_y, ts->max_y))
+				tc.y = min(ts->min_y, ts->max_y);
+
+			/* clip Z */
+			if (ts->max_rt < ts->min_rt)
+				rt = (ts->min_rt - rt) + ts->max_rt;
+
+			if (rt > max(ts->min_rt, ts->max_rt))
+				rt = max(ts->min_rt, ts->max_rt);
+			else if (rt < min(ts->min_rt, ts->max_rt))
+				rt = min(ts->min_rt, ts->max_rt);
+
+			dev_dbg(&ts->client->dev,
+					"shaped point(%4d,%4d), pressure (%4u)\n",
+					tc.x, tc.y, rt);
+
 			input_report_key(input, BTN_TOUCH, 1);
 			input_report_abs(input, ABS_X, tc.x);
 			input_report_abs(input, ABS_Y, tc.y);
@@ -299,6 +344,24 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
 		return -EINVAL;
 	}
 
+	ts->swap_xy = of_property_read_bool(np, "ti,swap-xy");
+
+	if (!of_property_read_u32(np, "ti,min-x", &val32))
+		ts->min_x = val32;
+	if (!of_property_read_u32(np, "ti,max-x", &val32))
+		ts->max_x = val32;
+	else
+		ts->max_x = MAX_12BIT;
+
+	if (!of_property_read_u32(np, "ti,min-y", &val32))
+		ts->min_y = val32;
+	if (!of_property_read_u32(np, "ti,max-y", &val32))
+		ts->max_y = val32;
+	else
+		ts->max_y = MAX_12BIT;
+
+	if (!of_property_read_u32(np, "ti,min-rt", &val32))
+		ts->min_rt = val32;
 	if (!of_property_read_u32(np, "ti,max-rt", &val32))
 		ts->max_rt = val32;
 	else
@@ -325,6 +388,16 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
 		return -EINVAL;
 	}
 
+	dev_dbg(&client->dev,
+			"min/max_x (%4d,%4d)\n",
+			ts->min_x, ts->max_x);
+	dev_dbg(&client->dev,
+			"min/max_y (%4d,%4d)\n",
+			ts->min_y, ts->max_y);
+	dev_dbg(&client->dev,
+			"min/max_rt (%4d,%4d)\n",
+			ts->min_rt, ts->max_rt);
+
 	ts->gpio = of_get_gpio(np, 0);
 	if (gpio_is_valid(ts->gpio))
 		ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
@@ -349,6 +422,12 @@ static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts,
 {
 	ts->model             = pdata->model;
 	ts->x_plate_ohms      = pdata->x_plate_ohms;
+	ts->swap_xy           = pdata->swap_xy;
+	ts->min_x             = pdata->min_x ? : 0;
+	ts->min_y             = pdata->min_y ? : 0;
+	ts->min_rt            = pdata->min_rt ? : 0;
+	ts->max_x             = pdata->max_x ? : MAX_12BIT;
+	ts->max_y             = pdata->max_y ? : MAX_12BIT;
 	ts->max_rt            = pdata->max_rt ? : MAX_12BIT;
 	ts->poll_period       = pdata->poll_period ? : 1;
 	ts->get_pendown_state = pdata->get_pendown_state;
@@ -422,9 +501,11 @@ static int tsc2007_probe(struct i2c_client *client,
 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
 	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
 
-	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
-	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
-	input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
+	input_set_abs_params(input_dev, ABS_X, min(ts->min_x, ts->max_x),
+			     max(ts->min_x, ts->max_x), ts->fuzzx, 0);
+	input_set_abs_params(input_dev, ABS_Y, min(ts->min_y, ts->max_y),
+			     max(ts->min_y, ts->max_y), ts->fuzzy, 0);
+	input_set_abs_params(input_dev, ABS_PRESSURE, ts->min_rt, ts->max_rt,
 			     ts->fuzzz, 0);
 
 	if (pdata) {
diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
index 4f35b6a..5ce7b79 100644
--- a/include/linux/i2c/tsc2007.h
+++ b/include/linux/i2c/tsc2007.h
@@ -6,6 +6,12 @@
 struct tsc2007_platform_data {
 	u16	model;				/* 2007. */
 	u16	x_plate_ohms;	/* must be non-zero value */
+	bool	swap_xy;	/* swap x and y axis */
+	u16	min_x;	/* min and max values to reported to user space */
+	u16	min_y;
+	u16	min_rt;
+	u16	max_x;
+	u16	max_y;
 	u16	max_rt; /* max. resistance above which samples are ignored */
 	unsigned long poll_period; /* time (in ms) between samples */
 	int	fuzzx; /* fuzz factor for X, Y and pressure axes */
-- 
1.9.3


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

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2014-09-30 20:17   ` Marek Belisko
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Belisko @ 2014-09-30 20:17 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	bcousson, tony, linux, dmitry.torokhov
  Cc: devicetree, hns, linux-kernel, linux-input, Marek Belisko,
	linux-omap, linux-arm-kernel

This patch adds new parameters that allow to address typical hardware
design differences: touch screens may be wired or oriented differently
(portrait or landscape). And usually the active area of the touch is a
little larger than the active area of the LCD. This results in the touch
coordinates that have some significant deviation from LCD coordinates.
Usually this is addressed in user space by a calibration tool (e.g. tslib
or xinput-calibrator) but some systems don't have these tools or require
that the screen is already roughly calibrated (e.g. Replicant) to operate
the device until a better calibration can be done. And, some systems
react very strangely if the touch event stream reports coordinates
outside of the active area.

This makes it necessry to be able to configure:
1. swapping x and y wires (coordinate values)
2. flipping of x (left - right) or y (top - bottom) or even both
3. define an active area so that an uncalibrated screen already
roughly matches the LCD to be useful.
4. clip reported coordinates to the active area.

If none of the new parameters is defined (in DT) or set in a board file,
the driver behaves the same as without this patch.

Author (1&2): H. Nikolaus Schaller <hns@goldelico.com>
Author (3&4): Paul Kocialkowski <contact@paulk.fr>

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/input/touchscreen/tsc2007.c | 89 +++++++++++++++++++++++++++++++++++--
 include/linux/i2c/tsc2007.h         |  6 +++
 2 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 1bf9906..cc0cc3c 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -74,6 +74,12 @@ struct tsc2007 {
 
 	u16			model;
 	u16			x_plate_ohms;
+	bool			swap_xy;	/* swap x and y axis */
+	u16			min_x;
+	u16			min_y;
+	u16			min_rt;
+	u16			max_x;
+	u16			max_y;
 	u16			max_rt;
 	unsigned long		poll_period;
 	int			fuzzx;
@@ -193,11 +199,50 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
 			break;
 		}
 
-		if (rt <= ts->max_rt) {
+		if (rt <= max(ts->min_rt, ts->max_rt)) {
 			dev_dbg(&ts->client->dev,
 				"DOWN point(%4d,%4d), pressure (%4u)\n",
 				tc.x, tc.y, rt);
 
+			if (ts->swap_xy) {
+				/* swap before applying the range limits */
+				u16 h = tc.x;
+
+				tc.x = tc.y;
+				tc.y = h;
+			}
+
+			/* flip and/or clip X */
+			if (ts->max_x < ts->min_x)
+				tc.x = (ts->min_x - tc.x) + ts->max_x;
+
+			if (tc.x > max(ts->min_x, ts->max_x))
+				tc.x = max(ts->min_x, ts->max_x);
+			else if (tc.x < min(ts->min_x, ts->max_x))
+				tc.x = min(ts->min_x, ts->max_x);
+
+			/* flip and/or clip Y */
+			if (ts->max_y < ts->min_y)
+				tc.y = (ts->min_y - tc.y) + ts->max_y;
+
+			if (tc.y > max(ts->min_y, ts->max_y))
+				tc.y = max(ts->min_y, ts->max_y);
+			else if (tc.y < min(ts->min_y, ts->max_y))
+				tc.y = min(ts->min_y, ts->max_y);
+
+			/* clip Z */
+			if (ts->max_rt < ts->min_rt)
+				rt = (ts->min_rt - rt) + ts->max_rt;
+
+			if (rt > max(ts->min_rt, ts->max_rt))
+				rt = max(ts->min_rt, ts->max_rt);
+			else if (rt < min(ts->min_rt, ts->max_rt))
+				rt = min(ts->min_rt, ts->max_rt);
+
+			dev_dbg(&ts->client->dev,
+					"shaped point(%4d,%4d), pressure (%4u)\n",
+					tc.x, tc.y, rt);
+
 			input_report_key(input, BTN_TOUCH, 1);
 			input_report_abs(input, ABS_X, tc.x);
 			input_report_abs(input, ABS_Y, tc.y);
@@ -299,6 +344,24 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
 		return -EINVAL;
 	}
 
+	ts->swap_xy = of_property_read_bool(np, "ti,swap-xy");
+
+	if (!of_property_read_u32(np, "ti,min-x", &val32))
+		ts->min_x = val32;
+	if (!of_property_read_u32(np, "ti,max-x", &val32))
+		ts->max_x = val32;
+	else
+		ts->max_x = MAX_12BIT;
+
+	if (!of_property_read_u32(np, "ti,min-y", &val32))
+		ts->min_y = val32;
+	if (!of_property_read_u32(np, "ti,max-y", &val32))
+		ts->max_y = val32;
+	else
+		ts->max_y = MAX_12BIT;
+
+	if (!of_property_read_u32(np, "ti,min-rt", &val32))
+		ts->min_rt = val32;
 	if (!of_property_read_u32(np, "ti,max-rt", &val32))
 		ts->max_rt = val32;
 	else
@@ -325,6 +388,16 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
 		return -EINVAL;
 	}
 
+	dev_dbg(&client->dev,
+			"min/max_x (%4d,%4d)\n",
+			ts->min_x, ts->max_x);
+	dev_dbg(&client->dev,
+			"min/max_y (%4d,%4d)\n",
+			ts->min_y, ts->max_y);
+	dev_dbg(&client->dev,
+			"min/max_rt (%4d,%4d)\n",
+			ts->min_rt, ts->max_rt);
+
 	ts->gpio = of_get_gpio(np, 0);
 	if (gpio_is_valid(ts->gpio))
 		ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
@@ -349,6 +422,12 @@ static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts,
 {
 	ts->model             = pdata->model;
 	ts->x_plate_ohms      = pdata->x_plate_ohms;
+	ts->swap_xy           = pdata->swap_xy;
+	ts->min_x             = pdata->min_x ? : 0;
+	ts->min_y             = pdata->min_y ? : 0;
+	ts->min_rt            = pdata->min_rt ? : 0;
+	ts->max_x             = pdata->max_x ? : MAX_12BIT;
+	ts->max_y             = pdata->max_y ? : MAX_12BIT;
 	ts->max_rt            = pdata->max_rt ? : MAX_12BIT;
 	ts->poll_period       = pdata->poll_period ? : 1;
 	ts->get_pendown_state = pdata->get_pendown_state;
@@ -422,9 +501,11 @@ static int tsc2007_probe(struct i2c_client *client,
 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
 	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
 
-	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
-	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
-	input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
+	input_set_abs_params(input_dev, ABS_X, min(ts->min_x, ts->max_x),
+			     max(ts->min_x, ts->max_x), ts->fuzzx, 0);
+	input_set_abs_params(input_dev, ABS_Y, min(ts->min_y, ts->max_y),
+			     max(ts->min_y, ts->max_y), ts->fuzzy, 0);
+	input_set_abs_params(input_dev, ABS_PRESSURE, ts->min_rt, ts->max_rt,
 			     ts->fuzzz, 0);
 
 	if (pdata) {
diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
index 4f35b6a..5ce7b79 100644
--- a/include/linux/i2c/tsc2007.h
+++ b/include/linux/i2c/tsc2007.h
@@ -6,6 +6,12 @@
 struct tsc2007_platform_data {
 	u16	model;				/* 2007. */
 	u16	x_plate_ohms;	/* must be non-zero value */
+	bool	swap_xy;	/* swap x and y axis */
+	u16	min_x;	/* min and max values to reported to user space */
+	u16	min_y;
+	u16	min_rt;
+	u16	max_x;
+	u16	max_y;
 	u16	max_rt; /* max. resistance above which samples are ignored */
 	unsigned long poll_period; /* time (in ms) between samples */
 	int	fuzzx; /* fuzz factor for X, Y and pressure axes */
-- 
1.9.3

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

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2014-09-30 20:17   ` Marek Belisko
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Belisko @ 2014-09-30 20:17 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds new parameters that allow to address typical hardware
design differences: touch screens may be wired or oriented differently
(portrait or landscape). And usually the active area of the touch is a
little larger than the active area of the LCD. This results in the touch
coordinates that have some significant deviation from LCD coordinates.
Usually this is addressed in user space by a calibration tool (e.g. tslib
or xinput-calibrator) but some systems don't have these tools or require
that the screen is already roughly calibrated (e.g. Replicant) to operate
the device until a better calibration can be done. And, some systems
react very strangely if the touch event stream reports coordinates
outside of the active area.

This makes it necessry to be able to configure:
1. swapping x and y wires (coordinate values)
2. flipping of x (left - right) or y (top - bottom) or even both
3. define an active area so that an uncalibrated screen already
roughly matches the LCD to be useful.
4. clip reported coordinates to the active area.

If none of the new parameters is defined (in DT) or set in a board file,
the driver behaves the same as without this patch.

Author (1&2): H. Nikolaus Schaller <hns@goldelico.com>
Author (3&4): Paul Kocialkowski <contact@paulk.fr>

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/input/touchscreen/tsc2007.c | 89 +++++++++++++++++++++++++++++++++++--
 include/linux/i2c/tsc2007.h         |  6 +++
 2 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 1bf9906..cc0cc3c 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -74,6 +74,12 @@ struct tsc2007 {
 
 	u16			model;
 	u16			x_plate_ohms;
+	bool			swap_xy;	/* swap x and y axis */
+	u16			min_x;
+	u16			min_y;
+	u16			min_rt;
+	u16			max_x;
+	u16			max_y;
 	u16			max_rt;
 	unsigned long		poll_period;
 	int			fuzzx;
@@ -193,11 +199,50 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
 			break;
 		}
 
-		if (rt <= ts->max_rt) {
+		if (rt <= max(ts->min_rt, ts->max_rt)) {
 			dev_dbg(&ts->client->dev,
 				"DOWN point(%4d,%4d), pressure (%4u)\n",
 				tc.x, tc.y, rt);
 
+			if (ts->swap_xy) {
+				/* swap before applying the range limits */
+				u16 h = tc.x;
+
+				tc.x = tc.y;
+				tc.y = h;
+			}
+
+			/* flip and/or clip X */
+			if (ts->max_x < ts->min_x)
+				tc.x = (ts->min_x - tc.x) + ts->max_x;
+
+			if (tc.x > max(ts->min_x, ts->max_x))
+				tc.x = max(ts->min_x, ts->max_x);
+			else if (tc.x < min(ts->min_x, ts->max_x))
+				tc.x = min(ts->min_x, ts->max_x);
+
+			/* flip and/or clip Y */
+			if (ts->max_y < ts->min_y)
+				tc.y = (ts->min_y - tc.y) + ts->max_y;
+
+			if (tc.y > max(ts->min_y, ts->max_y))
+				tc.y = max(ts->min_y, ts->max_y);
+			else if (tc.y < min(ts->min_y, ts->max_y))
+				tc.y = min(ts->min_y, ts->max_y);
+
+			/* clip Z */
+			if (ts->max_rt < ts->min_rt)
+				rt = (ts->min_rt - rt) + ts->max_rt;
+
+			if (rt > max(ts->min_rt, ts->max_rt))
+				rt = max(ts->min_rt, ts->max_rt);
+			else if (rt < min(ts->min_rt, ts->max_rt))
+				rt = min(ts->min_rt, ts->max_rt);
+
+			dev_dbg(&ts->client->dev,
+					"shaped point(%4d,%4d), pressure (%4u)\n",
+					tc.x, tc.y, rt);
+
 			input_report_key(input, BTN_TOUCH, 1);
 			input_report_abs(input, ABS_X, tc.x);
 			input_report_abs(input, ABS_Y, tc.y);
@@ -299,6 +344,24 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
 		return -EINVAL;
 	}
 
+	ts->swap_xy = of_property_read_bool(np, "ti,swap-xy");
+
+	if (!of_property_read_u32(np, "ti,min-x", &val32))
+		ts->min_x = val32;
+	if (!of_property_read_u32(np, "ti,max-x", &val32))
+		ts->max_x = val32;
+	else
+		ts->max_x = MAX_12BIT;
+
+	if (!of_property_read_u32(np, "ti,min-y", &val32))
+		ts->min_y = val32;
+	if (!of_property_read_u32(np, "ti,max-y", &val32))
+		ts->max_y = val32;
+	else
+		ts->max_y = MAX_12BIT;
+
+	if (!of_property_read_u32(np, "ti,min-rt", &val32))
+		ts->min_rt = val32;
 	if (!of_property_read_u32(np, "ti,max-rt", &val32))
 		ts->max_rt = val32;
 	else
@@ -325,6 +388,16 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
 		return -EINVAL;
 	}
 
+	dev_dbg(&client->dev,
+			"min/max_x (%4d,%4d)\n",
+			ts->min_x, ts->max_x);
+	dev_dbg(&client->dev,
+			"min/max_y (%4d,%4d)\n",
+			ts->min_y, ts->max_y);
+	dev_dbg(&client->dev,
+			"min/max_rt (%4d,%4d)\n",
+			ts->min_rt, ts->max_rt);
+
 	ts->gpio = of_get_gpio(np, 0);
 	if (gpio_is_valid(ts->gpio))
 		ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
@@ -349,6 +422,12 @@ static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts,
 {
 	ts->model             = pdata->model;
 	ts->x_plate_ohms      = pdata->x_plate_ohms;
+	ts->swap_xy           = pdata->swap_xy;
+	ts->min_x             = pdata->min_x ? : 0;
+	ts->min_y             = pdata->min_y ? : 0;
+	ts->min_rt            = pdata->min_rt ? : 0;
+	ts->max_x             = pdata->max_x ? : MAX_12BIT;
+	ts->max_y             = pdata->max_y ? : MAX_12BIT;
 	ts->max_rt            = pdata->max_rt ? : MAX_12BIT;
 	ts->poll_period       = pdata->poll_period ? : 1;
 	ts->get_pendown_state = pdata->get_pendown_state;
@@ -422,9 +501,11 @@ static int tsc2007_probe(struct i2c_client *client,
 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
 	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
 
-	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
-	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
-	input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
+	input_set_abs_params(input_dev, ABS_X, min(ts->min_x, ts->max_x),
+			     max(ts->min_x, ts->max_x), ts->fuzzx, 0);
+	input_set_abs_params(input_dev, ABS_Y, min(ts->min_y, ts->max_y),
+			     max(ts->min_y, ts->max_y), ts->fuzzy, 0);
+	input_set_abs_params(input_dev, ABS_PRESSURE, ts->min_rt, ts->max_rt,
 			     ts->fuzzz, 0);
 
 	if (pdata) {
diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
index 4f35b6a..5ce7b79 100644
--- a/include/linux/i2c/tsc2007.h
+++ b/include/linux/i2c/tsc2007.h
@@ -6,6 +6,12 @@
 struct tsc2007_platform_data {
 	u16	model;				/* 2007. */
 	u16	x_plate_ohms;	/* must be non-zero value */
+	bool	swap_xy;	/* swap x and y axis */
+	u16	min_x;	/* min and max values to reported to user space */
+	u16	min_y;
+	u16	min_rt;
+	u16	max_x;
+	u16	max_y;
 	u16	max_rt; /* max. resistance above which samples are ignored */
 	unsigned long poll_period; /* time (in ms) between samples */
 	int	fuzzx; /* fuzz factor for X, Y and pressure axes */
-- 
1.9.3

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

* [PATCH 2/3] Documentation: dt: input: tsc2007: Document new parameters
  2014-09-30 20:17 ` Marek Belisko
@ 2014-09-30 20:17   ` Marek Belisko
  -1 siblings, 0 replies; 36+ messages in thread
From: Marek Belisko @ 2014-09-30 20:17 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	bcousson, tony, linux, dmitry.torokhov
  Cc: hns, devicetree, linux-kernel, linux-omap, linux-arm-kernel,
	linux-input, Marek Belisko

Signed-off-by: Marek Belisko <marek@goldelico.com>
---
 .../devicetree/bindings/input/touchscreen/tsc2007.txt   | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
index ec365e1..46b086c 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
@@ -13,14 +13,25 @@ Optional properties:
   (see interrupt binding[0]).
 - interrupts: (gpio) interrupt to which the chip is connected
   (see interrupt binding[0]).
-- ti,max-rt: maximum pressure.
+- ti,swap-xy: if present, swap x and y values. Rotation left/right is
+  achieved by combination with flipping of x or y.
+- ti,min-x: minimum x (default 0). Use this for a coarse calibration of the
+  touch if there is no user space option (e.g. Android, X11).
+- ti,max-x: maximum x (default 4095). If max-x is smaller than min-x the
+  axis is swapped.
+- ti,min-y: minimum y (default 0).
+- ti,max-y: maximum y (default 4095).
+- ti,min-rt: minimum pressure (default 0).
+- ti,max-rt: maximum pressure (default 4095). Depending on your needs, you
+  can also invert the pressure value since the raw rt value  reports the
+  resistance and not the "pressure" (i.e. becomes lower for higher pressure).
 - ti,fuzzx: specifies the absolute input fuzz x value.
   If set, it will permit noise in the data up to +- the value given to the fuzz
-  parameter, that is used to filter noise from the event stream.
+  parameter, that is used to filter noise from the event stream (default 0).
 - ti,fuzzy: specifies the absolute input fuzz y value.
 - ti,fuzzz: specifies the absolute input fuzz z value.
 - ti,poll-period: how much time to wait (in milliseconds) before reading again the
-  values from the tsc2007.
+  values from the tsc2007 (default 1).
 
 [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
 [1]: Documentation/devicetree/bindings/gpio/gpio.txt
-- 
1.9.3


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

* [PATCH 2/3] Documentation: dt: input: tsc2007: Document new parameters
@ 2014-09-30 20:17   ` Marek Belisko
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Belisko @ 2014-09-30 20:17 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Marek Belisko <marek@goldelico.com>
---
 .../devicetree/bindings/input/touchscreen/tsc2007.txt   | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
index ec365e1..46b086c 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
@@ -13,14 +13,25 @@ Optional properties:
   (see interrupt binding[0]).
 - interrupts: (gpio) interrupt to which the chip is connected
   (see interrupt binding[0]).
-- ti,max-rt: maximum pressure.
+- ti,swap-xy: if present, swap x and y values. Rotation left/right is
+  achieved by combination with flipping of x or y.
+- ti,min-x: minimum x (default 0). Use this for a coarse calibration of the
+  touch if there is no user space option (e.g. Android, X11).
+- ti,max-x: maximum x (default 4095). If max-x is smaller than min-x the
+  axis is swapped.
+- ti,min-y: minimum y (default 0).
+- ti,max-y: maximum y (default 4095).
+- ti,min-rt: minimum pressure (default 0).
+- ti,max-rt: maximum pressure (default 4095). Depending on your needs, you
+  can also invert the pressure value since the raw rt value  reports the
+  resistance and not the "pressure" (i.e. becomes lower for higher pressure).
 - ti,fuzzx: specifies the absolute input fuzz x value.
   If set, it will permit noise in the data up to +- the value given to the fuzz
-  parameter, that is used to filter noise from the event stream.
+  parameter, that is used to filter noise from the event stream (default 0).
 - ti,fuzzy: specifies the absolute input fuzz y value.
 - ti,fuzzz: specifies the absolute input fuzz z value.
 - ti,poll-period: how much time to wait (in milliseconds) before reading again the
-  values from the tsc2007.
+  values from the tsc2007 (default 1).
 
 [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
 [1]: Documentation/devicetree/bindings/gpio/gpio.txt
-- 
1.9.3

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

* [PATCH 3/3] arm: dts: omap3-gta04: Extend touchscreen configs
  2014-09-30 20:17 ` Marek Belisko
@ 2014-09-30 20:17   ` Marek Belisko
  -1 siblings, 0 replies; 36+ messages in thread
From: Marek Belisko @ 2014-09-30 20:17 UTC (permalink / raw)
  To: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	bcousson, tony, linux, dmitry.torokhov
  Cc: hns, devicetree, linux-kernel, linux-omap, linux-arm-kernel,
	linux-input, Marek Belisko

Adding min/max values for various touschscreen properties.

Signed-off-by: Marek Belisko <marek@goldelico.com>
---
 arch/arm/boot/dts/omap3-gta04.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/omap3-gta04.dtsi b/arch/arm/boot/dts/omap3-gta04.dtsi
index fd34f91..2dafac3b 100644
--- a/arch/arm/boot/dts/omap3-gta04.dtsi
+++ b/arch/arm/boot/dts/omap3-gta04.dtsi
@@ -284,6 +284,12 @@
 		interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
 		gpios = <&gpio6 0 GPIO_ACTIVE_LOW>;
 		ti,x-plate-ohms = <600>;
+		ti,min-x = <0x100>;
+		ti,max-x = <0xf00>;
+		ti,min-y = <0xf00>;
+		ti,max-y = <0x100>;
+		ti,min-rt = <0xfff>;
+		ti,max-rt = <0>;
 	};
 };
 
-- 
1.9.3


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

* [PATCH 3/3] arm: dts: omap3-gta04: Extend touchscreen configs
@ 2014-09-30 20:17   ` Marek Belisko
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Belisko @ 2014-09-30 20:17 UTC (permalink / raw)
  To: linux-arm-kernel

Adding min/max values for various touschscreen properties.

Signed-off-by: Marek Belisko <marek@goldelico.com>
---
 arch/arm/boot/dts/omap3-gta04.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/omap3-gta04.dtsi b/arch/arm/boot/dts/omap3-gta04.dtsi
index fd34f91..2dafac3b 100644
--- a/arch/arm/boot/dts/omap3-gta04.dtsi
+++ b/arch/arm/boot/dts/omap3-gta04.dtsi
@@ -284,6 +284,12 @@
 		interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
 		gpios = <&gpio6 0 GPIO_ACTIVE_LOW>;
 		ti,x-plate-ohms = <600>;
+		ti,min-x = <0x100>;
+		ti,max-x = <0xf00>;
+		ti,min-y = <0xf00>;
+		ti,max-y = <0x100>;
+		ti,min-rt = <0xfff>;
+		ti,max-rt = <0>;
 	};
 };
 
-- 
1.9.3

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

* Re: [PATCH 0/3] input: tsc2007: Extend for pre-calibration, flipping and rotation
  2014-09-30 20:17 ` Marek Belisko
@ 2014-10-10  9:28   ` Belisko Marek
  -1 siblings, 0 replies; 36+ messages in thread
From: Belisko Marek @ 2014-10-10  9:28 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, ijc+devicetree,
	Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, Dmitry Torokhov
  Cc: Dr. H. Nikolaus Schaller, devicetree, LKML, linux-omap,
	linux-arm-kernel, linux-input, Marek Belisko

Ping. Any objections? Thanks

On Tue, Sep 30, 2014 at 10:17 PM, Marek Belisko <marek@goldelico.com> wrote:
> Following series add support to tsc2007 touchscreen driver for pre-calibration,
> flipping and rotation. Added bindings are documented and used in gta04 device tree.
>
> Marek Belisko (3):
>   input: tsc2007: Add pre-calibration, flipping and rotation
>   Documentation: dt: input: tsc2007: Document new parameters
>   arm: dts: omap3-gta04: Extend touchscreen configs
>
>  .../bindings/input/touchscreen/tsc2007.txt         | 17 ++++-
>  arch/arm/boot/dts/omap3-gta04.dtsi                 |  6 ++
>  drivers/input/touchscreen/tsc2007.c                | 89 +++++++++++++++++++++-
>  include/linux/i2c/tsc2007.h                        |  6 ++
>  4 files changed, 111 insertions(+), 7 deletions(-)
>
> --
> 1.9.3
>

BR,

marek

-- 
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com

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

* [PATCH 0/3] input: tsc2007: Extend for pre-calibration, flipping and rotation
@ 2014-10-10  9:28   ` Belisko Marek
  0 siblings, 0 replies; 36+ messages in thread
From: Belisko Marek @ 2014-10-10  9:28 UTC (permalink / raw)
  To: linux-arm-kernel

Ping. Any objections? Thanks

On Tue, Sep 30, 2014 at 10:17 PM, Marek Belisko <marek@goldelico.com> wrote:
> Following series add support to tsc2007 touchscreen driver for pre-calibration,
> flipping and rotation. Added bindings are documented and used in gta04 device tree.
>
> Marek Belisko (3):
>   input: tsc2007: Add pre-calibration, flipping and rotation
>   Documentation: dt: input: tsc2007: Document new parameters
>   arm: dts: omap3-gta04: Extend touchscreen configs
>
>  .../bindings/input/touchscreen/tsc2007.txt         | 17 ++++-
>  arch/arm/boot/dts/omap3-gta04.dtsi                 |  6 ++
>  drivers/input/touchscreen/tsc2007.c                | 89 +++++++++++++++++++++-
>  include/linux/i2c/tsc2007.h                        |  6 ++
>  4 files changed, 111 insertions(+), 7 deletions(-)
>
> --
> 1.9.3
>

BR,

marek

-- 
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com

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

* Re: [PATCH 3/3] arm: dts: omap3-gta04: Extend touchscreen configs
  2014-09-30 20:17   ` Marek Belisko
@ 2014-10-13 16:29     ` Tony Lindgren
  -1 siblings, 0 replies; 36+ messages in thread
From: Tony Lindgren @ 2014-10-13 16:29 UTC (permalink / raw)
  To: Marek Belisko
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	bcousson, linux, dmitry.torokhov, hns, devicetree, linux-kernel,
	linux-omap, linux-arm-kernel, linux-input

* Marek Belisko <marek@goldelico.com> [140930 13:19]:
> Adding min/max values for various touschscreen properties.

Assuming no other comments on this patch series, this should be
safe to merge along with the other patches in this series without
causing merge conflicts:

Acked-by: Tony Lindgren <tony@atomide.com>
 
> Signed-off-by: Marek Belisko <marek@goldelico.com>
> ---
>  arch/arm/boot/dts/omap3-gta04.dtsi | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/omap3-gta04.dtsi b/arch/arm/boot/dts/omap3-gta04.dtsi
> index fd34f91..2dafac3b 100644
> --- a/arch/arm/boot/dts/omap3-gta04.dtsi
> +++ b/arch/arm/boot/dts/omap3-gta04.dtsi
> @@ -284,6 +284,12 @@
>  		interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
>  		gpios = <&gpio6 0 GPIO_ACTIVE_LOW>;
>  		ti,x-plate-ohms = <600>;
> +		ti,min-x = <0x100>;
> +		ti,max-x = <0xf00>;
> +		ti,min-y = <0xf00>;
> +		ti,max-y = <0x100>;
> +		ti,min-rt = <0xfff>;
> +		ti,max-rt = <0>;
>  	};
>  };
>  
> -- 
> 1.9.3
> 

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

* [PATCH 3/3] arm: dts: omap3-gta04: Extend touchscreen configs
@ 2014-10-13 16:29     ` Tony Lindgren
  0 siblings, 0 replies; 36+ messages in thread
From: Tony Lindgren @ 2014-10-13 16:29 UTC (permalink / raw)
  To: linux-arm-kernel

* Marek Belisko <marek@goldelico.com> [140930 13:19]:
> Adding min/max values for various touschscreen properties.

Assuming no other comments on this patch series, this should be
safe to merge along with the other patches in this series without
causing merge conflicts:

Acked-by: Tony Lindgren <tony@atomide.com>
 
> Signed-off-by: Marek Belisko <marek@goldelico.com>
> ---
>  arch/arm/boot/dts/omap3-gta04.dtsi | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/omap3-gta04.dtsi b/arch/arm/boot/dts/omap3-gta04.dtsi
> index fd34f91..2dafac3b 100644
> --- a/arch/arm/boot/dts/omap3-gta04.dtsi
> +++ b/arch/arm/boot/dts/omap3-gta04.dtsi
> @@ -284,6 +284,12 @@
>  		interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
>  		gpios = <&gpio6 0 GPIO_ACTIVE_LOW>;
>  		ti,x-plate-ohms = <600>;
> +		ti,min-x = <0x100>;
> +		ti,max-x = <0xf00>;
> +		ti,min-y = <0xf00>;
> +		ti,max-y = <0x100>;
> +		ti,min-rt = <0xfff>;
> +		ti,max-rt = <0>;
>  	};
>  };
>  
> -- 
> 1.9.3
> 

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-10 14:15     ` Belisko Marek
  0 siblings, 0 replies; 36+ messages in thread
From: Belisko Marek @ 2015-01-10 14:15 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland, ijc+devicetree,
	Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, Dmitry Torokhov
  Cc: Dr. H. Nikolaus Schaller, devicetree, LKML, linux-omap,
	linux-arm-kernel, linux-input, Marek Belisko

Ping for input maintainer. DT changes was acked. Thanks.

On Tue, Sep 30, 2014 at 10:17 PM, Marek Belisko <marek@goldelico.com> wrote:
> This patch adds new parameters that allow to address typical hardware
> design differences: touch screens may be wired or oriented differently
> (portrait or landscape). And usually the active area of the touch is a
> little larger than the active area of the LCD. This results in the touch
> coordinates that have some significant deviation from LCD coordinates.
> Usually this is addressed in user space by a calibration tool (e.g. tslib
> or xinput-calibrator) but some systems don't have these tools or require
> that the screen is already roughly calibrated (e.g. Replicant) to operate
> the device until a better calibration can be done. And, some systems
> react very strangely if the touch event stream reports coordinates
> outside of the active area.
>
> This makes it necessry to be able to configure:
> 1. swapping x and y wires (coordinate values)
> 2. flipping of x (left - right) or y (top - bottom) or even both
> 3. define an active area so that an uncalibrated screen already
> roughly matches the LCD to be useful.
> 4. clip reported coordinates to the active area.
>
> If none of the new parameters is defined (in DT) or set in a board file,
> the driver behaves the same as without this patch.
>
> Author (1&2): H. Nikolaus Schaller <hns@goldelico.com>
> Author (3&4): Paul Kocialkowski <contact@paulk.fr>
>
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> ---
>  drivers/input/touchscreen/tsc2007.c | 89 +++++++++++++++++++++++++++++++++++--
>  include/linux/i2c/tsc2007.h         |  6 +++
>  2 files changed, 91 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
> index 1bf9906..cc0cc3c 100644
> --- a/drivers/input/touchscreen/tsc2007.c
> +++ b/drivers/input/touchscreen/tsc2007.c
> @@ -74,6 +74,12 @@ struct tsc2007 {
>
>         u16                     model;
>         u16                     x_plate_ohms;
> +       bool                    swap_xy;        /* swap x and y axis */
> +       u16                     min_x;
> +       u16                     min_y;
> +       u16                     min_rt;
> +       u16                     max_x;
> +       u16                     max_y;
>         u16                     max_rt;
>         unsigned long           poll_period;
>         int                     fuzzx;
> @@ -193,11 +199,50 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
>                         break;
>                 }
>
> -               if (rt <= ts->max_rt) {
> +               if (rt <= max(ts->min_rt, ts->max_rt)) {
>                         dev_dbg(&ts->client->dev,
>                                 "DOWN point(%4d,%4d), pressure (%4u)\n",
>                                 tc.x, tc.y, rt);
>
> +                       if (ts->swap_xy) {
> +                               /* swap before applying the range limits */
> +                               u16 h = tc.x;
> +
> +                               tc.x = tc.y;
> +                               tc.y = h;
> +                       }
> +
> +                       /* flip and/or clip X */
> +                       if (ts->max_x < ts->min_x)
> +                               tc.x = (ts->min_x - tc.x) + ts->max_x;
> +
> +                       if (tc.x > max(ts->min_x, ts->max_x))
> +                               tc.x = max(ts->min_x, ts->max_x);
> +                       else if (tc.x < min(ts->min_x, ts->max_x))
> +                               tc.x = min(ts->min_x, ts->max_x);
> +
> +                       /* flip and/or clip Y */
> +                       if (ts->max_y < ts->min_y)
> +                               tc.y = (ts->min_y - tc.y) + ts->max_y;
> +
> +                       if (tc.y > max(ts->min_y, ts->max_y))
> +                               tc.y = max(ts->min_y, ts->max_y);
> +                       else if (tc.y < min(ts->min_y, ts->max_y))
> +                               tc.y = min(ts->min_y, ts->max_y);
> +
> +                       /* clip Z */
> +                       if (ts->max_rt < ts->min_rt)
> +                               rt = (ts->min_rt - rt) + ts->max_rt;
> +
> +                       if (rt > max(ts->min_rt, ts->max_rt))
> +                               rt = max(ts->min_rt, ts->max_rt);
> +                       else if (rt < min(ts->min_rt, ts->max_rt))
> +                               rt = min(ts->min_rt, ts->max_rt);
> +
> +                       dev_dbg(&ts->client->dev,
> +                                       "shaped point(%4d,%4d), pressure (%4u)\n",
> +                                       tc.x, tc.y, rt);
> +
>                         input_report_key(input, BTN_TOUCH, 1);
>                         input_report_abs(input, ABS_X, tc.x);
>                         input_report_abs(input, ABS_Y, tc.y);
> @@ -299,6 +344,24 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
>                 return -EINVAL;
>         }
>
> +       ts->swap_xy = of_property_read_bool(np, "ti,swap-xy");
> +
> +       if (!of_property_read_u32(np, "ti,min-x", &val32))
> +               ts->min_x = val32;
> +       if (!of_property_read_u32(np, "ti,max-x", &val32))
> +               ts->max_x = val32;
> +       else
> +               ts->max_x = MAX_12BIT;
> +
> +       if (!of_property_read_u32(np, "ti,min-y", &val32))
> +               ts->min_y = val32;
> +       if (!of_property_read_u32(np, "ti,max-y", &val32))
> +               ts->max_y = val32;
> +       else
> +               ts->max_y = MAX_12BIT;
> +
> +       if (!of_property_read_u32(np, "ti,min-rt", &val32))
> +               ts->min_rt = val32;
>         if (!of_property_read_u32(np, "ti,max-rt", &val32))
>                 ts->max_rt = val32;
>         else
> @@ -325,6 +388,16 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
>                 return -EINVAL;
>         }
>
> +       dev_dbg(&client->dev,
> +                       "min/max_x (%4d,%4d)\n",
> +                       ts->min_x, ts->max_x);
> +       dev_dbg(&client->dev,
> +                       "min/max_y (%4d,%4d)\n",
> +                       ts->min_y, ts->max_y);
> +       dev_dbg(&client->dev,
> +                       "min/max_rt (%4d,%4d)\n",
> +                       ts->min_rt, ts->max_rt);
> +
>         ts->gpio = of_get_gpio(np, 0);
>         if (gpio_is_valid(ts->gpio))
>                 ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
> @@ -349,6 +422,12 @@ static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts,
>  {
>         ts->model             = pdata->model;
>         ts->x_plate_ohms      = pdata->x_plate_ohms;
> +       ts->swap_xy           = pdata->swap_xy;
> +       ts->min_x             = pdata->min_x ? : 0;
> +       ts->min_y             = pdata->min_y ? : 0;
> +       ts->min_rt            = pdata->min_rt ? : 0;
> +       ts->max_x             = pdata->max_x ? : MAX_12BIT;
> +       ts->max_y             = pdata->max_y ? : MAX_12BIT;
>         ts->max_rt            = pdata->max_rt ? : MAX_12BIT;
>         ts->poll_period       = pdata->poll_period ? : 1;
>         ts->get_pendown_state = pdata->get_pendown_state;
> @@ -422,9 +501,11 @@ static int tsc2007_probe(struct i2c_client *client,
>         input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
>         input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
>
> -       input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
> -       input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
> -       input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
> +       input_set_abs_params(input_dev, ABS_X, min(ts->min_x, ts->max_x),
> +                            max(ts->min_x, ts->max_x), ts->fuzzx, 0);
> +       input_set_abs_params(input_dev, ABS_Y, min(ts->min_y, ts->max_y),
> +                            max(ts->min_y, ts->max_y), ts->fuzzy, 0);
> +       input_set_abs_params(input_dev, ABS_PRESSURE, ts->min_rt, ts->max_rt,
>                              ts->fuzzz, 0);
>
>         if (pdata) {
> diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
> index 4f35b6a..5ce7b79 100644
> --- a/include/linux/i2c/tsc2007.h
> +++ b/include/linux/i2c/tsc2007.h
> @@ -6,6 +6,12 @@
>  struct tsc2007_platform_data {
>         u16     model;                          /* 2007. */
>         u16     x_plate_ohms;   /* must be non-zero value */
> +       bool    swap_xy;        /* swap x and y axis */
> +       u16     min_x;  /* min and max values to reported to user space */
> +       u16     min_y;
> +       u16     min_rt;
> +       u16     max_x;
> +       u16     max_y;
>         u16     max_rt; /* max. resistance above which samples are ignored */
>         unsigned long poll_period; /* time (in ms) between samples */
>         int     fuzzx; /* fuzz factor for X, Y and pressure axes */
> --
> 1.9.3
>

BR,

marek

-- 
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-10 14:15     ` Belisko Marek
  0 siblings, 0 replies; 36+ messages in thread
From: Belisko Marek @ 2015-01-10 14:15 UTC (permalink / raw)
  To: Rob Herring, Pawel Moll, Mark Rutland,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg, Kumar Gala,
	Benoit Cousson, Tony Lindgren, Russell King - ARM Linux,
	Dmitry Torokhov
  Cc: Dr. H. Nikolaus Schaller, devicetree-u79uwXL29TY76Z2rM5mHXA,
	LKML, linux-omap-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel,
	linux-input-u79uwXL29TY76Z2rM5mHXA, Marek Belisko

Ping for input maintainer. DT changes was acked. Thanks.

On Tue, Sep 30, 2014 at 10:17 PM, Marek Belisko <marek-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org> wrote:
> This patch adds new parameters that allow to address typical hardware
> design differences: touch screens may be wired or oriented differently
> (portrait or landscape). And usually the active area of the touch is a
> little larger than the active area of the LCD. This results in the touch
> coordinates that have some significant deviation from LCD coordinates.
> Usually this is addressed in user space by a calibration tool (e.g. tslib
> or xinput-calibrator) but some systems don't have these tools or require
> that the screen is already roughly calibrated (e.g. Replicant) to operate
> the device until a better calibration can be done. And, some systems
> react very strangely if the touch event stream reports coordinates
> outside of the active area.
>
> This makes it necessry to be able to configure:
> 1. swapping x and y wires (coordinate values)
> 2. flipping of x (left - right) or y (top - bottom) or even both
> 3. define an active area so that an uncalibrated screen already
> roughly matches the LCD to be useful.
> 4. clip reported coordinates to the active area.
>
> If none of the new parameters is defined (in DT) or set in a board file,
> the driver behaves the same as without this patch.
>
> Author (1&2): H. Nikolaus Schaller <hns-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
> Author (3&4): Paul Kocialkowski <contact-W9ppeneeCTY@public.gmane.org>
>
> Signed-off-by: H. Nikolaus Schaller <hns-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
> ---
>  drivers/input/touchscreen/tsc2007.c | 89 +++++++++++++++++++++++++++++++++++--
>  include/linux/i2c/tsc2007.h         |  6 +++
>  2 files changed, 91 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
> index 1bf9906..cc0cc3c 100644
> --- a/drivers/input/touchscreen/tsc2007.c
> +++ b/drivers/input/touchscreen/tsc2007.c
> @@ -74,6 +74,12 @@ struct tsc2007 {
>
>         u16                     model;
>         u16                     x_plate_ohms;
> +       bool                    swap_xy;        /* swap x and y axis */
> +       u16                     min_x;
> +       u16                     min_y;
> +       u16                     min_rt;
> +       u16                     max_x;
> +       u16                     max_y;
>         u16                     max_rt;
>         unsigned long           poll_period;
>         int                     fuzzx;
> @@ -193,11 +199,50 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
>                         break;
>                 }
>
> -               if (rt <= ts->max_rt) {
> +               if (rt <= max(ts->min_rt, ts->max_rt)) {
>                         dev_dbg(&ts->client->dev,
>                                 "DOWN point(%4d,%4d), pressure (%4u)\n",
>                                 tc.x, tc.y, rt);
>
> +                       if (ts->swap_xy) {
> +                               /* swap before applying the range limits */
> +                               u16 h = tc.x;
> +
> +                               tc.x = tc.y;
> +                               tc.y = h;
> +                       }
> +
> +                       /* flip and/or clip X */
> +                       if (ts->max_x < ts->min_x)
> +                               tc.x = (ts->min_x - tc.x) + ts->max_x;
> +
> +                       if (tc.x > max(ts->min_x, ts->max_x))
> +                               tc.x = max(ts->min_x, ts->max_x);
> +                       else if (tc.x < min(ts->min_x, ts->max_x))
> +                               tc.x = min(ts->min_x, ts->max_x);
> +
> +                       /* flip and/or clip Y */
> +                       if (ts->max_y < ts->min_y)
> +                               tc.y = (ts->min_y - tc.y) + ts->max_y;
> +
> +                       if (tc.y > max(ts->min_y, ts->max_y))
> +                               tc.y = max(ts->min_y, ts->max_y);
> +                       else if (tc.y < min(ts->min_y, ts->max_y))
> +                               tc.y = min(ts->min_y, ts->max_y);
> +
> +                       /* clip Z */
> +                       if (ts->max_rt < ts->min_rt)
> +                               rt = (ts->min_rt - rt) + ts->max_rt;
> +
> +                       if (rt > max(ts->min_rt, ts->max_rt))
> +                               rt = max(ts->min_rt, ts->max_rt);
> +                       else if (rt < min(ts->min_rt, ts->max_rt))
> +                               rt = min(ts->min_rt, ts->max_rt);
> +
> +                       dev_dbg(&ts->client->dev,
> +                                       "shaped point(%4d,%4d), pressure (%4u)\n",
> +                                       tc.x, tc.y, rt);
> +
>                         input_report_key(input, BTN_TOUCH, 1);
>                         input_report_abs(input, ABS_X, tc.x);
>                         input_report_abs(input, ABS_Y, tc.y);
> @@ -299,6 +344,24 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
>                 return -EINVAL;
>         }
>
> +       ts->swap_xy = of_property_read_bool(np, "ti,swap-xy");
> +
> +       if (!of_property_read_u32(np, "ti,min-x", &val32))
> +               ts->min_x = val32;
> +       if (!of_property_read_u32(np, "ti,max-x", &val32))
> +               ts->max_x = val32;
> +       else
> +               ts->max_x = MAX_12BIT;
> +
> +       if (!of_property_read_u32(np, "ti,min-y", &val32))
> +               ts->min_y = val32;
> +       if (!of_property_read_u32(np, "ti,max-y", &val32))
> +               ts->max_y = val32;
> +       else
> +               ts->max_y = MAX_12BIT;
> +
> +       if (!of_property_read_u32(np, "ti,min-rt", &val32))
> +               ts->min_rt = val32;
>         if (!of_property_read_u32(np, "ti,max-rt", &val32))
>                 ts->max_rt = val32;
>         else
> @@ -325,6 +388,16 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
>                 return -EINVAL;
>         }
>
> +       dev_dbg(&client->dev,
> +                       "min/max_x (%4d,%4d)\n",
> +                       ts->min_x, ts->max_x);
> +       dev_dbg(&client->dev,
> +                       "min/max_y (%4d,%4d)\n",
> +                       ts->min_y, ts->max_y);
> +       dev_dbg(&client->dev,
> +                       "min/max_rt (%4d,%4d)\n",
> +                       ts->min_rt, ts->max_rt);
> +
>         ts->gpio = of_get_gpio(np, 0);
>         if (gpio_is_valid(ts->gpio))
>                 ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
> @@ -349,6 +422,12 @@ static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts,
>  {
>         ts->model             = pdata->model;
>         ts->x_plate_ohms      = pdata->x_plate_ohms;
> +       ts->swap_xy           = pdata->swap_xy;
> +       ts->min_x             = pdata->min_x ? : 0;
> +       ts->min_y             = pdata->min_y ? : 0;
> +       ts->min_rt            = pdata->min_rt ? : 0;
> +       ts->max_x             = pdata->max_x ? : MAX_12BIT;
> +       ts->max_y             = pdata->max_y ? : MAX_12BIT;
>         ts->max_rt            = pdata->max_rt ? : MAX_12BIT;
>         ts->poll_period       = pdata->poll_period ? : 1;
>         ts->get_pendown_state = pdata->get_pendown_state;
> @@ -422,9 +501,11 @@ static int tsc2007_probe(struct i2c_client *client,
>         input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
>         input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
>
> -       input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
> -       input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
> -       input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
> +       input_set_abs_params(input_dev, ABS_X, min(ts->min_x, ts->max_x),
> +                            max(ts->min_x, ts->max_x), ts->fuzzx, 0);
> +       input_set_abs_params(input_dev, ABS_Y, min(ts->min_y, ts->max_y),
> +                            max(ts->min_y, ts->max_y), ts->fuzzy, 0);
> +       input_set_abs_params(input_dev, ABS_PRESSURE, ts->min_rt, ts->max_rt,
>                              ts->fuzzz, 0);
>
>         if (pdata) {
> diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
> index 4f35b6a..5ce7b79 100644
> --- a/include/linux/i2c/tsc2007.h
> +++ b/include/linux/i2c/tsc2007.h
> @@ -6,6 +6,12 @@
>  struct tsc2007_platform_data {
>         u16     model;                          /* 2007. */
>         u16     x_plate_ohms;   /* must be non-zero value */
> +       bool    swap_xy;        /* swap x and y axis */
> +       u16     min_x;  /* min and max values to reported to user space */
> +       u16     min_y;
> +       u16     min_rt;
> +       u16     max_x;
> +       u16     max_y;
>         u16     max_rt; /* max. resistance above which samples are ignored */
>         unsigned long poll_period; /* time (in ms) between samples */
>         int     fuzzx; /* fuzz factor for X, Y and pressure axes */
> --
> 1.9.3
>

BR,

marek

-- 
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com
--
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] 36+ messages in thread

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-10 14:15     ` Belisko Marek
  0 siblings, 0 replies; 36+ messages in thread
From: Belisko Marek @ 2015-01-10 14:15 UTC (permalink / raw)
  To: linux-arm-kernel

Ping for input maintainer. DT changes was acked. Thanks.

On Tue, Sep 30, 2014 at 10:17 PM, Marek Belisko <marek@goldelico.com> wrote:
> This patch adds new parameters that allow to address typical hardware
> design differences: touch screens may be wired or oriented differently
> (portrait or landscape). And usually the active area of the touch is a
> little larger than the active area of the LCD. This results in the touch
> coordinates that have some significant deviation from LCD coordinates.
> Usually this is addressed in user space by a calibration tool (e.g. tslib
> or xinput-calibrator) but some systems don't have these tools or require
> that the screen is already roughly calibrated (e.g. Replicant) to operate
> the device until a better calibration can be done. And, some systems
> react very strangely if the touch event stream reports coordinates
> outside of the active area.
>
> This makes it necessry to be able to configure:
> 1. swapping x and y wires (coordinate values)
> 2. flipping of x (left - right) or y (top - bottom) or even both
> 3. define an active area so that an uncalibrated screen already
> roughly matches the LCD to be useful.
> 4. clip reported coordinates to the active area.
>
> If none of the new parameters is defined (in DT) or set in a board file,
> the driver behaves the same as without this patch.
>
> Author (1&2): H. Nikolaus Schaller <hns@goldelico.com>
> Author (3&4): Paul Kocialkowski <contact@paulk.fr>
>
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> ---
>  drivers/input/touchscreen/tsc2007.c | 89 +++++++++++++++++++++++++++++++++++--
>  include/linux/i2c/tsc2007.h         |  6 +++
>  2 files changed, 91 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
> index 1bf9906..cc0cc3c 100644
> --- a/drivers/input/touchscreen/tsc2007.c
> +++ b/drivers/input/touchscreen/tsc2007.c
> @@ -74,6 +74,12 @@ struct tsc2007 {
>
>         u16                     model;
>         u16                     x_plate_ohms;
> +       bool                    swap_xy;        /* swap x and y axis */
> +       u16                     min_x;
> +       u16                     min_y;
> +       u16                     min_rt;
> +       u16                     max_x;
> +       u16                     max_y;
>         u16                     max_rt;
>         unsigned long           poll_period;
>         int                     fuzzx;
> @@ -193,11 +199,50 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
>                         break;
>                 }
>
> -               if (rt <= ts->max_rt) {
> +               if (rt <= max(ts->min_rt, ts->max_rt)) {
>                         dev_dbg(&ts->client->dev,
>                                 "DOWN point(%4d,%4d), pressure (%4u)\n",
>                                 tc.x, tc.y, rt);
>
> +                       if (ts->swap_xy) {
> +                               /* swap before applying the range limits */
> +                               u16 h = tc.x;
> +
> +                               tc.x = tc.y;
> +                               tc.y = h;
> +                       }
> +
> +                       /* flip and/or clip X */
> +                       if (ts->max_x < ts->min_x)
> +                               tc.x = (ts->min_x - tc.x) + ts->max_x;
> +
> +                       if (tc.x > max(ts->min_x, ts->max_x))
> +                               tc.x = max(ts->min_x, ts->max_x);
> +                       else if (tc.x < min(ts->min_x, ts->max_x))
> +                               tc.x = min(ts->min_x, ts->max_x);
> +
> +                       /* flip and/or clip Y */
> +                       if (ts->max_y < ts->min_y)
> +                               tc.y = (ts->min_y - tc.y) + ts->max_y;
> +
> +                       if (tc.y > max(ts->min_y, ts->max_y))
> +                               tc.y = max(ts->min_y, ts->max_y);
> +                       else if (tc.y < min(ts->min_y, ts->max_y))
> +                               tc.y = min(ts->min_y, ts->max_y);
> +
> +                       /* clip Z */
> +                       if (ts->max_rt < ts->min_rt)
> +                               rt = (ts->min_rt - rt) + ts->max_rt;
> +
> +                       if (rt > max(ts->min_rt, ts->max_rt))
> +                               rt = max(ts->min_rt, ts->max_rt);
> +                       else if (rt < min(ts->min_rt, ts->max_rt))
> +                               rt = min(ts->min_rt, ts->max_rt);
> +
> +                       dev_dbg(&ts->client->dev,
> +                                       "shaped point(%4d,%4d), pressure (%4u)\n",
> +                                       tc.x, tc.y, rt);
> +
>                         input_report_key(input, BTN_TOUCH, 1);
>                         input_report_abs(input, ABS_X, tc.x);
>                         input_report_abs(input, ABS_Y, tc.y);
> @@ -299,6 +344,24 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
>                 return -EINVAL;
>         }
>
> +       ts->swap_xy = of_property_read_bool(np, "ti,swap-xy");
> +
> +       if (!of_property_read_u32(np, "ti,min-x", &val32))
> +               ts->min_x = val32;
> +       if (!of_property_read_u32(np, "ti,max-x", &val32))
> +               ts->max_x = val32;
> +       else
> +               ts->max_x = MAX_12BIT;
> +
> +       if (!of_property_read_u32(np, "ti,min-y", &val32))
> +               ts->min_y = val32;
> +       if (!of_property_read_u32(np, "ti,max-y", &val32))
> +               ts->max_y = val32;
> +       else
> +               ts->max_y = MAX_12BIT;
> +
> +       if (!of_property_read_u32(np, "ti,min-rt", &val32))
> +               ts->min_rt = val32;
>         if (!of_property_read_u32(np, "ti,max-rt", &val32))
>                 ts->max_rt = val32;
>         else
> @@ -325,6 +388,16 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
>                 return -EINVAL;
>         }
>
> +       dev_dbg(&client->dev,
> +                       "min/max_x (%4d,%4d)\n",
> +                       ts->min_x, ts->max_x);
> +       dev_dbg(&client->dev,
> +                       "min/max_y (%4d,%4d)\n",
> +                       ts->min_y, ts->max_y);
> +       dev_dbg(&client->dev,
> +                       "min/max_rt (%4d,%4d)\n",
> +                       ts->min_rt, ts->max_rt);
> +
>         ts->gpio = of_get_gpio(np, 0);
>         if (gpio_is_valid(ts->gpio))
>                 ts->get_pendown_state = tsc2007_get_pendown_state_gpio;
> @@ -349,6 +422,12 @@ static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts,
>  {
>         ts->model             = pdata->model;
>         ts->x_plate_ohms      = pdata->x_plate_ohms;
> +       ts->swap_xy           = pdata->swap_xy;
> +       ts->min_x             = pdata->min_x ? : 0;
> +       ts->min_y             = pdata->min_y ? : 0;
> +       ts->min_rt            = pdata->min_rt ? : 0;
> +       ts->max_x             = pdata->max_x ? : MAX_12BIT;
> +       ts->max_y             = pdata->max_y ? : MAX_12BIT;
>         ts->max_rt            = pdata->max_rt ? : MAX_12BIT;
>         ts->poll_period       = pdata->poll_period ? : 1;
>         ts->get_pendown_state = pdata->get_pendown_state;
> @@ -422,9 +501,11 @@ static int tsc2007_probe(struct i2c_client *client,
>         input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
>         input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
>
> -       input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
> -       input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
> -       input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
> +       input_set_abs_params(input_dev, ABS_X, min(ts->min_x, ts->max_x),
> +                            max(ts->min_x, ts->max_x), ts->fuzzx, 0);
> +       input_set_abs_params(input_dev, ABS_Y, min(ts->min_y, ts->max_y),
> +                            max(ts->min_y, ts->max_y), ts->fuzzy, 0);
> +       input_set_abs_params(input_dev, ABS_PRESSURE, ts->min_rt, ts->max_rt,
>                              ts->fuzzz, 0);
>
>         if (pdata) {
> diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
> index 4f35b6a..5ce7b79 100644
> --- a/include/linux/i2c/tsc2007.h
> +++ b/include/linux/i2c/tsc2007.h
> @@ -6,6 +6,12 @@
>  struct tsc2007_platform_data {
>         u16     model;                          /* 2007. */
>         u16     x_plate_ohms;   /* must be non-zero value */
> +       bool    swap_xy;        /* swap x and y axis */
> +       u16     min_x;  /* min and max values to reported to user space */
> +       u16     min_y;
> +       u16     min_rt;
> +       u16     max_x;
> +       u16     max_y;
>         u16     max_rt; /* max. resistance above which samples are ignored */
>         unsigned long poll_period; /* time (in ms) between samples */
>         int     fuzzx; /* fuzz factor for X, Y and pressure axes */
> --
> 1.9.3
>

BR,

marek

-- 
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
  2015-01-10 14:15     ` Belisko Marek
@ 2015-01-15  0:59       ` Dmitry Torokhov
  -1 siblings, 0 replies; 36+ messages in thread
From: Dmitry Torokhov @ 2015-01-15  0:59 UTC (permalink / raw)
  To: Belisko Marek
  Cc: Rob Herring, Pawel Moll, Mark Rutland, ijc+devicetree,
	Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, Dr. H. Nikolaus Schaller, devicetree,
	LKML, linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard

On Sat, Jan 10, 2015 at 03:15:39PM +0100, Belisko Marek wrote:
> Ping for input maintainer. DT changes was acked. Thanks.
> 
> On Tue, Sep 30, 2014 at 10:17 PM, Marek Belisko <marek@goldelico.com> wrote:
> > This patch adds new parameters that allow to address typical hardware
> > design differences: touch screens may be wired or oriented differently
> > (portrait or landscape). And usually the active area of the touch is a
> > little larger than the active area of the LCD. This results in the touch
> > coordinates that have some significant deviation from LCD coordinates.
> > Usually this is addressed in user space by a calibration tool (e.g. tslib
> > or xinput-calibrator) but some systems don't have these tools or require
> > that the screen is already roughly calibrated (e.g. Replicant) to operate
> > the device until a better calibration can be done. And, some systems
> > react very strangely if the touch event stream reports coordinates
> > outside of the active area.
> >
> > This makes it necessry to be able to configure:
> > 1. swapping x and y wires (coordinate values)
> > 2. flipping of x (left - right) or y (top - bottom) or even both
> > 3. define an active area so that an uncalibrated screen already
> > roughly matches the LCD to be useful.
> > 4. clip reported coordinates to the active area.
> >
> > If none of the new parameters is defined (in DT) or set in a board file,
> > the driver behaves the same as without this patch.
> >
> > Author (1&2): H. Nikolaus Schaller <hns@goldelico.com>
> > Author (3&4): Paul Kocialkowski <contact@paulk.fr>
> >
> > Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>

OK, I was hesitant of adding these as normally we have tslib to perform
the conversion, but maybe it is time to allow it in the kernel and
standardize users. However, this seems like a general issue and we
should:

1. Perform conversion in input core rather than individual drivers. I
think we should allocate a new bitmaps for some transformations and have
the code do X/Y flip/clip of the coordinates.

2. Standardize on bindings. We already have of-touchscreen.c doing
rudimentary parsing, we shoudl look into extending it rather than
creating myriad of driver-specific bindings.

Also, do we need swap and flip or do we simply need rotation (like the
proposed Broadcom iproc driver has)?

Thanks.

-- 
Dmitry

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

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15  0:59       ` Dmitry Torokhov
  0 siblings, 0 replies; 36+ messages in thread
From: Dmitry Torokhov @ 2015-01-15  0:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Jan 10, 2015 at 03:15:39PM +0100, Belisko Marek wrote:
> Ping for input maintainer. DT changes was acked. Thanks.
> 
> On Tue, Sep 30, 2014 at 10:17 PM, Marek Belisko <marek@goldelico.com> wrote:
> > This patch adds new parameters that allow to address typical hardware
> > design differences: touch screens may be wired or oriented differently
> > (portrait or landscape). And usually the active area of the touch is a
> > little larger than the active area of the LCD. This results in the touch
> > coordinates that have some significant deviation from LCD coordinates.
> > Usually this is addressed in user space by a calibration tool (e.g. tslib
> > or xinput-calibrator) but some systems don't have these tools or require
> > that the screen is already roughly calibrated (e.g. Replicant) to operate
> > the device until a better calibration can be done. And, some systems
> > react very strangely if the touch event stream reports coordinates
> > outside of the active area.
> >
> > This makes it necessry to be able to configure:
> > 1. swapping x and y wires (coordinate values)
> > 2. flipping of x (left - right) or y (top - bottom) or even both
> > 3. define an active area so that an uncalibrated screen already
> > roughly matches the LCD to be useful.
> > 4. clip reported coordinates to the active area.
> >
> > If none of the new parameters is defined (in DT) or set in a board file,
> > the driver behaves the same as without this patch.
> >
> > Author (1&2): H. Nikolaus Schaller <hns@goldelico.com>
> > Author (3&4): Paul Kocialkowski <contact@paulk.fr>
> >
> > Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>

OK, I was hesitant of adding these as normally we have tslib to perform
the conversion, but maybe it is time to allow it in the kernel and
standardize users. However, this seems like a general issue and we
should:

1. Perform conversion in input core rather than individual drivers. I
think we should allocate a new bitmaps for some transformations and have
the code do X/Y flip/clip of the coordinates.

2. Standardize on bindings. We already have of-touchscreen.c doing
rudimentary parsing, we shoudl look into extending it rather than
creating myriad of driver-specific bindings.

Also, do we need swap and flip or do we simply need rotation (like the
proposed Broadcom iproc driver has)?

Thanks.

-- 
Dmitry

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
  2015-01-15  0:59       ` Dmitry Torokhov
  (?)
@ 2015-01-15  7:36         ` Dr. H. Nikolaus Schaller
  -1 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15  7:36 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Belisko Marek, Rob Herring, Pawel Moll, Mark Rutland,
	ijc+devicetree, Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, devicetree, LKML, linux-omap,
	linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List for communicating with real GTA04 owners

Hi,

Am 15.01.2015 um 01:59 schrieb Dmitry Torokhov <dmitry.torokhov@gmail.com>:

> On Sat, Jan 10, 2015 at 03:15:39PM +0100, Belisko Marek wrote:
>> Ping for input maintainer. DT changes was acked. Thanks.
>> 
>> On Tue, Sep 30, 2014 at 10:17 PM, Marek Belisko <marek@goldelico.com> wrote:
>>> This patch adds new parameters that allow to address typical hardware
>>> design differences: touch screens may be wired or oriented differently
>>> (portrait or landscape). And usually the active area of the touch is a
>>> little larger than the active area of the LCD. This results in the touch
>>> coordinates that have some significant deviation from LCD coordinates.
>>> Usually this is addressed in user space by a calibration tool (e.g. tslib
>>> or xinput-calibrator) but some systems don't have these tools or require
>>> that the screen is already roughly calibrated (e.g. Replicant) to operate
>>> the device until a better calibration can be done. And, some systems
>>> react very strangely if the touch event stream reports coordinates
>>> outside of the active area.
>>> 
>>> This makes it necessry to be able to configure:
>>> 1. swapping x and y wires (coordinate values)
>>> 2. flipping of x (left - right) or y (top - bottom) or even both
>>> 3. define an active area so that an uncalibrated screen already
>>> roughly matches the LCD to be useful.
>>> 4. clip reported coordinates to the active area.
>>> 
>>> If none of the new parameters is defined (in DT) or set in a board file,
>>> the driver behaves the same as without this patch.
>>> 
>>> Author (1&2): H. Nikolaus Schaller <hns@goldelico.com>
>>> Author (3&4): Paul Kocialkowski <contact@paulk.fr>
>>> 
>>> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> 
> OK, I was hesitant of adding these as normally we have tslib to perform
> the conversion, but maybe it is time to allow it in the kernel and
> standardize users.

Well, tslib isn’t a good replacement for this problem any more and
pre-initializing tslib makes some deep hardware dependency visible
in user space (each board needs a different tslib config and pointercal
default - and on some user spaces tslib is broken with Xorg).

But the issue to be solved is more hardware related, i.e. if the Y- and Y+
pins of the controller are connected in a swapped way to the resistor
ends of the panel.

Hence in a DT based system, this must IMHO be described by the DT
and can not be left to some user-space functions any more.

> However, this seems like a general issue and we
> should:
> 
> 1. Perform conversion in input core rather than individual drivers. I
> think we should allocate a new bitmaps for some transformations and have
> the code do X/Y flip/clip of the coordinates.

Do you have a suggestion where this should be (I have no clue how
the input system works or is structured - we just know how to extend a
driver that uses it)?

> 
> 2. Standardize on bindings. We already have of-touchscreen.c doing
> rudimentary parsing, we shoudl look into extending it rather than
> creating myriad of driver-specific bindings.

Ok, looks reasonable.

> 
> Also, do we need swap and flip or do we simply need rotation (like the
> proposed Broadcom iproc driver has)?

Well, since the DT should describe hardware, there are 3 sets of wires which
can have a cross-over: X+ and X-, Y+ and Y-, X and Y.

So IMHO hardware has no “rotation”, just crossover of wires. Rotation is an
interpretation of the result of these connections in combination with some
panel the touch is glued to and should therefore not be represented in the DT.

As a result we have proposed a scheme without explicit rotation. We specify what
coordinates X- and X+ should report at their ends (min, max) because the DT
programmer has to specify them anyways. Flipping is a result of defining these
coordinates in an ascending or descending way. Only swapping of the X and Y
wires can’t be implicitly defined so it has its own property. So the scheme we
have proposed tries to optimize the efforts needed to adapt new boards and write
DTs and focus the DT on hardware description.

As a bonus we also specify the min and max value to be reported for the touch
pressure (Z axis) using the same basic principle.

And it is a pure add-on on top of the existing driver so that it attempts not
to break existing device trees.

Maybe could you accept it as a first step for this specific driver (and let’s do
the big standardization work later on)?

— hns



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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15  7:36         ` Dr. H. Nikolaus Schaller
  0 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15  7:36 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Belisko Marek, Rob Herring, Pawel Moll, Mark Rutland,
	ijc+devicetree, Kumar Gala, Benoit Cousson, Tony Lindgren,
	Russell King - ARM Linux, devicetree, LKML, linux-omap,
	linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List for communicating with real GTA04 owners

Hi,

Am 15.01.2015 um 01:59 schrieb Dmitry Torokhov <dmitry.torokhov@gmail.com>:

> On Sat, Jan 10, 2015 at 03:15:39PM +0100, Belisko Marek wrote:
>> Ping for input maintainer. DT changes was acked. Thanks.
>> 
>> On Tue, Sep 30, 2014 at 10:17 PM, Marek Belisko <marek@goldelico.com> wrote:
>>> This patch adds new parameters that allow to address typical hardware
>>> design differences: touch screens may be wired or oriented differently
>>> (portrait or landscape). And usually the active area of the touch is a
>>> little larger than the active area of the LCD. This results in the touch
>>> coordinates that have some significant deviation from LCD coordinates.
>>> Usually this is addressed in user space by a calibration tool (e.g. tslib
>>> or xinput-calibrator) but some systems don't have these tools or require
>>> that the screen is already roughly calibrated (e.g. Replicant) to operate
>>> the device until a better calibration can be done. And, some systems
>>> react very strangely if the touch event stream reports coordinates
>>> outside of the active area.
>>> 
>>> This makes it necessry to be able to configure:
>>> 1. swapping x and y wires (coordinate values)
>>> 2. flipping of x (left - right) or y (top - bottom) or even both
>>> 3. define an active area so that an uncalibrated screen already
>>> roughly matches the LCD to be useful.
>>> 4. clip reported coordinates to the active area.
>>> 
>>> If none of the new parameters is defined (in DT) or set in a board file,
>>> the driver behaves the same as without this patch.
>>> 
>>> Author (1&2): H. Nikolaus Schaller <hns@goldelico.com>
>>> Author (3&4): Paul Kocialkowski <contact@paulk.fr>
>>> 
>>> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> 
> OK, I was hesitant of adding these as normally we have tslib to perform
> the conversion, but maybe it is time to allow it in the kernel and
> standardize users.

Well, tslib isn’t a good replacement for this problem any more and
pre-initializing tslib makes some deep hardware dependency visible
in user space (each board needs a different tslib config and pointercal
default - and on some user spaces tslib is broken with Xorg).

But the issue to be solved is more hardware related, i.e. if the Y- and Y+
pins of the controller are connected in a swapped way to the resistor
ends of the panel.

Hence in a DT based system, this must IMHO be described by the DT
and can not be left to some user-space functions any more.

> However, this seems like a general issue and we
> should:
> 
> 1. Perform conversion in input core rather than individual drivers. I
> think we should allocate a new bitmaps for some transformations and have
> the code do X/Y flip/clip of the coordinates.

Do you have a suggestion where this should be (I have no clue how
the input system works or is structured - we just know how to extend a
driver that uses it)?

> 
> 2. Standardize on bindings. We already have of-touchscreen.c doing
> rudimentary parsing, we shoudl look into extending it rather than
> creating myriad of driver-specific bindings.

Ok, looks reasonable.

> 
> Also, do we need swap and flip or do we simply need rotation (like the
> proposed Broadcom iproc driver has)?

Well, since the DT should describe hardware, there are 3 sets of wires which
can have a cross-over: X+ and X-, Y+ and Y-, X and Y.

So IMHO hardware has no “rotation”, just crossover of wires. Rotation is an
interpretation of the result of these connections in combination with some
panel the touch is glued to and should therefore not be represented in the DT.

As a result we have proposed a scheme without explicit rotation. We specify what
coordinates X- and X+ should report at their ends (min, max) because the DT
programmer has to specify them anyways. Flipping is a result of defining these
coordinates in an ascending or descending way. Only swapping of the X and Y
wires can’t be implicitly defined so it has its own property. So the scheme we
have proposed tries to optimize the efforts needed to adapt new boards and write
DTs and focus the DT on hardware description.

As a bonus we also specify the min and max value to be reported for the touch
pressure (Z axis) using the same basic principle.

And it is a pure add-on on top of the existing driver so that it attempts not
to break existing device trees.

Maybe could you accept it as a first step for this specific driver (and let’s do
the big standardization work later on)?

— hns


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

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

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15  7:36         ` Dr. H. Nikolaus Schaller
  0 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15  7:36 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

Am 15.01.2015 um 01:59 schrieb Dmitry Torokhov <dmitry.torokhov@gmail.com>:

> On Sat, Jan 10, 2015 at 03:15:39PM +0100, Belisko Marek wrote:
>> Ping for input maintainer. DT changes was acked. Thanks.
>> 
>> On Tue, Sep 30, 2014 at 10:17 PM, Marek Belisko <marek@goldelico.com> wrote:
>>> This patch adds new parameters that allow to address typical hardware
>>> design differences: touch screens may be wired or oriented differently
>>> (portrait or landscape). And usually the active area of the touch is a
>>> little larger than the active area of the LCD. This results in the touch
>>> coordinates that have some significant deviation from LCD coordinates.
>>> Usually this is addressed in user space by a calibration tool (e.g. tslib
>>> or xinput-calibrator) but some systems don't have these tools or require
>>> that the screen is already roughly calibrated (e.g. Replicant) to operate
>>> the device until a better calibration can be done. And, some systems
>>> react very strangely if the touch event stream reports coordinates
>>> outside of the active area.
>>> 
>>> This makes it necessry to be able to configure:
>>> 1. swapping x and y wires (coordinate values)
>>> 2. flipping of x (left - right) or y (top - bottom) or even both
>>> 3. define an active area so that an uncalibrated screen already
>>> roughly matches the LCD to be useful.
>>> 4. clip reported coordinates to the active area.
>>> 
>>> If none of the new parameters is defined (in DT) or set in a board file,
>>> the driver behaves the same as without this patch.
>>> 
>>> Author (1&2): H. Nikolaus Schaller <hns@goldelico.com>
>>> Author (3&4): Paul Kocialkowski <contact@paulk.fr>
>>> 
>>> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> 
> OK, I was hesitant of adding these as normally we have tslib to perform
> the conversion, but maybe it is time to allow it in the kernel and
> standardize users.

Well, tslib isn?t a good replacement for this problem any more and
pre-initializing tslib makes some deep hardware dependency visible
in user space (each board needs a different tslib config and pointercal
default - and on some user spaces tslib is broken with Xorg).

But the issue to be solved is more hardware related, i.e. if the Y- and Y+
pins of the controller are connected in a swapped way to the resistor
ends of the panel.

Hence in a DT based system, this must IMHO be described by the DT
and can not be left to some user-space functions any more.

> However, this seems like a general issue and we
> should:
> 
> 1. Perform conversion in input core rather than individual drivers. I
> think we should allocate a new bitmaps for some transformations and have
> the code do X/Y flip/clip of the coordinates.

Do you have a suggestion where this should be (I have no clue how
the input system works or is structured - we just know how to extend a
driver that uses it)?

> 
> 2. Standardize on bindings. We already have of-touchscreen.c doing
> rudimentary parsing, we shoudl look into extending it rather than
> creating myriad of driver-specific bindings.

Ok, looks reasonable.

> 
> Also, do we need swap and flip or do we simply need rotation (like the
> proposed Broadcom iproc driver has)?

Well, since the DT should describe hardware, there are 3 sets of wires which
can have a cross-over: X+ and X-, Y+ and Y-, X and Y.

So IMHO hardware has no ?rotation?, just crossover of wires. Rotation is an
interpretation of the result of these connections in combination with some
panel the touch is glued to and should therefore not be represented in the DT.

As a result we have proposed a scheme without explicit rotation. We specify what
coordinates X- and X+ should report at their ends (min, max) because the DT
programmer has to specify them anyways. Flipping is a result of defining these
coordinates in an ascending or descending way. Only swapping of the X and Y
wires can?t be implicitly defined so it has its own property. So the scheme we
have proposed tries to optimize the efforts needed to adapt new boards and write
DTs and focus the DT on hardware description.

As a bonus we also specify the min and max value to be reported for the touch
pressure (Z axis) using the same basic principle.

And it is a pure add-on on top of the existing driver so that it attempts not
to break existing device trees.

Maybe could you accept it as a first step for this specific driver (and let?s do
the big standardization work later on)?

? hns

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
  2015-01-15  7:36         ` Dr. H. Nikolaus Schaller
  (?)
@ 2015-01-15 14:38           ` Sebastian Reichel
  -1 siblings, 0 replies; 36+ messages in thread
From: Sebastian Reichel @ 2015-01-15 14:38 UTC (permalink / raw)
  To: Dr. H. Nikolaus Schaller
  Cc: Dmitry Torokhov, Belisko Marek, Rob Herring, Pawel Moll,
	Mark Rutland, ijc+devicetree, Kumar Gala, Benoit Cousson,
	Tony Lindgren, Russell King - ARM Linux, devicetree, LKML,
	linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List for communicating with real GTA04 owners

Hi,

On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
> > 1. Perform conversion in input core rather than individual drivers. I
> > think we should allocate a new bitmaps for some transformations and have
> > the code do X/Y flip/clip of the coordinates.
> 
> Do you have a suggestion where this should be (I have no clue how
> the input system works or is structured - we just know how to extend a
> driver that uses it)?
> 
> > 2. Standardize on bindings. We already have of-touchscreen.c doing
> > rudimentary parsing, we shoudl look into extending it rather than
> > creating myriad of driver-specific bindings.
> 
> Ok, looks reasonable.

Documentation is in 

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

> > Also, do we need swap and flip or do we simply need rotation (like the
> > proposed Broadcom iproc driver has)?
> 
> Well, since the DT should describe hardware, there are 3 sets of wires which
> can have a cross-over: X+ and X-, Y+ and Y-, X and Y.
>
> So IMHO hardware has no “rotation”, just crossover of wires. Rotation is an
> interpretation of the result of these connections in combination with some
> panel the touch is glued to and should therefore not be represented in the DT.
> 
> As a result we have proposed a scheme without explicit rotation. We specify what
> coordinates X- and X+ should report at their ends (min, max) because the DT
> programmer has to specify them anyways. Flipping is a result of defining these
> coordinates in an ascending or descending way. Only swapping of the X and Y
> wires can’t be implicitly defined so it has its own property. So the scheme we
> have proposed tries to optimize the efforts needed to adapt new boards and write
> DTs and focus the DT on hardware description.
> 
> As a bonus we also specify the min and max value to be reported for the touch
> pressure (Z axis) using the same basic principle.
> 
> And it is a pure add-on on top of the existing driver so that it attempts not
> to break existing device trees.

from what I can see there are no in-tree-users using any of the
new properties.

> Maybe could you accept it as a first step for this specific driver (and let’s do
> the big standardization work later on)?

That does not work, since you create an ABI.

-- Sebastian

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15 14:38           ` Sebastian Reichel
  0 siblings, 0 replies; 36+ messages in thread
From: Sebastian Reichel @ 2015-01-15 14:38 UTC (permalink / raw)
  To: Dr. H. Nikolaus Schaller
  Cc: Dmitry Torokhov, Belisko Marek, Rob Herring, Pawel Moll,
	Mark Rutland, ijc+devicetree, Kumar Gala, Benoit Cousson,
	Tony Lindgren, Russell King - ARM Linux, devicetree, LKML,
	linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List

Hi,

On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
> > 1. Perform conversion in input core rather than individual drivers. I
> > think we should allocate a new bitmaps for some transformations and have
> > the code do X/Y flip/clip of the coordinates.
> 
> Do you have a suggestion where this should be (I have no clue how
> the input system works or is structured - we just know how to extend a
> driver that uses it)?
> 
> > 2. Standardize on bindings. We already have of-touchscreen.c doing
> > rudimentary parsing, we shoudl look into extending it rather than
> > creating myriad of driver-specific bindings.
> 
> Ok, looks reasonable.

Documentation is in 

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

> > Also, do we need swap and flip or do we simply need rotation (like the
> > proposed Broadcom iproc driver has)?
> 
> Well, since the DT should describe hardware, there are 3 sets of wires which
> can have a cross-over: X+ and X-, Y+ and Y-, X and Y.
>
> So IMHO hardware has no “rotation”, just crossover of wires. Rotation is an
> interpretation of the result of these connections in combination with some
> panel the touch is glued to and should therefore not be represented in the DT.
> 
> As a result we have proposed a scheme without explicit rotation. We specify what
> coordinates X- and X+ should report at their ends (min, max) because the DT
> programmer has to specify them anyways. Flipping is a result of defining these
> coordinates in an ascending or descending way. Only swapping of the X and Y
> wires can’t be implicitly defined so it has its own property. So the scheme we
> have proposed tries to optimize the efforts needed to adapt new boards and write
> DTs and focus the DT on hardware description.
> 
> As a bonus we also specify the min and max value to be reported for the touch
> pressure (Z axis) using the same basic principle.
> 
> And it is a pure add-on on top of the existing driver so that it attempts not
> to break existing device trees.

from what I can see there are no in-tree-users using any of the
new properties.

> Maybe could you accept it as a first step for this specific driver (and let’s do
> the big standardization work later on)?

That does not work, since you create an ABI.

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

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

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15 14:38           ` Sebastian Reichel
  0 siblings, 0 replies; 36+ messages in thread
From: Sebastian Reichel @ 2015-01-15 14:38 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
> > 1. Perform conversion in input core rather than individual drivers. I
> > think we should allocate a new bitmaps for some transformations and have
> > the code do X/Y flip/clip of the coordinates.
> 
> Do you have a suggestion where this should be (I have no clue how
> the input system works or is structured - we just know how to extend a
> driver that uses it)?
> 
> > 2. Standardize on bindings. We already have of-touchscreen.c doing
> > rudimentary parsing, we shoudl look into extending it rather than
> > creating myriad of driver-specific bindings.
> 
> Ok, looks reasonable.

Documentation is in 

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

> > Also, do we need swap and flip or do we simply need rotation (like the
> > proposed Broadcom iproc driver has)?
> 
> Well, since the DT should describe hardware, there are 3 sets of wires which
> can have a cross-over: X+ and X-, Y+ and Y-, X and Y.
>
> So IMHO hardware has no ?rotation?, just crossover of wires. Rotation is an
> interpretation of the result of these connections in combination with some
> panel the touch is glued to and should therefore not be represented in the DT.
> 
> As a result we have proposed a scheme without explicit rotation. We specify what
> coordinates X- and X+ should report at their ends (min, max) because the DT
> programmer has to specify them anyways. Flipping is a result of defining these
> coordinates in an ascending or descending way. Only swapping of the X and Y
> wires can?t be implicitly defined so it has its own property. So the scheme we
> have proposed tries to optimize the efforts needed to adapt new boards and write
> DTs and focus the DT on hardware description.
> 
> As a bonus we also specify the min and max value to be reported for the touch
> pressure (Z axis) using the same basic principle.
> 
> And it is a pure add-on on top of the existing driver so that it attempts not
> to break existing device trees.

from what I can see there are no in-tree-users using any of the
new properties.

> Maybe could you accept it as a first step for this specific driver (and let?s do
> the big standardization work later on)?

That does not work, since you create an ABI.

-- Sebastian

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
  2015-01-15 14:38           ` Sebastian Reichel
  (?)
@ 2015-01-15 15:04             ` Dr. H. Nikolaus Schaller
  -1 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15 15:04 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Dmitry Torokhov, Belisko Marek, Rob Herring, Pawel Moll,
	Mark Rutland, ijc+devicetree, Kumar Gala, Benoit Cousson,
	Tony Lindgren, Russell King - ARM Linux, devicetree, LKML,
	linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List for communicating with real GTA04 owners

Hi,

Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:

> Hi,
> 
> On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
>>> 1. Perform conversion in input core rather than individual drivers. I
>>> think we should allocate a new bitmaps for some transformations and have
>>> the code do X/Y flip/clip of the coordinates.
>> 
>> Do you have a suggestion where this should be (I have no clue how
>> the input system works or is structured - we just know how to extend a
>> driver that uses it)?
>> 
>>> 2. Standardize on bindings. We already have of-touchscreen.c doing
>>> rudimentary parsing, we shoudl look into extending it rather than
>>> creating myriad of driver-specific bindings.
>> 
>> Ok, looks reasonable.
> 
> Documentation is in 
> 
> Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> 
>>> Also, do we need swap and flip or do we simply need rotation (like the
>>> proposed Broadcom iproc driver has)?
>> 
>> Well, since the DT should describe hardware, there are 3 sets of wires which
>> can have a cross-over: X+ and X-, Y+ and Y-, X and Y.
>> 
>> So IMHO hardware has no “rotation”, just crossover of wires. Rotation is an
>> interpretation of the result of these connections in combination with some
>> panel the touch is glued to and should therefore not be represented in the DT.
>> 
>> As a result we have proposed a scheme without explicit rotation. We specify what
>> coordinates X- and X+ should report at their ends (min, max) because the DT
>> programmer has to specify them anyways. Flipping is a result of defining these
>> coordinates in an ascending or descending way. Only swapping of the X and Y
>> wires can’t be implicitly defined so it has its own property. So the scheme we
>> have proposed tries to optimize the efforts needed to adapt new boards and write
>> DTs and focus the DT on hardware description.
>> 
>> As a bonus we also specify the min and max value to be reported for the touch
>> pressure (Z axis) using the same basic principle.
>> 
>> And it is a pure add-on on top of the existing driver so that it attempts not
>> to break existing device trees.
> 
> from what I can see there are no in-tree-users using any of the
> new properties.

Not yet. But our [patch 2/3] of this series defines the DT entry for the GTA04 devices:

https://lkml.org/lkml/2014/9/30/663

> 
>> Maybe could you accept it as a first step for this specific driver (and let’s do
>> the big standardization work later on)?
> 
> That does not work, since you create an ABI.

Hm. I don’t understand what you mean with creating an ABI?





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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15 15:04             ` Dr. H. Nikolaus Schaller
  0 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15 15:04 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Dmitry Torokhov, Belisko Marek, Rob Herring, Pawel Moll,
	Mark Rutland, ijc+devicetree, Kumar Gala, Benoit Cousson,
	Tony Lindgren, Russell King - ARM Linux, devicetree, LKML,
	linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List

Hi,

Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:

> Hi,
> 
> On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
>>> 1. Perform conversion in input core rather than individual drivers. I
>>> think we should allocate a new bitmaps for some transformations and have
>>> the code do X/Y flip/clip of the coordinates.
>> 
>> Do you have a suggestion where this should be (I have no clue how
>> the input system works or is structured - we just know how to extend a
>> driver that uses it)?
>> 
>>> 2. Standardize on bindings. We already have of-touchscreen.c doing
>>> rudimentary parsing, we shoudl look into extending it rather than
>>> creating myriad of driver-specific bindings.
>> 
>> Ok, looks reasonable.
> 
> Documentation is in 
> 
> Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> 
>>> Also, do we need swap and flip or do we simply need rotation (like the
>>> proposed Broadcom iproc driver has)?
>> 
>> Well, since the DT should describe hardware, there are 3 sets of wires which
>> can have a cross-over: X+ and X-, Y+ and Y-, X and Y.
>> 
>> So IMHO hardware has no “rotation”, just crossover of wires. Rotation is an
>> interpretation of the result of these connections in combination with some
>> panel the touch is glued to and should therefore not be represented in the DT.
>> 
>> As a result we have proposed a scheme without explicit rotation. We specify what
>> coordinates X- and X+ should report at their ends (min, max) because the DT
>> programmer has to specify them anyways. Flipping is a result of defining these
>> coordinates in an ascending or descending way. Only swapping of the X and Y
>> wires can’t be implicitly defined so it has its own property. So the scheme we
>> have proposed tries to optimize the efforts needed to adapt new boards and write
>> DTs and focus the DT on hardware description.
>> 
>> As a bonus we also specify the min and max value to be reported for the touch
>> pressure (Z axis) using the same basic principle.
>> 
>> And it is a pure add-on on top of the existing driver so that it attempts not
>> to break existing device trees.
> 
> from what I can see there are no in-tree-users using any of the
> new properties.

Not yet. But our [patch 2/3] of this series defines the DT entry for the GTA04 devices:

https://lkml.org/lkml/2014/9/30/663

> 
>> Maybe could you accept it as a first step for this specific driver (and let’s do
>> the big standardization work later on)?
> 
> That does not work, since you create an ABI.

Hm. I don’t understand what you mean with creating an ABI?




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

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

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15 15:04             ` Dr. H. Nikolaus Schaller
  0 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15 15:04 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:

> Hi,
> 
> On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
>>> 1. Perform conversion in input core rather than individual drivers. I
>>> think we should allocate a new bitmaps for some transformations and have
>>> the code do X/Y flip/clip of the coordinates.
>> 
>> Do you have a suggestion where this should be (I have no clue how
>> the input system works or is structured - we just know how to extend a
>> driver that uses it)?
>> 
>>> 2. Standardize on bindings. We already have of-touchscreen.c doing
>>> rudimentary parsing, we shoudl look into extending it rather than
>>> creating myriad of driver-specific bindings.
>> 
>> Ok, looks reasonable.
> 
> Documentation is in 
> 
> Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> 
>>> Also, do we need swap and flip or do we simply need rotation (like the
>>> proposed Broadcom iproc driver has)?
>> 
>> Well, since the DT should describe hardware, there are 3 sets of wires which
>> can have a cross-over: X+ and X-, Y+ and Y-, X and Y.
>> 
>> So IMHO hardware has no ?rotation?, just crossover of wires. Rotation is an
>> interpretation of the result of these connections in combination with some
>> panel the touch is glued to and should therefore not be represented in the DT.
>> 
>> As a result we have proposed a scheme without explicit rotation. We specify what
>> coordinates X- and X+ should report at their ends (min, max) because the DT
>> programmer has to specify them anyways. Flipping is a result of defining these
>> coordinates in an ascending or descending way. Only swapping of the X and Y
>> wires can?t be implicitly defined so it has its own property. So the scheme we
>> have proposed tries to optimize the efforts needed to adapt new boards and write
>> DTs and focus the DT on hardware description.
>> 
>> As a bonus we also specify the min and max value to be reported for the touch
>> pressure (Z axis) using the same basic principle.
>> 
>> And it is a pure add-on on top of the existing driver so that it attempts not
>> to break existing device trees.
> 
> from what I can see there are no in-tree-users using any of the
> new properties.

Not yet. But our [patch 2/3] of this series defines the DT entry for the GTA04 devices:

https://lkml.org/lkml/2014/9/30/663

> 
>> Maybe could you accept it as a first step for this specific driver (and let?s do
>> the big standardization work later on)?
> 
> That does not work, since you create an ABI.

Hm. I don?t understand what you mean with creating an ABI?

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
  2015-01-15 14:38           ` Sebastian Reichel
  (?)
@ 2015-01-15 16:14             ` Dr. H. Nikolaus Schaller
  -1 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15 16:14 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Dmitry Torokhov, Belisko Marek, Rob Herring, Pawel Moll,
	Mark Rutland, ijc+devicetree, Kumar Gala, Benoit Cousson,
	Tony Lindgren, Russell King - ARM Linux, devicetree, LKML,
	linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List for communicating with real GTA04 owners


Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:

> Hi,
> 
> On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
>>> 1. Perform conversion in input core rather than individual drivers. I
>>> think we should allocate a new bitmaps for some transformations and have
>>> the code do X/Y flip/clip of the coordinates.
>> 
>> Do you have a suggestion where this should be (I have no clue how
>> the input system works or is structured - we just know how to extend a
>> driver that uses it)?
>> 
>>> 2. Standardize on bindings. We already have of-touchscreen.c doing
>>> rudimentary parsing, we shoudl look into extending it rather than
>>> creating myriad of driver-specific bindings.
>> 
>> Ok, looks reasonable.
> 
> Documentation is in 
> 
> Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt

I did look into it now. Unfortunately, it does not fit well into my view of how bindings
should be. They should describe hardware (as we are told for many other kernel
subsystems).

Pixels and resolutions are IMHO related to the screen it is glued on - and that is
quite independent.

So I don’t see how they do describe the different ways the touch screen can be
wired to a tsc2007 controller.

Please can you add minimum and maximum properties for us?

Then, inverted-x and inverted-y is redundant because it is the same as having
an expected higher value from the ADC for the minimum coordinate and a lower
for the maximum.

> 
>>> Also, do we need swap and flip or do we simply need rotation (like the
>>> proposed Broadcom iproc driver has)?
>> 
>> Well, since the DT should describe hardware, there are 3 sets of wires which
>> can have a cross-over: X+ and X-, Y+ and Y-, X and Y.
>> 
>> So IMHO hardware has no “rotation”, just crossover of wires. Rotation is an
>> interpretation of the result of these connections in combination with some
>> panel the touch is glued to and should therefore not be represented in the DT.
>> 
>> As a result we have proposed a scheme without explicit rotation. We specify what
>> coordinates X- and X+ should report at their ends (min, max) because the DT
>> programmer has to specify them anyways. Flipping is a result of defining these
>> coordinates in an ascending or descending way. Only swapping of the X and Y
>> wires can’t be implicitly defined so it has its own property. So the scheme we
>> have proposed tries to optimize the efforts needed to adapt new boards and write
>> DTs and focus the DT on hardware description.
>> 
>> As a bonus we also specify the min and max value to be reported for the touch
>> pressure (Z axis) using the same basic principle.
>> 
>> And it is a pure add-on on top of the existing driver so that it attempts not
>> to break existing device trees.
> 
> from what I can see there are no in-tree-users using any of the
> new properties.
> 
>> Maybe could you accept it as a first step for this specific driver (and let’s do
>> the big standardization work later on)?
> 
> That does not work, since you create an ABI.
> 
> -- Sebastian


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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15 16:14             ` Dr. H. Nikolaus Schaller
  0 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15 16:14 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Dmitry Torokhov, Belisko Marek, Rob Herring, Pawel Moll,
	Mark Rutland, ijc+devicetree, Kumar Gala, Benoit Cousson,
	Tony Lindgren, Russell King - ARM Linux, devicetree, LKML,
	linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List


Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:

> Hi,
> 
> On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
>>> 1. Perform conversion in input core rather than individual drivers. I
>>> think we should allocate a new bitmaps for some transformations and have
>>> the code do X/Y flip/clip of the coordinates.
>> 
>> Do you have a suggestion where this should be (I have no clue how
>> the input system works or is structured - we just know how to extend a
>> driver that uses it)?
>> 
>>> 2. Standardize on bindings. We already have of-touchscreen.c doing
>>> rudimentary parsing, we shoudl look into extending it rather than
>>> creating myriad of driver-specific bindings.
>> 
>> Ok, looks reasonable.
> 
> Documentation is in 
> 
> Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt

I did look into it now. Unfortunately, it does not fit well into my view of how bindings
should be. They should describe hardware (as we are told for many other kernel
subsystems).

Pixels and resolutions are IMHO related to the screen it is glued on - and that is
quite independent.

So I don’t see how they do describe the different ways the touch screen can be
wired to a tsc2007 controller.

Please can you add minimum and maximum properties for us?

Then, inverted-x and inverted-y is redundant because it is the same as having
an expected higher value from the ADC for the minimum coordinate and a lower
for the maximum.

> 
>>> Also, do we need swap and flip or do we simply need rotation (like the
>>> proposed Broadcom iproc driver has)?
>> 
>> Well, since the DT should describe hardware, there are 3 sets of wires which
>> can have a cross-over: X+ and X-, Y+ and Y-, X and Y.
>> 
>> So IMHO hardware has no “rotation”, just crossover of wires. Rotation is an
>> interpretation of the result of these connections in combination with some
>> panel the touch is glued to and should therefore not be represented in the DT.
>> 
>> As a result we have proposed a scheme without explicit rotation. We specify what
>> coordinates X- and X+ should report at their ends (min, max) because the DT
>> programmer has to specify them anyways. Flipping is a result of defining these
>> coordinates in an ascending or descending way. Only swapping of the X and Y
>> wires can’t be implicitly defined so it has its own property. So the scheme we
>> have proposed tries to optimize the efforts needed to adapt new boards and write
>> DTs and focus the DT on hardware description.
>> 
>> As a bonus we also specify the min and max value to be reported for the touch
>> pressure (Z axis) using the same basic principle.
>> 
>> And it is a pure add-on on top of the existing driver so that it attempts not
>> to break existing device trees.
> 
> from what I can see there are no in-tree-users using any of the
> new properties.
> 
>> Maybe could you accept it as a first step for this specific driver (and let’s do
>> the big standardization work later on)?
> 
> That does not work, since you create an ABI.
> 
> -- Sebastian

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

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15 16:14             ` Dr. H. Nikolaus Schaller
  0 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15 16:14 UTC (permalink / raw)
  To: linux-arm-kernel


Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:

> Hi,
> 
> On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
>>> 1. Perform conversion in input core rather than individual drivers. I
>>> think we should allocate a new bitmaps for some transformations and have
>>> the code do X/Y flip/clip of the coordinates.
>> 
>> Do you have a suggestion where this should be (I have no clue how
>> the input system works or is structured - we just know how to extend a
>> driver that uses it)?
>> 
>>> 2. Standardize on bindings. We already have of-touchscreen.c doing
>>> rudimentary parsing, we shoudl look into extending it rather than
>>> creating myriad of driver-specific bindings.
>> 
>> Ok, looks reasonable.
> 
> Documentation is in 
> 
> Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt

I did look into it now. Unfortunately, it does not fit well into my view of how bindings
should be. They should describe hardware (as we are told for many other kernel
subsystems).

Pixels and resolutions are IMHO related to the screen it is glued on - and that is
quite independent.

So I don?t see how they do describe the different ways the touch screen can be
wired to a tsc2007 controller.

Please can you add minimum and maximum properties for us?

Then, inverted-x and inverted-y is redundant because it is the same as having
an expected higher value from the ADC for the minimum coordinate and a lower
for the maximum.

> 
>>> Also, do we need swap and flip or do we simply need rotation (like the
>>> proposed Broadcom iproc driver has)?
>> 
>> Well, since the DT should describe hardware, there are 3 sets of wires which
>> can have a cross-over: X+ and X-, Y+ and Y-, X and Y.
>> 
>> So IMHO hardware has no ?rotation?, just crossover of wires. Rotation is an
>> interpretation of the result of these connections in combination with some
>> panel the touch is glued to and should therefore not be represented in the DT.
>> 
>> As a result we have proposed a scheme without explicit rotation. We specify what
>> coordinates X- and X+ should report at their ends (min, max) because the DT
>> programmer has to specify them anyways. Flipping is a result of defining these
>> coordinates in an ascending or descending way. Only swapping of the X and Y
>> wires can?t be implicitly defined so it has its own property. So the scheme we
>> have proposed tries to optimize the efforts needed to adapt new boards and write
>> DTs and focus the DT on hardware description.
>> 
>> As a bonus we also specify the min and max value to be reported for the touch
>> pressure (Z axis) using the same basic principle.
>> 
>> And it is a pure add-on on top of the existing driver so that it attempts not
>> to break existing device trees.
> 
> from what I can see there are no in-tree-users using any of the
> new properties.
> 
>> Maybe could you accept it as a first step for this specific driver (and let?s do
>> the big standardization work later on)?
> 
> That does not work, since you create an ABI.
> 
> -- Sebastian

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
  2015-01-15 16:14             ` Dr. H. Nikolaus Schaller
  (?)
@ 2015-01-15 18:16               ` Dmitry Torokhov
  -1 siblings, 0 replies; 36+ messages in thread
From: Dmitry Torokhov @ 2015-01-15 18:16 UTC (permalink / raw)
  To: Dr. H. Nikolaus Schaller
  Cc: Sebastian Reichel, Belisko Marek, Rob Herring, Pawel Moll,
	Mark Rutland, ijc+devicetree, Kumar Gala, Benoit Cousson,
	Tony Lindgren, Russell King - ARM Linux, devicetree, LKML,
	linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List for communicating with real GTA04 owners

On Thu, Jan 15, 2015 at 05:14:38PM +0100, Dr. H. Nikolaus Schaller wrote:
> 
> Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:
> 
> > Hi,
> > 
> > On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
> >>> 1. Perform conversion in input core rather than individual drivers. I
> >>> think we should allocate a new bitmaps for some transformations and have
> >>> the code do X/Y flip/clip of the coordinates.
> >> 
> >> Do you have a suggestion where this should be (I have no clue how
> >> the input system works or is structured - we just know how to extend a
> >> driver that uses it)?
> >> 
> >>> 2. Standardize on bindings. We already have of-touchscreen.c doing
> >>> rudimentary parsing, we shoudl look into extending it rather than
> >>> creating myriad of driver-specific bindings.
> >> 
> >> Ok, looks reasonable.
> > 
> > Documentation is in 
> > 
> > Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> 
> I did look into it now. Unfortunately, it does not fit well into my view of how bindings
> should be. They should describe hardware (as we are told for many other kernel
> subsystems).
> 
> Pixels and resolutions are IMHO related to the screen it is glued on - and that is
> quite independent.

Well, I think pixels was the wrong word to be used there. It is meant to
be native units, as opposed to millimeters, inches, points, etc.

> 
> So I don’t see how they do describe the different ways the touch screen can be
> wired to a tsc2007 controller.
> 
> Please can you add minimum and maximum properties for us?
> 
> Then, inverted-x and inverted-y is redundant because it is the same as having
> an expected higher value from the ADC for the minimum coordinate and a lower
> for the maximum.

I'd rather not add minimum and maximum, but add the touchscreen-start-x and
touchscreen-start-y instead so that we limit the number of obsolete
properties.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15 18:16               ` Dmitry Torokhov
  0 siblings, 0 replies; 36+ messages in thread
From: Dmitry Torokhov @ 2015-01-15 18:16 UTC (permalink / raw)
  To: Dr. H. Nikolaus Schaller
  Cc: Sebastian Reichel, Belisko Marek, Rob Herring, Pawel Moll,
	Mark Rutland, ijc+devicetree, Kumar Gala, Benoit Cousson,
	Tony Lindgren, Russell King - ARM Linux, devicetree, LKML,
	linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List

On Thu, Jan 15, 2015 at 05:14:38PM +0100, Dr. H. Nikolaus Schaller wrote:
> 
> Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:
> 
> > Hi,
> > 
> > On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
> >>> 1. Perform conversion in input core rather than individual drivers. I
> >>> think we should allocate a new bitmaps for some transformations and have
> >>> the code do X/Y flip/clip of the coordinates.
> >> 
> >> Do you have a suggestion where this should be (I have no clue how
> >> the input system works or is structured - we just know how to extend a
> >> driver that uses it)?
> >> 
> >>> 2. Standardize on bindings. We already have of-touchscreen.c doing
> >>> rudimentary parsing, we shoudl look into extending it rather than
> >>> creating myriad of driver-specific bindings.
> >> 
> >> Ok, looks reasonable.
> > 
> > Documentation is in 
> > 
> > Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> 
> I did look into it now. Unfortunately, it does not fit well into my view of how bindings
> should be. They should describe hardware (as we are told for many other kernel
> subsystems).
> 
> Pixels and resolutions are IMHO related to the screen it is glued on - and that is
> quite independent.

Well, I think pixels was the wrong word to be used there. It is meant to
be native units, as opposed to millimeters, inches, points, etc.

> 
> So I don’t see how they do describe the different ways the touch screen can be
> wired to a tsc2007 controller.
> 
> Please can you add minimum and maximum properties for us?
> 
> Then, inverted-x and inverted-y is redundant because it is the same as having
> an expected higher value from the ADC for the minimum coordinate and a lower
> for the maximum.

I'd rather not add minimum and maximum, but add the touchscreen-start-x and
touchscreen-start-y instead so that we limit the number of obsolete
properties.

Thanks.

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

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

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15 18:16               ` Dmitry Torokhov
  0 siblings, 0 replies; 36+ messages in thread
From: Dmitry Torokhov @ 2015-01-15 18:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jan 15, 2015 at 05:14:38PM +0100, Dr. H. Nikolaus Schaller wrote:
> 
> Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:
> 
> > Hi,
> > 
> > On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
> >>> 1. Perform conversion in input core rather than individual drivers. I
> >>> think we should allocate a new bitmaps for some transformations and have
> >>> the code do X/Y flip/clip of the coordinates.
> >> 
> >> Do you have a suggestion where this should be (I have no clue how
> >> the input system works or is structured - we just know how to extend a
> >> driver that uses it)?
> >> 
> >>> 2. Standardize on bindings. We already have of-touchscreen.c doing
> >>> rudimentary parsing, we shoudl look into extending it rather than
> >>> creating myriad of driver-specific bindings.
> >> 
> >> Ok, looks reasonable.
> > 
> > Documentation is in 
> > 
> > Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> 
> I did look into it now. Unfortunately, it does not fit well into my view of how bindings
> should be. They should describe hardware (as we are told for many other kernel
> subsystems).
> 
> Pixels and resolutions are IMHO related to the screen it is glued on - and that is
> quite independent.

Well, I think pixels was the wrong word to be used there. It is meant to
be native units, as opposed to millimeters, inches, points, etc.

> 
> So I don?t see how they do describe the different ways the touch screen can be
> wired to a tsc2007 controller.
> 
> Please can you add minimum and maximum properties for us?
> 
> Then, inverted-x and inverted-y is redundant because it is the same as having
> an expected higher value from the ADC for the minimum coordinate and a lower
> for the maximum.

I'd rather not add minimum and maximum, but add the touchscreen-start-x and
touchscreen-start-y instead so that we limit the number of obsolete
properties.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
  2015-01-15 18:16               ` Dmitry Torokhov
  (?)
@ 2015-01-15 18:49                 ` Dr. H. Nikolaus Schaller
  -1 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15 18:49 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Sebastian Reichel, Belisko Marek, Rob Herring, Pawel Moll,
	Mark Rutland, ijc+devicetree, Kumar Gala, Benoit Cousson,
	Tony Lindgren, Russell King - ARM Linux, devicetree, LKML,
	linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List for communicating with real GTA04 owners


Am 15.01.2015 um 19:16 schrieb Dmitry Torokhov <dmitry.torokhov@gmail.com>:

> On Thu, Jan 15, 2015 at 05:14:38PM +0100, Dr. H. Nikolaus Schaller wrote:
>> 
>> Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:
>> 
>>> Hi,
>>> 
>>> On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
>>>>> 1. Perform conversion in input core rather than individual drivers. I
>>>>> think we should allocate a new bitmaps for some transformations and have
>>>>> the code do X/Y flip/clip of the coordinates.
>>>> 
>>>> Do you have a suggestion where this should be (I have no clue how
>>>> the input system works or is structured - we just know how to extend a
>>>> driver that uses it)?
>>>> 
>>>>> 2. Standardize on bindings. We already have of-touchscreen.c doing
>>>>> rudimentary parsing, we shoudl look into extending it rather than
>>>>> creating myriad of driver-specific bindings.
>>>> 
>>>> Ok, looks reasonable.
>>> 
>>> Documentation is in 
>>> 
>>> Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
>> 
>> I did look into it now. Unfortunately, it does not fit well into my view of how bindings
>> should be. They should describe hardware (as we are told for many other kernel
>> subsystems).
>> 
>> Pixels and resolutions are IMHO related to the screen it is glued on - and that is
>> quite independent.
> 
> Well, I think pixels was the wrong word to be used there. It is meant to
> be native units, as opposed to millimeters, inches, points, etc.

ok.

> 
>> 
>> So I don’t see how they do describe the different ways the touch screen can be
>> wired to a tsc2007 controller.
>> 
>> Please can you add minimum and maximum properties for us?
>> 
>> Then, inverted-x and inverted-y is redundant because it is the same as having
>> an expected higher value from the ADC for the minimum coordinate and a lower
>> for the maximum.
> 
> I'd rather not add minimum and maximum, but add the touchscreen-start-x and
> touchscreen-start-y instead so that we limit the number of obsolete
> properties.

ok, that should not be too difficult to add.

So we will modify our driver to use the new functions and align omap3-gta04.dtsi accordingly.

BR,
Nikolaus


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

* Re: [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15 18:49                 ` Dr. H. Nikolaus Schaller
  0 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15 18:49 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Sebastian Reichel, Belisko Marek, Rob Herring, Pawel Moll,
	Mark Rutland, ijc+devicetree, Kumar Gala, Benoit Cousson,
	Tony Lindgren, Russell King - ARM Linux, devicetree, LKML,
	linux-omap, linux-arm-kernel, linux-input, Marek Belisko,
	Jonathan Richardson, Scott Branden, Yoichi Yuasa, Maxime Ripard,
	List


Am 15.01.2015 um 19:16 schrieb Dmitry Torokhov <dmitry.torokhov@gmail.com>:

> On Thu, Jan 15, 2015 at 05:14:38PM +0100, Dr. H. Nikolaus Schaller wrote:
>> 
>> Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:
>> 
>>> Hi,
>>> 
>>> On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
>>>>> 1. Perform conversion in input core rather than individual drivers. I
>>>>> think we should allocate a new bitmaps for some transformations and have
>>>>> the code do X/Y flip/clip of the coordinates.
>>>> 
>>>> Do you have a suggestion where this should be (I have no clue how
>>>> the input system works or is structured - we just know how to extend a
>>>> driver that uses it)?
>>>> 
>>>>> 2. Standardize on bindings. We already have of-touchscreen.c doing
>>>>> rudimentary parsing, we shoudl look into extending it rather than
>>>>> creating myriad of driver-specific bindings.
>>>> 
>>>> Ok, looks reasonable.
>>> 
>>> Documentation is in 
>>> 
>>> Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
>> 
>> I did look into it now. Unfortunately, it does not fit well into my view of how bindings
>> should be. They should describe hardware (as we are told for many other kernel
>> subsystems).
>> 
>> Pixels and resolutions are IMHO related to the screen it is glued on - and that is
>> quite independent.
> 
> Well, I think pixels was the wrong word to be used there. It is meant to
> be native units, as opposed to millimeters, inches, points, etc.

ok.

> 
>> 
>> So I don’t see how they do describe the different ways the touch screen can be
>> wired to a tsc2007 controller.
>> 
>> Please can you add minimum and maximum properties for us?
>> 
>> Then, inverted-x and inverted-y is redundant because it is the same as having
>> an expected higher value from the ADC for the minimum coordinate and a lower
>> for the maximum.
> 
> I'd rather not add minimum and maximum, but add the touchscreen-start-x and
> touchscreen-start-y instead so that we limit the number of obsolete
> properties.

ok, that should not be too difficult to add.

So we will modify our driver to use the new functions and align omap3-gta04.dtsi accordingly.

BR,
Nikolaus

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

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

* [PATCH 1/3] input: tsc2007: Add pre-calibration, flipping and rotation
@ 2015-01-15 18:49                 ` Dr. H. Nikolaus Schaller
  0 siblings, 0 replies; 36+ messages in thread
From: Dr. H. Nikolaus Schaller @ 2015-01-15 18:49 UTC (permalink / raw)
  To: linux-arm-kernel


Am 15.01.2015 um 19:16 schrieb Dmitry Torokhov <dmitry.torokhov@gmail.com>:

> On Thu, Jan 15, 2015 at 05:14:38PM +0100, Dr. H. Nikolaus Schaller wrote:
>> 
>> Am 15.01.2015 um 15:38 schrieb Sebastian Reichel <sre@kernel.org>:
>> 
>>> Hi,
>>> 
>>> On Thu, Jan 15, 2015 at 08:36:44AM +0100, Dr. H. Nikolaus Schaller wrote:
>>>>> 1. Perform conversion in input core rather than individual drivers. I
>>>>> think we should allocate a new bitmaps for some transformations and have
>>>>> the code do X/Y flip/clip of the coordinates.
>>>> 
>>>> Do you have a suggestion where this should be (I have no clue how
>>>> the input system works or is structured - we just know how to extend a
>>>> driver that uses it)?
>>>> 
>>>>> 2. Standardize on bindings. We already have of-touchscreen.c doing
>>>>> rudimentary parsing, we shoudl look into extending it rather than
>>>>> creating myriad of driver-specific bindings.
>>>> 
>>>> Ok, looks reasonable.
>>> 
>>> Documentation is in 
>>> 
>>> Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
>> 
>> I did look into it now. Unfortunately, it does not fit well into my view of how bindings
>> should be. They should describe hardware (as we are told for many other kernel
>> subsystems).
>> 
>> Pixels and resolutions are IMHO related to the screen it is glued on - and that is
>> quite independent.
> 
> Well, I think pixels was the wrong word to be used there. It is meant to
> be native units, as opposed to millimeters, inches, points, etc.

ok.

> 
>> 
>> So I don?t see how they do describe the different ways the touch screen can be
>> wired to a tsc2007 controller.
>> 
>> Please can you add minimum and maximum properties for us?
>> 
>> Then, inverted-x and inverted-y is redundant because it is the same as having
>> an expected higher value from the ADC for the minimum coordinate and a lower
>> for the maximum.
> 
> I'd rather not add minimum and maximum, but add the touchscreen-start-x and
> touchscreen-start-y instead so that we limit the number of obsolete
> properties.

ok, that should not be too difficult to add.

So we will modify our driver to use the new functions and align omap3-gta04.dtsi accordingly.

BR,
Nikolaus

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

end of thread, other threads:[~2015-01-15 18:50 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-30 20:17 [PATCH 0/3] input: tsc2007: Extend for pre-calibration, flipping and rotation Marek Belisko
2014-09-30 20:17 ` Marek Belisko
2014-09-30 20:17 ` [PATCH 1/3] input: tsc2007: Add " Marek Belisko
2014-09-30 20:17   ` Marek Belisko
2014-09-30 20:17   ` Marek Belisko
2015-01-10 14:15   ` Belisko Marek
2015-01-10 14:15     ` Belisko Marek
2015-01-10 14:15     ` Belisko Marek
2015-01-15  0:59     ` Dmitry Torokhov
2015-01-15  0:59       ` Dmitry Torokhov
2015-01-15  7:36       ` Dr. H. Nikolaus Schaller
2015-01-15  7:36         ` Dr. H. Nikolaus Schaller
2015-01-15  7:36         ` Dr. H. Nikolaus Schaller
2015-01-15 14:38         ` Sebastian Reichel
2015-01-15 14:38           ` Sebastian Reichel
2015-01-15 14:38           ` Sebastian Reichel
2015-01-15 15:04           ` Dr. H. Nikolaus Schaller
2015-01-15 15:04             ` Dr. H. Nikolaus Schaller
2015-01-15 15:04             ` Dr. H. Nikolaus Schaller
2015-01-15 16:14           ` Dr. H. Nikolaus Schaller
2015-01-15 16:14             ` Dr. H. Nikolaus Schaller
2015-01-15 16:14             ` Dr. H. Nikolaus Schaller
2015-01-15 18:16             ` Dmitry Torokhov
2015-01-15 18:16               ` Dmitry Torokhov
2015-01-15 18:16               ` Dmitry Torokhov
2015-01-15 18:49               ` Dr. H. Nikolaus Schaller
2015-01-15 18:49                 ` Dr. H. Nikolaus Schaller
2015-01-15 18:49                 ` Dr. H. Nikolaus Schaller
2014-09-30 20:17 ` [PATCH 2/3] Documentation: dt: input: tsc2007: Document new parameters Marek Belisko
2014-09-30 20:17   ` Marek Belisko
2014-09-30 20:17 ` [PATCH 3/3] arm: dts: omap3-gta04: Extend touchscreen configs Marek Belisko
2014-09-30 20:17   ` Marek Belisko
2014-10-13 16:29   ` Tony Lindgren
2014-10-13 16:29     ` Tony Lindgren
2014-10-10  9:28 ` [PATCH 0/3] input: tsc2007: Extend for pre-calibration, flipping and rotation Belisko Marek
2014-10-10  9:28   ` Belisko Marek

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.