All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leif Middelschulte <leif.middelschulte@klsmartin.com>
To: dmitry.torokhov@gmail.com, devicetree@vger.kernel.org
Cc: linux-input@vger.kernel.org, robh+dt@kernel.org,
	mark.rutland@arm.com,
	Leif Middelschulte <leif.middelschulte@klsmartin.com>
Subject: [PATCH 04/10] Input: stmpe-ts - implement resolution support
Date: Mon, 27 May 2019 18:07:30 +0200	[thread overview]
Message-ID: <20190527160736.30569-5-leif.middelschulte@klsmartin.com> (raw)
In-Reply-To: <20190527160736.30569-1-leif.middelschulte@klsmartin.com>

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

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

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

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

  parent reply	other threads:[~2019-05-27 16:07 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190527160736.30569-5-leif.middelschulte@klsmartin.com \
    --to=leif.middelschulte@klsmartin.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.