All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Geis <pgwipeout@gmail.com>
To: alistair@alistair23.me
Cc: alistair23@gmail.com, andreas@kemnade.info,
	devicetree@vger.kernel.org, dmitry.torokhov@gmail.com,
	linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	maxime.ripard@bootlin.com, mylene.josserand@bootlin.com,
	robh+dt@kernel.org, rydberg@bitmath.org,
	Peter Geis <pgwipeout@gmail.com>
Subject: Re: [PATCH v5 1/4] Input: Add driver for Cypress Generation 5 touchscreen
Date: Tue, 18 Jan 2022 20:26:37 -0500	[thread overview]
Message-ID: <20220119012637.1713748-1-pgwipeout@gmail.com> (raw)
In-Reply-To: <20220109115331.388633-2-alistair@alistair23.me>

Good Evening,

I tried using this with a cypress tma448 and thought there was an issue
with the driver.
Further investigation found the tma448 in question had no configuration
burned into it, thus max size and pressure are zero.

I've added the patch below to extend the driver with device tree
overrides.
Unfortunately device_property_read_u16 is broken on arm64 currently, as
it returns zero.

Also, with this patch, the driver works spectacularly on my broken touch
screen.
As such-
Tested-by: Peter Geis <pgwipeout@gmail.com>

[PATCH] Input: cyttsp5: support touchscreen device tree overrides

It is possible for the cyttsp5 chip to not have a configuration burned
to it.
This leads to a sitatuion where all calibration values return zero,
leading to a broken touchscreen configuration.

The current driver does not support utilizing overrides from the device
tree.
Extend the driver to support this, and permit it to do some basic sanity
checking of the values for the touchscreen and abort if they are
invalid.

Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
 drivers/input/touchscreen/cyttsp5.c | 62 ++++++++++++++++++++++++++---
 1 file changed, 57 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp5.c b/drivers/input/touchscreen/cyttsp5.c
index 3ac45108090c..e837985d199a 100644
--- a/drivers/input/touchscreen/cyttsp5.c
+++ b/drivers/input/touchscreen/cyttsp5.c
@@ -507,15 +507,66 @@ static int cyttsp5_get_sysinfo_regs(struct cyttsp5 *ts)
 	struct cyttsp5_sensing_conf_data_dev *scd_dev =
 		(struct cyttsp5_sensing_conf_data_dev *)
 		&ts->response_buf[HID_SYSINFO_SENSING_OFFSET];
+	u32 tmp;
 
 	cyttsp5_si_get_btn_data(ts);
 
 	scd->max_tch = scd_dev->max_num_of_tch_per_refresh_cycle;
-	scd->res_x = get_unaligned_le16(&scd_dev->res_x);
-	scd->res_y = get_unaligned_le16(&scd_dev->res_y);
-	scd->max_z = get_unaligned_le16(&scd_dev->max_z);
-	scd->len_x = get_unaligned_le16(&scd_dev->len_x);
-	scd->len_y = get_unaligned_le16(&scd_dev->len_y);
+
+	if (scd->max_tch == 0) {
+		dev_dbg(ts->dev, "Max touch points cannot be zero\n");
+		scd->max_tch = 2;
+	}
+
+	if(device_property_read_u32(ts->dev, "touchscreen-size-x", &tmp))
+		scd->res_x = get_unaligned_le16(&scd_dev->res_x);
+	else
+		scd->res_x = tmp;
+
+	if (scd->res_x == 0) {
+		dev_err(ts->dev, "ABS_X cannot be zero\n");
+		return -ENODATA;
+	}
+
+	if(device_property_read_u32(ts->dev, "touchscreen-size-y", &tmp))
+		scd->res_y = get_unaligned_le16(&scd_dev->res_y);
+	else
+		scd->res_y = tmp;
+
+	if (scd->res_y == 0) {
+		dev_err(ts->dev, "ABS_Y cannot be zero\n");
+		return -ENODATA;
+	}
+
+	if(device_property_read_u32(ts->dev, "touchscreen-max-pressure", &tmp))
+		scd->max_z = get_unaligned_le16(&scd_dev->max_z);
+	else
+		scd->max_z = tmp;
+
+	if (scd->max_z == 0) {
+		dev_err(ts->dev, "ABS_PRESSURE cannot be zero\n");
+		return -ENODATA;
+	}
+
+	if(device_property_read_u32(ts->dev, "touchscreen-x-mm", &tmp))
+		scd->len_x = get_unaligned_le16(&scd_dev->len_x);
+	else
+		scd->len_x = tmp;
+
+	if (scd->len_x == 0) {
+		dev_dbg(ts->dev, "Touchscreen size x cannot be zero\n");
+		scd->len_x = scd->res_x + 1;
+	}
+
+	if(device_property_read_u32(ts->dev, "touchscreen-y-mm", &tmp))
+		scd->len_y = get_unaligned_le16(&scd_dev->len_y);
+	else
+		scd->len_y = tmp;
+
+	if (scd->len_y == 0) {
+		dev_dbg(ts->dev, "Touchscreen size y cannot be zero\n");
+		scd->len_y = scd->res_y + 1;
+	}
 
 	return 0;
 }
