[PATCH v7 4/9] Input: wacom_i2c - Add touchscren properties

From: Alistair Francis
Date: Thu Jul 08 2021 - 07:59:29 EST


Connect touchscreen properties to the wacom_i2c.

Signed-off-by: Alistair Francis <alistair@xxxxxxxxxxxxx>
---
drivers/input/touchscreen/wacom_i2c.c | 28 ++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/input/touchscreen/wacom_i2c.c b/drivers/input/touchscreen/wacom_i2c.c
index 6053595f2b30..b47bc08efdd1 100644
--- a/drivers/input/touchscreen/wacom_i2c.c
+++ b/drivers/input/touchscreen/wacom_i2c.c
@@ -11,6 +11,7 @@
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/irq.h>
+#include <linux/input/touchscreen.h>
#include <linux/interrupt.h>
#include <linux/of.h>
#include <asm/unaligned.h>
@@ -33,6 +34,8 @@ struct wacom_features {
struct wacom_i2c {
struct i2c_client *client;
struct input_dev *input;
+ struct touchscreen_properties props;
+ struct wacom_features features;
u8 data[WACOM_QUERY_SIZE];
bool prox;
int tool;
@@ -90,6 +93,7 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
{
struct wacom_i2c *wac_i2c = dev_id;
struct input_dev *input = wac_i2c->input;
+ struct wacom_features *features = &wac_i2c->features;
u8 *data = wac_i2c->data;
unsigned int x, y, pressure;
unsigned char tsw, f1, f2, ers;
@@ -114,12 +118,12 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)

wac_i2c->prox = data[3] & 0x20;

+ touchscreen_report_pos(input, &wac_i2c->props, features->x_max,
+ features->y_max, true);
input_report_key(input, BTN_TOUCH, tsw || ers);
input_report_key(input, wac_i2c->tool, wac_i2c->prox);
input_report_key(input, BTN_STYLUS, f1);
input_report_key(input, BTN_STYLUS2, f2);
- input_report_abs(input, ABS_X, x);
- input_report_abs(input, ABS_Y, y);
input_report_abs(input, ABS_PRESSURE, pressure);
input_sync(input);

@@ -151,7 +155,7 @@ static int wacom_i2c_probe(struct i2c_client *client,
struct device *dev = &client->dev;
struct wacom_i2c *wac_i2c;
struct input_dev *input;
- struct wacom_features features = { 0 };
+ struct wacom_features *features;
int error;

if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
@@ -159,14 +163,15 @@ static int wacom_i2c_probe(struct i2c_client *client,
return -EIO;
}

- error = wacom_query_device(client, &features);
- if (error)
- return error;
-
wac_i2c = devm_kzalloc(dev, sizeof(*wac_i2c), GFP_KERNEL);
if (!wac_i2c)
return -ENOMEM;

+ features = &wac_i2c->features;
+ error = wacom_query_device(client, features);
+ if (error)
+ return error;
+
wac_i2c->client = client;

input = devm_input_allocate_device(dev);
@@ -178,7 +183,7 @@ static int wacom_i2c_probe(struct i2c_client *client,
input->name = "Wacom I2C Digitizer";
input->id.bustype = BUS_I2C;
input->id.vendor = 0x56a;
- input->id.version = features.fw_version;
+ input->id.version = features->fw_version;
input->open = wacom_i2c_open;
input->close = wacom_i2c_close;

@@ -190,10 +195,11 @@ static int wacom_i2c_probe(struct i2c_client *client,
__set_bit(BTN_STYLUS2, input->keybit);
__set_bit(BTN_TOUCH, input->keybit);

- input_set_abs_params(input, ABS_X, 0, features.x_max, 0, 0);
- input_set_abs_params(input, ABS_Y, 0, features.y_max, 0, 0);
+ touchscreen_parse_properties(input, true, &wac_i2c->props);
+ input_set_abs_params(input, ABS_X, 0, features->x_max, 0, 0);
+ input_set_abs_params(input, ABS_Y, 0, features->y_max, 0, 0);
input_set_abs_params(input, ABS_PRESSURE,
- 0, features.pressure_max, 0, 0);
+ 0, features->pressure_max, 0, 0);

input_set_drvdata(input, wac_i2c);

--
2.31.1