Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1584738 > unrolled thread

[PATCH 0/3] Fix tsc2007 to report ABS_PRESSURE correctly

Started by"H. Nikolaus Schaller" <hns@goldelico.com>
First post2017-02-20 18:00 +0100
Last post2017-02-23 09:50 +0100
Articles 7 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/3] Fix tsc2007 to report ABS_PRESSURE correctly "H. Nikolaus Schaller" <hns@goldelico.com> - 2017-02-20 18:00 +0100
    [PATCH 3/3] Input: tsc2007 - add a property "ti,report-resistance" to restore the old pressure reporting state if needed. "H. Nikolaus Schaller" <hns@goldelico.com> - 2017-02-20 18:00 +0100
      Re: [PATCH 3/3] Input: tsc2007 - add a property  "ti,report-resistance" to restore the old pressure reporting state if  needed. Pavel Machek <pavel@ucw.cz> - 2017-02-21 12:10 +0100
        Re: [PATCH 3/3] Input: tsc2007 - add a property "ti,report-resistance" to restore the old pressure reporting state if needed. "H. Nikolaus Schaller" <hns@goldelico.com> - 2017-02-21 12:50 +0100
          Re: [PATCH 3/3] Input: tsc2007 - add a property  "ti,report-resistance" to restore the old pressure reporting state if  needed. Sebastian Reichel <sre@kernel.org> - 2017-02-21 18:30 +0100
    [PATCH 1/3] Input: tsc2007 - rename function tsc2007_calculate_pressure to tsc2007_calculate_resistance because that is what it does "H. Nikolaus Schaller" <hns@goldelico.com> - 2017-02-20 18:00 +0100
      Re: [PATCH 1/3] Input: tsc2007 - rename function  tsc2007_calculate_pressure to tsc2007_calculate_resistance because that is  what it does Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-02-23 09:50 +0100

#1584738 — [PATCH 0/3] Fix tsc2007 to report ABS_PRESSURE correctly

From"H. Nikolaus Schaller" <hns@goldelico.com>
Date2017-02-20 18:00 +0100
Subject[PATCH 0/3] Fix tsc2007 to report ABS_PRESSURE correctly
Message-ID<tcZtE-7aS-13@gated-at.bofh.it>
tsc2007 reports the touch resistance as ABS_PRESSURE, which jumps
to its maximum for light touch and goes down for increasing pressure.
This is not consistent with other touch drivers and not what one would
expect.

Additionally the name of the function tsc2007_calculate_pressure()
is misleading since the formula calculates an estimate for the touch
screen resistance. So it is renamed without changing the function.

While this patch changes the values reported to userspace,
ABS_PRESSURE is used rarely by userspace. Most software only
relies on BTN_TOUCH (boolean), which is not affected by this
patch. Some graphics software makes use of the interface and
does not work correctly with the currently used inverted
behaviour.

Note: this patch series assumes to be merged after

	"Input: tsc2007 - add iio interface to read external ADC input and temperature"

because that one renames tsc2007.c to tsc2007_core.c

H. Nikolaus Schaller (3):
  Input: tsc2007 - rename function tsc2007_calculate_pressure to
    tsc2007_calculate_resistance     because that is what it does
  Input: tsc2007 - correctly report pressure and not resistance to user
    space
  Input: tsc2007 - add a property "ti,report-resistance" to restore the
    old pressure reporting state     if needed.

 .../devicetree/bindings/input/touchscreen/tsc2007.txt      |  2 ++
 drivers/input/touchscreen/tsc2007.h                        |  1 +
 drivers/input/touchscreen/tsc2007_core.c                   | 14 ++++++++++----
 3 files changed, 13 insertions(+), 4 deletions(-)

-- 
2.7.3

[toc] | [next] | [standalone]


#1584743 — [PATCH 3/3] Input: tsc2007 - add a property "ti,report-resistance" to restore the old pressure reporting state if needed.

From"H. Nikolaus Schaller" <hns@goldelico.com>
Date2017-02-20 18:00 +0100
Subject[PATCH 3/3] Input: tsc2007 - add a property "ti,report-resistance" to restore the old pressure reporting state if needed.
Message-ID<tcZtE-7aS-31@gated-at.bofh.it>
In reply to#1584738
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt | 2 ++
 drivers/input/touchscreen/tsc2007.h                             | 1 +
 drivers/input/touchscreen/tsc2007_core.c                        | 6 +++++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
index ec365e1..9b686af 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
@@ -14,6 +14,8 @@ Optional properties:
 - interrupts: (gpio) interrupt to which the chip is connected
   (see interrupt binding[0]).
 - ti,max-rt: maximum pressure.
+- ti,report-resistance: report resistance (no pressure = max_rt) instead
+  of pressure (no pressure = 0).
 - 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.
