All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] ads7846: fix support for ADS7845
@ 2022-08-12  8:42 Luca Ellero
  2022-08-12  8:42 ` [PATCH v3 1/3] ads7846: don't report pressure for ads7845 Luca Ellero
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luca Ellero @ 2022-08-12  8:42 UTC (permalink / raw)
  To: dmitry.torokhov, daniel, m.felsch, andriy.shevchenko,
	u.kleine-koenig, mkl, miquel.raynal, imre.deak, luca.ellero
  Cc: linux-input, linux-kernel, Luca Ellero

ADS7845 support is buggy in this driver.
These patches fix various issues to get it work properly.

Changes for v2:
 - add missing period in patch 0001 message
 - elaborate comment in patch 0002
 
Changes for v3:
 - send from the same email address of "Signed-off"

Luca Ellero (3):
  ads7846: don't report pressure for ads7845
  ads7846: always set last command to PWRDOWN
  ads7846: don't check penirq immediately for 7845

 drivers/input/touchscreen/ads7846.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/3] ads7846: don't report pressure for ads7845
  2022-08-12  8:42 [PATCH v3 0/3] ads7846: fix support for ADS7845 Luca Ellero
@ 2022-08-12  8:42 ` Luca Ellero
  2022-08-12  8:42 ` [PATCH v3 2/3] ads7846: always set last command to PWRDOWN Luca Ellero
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luca Ellero @ 2022-08-12  8:42 UTC (permalink / raw)
  To: dmitry.torokhov, daniel, m.felsch, andriy.shevchenko,
	u.kleine-koenig, mkl, miquel.raynal, imre.deak, luca.ellero
  Cc: linux-input, linux-kernel, Luca Ellero

ADS7845 doesn't support pressure.
This patch avoids the following error reported by libinput-list-devices:
"ADS7845 Touchscreen: kernel bug: device has min == max on ABS_PRESSURE".

Signed-off-by: Luca Ellero <l.ellero@asem.it>
---
 drivers/input/touchscreen/ads7846.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index bed68a68f330..24605c40d039 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -1316,8 +1316,9 @@ static int ads7846_probe(struct spi_device *spi)
 			pdata->y_min ? : 0,
 			pdata->y_max ? : MAX_12BIT,
 			0, 0);
-	input_set_abs_params(input_dev, ABS_PRESSURE,
-			pdata->pressure_min, pdata->pressure_max, 0, 0);
+	if (ts->model != 7845)
+		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
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/3] ads7846: always set last command to PWRDOWN
  2022-08-12  8:42 [PATCH v3 0/3] ads7846: fix support for ADS7845 Luca Ellero
  2022-08-12  8:42 ` [PATCH v3 1/3] ads7846: don't report pressure for ads7845 Luca Ellero
