diff mbox series

[v3,4/9] input: elants: override touchscreen info with DT properties

Message ID cb3834494e837289fa792615925f06dbd91c1f75.1586784389.git.mirq-linux@rere.qmqm.pl (mailing list archive)
State Superseded
Headers show
Series input: elants: Support Asus TF300T touchscreen | expand

Commit Message

Michał Mirosław April 13, 2020, 1:32 p.m. UTC
Allow overriding of information from hardware and support additional
common DT properties like axis inversion. This is required for eg.
Nexus 7 and TF300T where the programmed values in firmware differ
from reality.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
[moved "prop" before DMA buffer]
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/input/touchscreen/elants_i2c.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Dmitry Torokhov April 26, 2020, 5:11 a.m. UTC | #1
On Mon, Apr 13, 2020 at 03:32:24PM +0200, Michał Mirosław wrote:
> Allow overriding of information from hardware and support additional
> common DT properties like axis inversion. This is required for eg.
> Nexus 7 and TF300T where the programmed values in firmware differ
> from reality.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> [moved "prop" before DMA buffer]
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

This needs a companion patch for the DT bindings.

> ---
>  drivers/input/touchscreen/elants_i2c.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index fcd3d189f184..87d686ce08f2 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -32,6 +32,7 @@
>  #include <linux/slab.h>
>  #include <linux/firmware.h>
>  #include <linux/input/mt.h>
> +#include <linux/input/touchscreen.h>
>  #include <linux/acpi.h>
>  #include <linux/of.h>
>  #include <linux/gpio/consumer.h>
> @@ -150,6 +151,7 @@ struct elants_data {
>  	unsigned int y_res;
>  	unsigned int x_max;
>  	unsigned int y_max;
> +	struct touchscreen_properties prop;
>  
>  	enum elants_state state;
>  	enum elants_iap_mode iap_mode;
> @@ -894,8 +896,7 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf,
>  
>  			input_mt_slot(input, i);
>  			input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
> -			input_event(input, EV_ABS, ABS_MT_POSITION_X, x);
> -			input_event(input, EV_ABS, ABS_MT_POSITION_Y, y);
> +			touchscreen_report_pos(input, &ts->prop, x, y, true);
>  			input_event(input, EV_ABS, ABS_MT_PRESSURE, p);
>  			input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, w);
>  
> @@ -1329,6 +1330,8 @@ static int elants_i2c_probe(struct i2c_client *client,
>  	input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res);
>  	input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, 1);
>  
> +	touchscreen_parse_properties(ts->input, true, &ts->prop);
> +
>  	error = input_register_device(ts->input);
>  	if (error) {
>  		dev_err(&client->dev,
> -- 
> 2.20.1
>
Dmitry Torokhov April 26, 2020, 5:12 a.m. UTC | #2
On Sat, Apr 25, 2020 at 10:11:22PM -0700, Dmitry Torokhov wrote:
> On Mon, Apr 13, 2020 at 03:32:24PM +0200, Michał Mirosław wrote:
> > Allow overriding of information from hardware and support additional
> > common DT properties like axis inversion. This is required for eg.
> > Nexus 7 and TF300T where the programmed values in firmware differ
> > from reality.
> > 
> > Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> > [moved "prop" before DMA buffer]
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> 
> This needs a companion patch for the DT bindings.

Ah, sorry, I missed the fact that it was later in the sequence.

> 
> > ---
> >  drivers/input/touchscreen/elants_i2c.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> > index fcd3d189f184..87d686ce08f2 100644
> > --- a/drivers/input/touchscreen/elants_i2c.c
> > +++ b/drivers/input/touchscreen/elants_i2c.c
> > @@ -32,6 +32,7 @@
> >  #include <linux/slab.h>
> >  #include <linux/firmware.h>
> >  #include <linux/input/mt.h>
> > +#include <linux/input/touchscreen.h>
> >  #include <linux/acpi.h>
> >  #include <linux/of.h>
> >  #include <linux/gpio/consumer.h>
> > @@ -150,6 +151,7 @@ struct elants_data {
> >  	unsigned int y_res;
> >  	unsigned int x_max;
> >  	unsigned int y_max;
> > +	struct touchscreen_properties prop;
> >  
> >  	enum elants_state state;
> >  	enum elants_iap_mode iap_mode;
> > @@ -894,8 +896,7 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf,
> >  
> >  			input_mt_slot(input, i);
> >  			input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
> > -			input_event(input, EV_ABS, ABS_MT_POSITION_X, x);
> > -			input_event(input, EV_ABS, ABS_MT_POSITION_Y, y);
> > +			touchscreen_report_pos(input, &ts->prop, x, y, true);
> >  			input_event(input, EV_ABS, ABS_MT_PRESSURE, p);
> >  			input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, w);
> >  
> > @@ -1329,6 +1330,8 @@ static int elants_i2c_probe(struct i2c_client *client,
> >  	input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res);
> >  	input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, 1);
> >  
> > +	touchscreen_parse_properties(ts->input, true, &ts->prop);
> > +
> >  	error = input_register_device(ts->input);
> >  	if (error) {
> >  		dev_err(&client->dev,
> > -- 
> > 2.20.1
> > 
> 
> -- 
> Dmitry
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index fcd3d189f184..87d686ce08f2 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -32,6 +32,7 @@ 
 #include <linux/slab.h>
 #include <linux/firmware.h>
 #include <linux/input/mt.h>
+#include <linux/input/touchscreen.h>
 #include <linux/acpi.h>
 #include <linux/of.h>
 #include <linux/gpio/consumer.h>
@@ -150,6 +151,7 @@  struct elants_data {
 	unsigned int y_res;
 	unsigned int x_max;
 	unsigned int y_max;
+	struct touchscreen_properties prop;
 
 	enum elants_state state;
 	enum elants_iap_mode iap_mode;
@@ -894,8 +896,7 @@  static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf,
 
 			input_mt_slot(input, i);
 			input_mt_report_slot_state(input, MT_TOOL_FINGER, true);
-			input_event(input, EV_ABS, ABS_MT_POSITION_X, x);
-			input_event(input, EV_ABS, ABS_MT_POSITION_Y, y);
+			touchscreen_report_pos(input, &ts->prop, x, y, true);
 			input_event(input, EV_ABS, ABS_MT_PRESSURE, p);
 			input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, w);
 
@@ -1329,6 +1330,8 @@  static int elants_i2c_probe(struct i2c_client *client,
 	input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res);
 	input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, 1);
 
+	touchscreen_parse_properties(ts->input, true, &ts->prop);
+
 	error = input_register_device(ts->input);
 	if (error) {
 		dev_err(&client->dev,