summaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2019-08-09 22:50:15 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2019-09-02 19:07:38 +0300
commit4b6253fa736494346bab381114611e358afae545 (patch)
tree267f347ed6b3a1feba5b3ab8138f89f1df1c3084 /drivers/input
parent307ec663f6c3e9a0a80c7092a1dea6e09debc127 (diff)
downloadlinux-4b6253fa736494346bab381114611e358afae545.tar.xz
Input: bu21013_ts - switch to using standard touchscreen properties
This switches the driver over to the standard touchscreen properties for coordinate transformation, while keeping old bindings working as well. Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/bu21013_ts.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 2bff3f3f4464..2f1f0d7607f8 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -10,6 +10,7 @@
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
+#include <linux/input/touchscreen.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -139,6 +140,7 @@
* struct bu21013_ts - touch panel data structure
* @client: pointer to the i2c client
* @in_dev: pointer to the input device structure
+ * @props: the device coordinate transformation properties
* @regulator: pointer to the Regulator used for touch screen
* @cs_gpiod: chip select GPIO line
* @int_gpiod: touch interrupt GPIO line
@@ -155,6 +157,7 @@
struct bu21013_ts {
struct i2c_client *client;
struct input_dev *in_dev;
+ struct touchscreen_properties props;
struct regulator *regulator;
struct gpio_desc *cs_gpiod;
struct gpio_desc *int_gpiod;
@@ -201,19 +204,13 @@ static int bu21013_do_touch_report(struct bu21013_ts *ts)
for (i = 0; i < MAX_FINGERS; i++) {
const u8 *data = &buf[4 * i + 3];
- struct input_mt_pos *p = &pos[finger_down_count];
+ unsigned int x, y;
- p->x = data[0] << SHIFT_2 | (data[1] & MASK_BITS);
- p->y = data[2] << SHIFT_2 | (data[3] & MASK_BITS);
- if (p->x == 0 || p->y == 0)
- continue;
-
- finger_down_count++;
-
- if (ts->x_flip)
- p->x = ts->touch_x_max - p->x;
- if (ts->y_flip)
- p->y = ts->touch_y_max - p->y;
+ x = data[0] << SHIFT_2 | (data[1] & MASK_BITS);
+ y = data[2] << SHIFT_2 | (data[3] & MASK_BITS);
+ if (x != 0 && y != 0)
+ touchscreen_set_mt_pos(&pos[finger_down_count++],
+ &ts->props, x, y);
}
if (finger_down_count == 2 &&
@@ -412,6 +409,8 @@ static int bu21013_probe(struct i2c_client *client,
{
struct bu21013_ts *ts;
struct input_dev *in_dev;
+ struct input_absinfo *info;
+ u32 max_x = 0, max_y = 0;
int error;
if (!i2c_check_functionality(client->adapter,
@@ -434,11 +433,6 @@ static int bu21013_probe(struct i2c_client *client,
ts->x_flip = device_property_read_bool(&client->dev, "rohm,flip-x");
ts->y_flip = device_property_read_bool(&client->dev, "rohm,flip-y");
- device_property_read_u32(&client->dev, "rohm,touch-max-x",
- &ts->touch_x_max);
- device_property_read_u32(&client->dev, "rohm,touch-max-y",
- &ts->touch_y_max);
-
in_dev = devm_input_allocate_device(&client->dev);
if (!in_dev) {
dev_err(&client->dev, "device memory alloc failed\n");
@@ -451,10 +445,28 @@ static int bu21013_probe(struct i2c_client *client,
in_dev->name = DRIVER_TP;
in_dev->id.bustype = BUS_I2C;
- input_set_abs_params(in_dev, ABS_MT_POSITION_X,
- 0, ts->touch_x_max, 0, 0);
- input_set_abs_params(in_dev, ABS_MT_POSITION_Y,
- 0, ts->touch_y_max, 0, 0);
+ device_property_read_u32(&client->dev, "rohm,touch-max-x", &max_x);
+ device_property_read_u32(&client->dev, "rohm,touch-max-y", &max_y);
+
+ input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, max_x, 0, 0);
+ input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
+
+ touchscreen_parse_properties(in_dev, true, &ts->props);
+
+ /* Adjust for the legacy "flip" properties, if present */
+ if (!ts->props.invert_x &&
+ device_property_read_bool(&client->dev, "rohm,flip-x")) {
+ info = &in_dev->absinfo[ABS_MT_POSITION_X];
+ info->maximum -= info->minimum;
+ info->minimum = 0;
+ }
+
+ if (!ts->props.invert_y &&
+ device_property_read_bool(&client->dev, "rohm,flip-y")) {
+ info = &in_dev->absinfo[ABS_MT_POSITION_Y];
+ info->maximum -= info->minimum;
+ info->minimum = 0;
+ }
error = input_mt_init_slots(in_dev, MAX_FINGERS,
INPUT_MT_DIRECT | INPUT_MT_TRACK |