All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] input: atmel_mxt_ts: detect touchpad from devicetree
@ 2017-10-04 19:35 Emil Renner Berthing
  2017-10-08 19:56 ` Nick Dyer
  0 siblings, 1 reply; 3+ messages in thread
From: Emil Renner Berthing @ 2017-10-04 19:35 UTC (permalink / raw)
  To: Nick Dyer
  Cc: Dmitry Torokhov, linux-input, linux-kernel, Emil Renner Berthing

The Samsung Chromebook Plus (rk3399-gru-kevin) has two of
these controllers. One for the touchscreen and one for
the touchpad. However the touchpad doesn't have any
associated gpio buttons, so it shows up as another
touchscreen.

This patch fixes it by matching the "atmel,atmel_mxt_tp"
compatibility string in the device tree.

Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
---
 drivers/input/touchscreen/atmel_mxt_ts.c   | 8 ++++++--
 include/linux/platform_data/atmel_mxt_ts.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 7659bc48f1db..4ea06f447d15 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1945,8 +1945,7 @@ static int mxt_initialize_input_device(struct mxt_data *data)
 		input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0);
 	}
 
-	/* If device has buttons we assume it is a touchpad */
-	if (pdata->t19_num_keys) {
+	if (pdata->touchpad) {
 		mxt_set_up_as_touchpad(input_dev, data);
 		mt_flags |= INPUT_MT_POINTER;
 	} else {
@@ -2936,6 +2935,9 @@ static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client)
 	if (!pdata)
 		return ERR_PTR(-ENOMEM);
 
+	if (of_device_is_compatible(np, "atmel,atmel_mxt_tp"))
+		pdata->touchpad = true;
+
 	if (of_find_property(np, "linux,gpio-keymap", &proplen)) {
 		pdata->t19_num_keys = proplen / sizeof(u32);
 
@@ -2986,6 +2988,7 @@ static struct mxt_acpi_platform_data samus_platform_data[] = {
 		.pdata	= {
 			.t19_num_keys	= ARRAY_SIZE(samus_touchpad_buttons),
 			.t19_keymap	= samus_touchpad_buttons,
+			.touchpad	= true,
 		},
 	},
 	{
@@ -3011,6 +3014,7 @@ static struct mxt_acpi_platform_data chromebook_platform_data[] = {
 		.pdata	= {
 			.t19_num_keys	= ARRAY_SIZE(chromebook_tp_buttons),
 			.t19_keymap	= chromebook_tp_buttons,
+			.touchpad	= true,
 		},
 	},
 	{
diff --git a/include/linux/platform_data/atmel_mxt_ts.h b/include/linux/platform_data/atmel_mxt_ts.h
index 695035a8d7fb..acb595bba02d 100644
--- a/include/linux/platform_data/atmel_mxt_ts.h
+++ b/include/linux/platform_data/atmel_mxt_ts.h
@@ -24,6 +24,7 @@ enum mxt_suspend_mode {
 struct mxt_platform_data {
 	unsigned long irqflags;
 	u8 t19_num_keys;
+	u8 touchpad;
 	const unsigned int *t19_keymap;
 	enum mxt_suspend_mode suspend_mode;
 };
-- 
2.14.2

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

* Re: [PATCH] input: atmel_mxt_ts: detect touchpad from devicetree
  2017-10-04 19:35 [PATCH] input: atmel_mxt_ts: detect touchpad from devicetree Emil Renner Berthing
@ 2017-10-08 19:56 ` Nick Dyer
  2017-10-09 17:35   ` Emil Renner Berthing
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Dyer @ 2017-10-08 19:56 UTC (permalink / raw)
  To: Emil Renner Berthing; +Cc: Dmitry Torokhov, linux-input, linux-kernel

On Wed, Oct 04, 2017 at 09:35:31PM +0200, Emil Renner Berthing wrote:
> The Samsung Chromebook Plus (rk3399-gru-kevin) has two of
> these controllers. One for the touchscreen and one for
> the touchpad. However the touchpad doesn't have any
> associated gpio buttons, so it shows up as another
> touchscreen.
> 
> This patch fixes it by matching the "atmel,atmel_mxt_tp"
> compatibility string in the device tree.

Thanks. I think this makes sense, given there are already devices out
there using "atmel_mxt_tp".

Is the hardcoded MXT_PIXELS_PER_MM going to cause issues on this new
device?

I think you need to add this to
Documentation/devicetree/bindings/input/atmel,maxtouch.txt

Reviewed-by: Nick Dyer <nick@shmanahar.org>

> Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
> ---
>  drivers/input/touchscreen/atmel_mxt_ts.c   | 8 ++++++--
>  include/linux/platform_data/atmel_mxt_ts.h | 1 +
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index 7659bc48f1db..4ea06f447d15 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> @@ -1945,8 +1945,7 @@ static int mxt_initialize_input_device(struct mxt_data *data)
>  		input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0);
>  	}
>  
> -	/* If device has buttons we assume it is a touchpad */
> -	if (pdata->t19_num_keys) {
> +	if (pdata->touchpad) {
>  		mxt_set_up_as_touchpad(input_dev, data);
>  		mt_flags |= INPUT_MT_POINTER;
>  	} else {
> @@ -2936,6 +2935,9 @@ static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client)
>  	if (!pdata)
>  		return ERR_PTR(-ENOMEM);
>  
> +	if (of_device_is_compatible(np, "atmel,atmel_mxt_tp"))
> +		pdata->touchpad = true;
> +
>  	if (of_find_property(np, "linux,gpio-keymap", &proplen)) {
>  		pdata->t19_num_keys = proplen / sizeof(u32);
>  
> @@ -2986,6 +2988,7 @@ static struct mxt_acpi_platform_data samus_platform_data[] = {
>  		.pdata	= {
>  			.t19_num_keys	= ARRAY_SIZE(samus_touchpad_buttons),
>  			.t19_keymap	= samus_touchpad_buttons,
> +			.touchpad	= true,
>  		},
>  	},
>  	{
> @@ -3011,6 +3014,7 @@ static struct mxt_acpi_platform_data chromebook_platform_data[] = {
>  		.pdata	= {
>  			.t19_num_keys	= ARRAY_SIZE(chromebook_tp_buttons),
>  			.t19_keymap	= chromebook_tp_buttons,
> +			.touchpad	= true,
>  		},
>  	},
>  	{
> diff --git a/include/linux/platform_data/atmel_mxt_ts.h b/include/linux/platform_data/atmel_mxt_ts.h
> index 695035a8d7fb..acb595bba02d 100644
> --- a/include/linux/platform_data/atmel_mxt_ts.h
> +++ b/include/linux/platform_data/atmel_mxt_ts.h
> @@ -24,6 +24,7 @@ enum mxt_suspend_mode {
>  struct mxt_platform_data {
>  	unsigned long irqflags;
>  	u8 t19_num_keys;
> +	u8 touchpad;
>  	const unsigned int *t19_keymap;
>  	enum mxt_suspend_mode suspend_mode;
>  };
> -- 
> 2.14.2
> 

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

* Re: [PATCH] input: atmel_mxt_ts: detect touchpad from devicetree
  2017-10-08 19:56 ` Nick Dyer
