From: Rob Herring <robh@kernel.org>
To: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Benoît Cousson" <bcousson@baylibre.com>,
"Tony Lindgren" <tony@atomide.com>,
"Russell King" <linux@armlinux.org.uk>,
"Arnd Bergmann" <arnd@arndb.de>,
"Michael Welling" <mwelling@ieee.org>,
"Mika Penttilä" <mika.penttila@nextfour.com>,
"Javier Martinez Canillas" <javier@osg.samsung.com>,
"Igor Grinberg" <grinberg@compulab.co.il>,
"Sebastian Reichel" <sre@kernel.org>,
"Andrew F. Davis" <afd@ti.com>,
linux-input@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
letux-kernel@openphoenux.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH v3 6/8] drivers:input:ads7846(+tsc2046): add new common binding names, pre-calibration and flipping
Date: Fri, 23 Sep 2016 17:50:23 -0500 [thread overview]
Message-ID: <20160923225023.GA9994@rob-hp-laptop> (raw)
In-Reply-To: <7f69bbab0e932cb00bd28668f56c8a30e83c59e0.1474634475.git.hns@goldelico.com>
On Fri, Sep 23, 2016 at 02:41:14PM +0200, H. Nikolaus Schaller wrote:
> commit b98abe52fa8e ("Input: add common DT binding for touchscreens")
> introduced common DT bindings for touchscreens [1] and a helper function to
> parse the DT.
>
> commit ed7c9870c9bc ("Input: of_touchscreen - add support for inverted / swapped axes")
> added another helper for parsing axis inversion and swapping
> and applying them to x and y coordinates.
>
> Both helpers have been integrated to accommodate any orientation of the
> touch panel in relation to the LCD.
>
> A new feature is to introduce scaling the min/max ADC values to the screen
> size.
>
> This makes it possible to pre-calibrate the touch so that is (almost)
> exactly matches the LCD pixel coordinates it is glued onto. This allows to
> well enough operate the touch before a user space calibration step can
> improve the precision.
This appears to be the prior patch's commit msg, or you don't need ADC
values in DT for this one?
>
> [1]: Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
>
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> ---
> .../devicetree/bindings/input/ads7846.txt | 9 +++-
> drivers/input/touchscreen/ads7846.c | 60 ++++++++++++++++++----
> 2 files changed, 57 insertions(+), 12 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/input/ads7846.txt b/Documentation/devicetree/bindings/input/ads7846.txt
> index 9fc47b0..29f91ed 100644
> --- a/Documentation/devicetree/bindings/input/ads7846.txt
> +++ b/Documentation/devicetree/bindings/input/ads7846.txt
> @@ -26,6 +26,12 @@ Additional required properties:
>
> Optional properties:
>
> +You can optionally specify any of the touchscreen parameters described in
> +
> + Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> +
> +This allows to scale, invert or swap coordinates and define the fuzz factors.
> +
> ti,vref-delay-usecs vref supply delay in usecs, 0 for
> external vref (u16).
> ti,vref-mv The VREF voltage, in millivolts (u16).
> @@ -33,7 +39,7 @@ Optional properties:
> (ADS7846).
> ti,keep-vref-on set to keep vref on for differential
> measurements as well
> - ti,swap-xy swap x and y axis
> + ti,swap-xy deprecated name for touchscreen-swapped-x-y
> ti,settle-delay-usec Settling time of the analog signals;
> a function of Vcc and the capacitance
> on the X/Y drivers. If set to non-zero,
> @@ -82,6 +88,7 @@ Example for a TSC2046 chip connected to an McSPI controller of an OMAP SoC::
> pendown-gpio = <&gpio1 8 0>;
> vcc-supply = <®_vcc3>;
>
> + touchscreen-swapped-x-y;
> ti,x-min = /bits/ 16 <0>;
> ti,x-max = /bits/ 16 <8000>;
> ti,y-min = /bits/ 16 <0>;
> diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
> index 1ce3ecb..400e421 100644
> --- a/drivers/input/touchscreen/ads7846.c
> +++ b/drivers/input/touchscreen/ads7846.c
> @@ -34,6 +34,7 @@
> #include <linux/spi/ads7846.h>
> #include <linux/regulator/consumer.h>
> #include <linux/module.h>
> +#include <linux/input/touchscreen.h>
> #include <asm/irq.h>
>
> /*
> @@ -109,8 +110,13 @@ struct ads7846 {
> u16 vref_delay_usecs;
> u16 x_plate_ohms;
> u16 pressure_max;
> + u16 x_min;
> + u16 x_max;
> + u16 y_min;
> + u16 y_max;
> +
> + struct touchscreen_properties prop;
>
> - bool swap_xy;
> bool use_internal;
>
> struct ads7846_packet *packet;
> @@ -825,22 +831,36 @@ static void ads7846_report_state(struct ads7846 *ts)
> */
> if (Rt) {
> struct input_dev *input = ts->input;
> + int sx, sy;
> +
> + dev_dbg(&ts->spi->dev,
> + "Raw point(%4d,%4d), pressure (%4u)\n",
> + x, y, Rt);
> +
> + /* scale ADC values to desired output range */
> + sx = (ts->prop.max_x * (x - ts->x_min))
> + / (ts->x_max - ts->x_min);
> + sy = (ts->prop.max_y * (y - ts->y_min))
> + / (ts->y_max - ts->y_min);
>
> - if (ts->swap_xy)
> - swap(x, y);
> + dev_dbg(&ts->spi->dev,
> + "Scaled point(%4d,%4d), pressure (%4u)\n",
> + sx, sy, Rt);
>
> + /* report event */
> 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(ts->input, &ts->prop,
> + (unsigned int) sx, (unsigned int) sy,
> + false);
> input_report_abs(input, ABS_PRESSURE, ts->pressure_max - Rt);
>
> input_sync(input);
> - dev_vdbg(&ts->spi->dev, "%4d/%4d/%4d\n", x, y, Rt);
> + dev_vdbg(&ts->spi->dev, "%4d/%4d/%4d\n", sx, sy, Rt);
> }
> }
>
> @@ -1212,6 +1232,8 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
> pdata->keep_vref_on = of_property_read_bool(node, "ti,keep-vref-on");
>
> pdata->swap_xy = of_property_read_bool(node, "ti,swap-xy");
> + if (pdata->swap_xy)
> + dev_notice(dev, "please update device tree to use touchscreen-swapped-x-y");
>
> of_property_read_u16(node, "ti,settle-delay-usec",
> &pdata->settle_delay_usecs);
> @@ -1315,7 +1337,6 @@ static int ads7846_probe(struct spi_device *spi)
> 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) {
> @@ -1355,18 +1376,35 @@ static int ads7846_probe(struct spi_device *spi)
> input_dev->dev.parent = &spi->dev;
>
> input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
> + input_dev->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |
> + BIT_MASK(ABS_PRESSURE);
> input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
> +
> + ts->x_min = pdata->x_min ? : 0;
> + ts->x_max = pdata->x_max ? : MAX_12BIT;
> + ts->y_min = pdata->y_min ? : 0;
> + ts->y_max = pdata->y_max ? : MAX_12BIT;
> +
> input_set_abs_params(input_dev, ABS_X,
> - pdata->x_min ? : 0,
> - pdata->x_max ? : MAX_12BIT,
> + ts->x_min,
> + ts->x_max,
> 0, 0);
> input_set_abs_params(input_dev, ABS_Y,
> - pdata->y_min ? : 0,
> - pdata->y_max ? : MAX_12BIT,
> + ts->y_min,
> + ts->y_max,
> 0, 0);
> input_set_abs_params(input_dev, ABS_PRESSURE,
> pdata->pressure_min, pdata->pressure_max, 0, 0);
>
> + if (spi->dev.of_node) {
> + input_abs_set_min(input_dev, ABS_X, 0);
> + input_abs_set_min(input_dev, ABS_Y, 0);
> +
> + touchscreen_parse_properties(ts->input, false, &ts->prop);
> + }
> +
> + ts->prop.swap_x_y |= pdata->swap_xy;
> +
> ads7846_setup_spi_msg(ts, pdata);
>
> ts->reg = regulator_get(&spi->dev, "vcc");
> --
> 2.7.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-09-23 22:50 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 12:41 [PATCH v3 0/8] drivers: touchscreen: tsc2007 and ads7846/tsc2046 improvements (use common touchscreen bindings, pre-calibration, spi fix and provide iio raw values) H. Nikolaus Schaller
2016-09-23 12:41 ` [PATCH v3 1/8] drivers:input:tsc2007: add new common binding names, pre-calibration, flipping and rotation H. Nikolaus Schaller
[not found] ` <1409ed9845f17445a8a67bd6fb16c902c3e4f69c.1474634475.git.hns-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2016-09-23 22:47 ` Rob Herring
2016-09-24 0:31 ` Sebastian Reichel
2016-09-24 5:55 ` H. Nikolaus Schaller
[not found] ` <E8C59C6C-23D4-4417-8A9E-3E9AE5D2D100-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2016-09-30 14:16 ` Sebastian Reichel
2016-09-30 14:40 ` H. Nikolaus Schaller
[not found] ` <29036A28-9997-4ED6-81FE-3ABC659EEEEB-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2016-10-17 13:57 ` H. Nikolaus Schaller
2016-09-24 5:28 ` H. Nikolaus Schaller
2016-09-30 16:23 ` [Letux-kernel] " Christ van Willegen
[not found] ` <CA+Ot1Owa_evu62LJpH+TdUkLWd0n+0Dm30Q1-5KFJ6w_UBPfQQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-30 16:36 ` H. Nikolaus Schaller
2016-09-23 12:41 ` [PATCH v3 2/8] drivers:input:tsc2007: send pendown and penup only once like ads7846(+tsc2046) driver does H. Nikolaus Schaller
[not found] ` <cover.1474634475.git.hns-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2016-09-23 12:41 ` [PATCH v3 3/8] drivers:input:tsc2007: add iio interface to read external ADC input, temperature and raw conversion values H. Nikolaus Schaller
[not found] ` <909d06d4f54359c7ac0dcf36a49cbd3ff7e8ebf2.1474634475.git.hns-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2016-09-24 16:07 ` Jonathan Cameron
2016-09-24 17:07 ` H. Nikolaus Schaller
[not found] ` <8A30B517-FE25-418B-9921-407243B0B72B-xXXSsgcRVICgSpxsJD1C4w@public.gmane.org>
2016-09-24 17:26 ` Jonathan Cameron
2016-09-24 17:42 ` H. Nikolaus Schaller
2016-09-24 17:44 ` Dmitry Torokhov
[not found] ` <CAKdAkRS3OhUp=WXtrLxQSJAvtgt24jo2W8Nw_NwR4O=R9jboaA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-24 17:51 ` H. Nikolaus Schaller
2016-09-23 12:41 ` [PATCH v3 5/8] DT:omap3+tsc2007: use new common touchscreen bindings H. Nikolaus Schaller
2016-09-23 12:41 ` [PATCH v3 4/8] drivers:input:tsc2007: check for presence and power down tsc2007 during probe H. Nikolaus Schaller
2016-09-23 12:41 ` [PATCH v3 6/8] drivers:input:ads7846(+tsc2046): add new common binding names, pre-calibration and flipping H. Nikolaus Schaller
2016-09-23 22:50 ` Rob Herring [this message]
2016-09-23 12:41 ` [PATCH v3 7/8] drivers:input:ads7846(+tsc2046): fix spi module table H. Nikolaus Schaller
2016-09-23 12:41 ` [PATCH v3 8/8] DT:omap3+ads7846: use new common touchscreen bindings H. Nikolaus Schaller
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=20160923225023.GA9994@rob-hp-laptop \
--to=robh@kernel.org \
--cc=afd@ti.com \
--cc=arnd@arndb.de \
--cc=bcousson@baylibre.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=grinberg@compulab.co.il \
--cc=hns@goldelico.com \
--cc=javier@osg.samsung.com \
--cc=letux-kernel@openphoenux.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=mika.penttila@nextfour.com \
--cc=mwelling@ieee.org \
--cc=sre@kernel.org \
--cc=tony@atomide.com \
/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