@@ -877,6 +928,7 @@ static int cyttsp5_i2c_probe(struct i2c_client *client,
 
 static const struct of_device_id cyttsp5_of_match[] = {
 	{ .compatible = "cypress,tt21000", },
+	{ .compatible = "cypress,tma448", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, cyttsp5_of_match);
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Peter Geis <pgwipeout@gmail.com>
To: alistair@alistair23.me
Cc: alistair23@gmail.com, andreas@kemnade.info,
	devicetree@vger.kernel.org, dmitry.torokhov@gmail.com,
	linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	maxime.ripard@bootlin.com, mylene.josserand@bootlin.com,
	robh+dt@kernel.org, rydberg@bitmath.org,
	Peter Geis <pgwipeout@gmail.com>
Subject: Re: [PATCH v5 1/4] Input: Add driver for Cypress Generation 5 touchscreen
Date: Tue, 18 Jan 2022 20:26:37 -0500	[thread overview]
Message-ID: <20220119012637.1713748-1-pgwipeout@gmail.com> (raw)
In-Reply-To: <20220109115331.388633-2-alistair@alistair23.me>

Good Evening,

I tried using this with a cypress tma448 and thought there was an issue
with the driver.
Further investigation found the tma448 in question had no configuration
burned into it, thus max size and pressure are zero.

I've added the patch below to extend the driver with device tree
overrides.
Unfortunately device_property_read_u16 is broken on arm64 currently, as
it returns zero.

Also, with this patch, the driver works spectacularly on my broken touch
screen.
As such-
Tested-by: Peter Geis <pgwipeout@gmail.com>

[PATCH] Input: cyttsp5: support touchscreen device tree overrides

It is possible for the cyttsp5 chip to not have a configuration burned
to it.
This leads to a sitatuion where all calibration values return zero,
leading to a broken touchscreen configuration.

The current driver does not support utilizing overrides from the device
tree.
Extend the driver to support this, and permit it to do some basic sanity
checking of the values for the touchscreen and abort if they are
invalid.

Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
 drivers/input/touchscreen/cyttsp5.c | 62 ++++++++++++++++++++++++++---
 1 file changed, 57 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp5.c b/drivers/input/touchscreen/cyttsp5.c
index 3ac45108090c..e837985d199a 100644
--- a/drivers/input/touchscreen/cyttsp5.c
+++ b/drivers/input/touchscreen/cyttsp5.c
@@ -507,15 +507,66 @@ static int cyttsp5_get_sysinfo_regs(struct cyttsp5 *ts)
 	struct cyttsp5_sensing_conf_data_dev *scd_dev =
 		(struct cyttsp5_sensing_conf_data_dev *)
 		&ts->response_buf[HID_SYSINFO_SENSING_OFFSET];
+	u32 tmp;
 
 	cyttsp5_si_get_btn_data(ts);
 
 	scd->max_tch = scd_dev->max_num_of_tch_per_refresh_cycle;
-	scd->res_x = get_unaligned_le16(&scd_dev->res_x);
-	scd->res_y = get_unaligned_le16(&scd_dev->res_y);
-	scd->max_z = get_unaligned_le16(&scd_dev->max_z);
-	scd->len_x = get_unaligned_le16(&scd_dev->len_x);
-	scd->len_y = get_unaligned_le16(&scd_dev->len_y);
+
+	if (scd->max_tch == 0) {
+		dev_dbg(ts->dev, "Max touch points cannot be zero\n");
+		scd->max_tch = 2;
+	}
+
+	if(device_property_read_u32(ts->dev, "touchscreen-size-x", &tmp))
+		scd->res_x = get_unaligned_le16(&scd_dev->res_x);
+	else
+		scd->res_x = tmp;
+
+	if (scd->res_x == 0) {
+		dev_err(ts->dev, "ABS_X cannot be zero\n");
+		return -ENODATA;
+	}
+
+	if(device_property_read_u32(ts->dev, "touchscreen-size-y", &tmp))
+		scd->res_y = get_unaligned_le16(&scd_dev->res_y);
+	else
+		scd->res_y = tmp;
+
+	if (scd->res_y == 0) {
+		dev_err(ts->dev, "ABS_Y cannot be zero\n");
+		return -ENODATA;
+	}
+
+	if(device_property_read_u32(ts->dev, "touchscreen-max-pressure", &tmp))
+		scd->max_z = get_unaligned_le16(&scd_dev->max_z);
+	else
+		scd->max_z = tmp;
+
+	if (scd->max_z == 0) {
+		dev_err(ts->dev, "ABS_PRESSURE cannot be zero\n");
+		return -ENODATA;
+	}
+
+	if(device_property_read_u32(ts->dev, "touchscreen-x-mm", &tmp))
+		scd->len_x = get_unaligned_le16(&scd_dev->len_x);
+	else
+		scd->len_x = tmp;
+
+	if (scd->len_x == 0) {
+		dev_dbg(ts->dev, "Touchscreen size x cannot be zero\n");
+		scd->len_x = scd->res_x + 1;
+	}
+
+	if(device_property_read_u32(ts->dev, "touchscreen-y-mm", &tmp))
+		scd->len_y = get_unaligned_le16(&scd_dev->len_y);
+	else
+		scd->len_y = tmp;
+
+	if (scd->len_y == 0) {
+		dev_dbg(ts->dev, "Touchscreen size y cannot be zero\n");
+		scd->len_y = scd->res_y + 1;
+	}
 
 	return 0;
 }
@@ -877,6 +928,7 @@ static int cyttsp5_i2c_probe(struct i2c_client *client,
 
 static const struct of_device_id cyttsp5_of_match[] = {
 	{ .compatible = "cypress,tt21000", },
+	{ .compatible = "cypress,tma448", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, cyttsp5_of_match);
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-01-19  1:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-09 11:53 [PATCH v5 0/4] Add support for the Cypress cyttsp5 Alistair Francis
2022-01-09 11:53 ` Alistair Francis
2022-01-09 11:53 ` [PATCH v5 1/4] Input: Add driver for Cypress Generation 5 touchscreen Alistair Francis
2022-01-09 11:53   ` Alistair Francis
2022-01-19  1:26   ` Peter Geis [this message]
2022-01-19  1:26     ` Peter Geis
2022-01-21 22:43     ` Rob Herring
2022-01-21 22:43       ` Rob Herring
2022-01-09 11:53 ` [PATCH v5 2/4] dt-bindings: input: Add Cypress TT2100 touchscreen controller Alistair Francis
2022-01-09 11:53   ` Alistair Francis
2022-01-16  0:34   ` Linus Walleij
2022-01-16  0:34     ` Linus Walleij
2022-01-21 22:08   ` Rob Herring
2022-01-21 22:08     ` Rob Herring
2022-01-09 11:53 ` [PATCH v5 3/4] ARM: imx_v6_v7_defconfig: Enable the cyttsp5 touchscreen Alistair Francis
2022-01-09 11:53   ` Alistair Francis
2022-01-09 11:53 ` [PATCH v5 4/4] ARM: dts: imx7d-remarkable2: Enable the cyttsp5 Alistair Francis
2022-01-09 11:53   ` Alistair Francis

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=20220119012637.1713748-1-pgwipeout@gmail.com \
    --to=pgwipeout@gmail.com \
    --cc=alistair23@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=andreas@kemnade.info \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@bootlin.com \
    --cc=mylene.josserand@bootlin.com \
    --cc=robh+dt@kernel.org \
    --cc=rydberg@bitmath.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 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.