@ 2022-08-12  8:42 ` Luca Ellero
  2022-08-12  8:42 ` [PATCH v3 3/3] ads7846: don't check penirq immediately for 7845 Luca Ellero
  2022-08-23 14:26 ` [PATCH v3 0/3] ads7846: fix support for ADS7845 Andy Shevchenko
  3 siblings, 0 replies; 5+ messages in thread
From: Luca Ellero @ 2022-08-12  8:42 UTC (permalink / raw)
  To: dmitry.torokhov, daniel, m.felsch, andriy.shevchenko,
	u.kleine-koenig, mkl, miquel.raynal, imre.deak, luca.ellero
  Cc: linux-input, linux-kernel, Luca Ellero

Controllers that report pressure (e.g. ADS7846) use 5 commands and the
correct sequence is READ_X, READ_Y, READ_Z1, READ_Z2, PWRDOWN.

Controllers that don't report pressure (e.g. ADS7845/ADS7843) use only 3
commands and the correct sequence should be READ_X, READ_Y, PWRDOWN. But
the sequence sent was incorrect: READ_X, READ_Y, READ_Z1.

This patch fixes it.

Signed-off-by: Luca Ellero <l.ellero@asem.it>
---
 drivers/input/touchscreen/ads7846.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 24605c40d039..9e15cdf6faa0 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -1066,6 +1066,9 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts,
 		struct ads7846_buf_layout *l = &packet->l[cmd_idx];
 		unsigned int max_count;
 
+		if (cmd_idx == packet->cmds - 1)
+			cmd_idx = ADS7846_PWDOWN;
+
 		if (ads7846_cmd_need_settle(cmd_idx))
 			max_count = packet->count + packet->count_skip;
 		else
@@ -1102,7 +1105,12 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts,
 
 	for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) {
 		struct ads7846_buf_layout *l = &packet->l[cmd_idx];
-		u8 cmd = ads7846_get_cmd(cmd_idx, vref);
+		u8 cmd;
+
+		if (cmd_idx == packet->cmds - 1)
+			cmd_idx = ADS7846_PWDOWN;
+
+		cmd = ads7846_get_cmd(cmd_idx, vref);
 
 		for (b = 0; b < l->count; b++)
 			packet->tx[l->offset + b].cmd = cmd;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 3/3] ads7846: don't check penirq immediately for 7845
  2022-08-12  8:42 [PATCH v3 0/3] ads7846: fix support for ADS7845 Luca Ellero
  2022-08-12  8:42 ` [PATCH v3 1/3] ads7846: don't report pressure for ads7845 Luca Ellero
  2022-08-12  8:42 ` [PATCH v3 2/3] ads7846: always set last command to PWRDOWN Luca Ellero
@ 2022-08-12  8:42 ` Luca Ellero
  2022-08-23 14:26 ` [PATCH v3 0/3] ads7846: fix support for ADS7845 Andy Shevchenko
  3 siblings, 0 replies; 5+ messages in thread
From: Luca Ellero @ 2022-08-12  8:42 UTC (permalink / raw)
  To: dmitry.torokhov, daniel, m.felsch, andriy.shevchenko,
	u.kleine-koenig, mkl, miquel.raynal, imre.deak, luca.ellero
  Cc: linux-input, linux-kernel, Luca Ellero

To discard false readings, one should use "ti,penirq-recheck-delay-usecs".
Checking get_pendown_state() at the beginning, most of the time fails
causing malfunctioning.

Signed-off-by: Luca Ellero <l.ellero@asem.it>
---
 drivers/input/touchscreen/ads7846.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 9e15cdf6faa0..122d3a13b7c5 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -843,14 +843,8 @@ static void ads7846_report_state(struct ads7846 *ts)
 	if (x == MAX_12BIT)
 		x = 0;
 
-	if (ts->model == 7843) {
+	if (ts->model == 7843 || ts->model == 7845) {
 		Rt = ts->pressure_max / 2;
-	} else if (ts->model == 7845) {
-		if (get_pendown_state(ts))
-			Rt = ts->pressure_max / 2;
-		else
-			Rt = 0;
-		dev_vdbg(&ts->spi->dev, "x/y: %d/%d, PD %d\n", x, y, Rt);
 	} else if (likely(x && z1)) {
 		/* compute touch pressure resistance using equation #2 */
 		Rt = z2;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 0/3] ads7846: fix support for ADS7845
  2022-08-12  8:42 [PATCH v3 0/3] ads7846: fix support for ADS7845 Luca Ellero
                   ` (2 preceding siblings ...)
  2022-08-12  8:42 ` [PATCH v3 3/3] ads7846: don't check penirq immediately for 7845 Luca Ellero
@ 2022-08-23 14:26 ` Andy Shevchenko
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-08-23 14:26 UTC (permalink / raw)
  To: Luca Ellero
  Cc: dmitry.torokhov, daniel, m.felsch, u.kleine-koenig, mkl,
	miquel.raynal, imre.deak, luca.ellero, linux-input, linux-kernel

On Fri, Aug 12, 2022 at 10:42:45AM +0200, Luca Ellero wrote:
> ADS7845 support is buggy in this driver.
> These patches fix various issues to get it work properly.

Don't remember if I given a tag already (note, it's contributor's
responsibility to carry tags if received), so here it is:

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Changes for v2:
>  - add missing period in patch 0001 message
>  - elaborate comment in patch 0002
>  
> Changes for v3:
>  - send from the same email address of "Signed-off"
> 
> Luca Ellero (3):
>   ads7846: don't report pressure for ads7845
>   ads7846: always set last command to PWRDOWN
>   ads7846: don't check penirq immediately for 7845
> 
>  drivers/input/touchscreen/ads7846.c | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> -- 
> 2.25.1
> 

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-23 16:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12  8:42 [PATCH v3 0/3] ads7846: fix support for ADS7845 Luca Ellero
2022-08-12  8:42 ` [PATCH v3 1/3] ads7846: don't report pressure for ads7845 Luca Ellero
2022-08-12  8:42 ` [PATCH v3 2/3] ads7846: always set last command to PWRDOWN Luca Ellero
2022-08-12  8:42 ` [PATCH v3 3/3] ads7846: don't check penirq immediately for 7845 Luca Ellero
2022-08-23 14:26 ` [PATCH v3 0/3] ads7846: fix support for ADS7845 Andy Shevchenko

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.