Skip to content

Commit 435e84e

Browse files
akemnadedtor
authored andcommitted
Input: zforce_ts - accept standard touchscreen properties
Only driver-specific properties were accepted, change it to use the now-available standard properties. Signed-off-by: Andreas Kemnade <andreas@kemnade.info> Link: https://lore.kernel.org/r/20231223221213.774868-4-andreas@kemnade.info Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent cc040e4 commit 435e84e

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

drivers/input/touchscreen/zforce_ts.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/device.h>
2121
#include <linux/sysfs.h>
2222
#include <linux/input/mt.h>
23+
#include <linux/input/touchscreen.h>
2324
#include <linux/platform_data/zforce_ts.h>
2425
#include <linux/regulator/consumer.h>
2526
#include <linux/of.h>
@@ -106,6 +107,7 @@ struct zforce_point {
106107
struct zforce_ts {
107108
struct i2c_client *client;
108109
struct input_dev *input;
110+
struct touchscreen_properties prop;
109111
const struct zforce_ts_platdata *pdata;
110112
char phys[32];
111113

@@ -266,7 +268,6 @@ static int zforce_setconfig(struct zforce_ts *ts, char b1)
266268
static int zforce_start(struct zforce_ts *ts)
267269
{
268270
struct i2c_client *client = ts->client;
269-
const struct zforce_ts_platdata *pdata = ts->pdata;
270271
int ret;
271272

272273
dev_dbg(&client->dev, "starting device\n");
@@ -277,7 +278,7 @@ static int zforce_start(struct zforce_ts *ts)
277278
return ret;
278279
}
279280

280-
ret = zforce_resolution(ts, pdata->x_max, pdata->y_max);
281+
ret = zforce_resolution(ts, ts->prop.max_x, ts->prop.max_y);
281282
if (ret) {
282283
dev_err(&client->dev, "Unable to set resolution, %d\n", ret);
283284
goto error;
@@ -337,7 +338,6 @@ static int zforce_stop(struct zforce_ts *ts)
337338
static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
338339
{
339340
struct i2c_client *client = ts->client;
340-
const struct zforce_ts_platdata *pdata = ts->pdata;
341341
struct zforce_point point;
342342
int count, i, num = 0;
343343

@@ -355,8 +355,8 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
355355
point.coord_y =
356356
payload[9 * i + 4] << 8 | payload[9 * i + 3];
357357

358-
if (point.coord_x > pdata->x_max ||
359-
point.coord_y > pdata->y_max) {
358+
if (point.coord_x > ts->prop.max_x ||
359+
point.coord_y > ts->prop.max_y) {
360360
dev_warn(&client->dev, "coordinates (%d,%d) invalid\n",
361361
point.coord_x, point.coord_y);
362362
point.coord_x = point.coord_y = 0;
@@ -390,10 +390,9 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
390390
point.state != STATE_UP);
391391

392392
if (point.state != STATE_UP) {
393-
input_report_abs(ts->input, ABS_MT_POSITION_X,
394-
point.coord_x);
395-
input_report_abs(ts->input, ABS_MT_POSITION_Y,
396-
point.coord_y);
393+
touchscreen_report_pos(ts->input, &ts->prop,
394+
point.coord_x, point.coord_y,
395+
true);
397396
input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR,
398397
point.area_major);
399398
input_report_abs(ts->input, ABS_MT_TOUCH_MINOR,
@@ -719,15 +718,8 @@ static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
719718
return ERR_PTR(-ENOMEM);
720719
}
721720

722-
if (of_property_read_u32(np, "x-size", &pdata->x_max)) {
723-
dev_err(dev, "failed to get x-size property\n");
724-
return ERR_PTR(-EINVAL);
725-
}
726-
727-
if (of_property_read_u32(np, "y-size", &pdata->y_max)) {
728-
dev_err(dev, "failed to get y-size property\n");
729-
return ERR_PTR(-EINVAL);
730-
}
721+
of_property_read_u32(np, "x-size", &pdata->x_max);
722+
of_property_read_u32(np, "y-size", &pdata->y_max);
731723

732724
return pdata;
733725
}
@@ -856,6 +848,12 @@ static int zforce_probe(struct i2c_client *client)
856848
input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
857849
pdata->y_max, 0, 0);
858850

851+
touchscreen_parse_properties(input_dev, true, &ts->prop);
852+
if (ts->prop.max_x == 0 || ts->prop.max_y == 0) {
853+
dev_err(&client->dev, "no size specified\n");
854+
return -EINVAL;
855+
}
856+
859857
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
860858
ZFORCE_MAX_AREA, 0, 0);
861859
input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0,

0 commit comments

Comments
 (0)