[v4,03/10] input: elants: remove unused axes
diff mbox series

Message ID b6cb0f810eec2d5c6245d6128502eebd342ca02a.1587916846.git.mirq-linux@rere.qmqm.pl
State Superseded
Headers show
Series
  • input: elants: Support Asus TF300T touchscreen
Related show

Commit Message

Michał Mirosław April 26, 2020, 4:11 p.m. UTC
Driver only ever reports MT events and input_mt_init_slots() sets up
emulated axes already.  Clear the capabilities not generated directly
and move MT axes setup, so they are visible by input_mt_init_slots().

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
---
v4: reword commitmsg; reorder axis setup
---
 drivers/input/touchscreen/elants_i2c.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

Comments

Dmitry Osipenko April 26, 2020, 4:35 p.m. UTC | #1
26.04.2020 19:11, Michał Mirosław пишет:
> Driver only ever reports MT events and input_mt_init_slots() sets up
> emulated axes already.  Clear the capabilities not generated directly
> and move MT axes setup, so they are visible by input_mt_init_slots().
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
> Tested-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> v4: reword commitmsg; reorder axis setup
> ---

Legacy pointer emulation doesn't work using v4. I think it will be
better to drop this patch for now and add this hunk to the patch #4:

--- >8 ---
diff --git a/drivers/input/touchscreen/elants_i2c.c
b/drivers/input/touchscreen/elants_i2c.c
index 060c60c04f25..3644b5b48081 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -1414,6 +1414,8 @@ static int elants_i2c_probe(struct i2c_client *client,
 	input_abs_set_res(ts->input, ABS_X, ts->x_res);
 	input_abs_set_res(ts->input, ABS_Y, ts->y_res);

+	touchscreen_parse_properties(ts->input, false, &ts->prop);
+
 	/* Multitouch input params setup */
 	error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM,
 				    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
--- >8 ---

This hunk makes the DT properties to be applied for the legacy pointer,
fixing the cursor position on Nexus 7 device using Ubuntu 12.04. The MT
still works fine using Ubuntu 20.04.

Maybe input_mt_init_slots() could be changed to set up all the
properties that are needed for the legacy pointer, but I'm not 100% sure
because not very familiar with that code. Perhaps Dmitry Torokhov could
clarify?
Michał Mirosław April 26, 2020, 5:29 p.m. UTC | #2
On Sun, Apr 26, 2020 at 07:35:47PM +0300, Dmitry Osipenko wrote:
> 26.04.2020 19:11, Michał Mirosław пишет:
> > Driver only ever reports MT events and input_mt_init_slots() sets up
> > emulated axes already.  Clear the capabilities not generated directly
> > and move MT axes setup, so they are visible by input_mt_init_slots().
> > 
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
> > Tested-by: Dmitry Osipenko <digetx@gmail.com>
> > ---
> > v4: reword commitmsg; reorder axis setup
> > ---
> 
> Legacy pointer emulation doesn't work using v4. I think it will be
> better to drop this patch for now and add this hunk to the patch #4:

Have you tried it together with the next patch? It adds
touchscreen_parse_properties() to initialize axes also from DT, and
should be equivalent to the hunk you proposed.

[...]
> Maybe input_mt_init_slots() could be changed to set up all the
> properties that are needed for the legacy pointer, but I'm not 100% sure
> because not very familiar with that code. Perhaps Dmitry Torokhov could
> clarify?

The code of input_mt_init_slots() looks like it does initialize the
properties needed. What does evtest return with and without the patches?

Best Regards
Michał Mirosław
Dmitry Osipenko April 26, 2020, 5:45 p.m. UTC | #3
26.04.2020 20:29, Michał Mirosław пишет:
> On Sun, Apr 26, 2020 at 07:35:47PM +0300, Dmitry Osipenko wrote:
>> 26.04.2020 19:11, Michał Mirosław пишет:
>>> Driver only ever reports MT events and input_mt_init_slots() sets up
>>> emulated axes already.  Clear the capabilities not generated directly
>>> and move MT axes setup, so they are visible by input_mt_init_slots().
>>>
>>> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
>>> Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
>>> Tested-by: Dmitry Osipenko <digetx@gmail.com>
>>> ---
>>> v4: reword commitmsg; reorder axis setup
>>> ---
>>
>> Legacy pointer emulation doesn't work using v4. I think it will be
>> better to drop this patch for now and add this hunk to the patch #4:
> 
> Have you tried it together with the next patch? It adds
> touchscreen_parse_properties() to initialize axes also from DT, and
> should be equivalent to the hunk you proposed.

Yes, the touchscreen_parse_properties() takes bool multitouch for the
argument, and thus, it needs to be applied to both MT/non-MT cases.

https://elixir.bootlin.com/linux/v5.7-rc2/source/drivers/input/touchscreen/of_touchscreen.c#L64

> [...]
>> Maybe input_mt_init_slots() could be changed to set up all the
>> properties that are needed for the legacy pointer, but I'm not 100% sure
>> because not very familiar with that code. Perhaps Dmitry Torokhov could
>> clarify?
> 
> The code of input_mt_init_slots() looks like it does initialize the
> properties needed. What does evtest return with and without the patches?

==== vanilla v4 (doesn't work) ====

Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "Elan Touchscreen"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
  Event type 3 (EV_ABS)
    Event code 47 (ABS_MT_SLOT)
      Value      0
      Min        0
      Max        9
    Event code 48 (ABS_MT_TOUCH_MAJOR)
      Value      0
      Min        0
      Max      255
      Resolution       1
    Event code 53 (ABS_MT_POSITION_X)
      Value      0
      Min        0
      Max     1279
    Event code 54 (ABS_MT_POSITION_Y)
      Value      0
      Min        0
      Max     2111
    Event code 55 (ABS_MT_TOOL_TYPE)
      Value      0
      Min        0
      Max        2
    Event code 57 (ABS_MT_TRACKING_ID)
      Value      0
      Min        0
      Max    65535
    Event code 58 (ABS_MT_PRESSURE)
      Value      0
      Min        0
      Max      255

Event: time 1587922487.077439, type 3 (EV_ABS), code 57
(ABS_MT_TRACKING_ID), value 64
Event: time 1587922487.077439, type 3 (EV_ABS), code 53
(ABS_MT_POSITION_X), value 855
Event: time 1587922487.077439, type 3 (EV_ABS), code 54
(ABS_MT_POSITION_Y), value 893
Event: time 1587922487.077439, type 3 (EV_ABS), code 58
(ABS_MT_PRESSURE), value 47
Event: time 1587922487.077439, type 1 (EV_KEY), code 330 (BTN_TOUCH),
value 1
Event: time 1587922487.077439, -------------- SYN_REPORT ------------
Event: time 1587922487.089144, type 3 (EV_ABS), code 54
(ABS_MT_POSITION_Y), value 899
Event: time 1587922487.089144, type 3 (EV_ABS), code 58
(ABS_MT_PRESSURE), value 124
Event: time 1587922487.089144, type 3 (EV_ABS), code 48
(ABS_MT_TOUCH_MAJOR), value 11
Event: time 1587922487.089144, -------------- SYN_REPORT ------------
Event: time 1587922487.100292, type 3 (EV_ABS), code 53
(ABS_MT_POSITION_X), value 854
Event: time 1587922487.100292, type 3 (EV_ABS), code 54
(ABS_MT_POSITION_Y), value 911
Event: time 1587922487.100292, type 3 (EV_ABS), code 58
(ABS_MT_PRESSURE), value 166
Event: time 1587922487.100292, -------------- SYN_REPORT ------------
Event: time 1587922487.109238, type 3 (EV_ABS), code 53
(ABS_MT_POSITION_X), value 851
Event: time 1587922487.109238, type 3 (EV_ABS), code 54
(ABS_MT_POSITION_Y), value 922
Event: time 1587922487.109238, type 3 (EV_ABS), code 58
(ABS_MT_PRESSURE), value 180
Event: time 1587922487.109238, -------------- SYN_REPORT ------------
Event: time 1587922487.117997, type 3 (EV_ABS), code 53
(ABS_MT_POSITION_X), value 847
Event: time 1587922487.117997, type 3 (EV_ABS), code 54
(ABS_MT_POSITION_Y), value 936
Event: time 1587922487.117997, type 3 (EV_ABS), code 58
(ABS_MT_PRESSURE), value 187
Event: time 1587922487.117997, -------------- SYN_REPORT ------------
Event: time 1587922487.126925, type 3 (EV_ABS), code 53
(ABS_MT_POSITION_X), value 841
Event: time 1587922487.126925, type 3 (EV_ABS), code 54
(ABS_MT_POSITION_Y), value 947
Event: time 1587922487.126925, type 3 (EV_ABS), code 58
(ABS_MT_PRESSURE), value 199
Event: time 1587922487.126925, -------------- SYN_REPORT ------------
Event: time 1587922487.139066, type 3 (EV_ABS), code 53
(ABS_MT_POSITION_X), value 836
Event: time 1587922487.139066, type 3 (EV_ABS), code 54
(ABS_MT_POSITION_Y), value 958
Event: time 1587922487.139066, type 3 (EV_ABS), code 58
(ABS_MT_PRESSURE), value 204
Event: time 1587922487.139066, -------------- SYN_REPORT ------------
Event: time 1587922487.150355, type 3 (EV_ABS), code 53
(ABS_MT_POSITION_X), value 829
Event: time 1587922487.150355, type 3 (EV_ABS), code 54
(ABS_MT_POSITION_Y), value 969
Event: time 1587922487.150355, type 3 (EV_ABS), code 58
(ABS_MT_PRESSURE), value 207
Event: time 1587922487.150355, -------------- SYN_REPORT ------------
Event: time 1587922487.172261, type 3 (EV_ABS), code 53
(ABS_MT_POSITION_X), value 826
Event: time 1587922487.172261, type 3 (EV_ABS), code 54
(ABS_MT_POSITION_Y), value 977
Event: time 1587922487.172261, type 3 (EV_ABS), code 58
(ABS_MT_PRESSURE), value 183
Event: time 1587922487.172261, -------------- SYN_REPORT ------------
Event: time 1587922487.205326, type 3 (EV_ABS), code 57
(ABS_MT_TRACKING_ID), value -1
Event: time 1587922487.205326, type 1 (EV_KEY), code 330 (BTN_TOUCH),
value 0
Event: time 1587922487.205326, -------------- SYN_REPORT ------------


==== v4 with reverted patch #3 + my hunk applied (works) ====

Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "Elan Touchscreen"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value      0
      Min        0
      Max     1279
    Event code 1 (ABS_Y)
      Value      0
      Min        0
      Max     2111
    Event code 24 (ABS_PRESSURE)
      Value      0
      Min        0
      Max      255
    Event code 47 (ABS_MT_SLOT)
      Value      0
      Min        0
      Max        9
    Event code 48 (ABS_MT_TOUCH_MAJOR)
      Value      0
      Min        0
      Max      255
      Resolution       1
    Event code 53 (ABS_MT_POSITION_X)
      Value      0
      Min        0
      Max     1279
    Event code 54 (ABS_MT_POSITION_Y)
      Value      0
      Min        0
      Max     2111
    Event code 55 (ABS_MT_TOOL_TYPE)
      Value      0
      Min        0
      Max        2
    Event code 57 (ABS_MT_TRACKING_ID)
      Value      0
      Min        0
      Max    65535
    Event code 58 (ABS_MT_PRESSURE)
      Value      0
      Min        0
      Max      255
Testing ... (interrupt to exit)
Event: time 1587922846.335151, type 3 (EV_ABS), code 57
(ABS_MT_TRACKING_ID), value 0
Event: time 1587922846.335151, type 3 (EV_ABS), code 53
(ABS_MT_POSITION_X), value 565
Event: time 1587922846.335151, type 3 (EV_ABS), code 54
(ABS_MT_POSITION_Y), value 423
Event: time 1587922846.335151, type 3 (EV_ABS), code 58
(ABS_MT_PRESSURE), value 39
Event: time 1587922846.335151, type 3 (EV_ABS), code 48
(ABS_MT_TOUCH_MAJOR), value 10
Event: time 1587922846.335151, type 1 (EV_KEY), code 330 (BTN_TOUCH),
value 1
Event: time 1587922846.335151, type 3 (EV_ABS), code 0 (ABS_X), value 565
Event: time 1587922846.335151, type 3 (EV_ABS), code 1 (ABS_Y), value 423
Event: time 1587922846.335151, type 3 (EV_ABS), code 24 (ABS_PRESSURE),
value 39
Event: time 1587922846.335151, -------------- SYN_REPORT ------------
Event: time 1587922846.464426, type 3 (EV_ABS), code 57
(ABS_MT_TRACKING_ID), value -1
Event: time 1587922846.464426, type 1 (EV_KEY), code 330 (BTN_TOUCH),
value 0
Event: time 1587922846.464426, type 3 (EV_ABS), code 24 (ABS_PRESSURE),
value 0
Event: time 1587922846.464426, -------------- SYN_REPORT ------------
Dmitry Osipenko April 26, 2020, 5:58 p.m. UTC | #4
26.04.2020 20:45, Dmitry Osipenko пишет:
> 26.04.2020 20:29, Michał Mirosław пишет:
>> On Sun, Apr 26, 2020 at 07:35:47PM +0300, Dmitry Osipenko wrote:
>>> 26.04.2020 19:11, Michał Mirosław пишет:
>>>> Driver only ever reports MT events and input_mt_init_slots() sets up
>>>> emulated axes already.  Clear the capabilities not generated directly
>>>> and move MT axes setup, so they are visible by input_mt_init_slots().
>>>>
>>>> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
>>>> Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
>>>> Tested-by: Dmitry Osipenko <digetx@gmail.com>
>>>> ---
>>>> v4: reword commitmsg; reorder axis setup
>>>> ---
>>>
>>> Legacy pointer emulation doesn't work using v4. I think it will be
>>> better to drop this patch for now and add this hunk to the patch #4:
>>
>> Have you tried it together with the next patch? It adds
>> touchscreen_parse_properties() to initialize axes also from DT, and
>> should be equivalent to the hunk you proposed.
> 
> Yes, the touchscreen_parse_properties() takes bool multitouch for the
> argument, and thus, it needs to be applied to both MT/non-MT cases.
> 
> https://elixir.bootlin.com/linux/v5.7-rc2/source/drivers/input/touchscreen/of_touchscreen.c#L64
> 
>> [...]
>>> Maybe input_mt_init_slots() could be changed to set up all the
>>> properties that are needed for the legacy pointer, but I'm not 100% sure
>>> because not very familiar with that code. Perhaps Dmitry Torokhov could
>>> clarify?
>>
>> The code of input_mt_init_slots() looks like it does initialize the
>> properties needed. What does evtest return with and without the patches?

Oh wait, seems I messed up something while was applying the patches.
I'll try the v5 now.
Michał Mirosław April 26, 2020, 6:15 p.m. UTC | #5
On Sun, Apr 26, 2020 at 08:45:14PM +0300, Dmitry Osipenko wrote:
> 26.04.2020 20:29, Michał Mirosław пишет:
> > On Sun, Apr 26, 2020 at 07:35:47PM +0300, Dmitry Osipenko wrote:
> >> 26.04.2020 19:11, Michał Mirosław пишет:
> >>> Driver only ever reports MT events and input_mt_init_slots() sets up
> >>> emulated axes already.  Clear the capabilities not generated directly
> >>> and move MT axes setup, so they are visible by input_mt_init_slots().
> >>>
> >>> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> >>> Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
> >>> Tested-by: Dmitry Osipenko <digetx@gmail.com>
> >>> ---
> >>> v4: reword commitmsg; reorder axis setup
> >>> ---
> >>
> >> Legacy pointer emulation doesn't work using v4. I think it will be
> >> better to drop this patch for now and add this hunk to the patch #4:
> > 
> > Have you tried it together with the next patch? It adds
> > touchscreen_parse_properties() to initialize axes also from DT, and
> > should be equivalent to the hunk you proposed.
> 
> Yes, the touchscreen_parse_properties() takes bool multitouch for the
> argument, and thus, it needs to be applied to both MT/non-MT cases.
> 
> https://elixir.bootlin.com/linux/v5.7-rc2/source/drivers/input/touchscreen/of_touchscreen.c#L64

input_mt_init_slots() should copy MT axes to non-MT if they are
described before the call.

With v5 applied, I can see in evtest MT and non-MT events.

Best Regards,
Michał Mirosław

Patch
diff mbox series

diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index ddebd3741145..58aa9b7dbcbf 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -1312,25 +1312,7 @@  static int elants_i2c_probe(struct i2c_client *client,
 	ts->input->name = "Elan Touchscreen";
 	ts->input->id.bustype = BUS_I2C;
 
-	__set_bit(BTN_TOUCH, ts->input->keybit);
-	__set_bit(EV_ABS, ts->input->evbit);
-	__set_bit(EV_KEY, ts->input->evbit);
-
-	/* Single touch input params setup */
-	input_set_abs_params(ts->input, ABS_X, 0, ts->x_max, 0, 0);
-	input_set_abs_params(ts->input, ABS_Y, 0, ts->y_max, 0, 0);
-	input_set_abs_params(ts->input, ABS_PRESSURE, 0, 255, 0, 0);
-	input_abs_set_res(ts->input, ABS_X, ts->x_res);
-	input_abs_set_res(ts->input, ABS_Y, ts->y_res);
-
 	/* Multitouch input params setup */
-	error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM,
-				    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
-	if (error) {
-		dev_err(&client->dev,
-			"failed to initialize MT slots: %d\n", error);
-		return error;
-	}
 
 	input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0);
 	input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0);
@@ -1340,6 +1322,14 @@  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);
 
+	error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM,
+				    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
+	if (error) {
+		dev_err(&client->dev,
+			"failed to initialize MT slots: %d\n", error);
+		return error;
+	}
+
 	error = input_register_device(ts->input);
 	if (error) {
 		dev_err(&client->dev,