linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>, linux-input@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] input: elants: support common touchscreen DT properties
Date: Tue, 10 Dec 2019 04:03:18 +0300	[thread overview]
Message-ID: <17bb20b8-a62c-828f-d329-cd3aa89c1c06@gmail.com> (raw)
In-Reply-To: <7e650a6ef98e3178d6829c3c2c83f21437070d84.1575936961.git.mirq-linux@rere.qmqm.pl>

10.12.2019 03:19, Michał Mirosław пишет:
> Support common DT properties like axis inversions to complement
> information obtained from device's firmware.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  drivers/input/touchscreen/elants_i2c.c | 27 ++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index eadd26d5a06f..02bd5e3e2171 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -31,6 +31,7 @@
>  #include <linux/buffer_head.h>
>  #include <linux/slab.h>
>  #include <linux/firmware.h>
> +#include <linux/input/touchscreen.h>
>  #include <linux/input/mt.h>
>  #include <linux/acpi.h>
>  #include <linux/of.h>
> @@ -146,8 +147,7 @@ struct elants_data {
>  	u16 hw_version;
>  	unsigned int x_res;	/* resolution in units/mm */
>  	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;
> @@ -498,10 +498,10 @@ static int elants_i2c_query_ts_info(struct elants_data *ts)
>  			 rows, cols, osr);
>  	} else {
>  		/* translate trace number to TS resolution */
> -		ts->x_max = ELAN_TS_RESOLUTION(rows, osr);
> -		ts->x_res = DIV_ROUND_CLOSEST(ts->x_max, phy_x);
> -		ts->y_max = ELAN_TS_RESOLUTION(cols, osr);
> -		ts->y_res = DIV_ROUND_CLOSEST(ts->y_max, phy_y);
> +		ts->prop.max_x = ELAN_TS_RESOLUTION(rows, osr);
> +		ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, phy_x);
> +		ts->prop.max_y = ELAN_TS_RESOLUTION(cols, osr);
> +		ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, phy_y);
>  	}
>  
>  	return 0;
> @@ -833,8 +833,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);
>  
> @@ -1251,13 +1250,15 @@ static int elants_i2c_probe(struct i2c_client *client,
>  	ts->input->name = "Elan Touchscreen";
>  	ts->input->id.bustype = BUS_I2C;
>  
> +	touchscreen_parse_properties(ts->input, true, &ts->prop);

Shouldn't this function be invoked after setting the max x/y sizes with
the hardware values? That's what all other drivers do and then you won't
need to set the ts->prop.max_x/y above in the code.

>  	__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_X, 0, ts->prop.max_x, 0, 0);
> +	input_set_abs_params(ts->input, ABS_Y, 0, ts->prop.max_y, 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);
> @@ -1271,8 +1272,10 @@ static int elants_i2c_probe(struct i2c_client *client,
>  		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);
> +	input_set_abs_params(ts->input, ABS_MT_POSITION_X,
> +			     0, ts->prop.max_x, 0, 0);
> +	input_set_abs_params(ts->input, ABS_MT_POSITION_Y,
> +			     0, ts->prop.max_y, 0, 0);
>  	input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
>  	input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0);
>  	input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res);
> 


  reply	other threads:[~2019-12-10  1:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-10  0:19 [PATCH 0/6] input: elants: Support Asus TF300T touchscreen Michał Mirosław
2019-12-10  0:19 ` [PATCH 2/6] input: elants: support old touch report format Michał Mirosław
2019-12-10  0:19 ` [PATCH 3/6] input: elants: support common touchscreen DT properties Michał Mirosław
2019-12-10  1:03   ` Dmitry Osipenko [this message]
2019-12-10  1:07     ` Dmitry Osipenko
2019-12-10  2:38     ` Michał Mirosław
2019-12-10 15:21       ` Dmitry Osipenko
2019-12-11  3:28         ` Michał Mirosław
2019-12-11 15:26           ` Dmitry Osipenko
2019-12-10  0:19 ` [PATCH 1/6] input: elants: document some registers and values Michał Mirosław
2019-12-10  0:19 ` [PATCH 6/6] input: elants: read touchscreen size for EKTF3624 Michał Mirosław
2019-12-10  1:23   ` Dmitry Osipenko
2019-12-10  1:48     ` Dmitry Osipenko
2019-12-10 18:32   ` kbuild test robot
2019-12-10  0:19 ` [PATCH 5/6] input: elants: refactor elants_i2c_execute_command() Michał Mirosław
2019-12-10  1:34   ` Dmitry Osipenko
2019-12-10  0:19 ` [PATCH 4/6] input: elants: detect max_x/y from hardware Michał Mirosław
2019-12-10  0:59 ` [PATCH 0/6] input: elants: Support Asus TF300T touchscreen Dmitry Osipenko
2019-12-10 15:26   ` Dmitry Osipenko

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=17bb20b8-a62c-828f-d329-cd3aa89c1c06@gmail.com \
    --to=digetx@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mirq-linux@rere.qmqm.pl \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).