diff --git a/drivers/input/touchscreen/tsc2007.h b/drivers/input/touchscreen/tsc2007.h
index 474bd29..81baabb 100644
--- a/drivers/input/touchscreen/tsc2007.h
+++ b/drivers/input/touchscreen/tsc2007.h
@@ -66,6 +66,7 @@ struct tsc2007 {
 
 	u16			model;
 	u16			x_plate_ohms;
+	bool			report_resistance;
 	u16			max_rt;
 	unsigned long		poll_period; /* in jiffies */
 	int			fuzzx;
diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
index fc73849..984710f 100644
--- a/drivers/input/touchscreen/tsc2007_core.c
+++ b/drivers/input/touchscreen/tsc2007_core.c
@@ -141,7 +141,8 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
 				"DOWN point(%4d,%4d), resistance (%4u)\n",
 				tc.x, tc.y, rt);
 
-			rt = ts->max_rt - rt;
+			if (!ts->report_resistance)
+				rt = ts->max_rt - rt;
 
 			input_report_key(input, BTN_TOUCH, 1);
 			input_report_abs(input, ABS_X, tc.x);
@@ -248,6 +249,9 @@ static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts)
 	else
 		ts->max_rt = MAX_12BIT;
 
+	ts->report_resistance =
+		of_property_read_bool(np, "ti,report-resistance");
+
 	if (!of_property_read_u32(np, "ti,fuzzx", &val32))
 		ts->fuzzx = val32;
 
-- 
2.7.3

[toc] | [prev] | [next] | [standalone]


#1585226 — Re: [PATCH 3/3] Input: tsc2007 - add a property "ti,report-resistance" to restore the old pressure reporting state if needed.

FromPavel Machek <pavel@ucw.cz>
Date2017-02-21 12:10 +0100
SubjectRe: [PATCH 3/3] Input: tsc2007 - add a property "ti,report-resistance" to restore the old pressure reporting state if needed.
Message-ID<tdguu-1L2-31@gated-at.bofh.it>
In reply to#1584743

[Multipart message — attachments visible in raw view] — view raw

On Mon 2017-02-20 17:56:36, H. Nikolaus Schaller wrote:
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>

No. device tree is for hardware description, not kernel configuration.

									Pavel
									
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[toc] | [prev] | [next] | [standalone]


#1585243 — Re: [PATCH 3/3] Input: tsc2007 - add a property "ti,report-resistance" to restore the old pressure reporting state if needed.

From"H. Nikolaus Schaller" <hns@goldelico.com>
Date2017-02-21 12:50 +0100
SubjectRe: [PATCH 3/3] Input: tsc2007 - add a property "ti,report-resistance" to restore the old pressure reporting state if needed.
Message-ID<tdh7c-21y-15@gated-at.bofh.it>
In reply to#1585226

[Multipart message — attachments visible in raw view] — view raw

Hi Pavel,

> Am 21.02.2017 um 12:07 schrieb Pavel Machek <pavel@ucw.cz>:
> 
> On Mon 2017-02-20 17:56:36, H. Nikolaus Schaller wrote:
>> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> 
> No. device tree is for hardware description, not kernel configuration.

Yes, I agree. A new Kernel CONFIG would be better in this case.
I just did copy&paste from the old patch set without thinking that far.

Would

CONFIG_TSC2007_REPORT_RAW_RESISTANCE_AS_PRESSURE

be ok?

BR and thanks,
Nikolaus

[toc] | [prev] | [next] | [standalone]


#1585556 — Re: [PATCH 3/3] Input: tsc2007 - add a property "ti,report-resistance" to restore the old pressure reporting state if needed.

FromSebastian Reichel <sre@kernel.org>
Date2017-02-21 18:30 +0100
SubjectRe: [PATCH 3/3] Input: tsc2007 - add a property "ti,report-resistance" to restore the old pressure reporting state if needed.
Message-ID<tdmqe-5F2-23@gated-at.bofh.it>
In reply to#1585243

[Multipart message — attachments visible in raw view] — view raw

Hi,

On Tue, Feb 21, 2017 at 12:43:28PM +0100, H. Nikolaus Schaller wrote:
> > Am 21.02.2017 um 12:07 schrieb Pavel Machek <pavel@ucw.cz>:
> > On Mon 2017-02-20 17:56:36, H. Nikolaus Schaller wrote:
> >> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> > 
> > No. device tree is for hardware description, not kernel configuration.
> 
> Yes, I agree. A new Kernel CONFIG would be better in this case.
> I just did copy&paste from the old patch set without thinking that far.
> 
> Would
> 
> CONFIG_TSC2007_REPORT_RAW_RESISTANCE_AS_PRESSURE
> 
> be ok?