@ 2017-10-09 17:35   ` Emil Renner Berthing
  0 siblings, 0 replies; 3+ messages in thread
From: Emil Renner Berthing @ 2017-10-09 17:35 UTC (permalink / raw)
  To: Nick Dyer; +Cc: Dmitry Torokhov, linux-input, linux-kernel

On 8 October 2017 at 21:56, Nick Dyer <nick@shmanahar.org> wrote:
> On Wed, Oct 04, 2017 at 09:35:31PM +0200, Emil Renner Berthing wrote:
>> The Samsung Chromebook Plus (rk3399-gru-kevin) has two of
>> these controllers. One for the touchscreen and one for
>> the touchpad. However the touchpad doesn't have any
>> associated gpio buttons, so it shows up as another
>> touchscreen.
>>
>> This patch fixes it by matching the "atmel,atmel_mxt_tp"
>> compatibility string in the device tree.
>
> Thanks. I think this makes sense, given there are already devices out
> there using "atmel_mxt_tp".
>
> Is the hardcoded MXT_PIXELS_PER_MM going to cause issues on this new
> device?

I'm not exactly sure what kind of issues a wrong value would give, but
the touchpad feels totally usable in X with libinput.
I just checked google's chromeos kernel and it seems to use the same
hard-coded value.

> I think you need to add this to
> Documentation/devicetree/bindings/input/atmel,maxtouch.txt

Speaking of issues I was just about to complain that the "click
button" in the touchpad
didn't work, but only touch. It turns out I completely misunderstood what those
"gpio buttons" was all about. Adding

+               linux,gpio-keymap = <KEY_RESERVED
+                                    KEY_RESERVED
+                                    KEY_RESERVED
+                                    BTN_LEFT>;

to the device tree fixes exactly that, and hence the current logic
in the driver is fine for detecting the touchpad.

I'll submit another patch to add this to the device tree rather than
this misunderstood patch.

> Reviewed-by: Nick Dyer <nick@shmanahar.org>

Thank you for the review, and sorry about the noise.

/Emil

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

end of thread, other threads:[~2017-10-09 17:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-04 19:35 [PATCH] input: atmel_mxt_ts: detect touchpad from devicetree Emil Renner Berthing
2017-10-08 19:56 ` Nick Dyer
2017-10-09 17:35   ` Emil Renner Berthing

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.