Commit 435e84ec authored by Andreas Kemnade's avatar Andreas Kemnade Committed by Dmitry Torokhov

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: default avatarAndreas Kemnade <andreas@kemnade.info>
Link: https://lore.kernel.org/r/20231223221213.774868-4-andreas@kemnade.infoSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent cc040e42
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/input/mt.h> #include <linux/input/mt.h>
#include <linux/input/touchscreen.h>
#include <linux/platform_data/zforce_ts.h> #include <linux/platform_data/zforce_ts.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/of.h> #include <linux/of.h>
...@@ -106,6 +107,7 @@ struct zforce_point { ...@@ -106,6 +107,7 @@ struct zforce_point {
struct zforce_ts { struct zforce_ts {
struct i2c_client *client; struct i2c_client *client;
struct input_dev *input; struct input_dev *input;
struct touchscreen_properties prop;
const struct zforce_ts_platdata *pdata; const struct zforce_ts_platdata *pdata;
char phys[32]; char phys[32];
...@@ -266,7 +268,6 @@ static int zforce_setconfig(struct zforce_ts *ts, char b1) ...@@ -266,7 +268,6 @@ static int zforce_setconfig(struct zforce_ts *ts, char b1)
static int zforce_start(struct zforce_ts *ts) static int zforce_start(struct zforce_ts *ts)
{ {
struct i2c_client *client = ts->client; struct i2c_client *client = ts->client;
const struct zforce_ts_platdata *pdata = ts->pdata;
int ret; int ret;
dev_dbg(&client->dev, "starting device\n"); dev_dbg(&client->dev, "starting device\n");
...@@ -277,7 +278,7 @@ static int zforce_start(struct zforce_ts *ts) ...@@ -277,7 +278,7 @@ static int zforce_start(struct zforce_ts *ts)
return ret; return ret;
} }
ret = zforce_resolution(ts, pdata->x_max, pdata->y_max); ret = zforce_resolution(ts, ts->prop.max_x, ts->prop.max_y);
if (ret) { if (ret) {
dev_err(&client->dev, "Unable to set resolution, %d\n", ret); dev_err(&client->dev, "Unable to set resolution, %d\n", ret);
goto error; goto error;
...@@ -337,7 +338,6 @@ static int zforce_stop(struct zforce_ts *ts) ...@@ -337,7 +338,6 @@ static int zforce_stop(struct zforce_ts *ts)
static int zforce_touch_event(struct zforce_ts *ts, u8 *payload) static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
{ {
struct i2c_client *client = ts->client; struct i2c_client *client = ts->client;
const struct zforce_ts_platdata *pdata = ts->pdata;
struct zforce_point point; struct zforce_point point;
int count, i, num = 0; int count, i, num = 0;
...@@ -355,8 +355,8 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload) ...@@ -355,8 +355,8 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
point.coord_y = point.coord_y =
payload[9 * i + 4] << 8 | payload[9 * i + 3]; payload[9 * i + 4] << 8 | payload[9 * i + 3];
if (point.coord_x > pdata->x_max || if (point.coord_x > ts->prop.max_x ||
point.coord_y > pdata->y_max) { point.coord_y > ts->prop.max_y) {
dev_warn(&client->dev, "coordinates (%d,%d) invalid\n", dev_warn(&client->dev, "coordinates (%d,%d) invalid\n",
point.coord_x, point.coord_y); point.coord_x, point.coord_y);
point.coord_x = point.coord_y = 0; point.coord_x = point.coord_y = 0;
...@@ -390,10 +390,9 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload) ...@@ -390,10 +390,9 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
point.state != STATE_UP); point.state != STATE_UP);
if (point.state != STATE_UP) { if (point.state != STATE_UP) {
input_report_abs(ts->input, ABS_MT_POSITION_X, touchscreen_report_pos(ts->input, &ts->prop,
point.coord_x); point.coord_x, point.coord_y,
input_report_abs(ts->input, ABS_MT_POSITION_Y, true);
point.coord_y);
input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR,
point.area_major); point.area_major);
input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, input_report_abs(ts->input, ABS_MT_TOUCH_MINOR,
...@@ -719,15 +718,8 @@ static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev) ...@@ -719,15 +718,8 @@ static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
if (of_property_read_u32(np, "x-size", &pdata->x_max)) { of_property_read_u32(np, "x-size", &pdata->x_max);
dev_err(dev, "failed to get x-size property\n"); of_property_read_u32(np, "y-size", &pdata->y_max);
return ERR_PTR(-EINVAL);
}
if (of_property_read_u32(np, "y-size", &pdata->y_max)) {
dev_err(dev, "failed to get y-size property\n");
return ERR_PTR(-EINVAL);
}
return pdata; return pdata;
} }
...@@ -856,6 +848,12 @@ static int zforce_probe(struct i2c_client *client) ...@@ -856,6 +848,12 @@ static int zforce_probe(struct i2c_client *client)
input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
pdata->y_max, 0, 0); pdata->y_max, 0, 0);
touchscreen_parse_properties(input_dev, true, &ts->prop);
if (ts->prop.max_x == 0 || ts->prop.max_y == 0) {
dev_err(&client->dev, "no size specified\n");
return -EINVAL;
}
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0,
ZFORCE_MAX_AREA, 0, 0); ZFORCE_MAX_AREA, 0, 0);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment