mbox series

[v3,0/4] Add support for the Cypress cyttsp5

Message ID 20211202122021.43124-1-alistair@alistair23.me
Headers show
Series Add support for the Cypress cyttsp5 | expand

Message

Alistair Dec. 2, 2021, 12:20 p.m. UTC
This patch series builds on top of [1] and adds support for the cyttsp5
touchscreen controller for the reMarkable 2.

I first tried to add an I2C HID device. Although the cyttsp5 has some HID
looking aspects it is not HID compatible. Just in trying to probe the device
I found:
 - The HID descriptor has extra padding
 - The HID descriptor sets the high bytes of the descriptor length
 - The HID descriptor has extra unrecognised tags
 - The HID reset command doesn't appear to work

I don't think there is a way to use the I2C HID framework with the cyttsp5.
For anyone interested you can see the work here [2]. In that branch though I
can only obtain a HID descriptor, nothing else works without more core
changes.

So instead I rebased the series from [1]. Converted to the new yaml DTS
documentation, added regulator support and fixed a x/y miscalculation bug.

1: https://lwn.net/ml/linux-kernel/20180703094309.18514-1-mylene.josserand@bootlin.com/
2: https://github.com/alistair23/linux/commits/rM2-mainline-cyttsp5-hid

Alistair Francis (2):
  ARM: imx_v6_v7_defconfig: Enable the cyttsp5 touchscreen
  ARM: dts: imx7d: remarkable2: Enable the cyttsp5

Mylène Josserand (2):
  Input: Add driver for Cypress Generation 5 touchscreen
  Documentation: DT: bindings: input: Add documentation for cyttsp5

 .../input/touchscreen/cypress,tt21000.yaml    |   92 ++
 arch/arm/boot/dts/imx7d-remarkable2.dts       |   89 ++
 arch/arm/configs/imx_v6_v7_defconfig          |    1 +
 drivers/input/touchscreen/Kconfig             |   14 +
 drivers/input/touchscreen/Makefile            |    1 +
 drivers/input/touchscreen/cyttsp5.c           | 1002 +++++++++++++++++
 6 files changed, 1199 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/cypress,tt21000.yaml
 create mode 100644 drivers/input/touchscreen/cyttsp5.c

Comments

Andreas Kemnade Dec. 4, 2021, 7:46 p.m. UTC | #1
Hi,

On Thu,  2 Dec 2021 22:20:18 +1000
Alistair Francis <alistair@alistair23.me> wrote:

> +static int cyttsp5_setup_input_device(struct device *dev)
> +{
> +	struct cyttsp5 *ts = dev_get_drvdata(dev);
> +	struct cyttsp5_sysinfo *si = &ts->sysinfo;
> +	int max_x, max_y, max_p;
> +	int max_x_tmp, max_y_tmp;
> +	int error;
> +
> +	__set_bit(EV_REL, ts->input->evbit);
> +
> +	max_x_tmp = si->sensing_conf_data.res_x;
> +	max_y_tmp = si->sensing_conf_data.res_y;
> +	max_x = max_x_tmp - 1;
> +	max_y = max_y_tmp - 1;
> +	max_p = si->sensing_conf_data.max_z;
> +
> +	error = input_mt_init_slots(ts->input, si->tch_abs[CY_TCH_T].max,
> +		INPUT_MT_DROP_UNUSED | INPUT_MT_POINTER);
> +	if (error < 0)
> +		return error;
still some issues with X, sometimes it is even a mouse, depending on
config.
hmm, why is it INPUT_MT_POINTER and not INPUT_MT_DIRECT?

#define INPUT_MT_POINTER        0x0001  /* pointer device, e.g. trackpad */
#define INPUT_MT_DIRECT         0x0002  /* direct device, e.g. touchscreen */

Regards,
Andreas
Andreas Kemnade Dec. 4, 2021, 10:32 p.m. UTC | #2
Hi,


On Thu,  2 Dec 2021 22:20:18 +1000
Alistair Francis <alistair@alistair23.me> wrote:

> From: Mylène Josserand <mylene.josserand@bootlin.com>
> 
> This is the basic driver for the Cypress TrueTouch Gen5 touchscreen
> controllers. This driver supports only the I2C bus but it uses regmap
> so SPI support could be added later.
> The touchscreen can retrieve some defined zone that are handled as
> buttons (according to the hardware). That is why it handles
> button and multitouch events.
> 
> Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
> Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com>
> Message-Id: <20180703094309.18514-2-mylene.josserand@bootlin.com>
> Signed-off-by: Alistair Francis <alistair@alistair23.me>

I finally got it working. The order of initialisation is important.
Params are copied on input_mt_init_slots() from ABS_MT* to ABS_*, so you
have to set params first.

Here is the patch i need on top of this one to make it actually work
with X (evdev and libinput is tested):

diff --git a/drivers/input/touchscreen/cyttsp5.c b/drivers/input/touchscreen/cyttsp5.c
index b5d96eb71e46..3894ec85a732 100644
--- a/drivers/input/touchscreen/cyttsp5.c
+++ b/drivers/input/touchscreen/cyttsp5.c
@@ -415,19 +415,12 @@ static int cyttsp5_setup_input_device(struct device *dev)
 	int max_x_tmp, max_y_tmp;
 	int error;
 
-	__set_bit(EV_REL, ts->input->evbit);
-
 	max_x_tmp = si->sensing_conf_data.res_x;
 	max_y_tmp = si->sensing_conf_data.res_y;
 	max_x = max_x_tmp - 1;
 	max_y = max_y_tmp - 1;
 	max_p = si->sensing_conf_data.max_z;
 
-	error = input_mt_init_slots(ts->input, si->tch_abs[CY_TCH_T].max,
-		INPUT_MT_DROP_UNUSED | INPUT_MT_POINTER);
-	if (error < 0)
-		return error;
-
 	input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, max_x, 0, 0);
 	input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
 	input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, max_p, 0, 0);
@@ -435,6 +428,11 @@ static int cyttsp5_setup_input_device(struct device *dev)
 	input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, MAX_AREA, 0, 0);
 	input_set_abs_params(ts->input, ABS_MT_TOUCH_MINOR, 0, MAX_AREA, 0, 0);
 
+	error = input_mt_init_slots(ts->input, si->tch_abs[CY_TCH_T].max,
+		INPUT_MT_DROP_UNUSED | INPUT_MT_DIRECT);
+	if (error < 0)
+		return error;
+
 	error = input_register_device(ts->input);
 	if (error < 0)
 		dev_err(dev, "Error, failed register input device r=%d\n", error);