I guess either a CONFIG or a module parameter may be used to provide
the previous (broken) behaviour. I suggest to ignore the problem
until its reported, though. There is a high chance, that nobody will
notice the change at all / nobody needs the compat layer.

-- Sebastian

[toc] | [prev] | [next] | [standalone]


#1584750 — [PATCH 1/3] Input: tsc2007 - rename function tsc2007_calculate_pressure to tsc2007_calculate_resistance because that is what it does

From"H. Nikolaus Schaller" <hns@goldelico.com>
Date2017-02-20 18:00 +0100
Subject[PATCH 1/3] Input: tsc2007 - rename function tsc2007_calculate_pressure to tsc2007_calculate_resistance because that is what it does
Message-ID<tcZtF-7aS-55@gated-at.bofh.it>
In reply to#1584738
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/input/touchscreen/tsc2007_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
index 98dbefc..30b53ca 100644
--- a/drivers/input/touchscreen/tsc2007_core.c
+++ b/drivers/input/touchscreen/tsc2007_core.c
@@ -68,7 +68,7 @@ static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
 	tsc2007_xfer(tsc, PWRDOWN);
 }
 
-u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc)
+u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)
 {
 	u32 rt = 0;
 
@@ -77,7 +77,7 @@ u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc)
 		tc->x = 0;
 
 	if (likely(tc->x && tc->z1)) {
-		/* compute touch pressure resistance using equation #1 */
+		/* compute touch resistance using equation #1 */
 		rt = tc->z2 - tc->z1;
 		rt *= tc->x;
 		rt *= tsc->x_plate_ohms;
@@ -125,7 +125,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
 		tsc2007_read_values(ts, &tc);
 		mutex_unlock(&ts->mlock);
 
-		rt = tsc2007_calculate_pressure(ts, &tc);
+		rt = tsc2007_calculate_resistance(ts, &tc);
 
 		if (!rt && !ts->get_pendown_state) {
 			/*
@@ -138,7 +138,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
 
 		if (rt <= ts->max_rt) {
 			dev_dbg(&ts->client->dev,
-				"DOWN point(%4d,%4d), pressure (%4u)\n",
+				"DOWN point(%4d,%4d), resistance (%4u)\n",
 				tc.x, tc.y, rt);
 
 			input_report_key(input, BTN_TOUCH, 1);
-- 
2.7.3

[toc] | [prev] | [next] | [standalone]


#1586741 — Re: [PATCH 1/3] Input: tsc2007 - rename function tsc2007_calculate_pressure to tsc2007_calculate_resistance because that is what it does

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-02-23 09:50 +0100
SubjectRe: [PATCH 1/3] Input: tsc2007 - rename function tsc2007_calculate_pressure to tsc2007_calculate_resistance because that is what it does
Message-ID<tdXg6-7i8-15@gated-at.bofh.it>
In reply to#1584750
On Mon, Feb 20, 2017 at 05:56:34PM +0100, H. Nikolaus Schaller wrote:
>p Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>

Applied, thank you.

> ---
>  drivers/input/touchscreen/tsc2007_core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/tsc2007_core.c b/drivers/input/touchscreen/tsc2007_core.c
> index 98dbefc..30b53ca 100644
> --- a/drivers/input/touchscreen/tsc2007_core.c
> +++ b/drivers/input/touchscreen/tsc2007_core.c
> @@ -68,7 +68,7 @@ static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
>  	tsc2007_xfer(tsc, PWRDOWN);
>  }
>  
> -u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc)
> +u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)
>  {
>  	u32 rt = 0;
>  
> @@ -77,7 +77,7 @@ u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc)
>  		tc->x = 0;
>  
>  	if (likely(tc->x && tc->z1)) {
> -		/* compute touch pressure resistance using equation #1 */
> +		/* compute touch resistance using equation #1 */
>  		rt = tc->z2 - tc->z1;
>  		rt *= tc->x;
>  		rt *= tsc->x_plate_ohms;
> @@ -125,7 +125,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
>  		tsc2007_read_values(ts, &tc);
>  		mutex_unlock(&ts->mlock);
>  
> -		rt = tsc2007_calculate_pressure(ts, &tc);
> +		rt = tsc2007_calculate_resistance(ts, &tc);
>  
>  		if (!rt && !ts->get_pendown_state) {
>  			/*
> @@ -138,7 +138,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
>  
>  		if (rt <= ts->max_rt) {
>  			dev_dbg(&ts->client->dev,
> -				"DOWN point(%4d,%4d), pressure (%4u)\n",
> +				"DOWN point(%4d,%4d), resistance (%4u)\n",
>  				tc.x, tc.y, rt);
>  
>  			input_report_key(input, BTN_TOUCH, 1);
> -- 
> 2.7.3
> 

-- 
Dmitry

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web