Message ID | 7e650a6ef98e3178d6829c3c2c83f21437070d84.1575936961.git.mirq-linux@rere.qmqm.pl (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | input: elants: Support Asus TF300T touchscreen | expand |
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); >
10.12.2019 04:03, Dmitry Osipenko пишет: > 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); I'm actually wondering why this part is needed at all, the driver doesn't report single-touch events. >> @@ -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); >> >
On Tue, Dec 10, 2019 at 04:03:18AM +0300, Dmitry Osipenko wrote: > 10.12.2019 03:19, Michał Mirosław пишет: > > Support common DT properties like axis inversions to complement > > information obtained from device's firmware.a [...] > > @@ -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. This is done later in the series - this patch only adds axis inversion support and ignores DT-provided sizes. Best Regards, Michał Mirosław
10.12.2019 05:38, Michał Mirosław пишет: > On Tue, Dec 10, 2019 at 04:03:18AM +0300, Dmitry Osipenko wrote: >> 10.12.2019 03:19, Michał Mirosław пишет: >>> Support common DT properties like axis inversions to complement >>> information obtained from device's firmware.a > [...] >>> @@ -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. > > This is done later in the series - this patch only adds axis inversion > support and ignores DT-provided sizes. What is the reason of splitting it into two patches? Perhaps I'm still missing something, but why something a bit more simple like this wouldn't yield exactly the same result: diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index d4ad24ea54c8..8763a3b25c29 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> @@ -147,6 +148,8 @@ struct elants_data { /* Must be last to be used for DMA operations */ u8 buf[MAX_PACKET_SIZE] ____cacheline_aligned; + + struct touchscreen_properties prop; }; static int elants_i2c_send(struct i2c_client *client, @@ -807,8 +810,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(ts->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); @@ -1249,6 +1251,8 @@ static int elants_i2c_probe(struct i2c_client *client, input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); + touchscreen_parse_properties(ts->input, true, &ts->prop); + error = input_register_device(ts->input); if (error) { dev_err(&client->dev,
On Tue, Dec 10, 2019 at 06:21:02PM +0300, Dmitry Osipenko wrote: > 10.12.2019 05:38, Michał Mirosław пишет: > > On Tue, Dec 10, 2019 at 04:03:18AM +0300, Dmitry Osipenko wrote: > >> 10.12.2019 03:19, Michał Mirosław пишет: > >>> Support common DT properties like axis inversions to complement > >>> information obtained from device's firmware.a > > [...] > >>> @@ -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. > > > > This is done later in the series - this patch only adds axis inversion > > support and ignores DT-provided sizes. > > What is the reason of splitting it into two patches? > > Perhaps I'm still missing something, but why something a bit more simple > like this wouldn't yield exactly the same result: [...] Originally I thought to skip probing the hardware when all info is already provided in devicetree. This didn't happen, though. I'll take your patch then, with a slight adjustment in "prop"'s position... And the rest of them, so as to not duplicate the work. :-) Best Regards, Michał Mirosław
11.12.2019 06:28, Michał Mirosław пишет: > On Tue, Dec 10, 2019 at 06:21:02PM +0300, Dmitry Osipenko wrote: >> 10.12.2019 05:38, Michał Mirosław пишет: >>> On Tue, Dec 10, 2019 at 04:03:18AM +0300, Dmitry Osipenko wrote: >>>> 10.12.2019 03:19, Michał Mirosław пишет: >>>>> Support common DT properties like axis inversions to complement >>>>> information obtained from device's firmware.a >>> [...] >>>>> @@ -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. >>> >>> This is done later in the series - this patch only adds axis inversion >>> support and ignores DT-provided sizes. >> >> What is the reason of splitting it into two patches? >> >> Perhaps I'm still missing something, but why something a bit more simple >> like this wouldn't yield exactly the same result: > [...] > > Originally I thought to skip probing the hardware when all info is > already provided in devicetree. This didn't happen, though. I'll take > your patch then, with a slight adjustment in "prop"'s position... And > the rest of them, so as to not duplicate the work. :-) Okay
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); + __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);
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(-)