From: Marco Felsch <m.felsch@pengutronix.de>
To: dmitry.torokhov@gmail.com, robh+dt@kernel.org
Cc: kernel@pengutronix.de, linux-input@vger.kernel.org,
devicetree@vger.kernel.org
Subject: [PATCH 4/4] Input: ads7846 - add support for general touchscreen bindings
Date: Wed, 27 Mar 2019 14:39:27 +0100 [thread overview]
Message-ID: <20190327133927.1340-5-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20190327133927.1340-1-m.felsch@pengutronix.de>
A few vendor specific bindings are now covered by common bindings.
Let the driver parse the common bindings to make use of common
inverting and swapping mechnism. Aslo make use of
touchscreen_report_pos() to ensure the correct inverting-swapping
order.
The vendor specific properties are used as default (backward
compatibility) and gets overwritten by common bindings.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/input/touchscreen/ads7846.c | 38 +++++++++++++++++++++++------
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 5a7a8425d619..2fe3b91f1db8 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -23,6 +23,7 @@
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/input.h>
+#include <linux/input/touchscreen.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/pm.h>
@@ -132,6 +133,8 @@ struct ads7846 {
u16 penirq_recheck_delay_usecs;
+ struct touchscreen_properties core_prop;
+
struct mutex lock;
bool stopped; /* P: lock */
bool disabled; /* P: lock */
@@ -826,17 +829,13 @@ static void ads7846_report_state(struct ads7846 *ts)
if (Rt) {
struct input_dev *input = ts->input;
- if (ts->swap_xy)
- swap(x, y);
-
if (!ts->pendown) {
input_report_key(input, BTN_TOUCH, 1);
ts->pendown = true;
dev_vdbg(&ts->spi->dev, "DOWN\n");
}
- input_report_abs(input, ABS_X, x);
- input_report_abs(input, ABS_Y, y);
+ touchscreen_report_pos(input, &ts->core_prop, x, y, false);
input_report_abs(input, ABS_PRESSURE, ts->pressure_max - Rt);
input_sync(input);
@@ -1188,6 +1187,7 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
struct ads7846_platform_data *pdata;
struct device_node *node = dev->of_node;
const struct of_device_id *match;
+ u32 value;
if (!node) {
dev_err(dev, "Device does not have associated DT data\n");
@@ -1226,10 +1226,18 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
of_property_read_u16(node, "ti,x-max", &pdata->x_max);
of_property_read_u16(node, "ti,y-max", &pdata->y_max);
+ /*
+ * touchscreen-max-pressure gets parsed during
+ * touchscreen_parse_properties()
+ */
of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min);
+ if (!of_property_read_u32(node, "touchscreen-min-pressure", &value))
+ pdata->pressure_min = (u16) value;
of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max);
of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max);
+ if (!of_property_read_u32(node, "touchscreen-average-samples", &value))
+ pdata->debounce_max = (u16) value;
of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol);
of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep);
@@ -1314,10 +1322,7 @@ static int ads7846_probe(struct spi_device *spi)
ts->model = pdata->model ? : 7846;
ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100;
ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
- ts->pressure_max = pdata->pressure_max ? : ~0;
-
ts->vref_mv = pdata->vref_mv;
- ts->swap_xy = pdata->swap_xy;
if (pdata->filter != NULL) {
if (pdata->filter_init != NULL) {
@@ -1368,6 +1373,23 @@ static int ads7846_probe(struct spi_device *spi)
input_set_abs_params(input_dev, ABS_PRESSURE,
pdata->pressure_min, pdata->pressure_max, 0, 0);
+ /*
+ * Parse common framework properties. Must be done here to ensure the
+ * correct behaviour in case of using the legacy vendor bindings. The
+ * general binding value overrides the vendor specific one.
+ */
+ touchscreen_parse_properties(ts->input, false, &ts->core_prop);
+ ts->pressure_max = input_abs_get_max(input_dev, ABS_PRESSURE) ? : ~0;
+
+ /*
+ * Check if legacy ti,swap-xy binding is used instead of
+ * touchscreen-swapped-x-y
+ */
+ if (!ts->core_prop.swap_x_y && pdata->swap_xy) {
+ swap(input_dev->absinfo[ABS_X], input_dev->absinfo[ABS_Y]);
+ ts->core_prop.swap_x_y = true;
+ }
+
ads7846_setup_spi_msg(ts, pdata);
ts->reg = regulator_get(&spi->dev, "vcc");
--
2.20.1
next prev parent reply other threads:[~2019-03-27 13:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-27 13:39 [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch
2019-03-27 13:39 ` [PATCH 1/4] Input: ads7846 - convert to devm_ alloc functions Marco Felsch
2019-08-09 16:44 ` Dmitry Torokhov
2019-03-27 13:39 ` [PATCH 2/4] dt-bindings: input: ads7846: fix property description Marco Felsch
[not found] ` <5ca06164.1c69fb81.39fb3.79f9@mx.google.com>
2019-08-09 16:42 ` Dmitry Torokhov
2019-03-27 13:39 ` [PATCH 3/4] dt-bindings: input: ads7846: replace vendor-bindings by general ones Marco Felsch
[not found] ` <5ca06167.1c69fb81.6e121.c248@mx.google.com>
2019-08-21 7:36 ` Marco Felsch
2019-08-22 17:44 ` Dmitry Torokhov
2019-03-27 13:39 ` Marco Felsch [this message]
2019-08-09 16:42 ` [PATCH 4/4] Input: ads7846 - add support for general touchscreen bindings Dmitry Torokhov
2019-08-09 9:30 ` [PATCH 0/4] ADS7846 add general touchscreen features Marco Felsch
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=20190327133927.1340-5-m.felsch@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-input@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).