Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1490014 > unrolled thread
| Started by | "H. Nikolaus Schaller" <hns@goldelico.com> |
|---|---|
| First post | 2016-09-23 14:50 +0200 |
| Last post | 2016-09-24 01:00 +0200 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
[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" <hns@goldelico.com> - 2016-09-23 14:50 +0200
[PATCH v3 7/8] drivers:input:ads7846(+tsc2046): fix spi module table "H. Nikolaus Schaller" <hns@goldelico.com> - 2016-09-23 14:50 +0200
[PATCH v3 4/8] drivers:input:tsc2007: check for presence and power down tsc2007 during probe "H. Nikolaus Schaller" <hns@goldelico.com> - 2016-09-23 14:50 +0200
[PATCH v3 8/8] DT:omap3+ads7846: use new common touchscreen bindings "H. Nikolaus Schaller" <hns@goldelico.com> - 2016-09-23 14:50 +0200
[PATCH v3 6/8] drivers:input:ads7846(+tsc2046): add new common binding names, pre-calibration and flipping "H. Nikolaus Schaller" <hns@goldelico.com> - 2016-09-23 14:50 +0200
Re: [PATCH v3 6/8] drivers:input:ads7846(+tsc2046): add new common binding names, pre-calibration and flipping Rob Herring <robh@kernel.org> - 2016-09-24 01:00 +0200
| From | "H. Nikolaus Schaller" <hns@goldelico.com> |
|---|---|
| Date | 2016-09-23 14:50 +0200 |
| Subject | [PATCH v3 0/8] drivers: touchscreen: tsc2007 and ads7846/tsc2046 improvements (use common touchscreen bindings, pre-calibration, spi fix and provide iio raw values) |
| Message-ID | <sky5r-3Iu-7@gated-at.bofh.it> |
It was quite a while ago that this patch set was in review, but here is a new version for consideration.
Changes V3:
* fix an issue with swapping
* remove hard clipping to min/max rectangle - some systems expect to handle negative coordinates
* make use of commit ed7c9870c9bc ("Input: of_touchscreen - add support for inverted / swapped axes")
2015-11-13 21:36:07: Changes V2:
* add a patch to make drivers still recognise the old "ti,swap-xy" property (suggested by Rob Herring)
2015-11-06 16:14:53: This patch series improves the drivers for the tsc2007 and
ads7846/tsc2046 touchscreen controllers which are e.g. used by the GTA04
OpenPandora and Pyra devices.
New common bindings have been defined by
commit b98abe52fa8e ("Input: add common DT binding for touchscreens"):
Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
which also defines a helper function to parse the DT. These new parameters
allow to specify the fuzz factors (jitter suppression), inversion of x or y axis and
swapping of x and y to achieve inversion and rotation so that the touch
coordinate axes match the natural orientation of the display panel.
Another improvement is to better use the min/max ADC values and
scale to the screen size as defined by the DT. This allows to coarsely
calibrate the touch to match the LCD to which it is glued on so that the
touch can quite precisely be operated before any user-space fine-calibration
can be (and needs to be) started.
For the adc7846 we fix an issue with the spi module table.
Finally we add an iio interface for the AUX and temperature ADC channels of
the tsc2007 and also provide the touch screen raw values. This allows to read
an optional ambient light sensor installed on the gta04 board and improves
calibration and hardware monitoring.
H. Nikolaus Schaller (8):
drivers:input:tsc2007: add new common binding names, pre-calibration,
flipping and rotation
drivers:input:tsc2007: send pendown and penup only once like
ads7846(+tsc2046) driver does
drivers:input:tsc2007: add iio interface to read external ADC input,
temperature and raw conversion values
drivers:input:tsc2007: check for presence and power down tsc2007
during probe
DT:omap3+tsc2007: use new common touchscreen bindings
drivers:input:ads7846(+tsc2046): add new common binding names,
pre-calibration and flipping
drivers:input:ads7846(+tsc2046): fix spi module table
DT:omap3+ads7846: use new common touchscreen bindings
.../devicetree/bindings/input/ads7846.txt | 9 +-
.../bindings/input/touchscreen/tsc2007.txt | 20 +-
arch/arm/boot/dts/omap3-gta04.dtsi | 25 +-
arch/arm/boot/dts/omap3-lilly-a83x.dtsi | 2 +-
arch/arm/boot/dts/omap3-pandora-common.dtsi | 17 +-
.../boot/dts/omap3-panel-sharp-ls037v7dw01.dtsi | 3 +-
drivers/input/touchscreen/Kconfig | 1 +
drivers/input/touchscreen/ads7846.c | 71 +++++-
drivers/input/touchscreen/tsc2007.c | 281 +++++++++++++++++++--
include/linux/i2c/tsc2007.h | 8 +
10 files changed, 382 insertions(+), 55 deletions(-)
--
2.7.3
[toc] | [next] | [standalone]
| From | "H. Nikolaus Schaller" <hns@goldelico.com> |
|---|---|
| Date | 2016-09-23 14:50 +0200 |
| Subject | [PATCH v3 7/8] drivers:input:ads7846(+tsc2046): fix spi module table |
| Message-ID | <sky5r-3Iu-21@gated-at.bofh.it> |
| In reply to | #1490014 |
Fix module table so that the driver is loaded if compiled
as module and requested by DT.
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
drivers/input/touchscreen/ads7846.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 400e421..9a5d84d 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -1532,6 +1532,17 @@ static int ads7846_remove(struct spi_device *spi)
return 0;
}
+static const struct spi_device_id ads7846_idtable[] = {
+ { "tsc2046", 0 },
+ { "ads7843", 0 },
+ { "ads7845", 0 },
+ { "ads7846", 0 },
+ { "ads7873", 0 },
+ { }
+};
+
+MODULE_DEVICE_TABLE(spi, ads7846_idtable);
+
static struct spi_driver ads7846_driver = {
.driver = {
.name = "ads7846",
--
2.7.3
[toc] | [prev] | [next] | [standalone]
| From | "H. Nikolaus Schaller" <hns@goldelico.com> |
|---|---|
| Date | 2016-09-23 14:50 +0200 |
| Subject | [PATCH v3 4/8] drivers:input:tsc2007: check for presence and power down tsc2007 during probe |
| Message-ID | <sky5s-3Iu-25@gated-at.bofh.it> |
| In reply to | #1490014 |
1. check if chip is really present and don't succeed if it isn't.
2. if it succeeds, power down the chip until accessed
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
drivers/input/touchscreen/tsc2007.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 559cbc6..3ddc31e 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -657,6 +657,15 @@ static int tsc2007_probe(struct i2c_client *client,
tsc2007_stop(ts);
+ /* power down the chip (TSC2007_SETUP does not ACK on I2C) */
+ err = tsc2007_xfer(ts, PWRDOWN);
+ if (err < 0) {
+ dev_err(&client->dev,
+ "Failed to setup chip: %d\n", err);
+ iio_device_unregister(indio_dev);
+ return err; /* usually, chip does not respond */
+ }
+
err = input_register_device(input_dev);
if (err) {
dev_err(&client->dev,
--
2.7.3
[toc] | [prev] | [next] | [standalone]
| From | "H. Nikolaus Schaller" <hns@goldelico.com> |
|---|---|
| Date | 2016-09-23 14:50 +0200 |
| Subject | [PATCH v3 8/8] DT:omap3+ads7846: use new common touchscreen bindings |
| Message-ID | <sky5s-3Iu-29@gated-at.bofh.it> |
| In reply to | #1490014 |
The standard touch screen bindings [1] replace the private ti,swap-xy with touchscreen-swaped-x-y. And for the Openpandora we use touchscreen-size etc. to match the LCD screen size. [1]: Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt Tested with OpenPandora. Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com> --- arch/arm/boot/dts/omap3-lilly-a83x.dtsi | 2 +- arch/arm/boot/dts/omap3-pandora-common.dtsi | 17 +++++++++++++---- arch/arm/boot/dts/omap3-panel-sharp-ls037v7dw01.dtsi | 3 ++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/arm/boot/dts/omap3-lilly-a83x.dtsi b/arch/arm/boot/dts/omap3-lilly-a83x.dtsi index eff816e..af6b66c 100644 --- a/arch/arm/boot/dts/omap3-lilly-a83x.dtsi +++ b/arch/arm/boot/dts/omap3-lilly-a83x.dtsi @@ -325,7 +325,7 @@ ti,y-max = /bits/ 16 <3600>; ti,x-plate-ohms = /bits/ 16 <80>; ti,pressure-max = /bits/ 16 <255>; - ti,swap-xy; + touchscreen-swapped-x-y; wakeup-source; }; diff --git a/arch/arm/boot/dts/omap3-pandora-common.dtsi b/arch/arm/boot/dts/omap3-pandora-common.dtsi index cbc47af..f66a2b4 100644 --- a/arch/arm/boot/dts/omap3-pandora-common.dtsi +++ b/arch/arm/boot/dts/omap3-pandora-common.dtsi @@ -700,10 +700,19 @@ pendown-gpio = <&gpio3 30 GPIO_ACTIVE_HIGH>; vcc-supply = <&vaux4>; - ti,x-min = /bits/ 16 <0>; - ti,x-max = /bits/ 16 <8000>; - ti,y-min = /bits/ 16 <0>; - ti,y-max = /bits/ 16 <4800>; + touchscreen-size-x = <800>; + touchscreen-size-y = <480>; + touchscreen-max-pressure = <1000>; + touchscreen-fuzz-x = <16>; + touchscreen-fuzz-y = <16>; + touchscreen-fuzz-pressure = <10>; + touchscreen-inverted-x; + touchscreen-inverted-y; + + ti,x-min = /bits/ 16 <160>; + ti,x-max = /bits/ 16 <3900>; + ti,y-min = /bits/ 16 <220>; + ti,y-max = /bits/ 16 <3750>; ti,x-plate-ohms = /bits/ 16 <40>; ti,pressure-max = /bits/ 16 <255>; diff --git a/arch/arm/boot/dts/omap3-panel-sharp-ls037v7dw01.dtsi b/arch/arm/boot/dts/omap3-panel-sharp-ls037v7dw01.dtsi index 157345b..3627a63 100644 --- a/arch/arm/boot/dts/omap3-panel-sharp-ls037v7dw01.dtsi +++ b/arch/arm/boot/dts/omap3-panel-sharp-ls037v7dw01.dtsi @@ -66,6 +66,7 @@ ti,x-plate-ohms = /bits/ 16 <40>; ti,pressure-max = /bits/ 16 <255>; ti,swap-xy; - wakeup-source; + touchscreen-swapped-x-y; + linux,wakeup; }; }; -- 2.7.3
[toc] | [prev] | [next] | [standalone]
| From | "H. Nikolaus Schaller" <hns@goldelico.com> |
|---|---|
| Date | 2016-09-23 14:50 +0200 |
| Subject | [PATCH v3 6/8] drivers:input:ads7846(+tsc2046): add new common binding names, pre-calibration and flipping |
| Message-ID | <sky5s-3Iu-31@gated-at.bofh.it> |
| In reply to | #1490014 |
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.
[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
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh@kernel.org> |
|---|---|
| Date | 2016-09-24 01:00 +0200 |
| Subject | Re: [PATCH v3 6/8] drivers:input:ads7846(+tsc2046): add new common binding names, pre-calibration and flipping |
| Message-ID | <skHBL-1nK-5@gated-at.bofh.it> |
| In reply to | #1490020 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web