* [PATCH resend 0/4] of_touchscreen-helpers: Add support for inverted / swapped axis
@ 2016-03-29 8:29 ` Hans de Goede
0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-03-29 8:29 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Maxime Ripard, Chen-Yu Tsai, linux-input, linux-arm-kernel, devicetree
Hi Dmitry,
It seems that this series has fallen through the cracks *again*.
This is a resend of the resend of this set posted a while back, now rebased
on top of v4.6-rc1.
Last time one remark you made was:
+#include <asm/types.h>
> If you are trying to add this to have s32 typedefs
> then I think it is wrong one.
I've double checked and I believe it is the right one,
s32 is typedef-ed in <asm-generic/int-ll64.h> but no-one is including that
directly.
Regards,
Hans
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH resend 0/4] of_touchscreen-helpers: Add support for inverted / swapped axis
@ 2016-03-29 8:29 ` Hans de Goede
0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-03-29 8:29 UTC (permalink / raw)
To: linux-arm-kernel
Hi Dmitry,
It seems that this series has fallen through the cracks *again*.
This is a resend of the resend of this set posted a while back, now rebased
on top of v4.6-rc1.
Last time one remark you made was:
+#include <asm/types.h>
> If you are trying to add this to have s32 typedefs
> then I think it is wrong one.
I've double checked and I believe it is the right one,
s32 is typedef-ed in <asm-generic/int-ll64.h> but no-one is including that
directly.
Regards,
Hans
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH resend 1/4] of_touchscreen-helpers: Add support for inverted / swapped axis
2016-03-29 8:29 ` Hans de Goede
@ 2016-03-29 8:29 ` Hans de Goede
-1 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-03-29 8:29 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Maxime Ripard, Chen-Yu Tsai, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
Hans de Goede
Extend touchscreen_parse_properties() with support for the
touchscreen-inverted-x/y and touchscreen-swapped-x-y properties and
add a touchscreen_apply_prop_to_x_y() helper function for adjusting
x and y coordinates to take these properties into account.
This commit also modifies the existing callers of
touchscreen_parse_properties() to pass in NULL for the new third
argument, keeping the existing behavior.
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
drivers/input/touchscreen/edt-ft5x06.c | 2 +-
drivers/input/touchscreen/of_touchscreen.c | 56 +++++++++++++++++++++++++++++-
drivers/input/touchscreen/pixcir_i2c_ts.c | 2 +-
drivers/input/touchscreen/tsc200x-core.c | 2 +-
include/linux/input/touchscreen.h | 16 ++++++++-
5 files changed, 73 insertions(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 23fbe38..e8825e5 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -972,7 +972,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_MT_POSITION_Y,
0, tsdata->num_y * 64 - 1, 0, 0);
- touchscreen_parse_properties(input, true);
+ touchscreen_parse_properties(input, true, NULL);
error = input_mt_init_slots(input, tsdata->max_support_points,
INPUT_MT_DIRECT);
diff --git a/drivers/input/touchscreen/of_touchscreen.c b/drivers/input/touchscreen/of_touchscreen.c
index bb6f2fe..6fd9872 100644
--- a/drivers/input/touchscreen/of_touchscreen.c
+++ b/drivers/input/touchscreen/of_touchscreen.c
@@ -55,12 +55,16 @@ static void touchscreen_set_params(struct input_dev *dev,
* @input: input device that should be parsed
* @multitouch: specifies whether parsed properties should be applied to
* single-touch or multi-touch axes
+ * @prop: pointer to a struct touchscreen_properties into which to store
+ * axis swap and invert info for use with touchscreen_report_x_y();
+ * or NULL
*
* This function parses common DT properties for touchscreens and setups the
* input device accordingly. The function keeps previously set up default
* values if no value is specified via DT.
*/
-void touchscreen_parse_properties(struct input_dev *input, bool multitouch)
+void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
+ struct touchscreen_properties *prop)
{
struct device *dev = input->dev.parent;
unsigned int axis;
@@ -104,5 +108,55 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch)
&fuzz);
if (data_present)
touchscreen_set_params(input, axis, maximum, fuzz);
+
+ if (!prop)
+ return;
+
+ axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
+
+ prop->max_x = input_abs_get_max(input, axis);
+ prop->max_y = input_abs_get_max(input, axis + 1);
+ prop->invert_x =
+ device_property_read_bool(dev, "touchscreen-inverted-x");
+ prop->invert_y =
+ device_property_read_bool(dev, "touchscreen-inverted-y");
+ prop->swap_x_y =
+ device_property_read_bool(dev, "touchscreen-swapped-x-y");
+
+ if (prop->swap_x_y) {
+ struct input_absinfo tmp_absinfo;
+
+ tmp_absinfo = input->absinfo[axis];
+ input->absinfo[axis] = input->absinfo[axis + 1];
+ input->absinfo[axis + 1] = tmp_absinfo;
+ }
}
EXPORT_SYMBOL(touchscreen_parse_properties);
+
+/**
+ * touchscreen_apply_prop_to_x_y - Adjust abs x and y coordinates
+ * @prop: pointer to a struct touchscreen_properties
+ * @x: X coordinate to apply inversion and swapping to
+ * @y: Y coordinate to apply inversion and swapping to
+ *
+ * Adjust the passed in x and y values applying any axis inversion and
+ * swapping requested in the passed in touchscreen_properties.
+ */
+void touchscreen_apply_prop_to_x_y(struct touchscreen_properties *prop,
+ s16 *x, s16 *y)
+{
+ if (prop->invert_x)
+ *x = prop->max_x - *x;
+
+ if (prop->invert_y)
+ *y = prop->max_y - *y;
+
+ if (prop->swap_x_y) {
+ s16 tmp;
+
+ tmp = *x;
+ *x = *y;
+ *y = tmp;
+ }
+}
+EXPORT_SYMBOL(touchscreen_apply_prop_to_x_y);
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 09523a3..f58784d 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -515,7 +515,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
} else {
input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
- touchscreen_parse_properties(input, true);
+ touchscreen_parse_properties(input, true, NULL);
if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
!input_abs_get_max(input, ABS_MT_POSITION_Y)) {
dev_err(dev, "Touchscreen size is not specified\n");
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
index 15240c1..26e81d1b 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -559,7 +559,7 @@ int tsc200x_probe(struct device *dev, int irq, __u16 bustype,
input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0);
if (np)
- touchscreen_parse_properties(input_dev, false);
+ touchscreen_parse_properties(input_dev, false, NULL);
input_dev->open = tsc200x_open;
input_dev->close = tsc200x_close;
diff --git a/include/linux/input/touchscreen.h b/include/linux/input/touchscreen.h
index c91e137..9e6ba20 100644
--- a/include/linux/input/touchscreen.h
+++ b/include/linux/input/touchscreen.h
@@ -9,8 +9,22 @@
#ifndef _TOUCHSCREEN_H
#define _TOUCHSCREEN_H
+#include <asm/types.h>
+
struct input_dev;
-void touchscreen_parse_properties(struct input_dev *dev, bool multitouch);
+struct touchscreen_properties {
+ s32 max_x;
+ s32 max_y;
+ bool invert_x;
+ bool invert_y;
+ bool swap_x_y;
+};
+
+void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
+ struct touchscreen_properties *prop);
+
+void touchscreen_apply_prop_to_x_y(struct touchscreen_properties *prop,
+ s16 *x, s16 *y);
#endif
--
2.7.3
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH resend 1/4] of_touchscreen-helpers: Add support for inverted / swapped axis
@ 2016-03-29 8:29 ` Hans de Goede
0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-03-29 8:29 UTC (permalink / raw)
To: linux-arm-kernel
Extend touchscreen_parse_properties() with support for the
touchscreen-inverted-x/y and touchscreen-swapped-x-y properties and
add a touchscreen_apply_prop_to_x_y() helper function for adjusting
x and y coordinates to take these properties into account.
This commit also modifies the existing callers of
touchscreen_parse_properties() to pass in NULL for the new third
argument, keeping the existing behavior.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/input/touchscreen/edt-ft5x06.c | 2 +-
drivers/input/touchscreen/of_touchscreen.c | 56 +++++++++++++++++++++++++++++-
drivers/input/touchscreen/pixcir_i2c_ts.c | 2 +-
drivers/input/touchscreen/tsc200x-core.c | 2 +-
include/linux/input/touchscreen.h | 16 ++++++++-
5 files changed, 73 insertions(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 23fbe38..e8825e5 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -972,7 +972,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_MT_POSITION_Y,
0, tsdata->num_y * 64 - 1, 0, 0);
- touchscreen_parse_properties(input, true);
+ touchscreen_parse_properties(input, true, NULL);
error = input_mt_init_slots(input, tsdata->max_support_points,
INPUT_MT_DIRECT);
diff --git a/drivers/input/touchscreen/of_touchscreen.c b/drivers/input/touchscreen/of_touchscreen.c
index bb6f2fe..6fd9872 100644
--- a/drivers/input/touchscreen/of_touchscreen.c
+++ b/drivers/input/touchscreen/of_touchscreen.c
@@ -55,12 +55,16 @@ static void touchscreen_set_params(struct input_dev *dev,
* @input: input device that should be parsed
* @multitouch: specifies whether parsed properties should be applied to
* single-touch or multi-touch axes
+ * @prop: pointer to a struct touchscreen_properties into which to store
+ * axis swap and invert info for use with touchscreen_report_x_y();
+ * or NULL
*
* This function parses common DT properties for touchscreens and setups the
* input device accordingly. The function keeps previously set up default
* values if no value is specified via DT.
*/
-void touchscreen_parse_properties(struct input_dev *input, bool multitouch)
+void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
+ struct touchscreen_properties *prop)
{
struct device *dev = input->dev.parent;
unsigned int axis;
@@ -104,5 +108,55 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch)
&fuzz);
if (data_present)
touchscreen_set_params(input, axis, maximum, fuzz);
+
+ if (!prop)
+ return;
+
+ axis = multitouch ? ABS_MT_POSITION_X : ABS_X;
+
+ prop->max_x = input_abs_get_max(input, axis);
+ prop->max_y = input_abs_get_max(input, axis + 1);
+ prop->invert_x =
+ device_property_read_bool(dev, "touchscreen-inverted-x");
+ prop->invert_y =
+ device_property_read_bool(dev, "touchscreen-inverted-y");
+ prop->swap_x_y =
+ device_property_read_bool(dev, "touchscreen-swapped-x-y");
+
+ if (prop->swap_x_y) {
+ struct input_absinfo tmp_absinfo;
+
+ tmp_absinfo = input->absinfo[axis];
+ input->absinfo[axis] = input->absinfo[axis + 1];
+ input->absinfo[axis + 1] = tmp_absinfo;
+ }
}
EXPORT_SYMBOL(touchscreen_parse_properties);
+
+/**
+ * touchscreen_apply_prop_to_x_y - Adjust abs x and y coordinates
+ * @prop: pointer to a struct touchscreen_properties
+ * @x: X coordinate to apply inversion and swapping to
+ * @y: Y coordinate to apply inversion and swapping to
+ *
+ * Adjust the passed in x and y values applying any axis inversion and
+ * swapping requested in the passed in touchscreen_properties.
+ */
+void touchscreen_apply_prop_to_x_y(struct touchscreen_properties *prop,
+ s16 *x, s16 *y)
+{
+ if (prop->invert_x)
+ *x = prop->max_x - *x;
+
+ if (prop->invert_y)
+ *y = prop->max_y - *y;
+
+ if (prop->swap_x_y) {
+ s16 tmp;
+
+ tmp = *x;
+ *x = *y;
+ *y = tmp;
+ }
+}
+EXPORT_SYMBOL(touchscreen_apply_prop_to_x_y);
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 09523a3..f58784d 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -515,7 +515,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
} else {
input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
- touchscreen_parse_properties(input, true);
+ touchscreen_parse_properties(input, true, NULL);
if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
!input_abs_get_max(input, ABS_MT_POSITION_Y)) {
dev_err(dev, "Touchscreen size is not specified\n");
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
index 15240c1..26e81d1b 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -559,7 +559,7 @@ int tsc200x_probe(struct device *dev, int irq, __u16 bustype,
input_set_abs_params(input_dev, ABS_PRESSURE, 0, max_p, fudge_p, 0);
if (np)
- touchscreen_parse_properties(input_dev, false);
+ touchscreen_parse_properties(input_dev, false, NULL);
input_dev->open = tsc200x_open;
input_dev->close = tsc200x_close;
diff --git a/include/linux/input/touchscreen.h b/include/linux/input/touchscreen.h
index c91e137..9e6ba20 100644
--- a/include/linux/input/touchscreen.h
+++ b/include/linux/input/touchscreen.h
@@ -9,8 +9,22 @@
#ifndef _TOUCHSCREEN_H
#define _TOUCHSCREEN_H
+#include <asm/types.h>
+
struct input_dev;
-void touchscreen_parse_properties(struct input_dev *dev, bool multitouch);
+struct touchscreen_properties {
+ s32 max_x;
+ s32 max_y;
+ bool invert_x;
+ bool invert_y;
+ bool swap_x_y;
+};
+
+void touchscreen_parse_properties(struct input_dev *input, bool multitouch,
+ struct touchscreen_properties *prop);
+
+void touchscreen_apply_prop_to_x_y(struct touchscreen_properties *prop,
+ s16 *x, s16 *y);
#endif
--
2.7.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH resend 2/4] touchscreen: ft5x06: Add support for axis inversion / swapping
2016-03-29 8:29 ` Hans de Goede
@ 2016-03-29 8:29 ` Hans de Goede
-1 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-03-29 8:29 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Maxime Ripard, Chen-Yu Tsai, linux-input, linux-arm-kernel,
devicetree, Hans de Goede
Add support for axis inversion / swapping using the new
touchscreen_parse_properties and touchscreen_apply_prop_to_x_y
functionality.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/input/touchscreen/edt-ft5x06.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index e8825e5..864a7e0 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -86,6 +86,7 @@ struct edt_reg_addr {
struct edt_ft5x06_ts_data {
struct i2c_client *client;
struct input_dev *input;
+ struct touchscreen_properties prop;
u16 num_x;
u16 num_y;
@@ -173,7 +174,8 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
struct device *dev = &tsdata->client->dev;
u8 cmd;
u8 rdbuf[63];
- int i, type, x, y, id;
+ s16 x, y;
+ int i, type, id;
int offset, tplen, datalen, crclen;
int error;
@@ -246,6 +248,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
if (!down)
continue;
+ touchscreen_apply_prop_to_x_y(&tsdata->prop, &x, &y);
input_report_abs(tsdata->input, ABS_MT_POSITION_X, x);
input_report_abs(tsdata->input, ABS_MT_POSITION_Y, y);
}
@@ -972,7 +975,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_MT_POSITION_Y,
0, tsdata->num_y * 64 - 1, 0, 0);
- touchscreen_parse_properties(input, true, NULL);
+ touchscreen_parse_properties(input, true, &tsdata->prop);
error = input_mt_init_slots(input, tsdata->max_support_points,
INPUT_MT_DIRECT);
--
2.7.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH resend 2/4] touchscreen: ft5x06: Add support for axis inversion / swapping
@ 2016-03-29 8:29 ` Hans de Goede
0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-03-29 8:29 UTC (permalink / raw)
To: linux-arm-kernel
Add support for axis inversion / swapping using the new
touchscreen_parse_properties and touchscreen_apply_prop_to_x_y
functionality.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/input/touchscreen/edt-ft5x06.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index e8825e5..864a7e0 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -86,6 +86,7 @@ struct edt_reg_addr {
struct edt_ft5x06_ts_data {
struct i2c_client *client;
struct input_dev *input;
+ struct touchscreen_properties prop;
u16 num_x;
u16 num_y;
@@ -173,7 +174,8 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
struct device *dev = &tsdata->client->dev;
u8 cmd;
u8 rdbuf[63];
- int i, type, x, y, id;
+ s16 x, y;
+ int i, type, id;
int offset, tplen, datalen, crclen;
int error;
@@ -246,6 +248,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
if (!down)
continue;
+ touchscreen_apply_prop_to_x_y(&tsdata->prop, &x, &y);
input_report_abs(tsdata->input, ABS_MT_POSITION_X, x);
input_report_abs(tsdata->input, ABS_MT_POSITION_Y, y);
}
@@ -972,7 +975,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_MT_POSITION_Y,
0, tsdata->num_y * 64 - 1, 0, 0);
- touchscreen_parse_properties(input, true, NULL);
+ touchscreen_parse_properties(input, true, &tsdata->prop);
error = input_mt_init_slots(input, tsdata->max_support_points,
INPUT_MT_DIRECT);
--
2.7.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH resend 3/4] touchscreen: icn8318: Use parse_properties and apply_prop_to_x_y helpers
2016-03-29 8:29 ` Hans de Goede
@ 2016-03-29 8:29 ` Hans de Goede
-1 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-03-29 8:29 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Maxime Ripard, Chen-Yu Tsai, linux-input, linux-arm-kernel,
devicetree, Hans de Goede
Use the touchscreen_parse_properties and touchscreen_apply_prop_to_x_y
functions, instead of DIY code, this results in a nice cleanup.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Call input_set_capability() before calling touchscreen_parse_properties()
---
drivers/input/touchscreen/chipone_icn8318.c | 58 +++++++----------------------
1 file changed, 14 insertions(+), 44 deletions(-)
diff --git a/drivers/input/touchscreen/chipone_icn8318.c b/drivers/input/touchscreen/chipone_icn8318.c
index 22a6fea..92151f9 100644
--- a/drivers/input/touchscreen/chipone_icn8318.c
+++ b/drivers/input/touchscreen/chipone_icn8318.c
@@ -17,6 +17,7 @@
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
+#include <linux/input/touchscreen.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -52,11 +53,7 @@ struct icn8318_data {
struct i2c_client *client;
struct input_dev *input;
struct gpio_desc *wake_gpio;
- u32 max_x;
- u32 max_y;
- bool invert_x;
- bool invert_y;
- bool swap_x_y;
+ struct touchscreen_properties prop;
};
static int icn8318_read_touch_data(struct i2c_client *client,
@@ -91,7 +88,8 @@ static irqreturn_t icn8318_irq(int irq, void *dev_id)
struct icn8318_data *data = dev_id;
struct device *dev = &data->client->dev;
struct icn8318_touch_data touch_data;
- int i, ret, x, y;
+ int i, ret;
+ s16 x, y;
ret = icn8318_read_touch_data(data->client, &touch_data);
if (ret < 0) {
@@ -127,19 +125,9 @@ static irqreturn_t icn8318_irq(int irq, void *dev_id)
x = be16_to_cpu(touch->x);
y = be16_to_cpu(touch->y);
- if (data->invert_x)
- x = data->max_x - x;
-
- if (data->invert_y)
- y = data->max_y - y;
-
- if (!data->swap_x_y) {
- input_event(data->input, EV_ABS, ABS_MT_POSITION_X, x);
- input_event(data->input, EV_ABS, ABS_MT_POSITION_Y, y);
- } else {
- input_event(data->input, EV_ABS, ABS_MT_POSITION_X, y);
- input_event(data->input, EV_ABS, ABS_MT_POSITION_Y, x);
- }
+ touchscreen_apply_prop_to_x_y(&data->prop, &x, &y);
+ input_event(data->input, EV_ABS, ABS_MT_POSITION_X, x);
+ input_event(data->input, EV_ABS, ABS_MT_POSITION_Y, y);
}
input_mt_sync_frame(data->input);
@@ -200,10 +188,8 @@ static int icn8318_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
- struct device_node *np = dev->of_node;
struct icn8318_data *data;
struct input_dev *input;
- u32 fuzz_x = 0, fuzz_y = 0;
int error;
if (!client->irq) {
@@ -223,19 +209,6 @@ static int icn8318_probe(struct i2c_client *client,
return error;
}
- if (of_property_read_u32(np, "touchscreen-size-x", &data->max_x) ||
- of_property_read_u32(np, "touchscreen-size-y", &data->max_y)) {
- dev_err(dev, "Error touchscreen-size-x and/or -y missing\n");
- return -EINVAL;
- }
-
- /* Optional */
- of_property_read_u32(np, "touchscreen-fuzz-x", &fuzz_x);
- of_property_read_u32(np, "touchscreen-fuzz-y", &fuzz_y);
- data->invert_x = of_property_read_bool(np, "touchscreen-inverted-x");
- data->invert_y = of_property_read_bool(np, "touchscreen-inverted-y");
- data->swap_x_y = of_property_read_bool(np, "touchscreen-swapped-x-y");
-
input = devm_input_allocate_device(dev);
if (!input)
return -ENOMEM;
@@ -246,16 +219,13 @@ static int icn8318_probe(struct i2c_client *client,
input->close = icn8318_stop;
input->dev.parent = dev;
- if (!data->swap_x_y) {
- input_set_abs_params(input, ABS_MT_POSITION_X, 0,
- data->max_x, fuzz_x, 0);
- input_set_abs_params(input, ABS_MT_POSITION_Y, 0,
- data->max_y, fuzz_y, 0);
- } else {
- input_set_abs_params(input, ABS_MT_POSITION_X, 0,
- data->max_y, fuzz_y, 0);
- input_set_abs_params(input, ABS_MT_POSITION_Y, 0,
- data->max_x, fuzz_x, 0);
+ input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
+ input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
+ touchscreen_parse_properties(input, true, &data->prop);
+ if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
+ !input_abs_get_max(input, ABS_MT_POSITION_Y)) {
+ dev_err(dev, "Error touchscreen-size-x and/or -y missing\n");
+ return -EINVAL;
}
error = input_mt_init_slots(input, ICN8318_MAX_TOUCHES,
--
2.7.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH resend 3/4] touchscreen: icn8318: Use parse_properties and apply_prop_to_x_y helpers
@ 2016-03-29 8:29 ` Hans de Goede
0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-03-29 8:29 UTC (permalink / raw)
To: linux-arm-kernel
Use the touchscreen_parse_properties and touchscreen_apply_prop_to_x_y
functions, instead of DIY code, this results in a nice cleanup.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Call input_set_capability() before calling touchscreen_parse_properties()
---
drivers/input/touchscreen/chipone_icn8318.c | 58 +++++++----------------------
1 file changed, 14 insertions(+), 44 deletions(-)
diff --git a/drivers/input/touchscreen/chipone_icn8318.c b/drivers/input/touchscreen/chipone_icn8318.c
index 22a6fea..92151f9 100644
--- a/drivers/input/touchscreen/chipone_icn8318.c
+++ b/drivers/input/touchscreen/chipone_icn8318.c
@@ -17,6 +17,7 @@
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
+#include <linux/input/touchscreen.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -52,11 +53,7 @@ struct icn8318_data {
struct i2c_client *client;
struct input_dev *input;
struct gpio_desc *wake_gpio;
- u32 max_x;
- u32 max_y;
- bool invert_x;
- bool invert_y;
- bool swap_x_y;
+ struct touchscreen_properties prop;
};
static int icn8318_read_touch_data(struct i2c_client *client,
@@ -91,7 +88,8 @@ static irqreturn_t icn8318_irq(int irq, void *dev_id)
struct icn8318_data *data = dev_id;
struct device *dev = &data->client->dev;
struct icn8318_touch_data touch_data;
- int i, ret, x, y;
+ int i, ret;
+ s16 x, y;
ret = icn8318_read_touch_data(data->client, &touch_data);
if (ret < 0) {
@@ -127,19 +125,9 @@ static irqreturn_t icn8318_irq(int irq, void *dev_id)
x = be16_to_cpu(touch->x);
y = be16_to_cpu(touch->y);
- if (data->invert_x)
- x = data->max_x - x;
-
- if (data->invert_y)
- y = data->max_y - y;
-
- if (!data->swap_x_y) {
- input_event(data->input, EV_ABS, ABS_MT_POSITION_X, x);
- input_event(data->input, EV_ABS, ABS_MT_POSITION_Y, y);
- } else {
- input_event(data->input, EV_ABS, ABS_MT_POSITION_X, y);
- input_event(data->input, EV_ABS, ABS_MT_POSITION_Y, x);
- }
+ touchscreen_apply_prop_to_x_y(&data->prop, &x, &y);
+ input_event(data->input, EV_ABS, ABS_MT_POSITION_X, x);
+ input_event(data->input, EV_ABS, ABS_MT_POSITION_Y, y);
}
input_mt_sync_frame(data->input);
@@ -200,10 +188,8 @@ static int icn8318_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
- struct device_node *np = dev->of_node;
struct icn8318_data *data;
struct input_dev *input;
- u32 fuzz_x = 0, fuzz_y = 0;
int error;
if (!client->irq) {
@@ -223,19 +209,6 @@ static int icn8318_probe(struct i2c_client *client,
return error;
}
- if (of_property_read_u32(np, "touchscreen-size-x", &data->max_x) ||
- of_property_read_u32(np, "touchscreen-size-y", &data->max_y)) {
- dev_err(dev, "Error touchscreen-size-x and/or -y missing\n");
- return -EINVAL;
- }
-
- /* Optional */
- of_property_read_u32(np, "touchscreen-fuzz-x", &fuzz_x);
- of_property_read_u32(np, "touchscreen-fuzz-y", &fuzz_y);
- data->invert_x = of_property_read_bool(np, "touchscreen-inverted-x");
- data->invert_y = of_property_read_bool(np, "touchscreen-inverted-y");
- data->swap_x_y = of_property_read_bool(np, "touchscreen-swapped-x-y");
-
input = devm_input_allocate_device(dev);
if (!input)
return -ENOMEM;
@@ -246,16 +219,13 @@ static int icn8318_probe(struct i2c_client *client,
input->close = icn8318_stop;
input->dev.parent = dev;
- if (!data->swap_x_y) {
- input_set_abs_params(input, ABS_MT_POSITION_X, 0,
- data->max_x, fuzz_x, 0);
- input_set_abs_params(input, ABS_MT_POSITION_Y, 0,
- data->max_y, fuzz_y, 0);
- } else {
- input_set_abs_params(input, ABS_MT_POSITION_X, 0,
- data->max_y, fuzz_y, 0);
- input_set_abs_params(input, ABS_MT_POSITION_Y, 0,
- data->max_x, fuzz_x, 0);
+ input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
+ input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
+ touchscreen_parse_properties(input, true, &data->prop);
+ if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
+ !input_abs_get_max(input, ABS_MT_POSITION_Y)) {
+ dev_err(dev, "Error touchscreen-size-x and/or -y missing\n");
+ return -EINVAL;
}
error = input_mt_init_slots(input, ICN8318_MAX_TOUCHES,
--
2.7.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH resend 4/4] touchscreen: pixcir_ts: Add support for axis inversion / swapping
2016-03-29 8:29 ` Hans de Goede
@ 2016-03-29 8:29 ` Hans de Goede
-1 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-03-29 8:29 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Maxime Ripard, Chen-Yu Tsai, linux-input, linux-arm-kernel,
devicetree, Hans de Goede
Add support for axis inversion / swapping using the new
touchscreen_parse_properties and touchscreen_apply_prop_to_x_y
functionality.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Add a fix which actually makes this patch compile, which accidentally ended
up in a later commit in my tree
---
drivers/input/touchscreen/pixcir_i2c_ts.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index f58784d..0321be3 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -41,13 +41,14 @@ struct pixcir_i2c_ts_data {
struct gpio_desc *gpio_enable;
struct gpio_desc *gpio_wake;
const struct pixcir_i2c_chip_data *chip;
+ struct touchscreen_properties prop;
int max_fingers; /* Max fingers supported in this instance */
bool running;
};
struct pixcir_touch {
- int x;
- int y;
+ s16 x;
+ s16 y;
int id;
};
@@ -100,6 +101,9 @@ static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
for (i = 0; i < touch; i++) {
report->touches[i].x = (bufptr[1] << 8) | bufptr[0];
report->touches[i].y = (bufptr[3] << 8) | bufptr[2];
+ touchscreen_apply_prop_to_x_y(&tsdata->prop,
+ &report->touches[i].x,
+ &report->touches[i].y);
if (chip->has_hw_ids) {
report->touches[i].id = bufptr[4];
@@ -515,7 +519,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
} else {
input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
- touchscreen_parse_properties(input, true, NULL);
+ touchscreen_parse_properties(input, true, &tsdata->prop);
if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
!input_abs_get_max(input, ABS_MT_POSITION_Y)) {
dev_err(dev, "Touchscreen size is not specified\n");
--
2.7.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH resend 4/4] touchscreen: pixcir_ts: Add support for axis inversion / swapping
@ 2016-03-29 8:29 ` Hans de Goede
0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-03-29 8:29 UTC (permalink / raw)
To: linux-arm-kernel
Add support for axis inversion / swapping using the new
touchscreen_parse_properties and touchscreen_apply_prop_to_x_y
functionality.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Add a fix which actually makes this patch compile, which accidentally ended
up in a later commit in my tree
---
drivers/input/touchscreen/pixcir_i2c_ts.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index f58784d..0321be3 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -41,13 +41,14 @@ struct pixcir_i2c_ts_data {
struct gpio_desc *gpio_enable;
struct gpio_desc *gpio_wake;
const struct pixcir_i2c_chip_data *chip;
+ struct touchscreen_properties prop;
int max_fingers; /* Max fingers supported in this instance */
bool running;
};
struct pixcir_touch {
- int x;
- int y;
+ s16 x;
+ s16 y;
int id;
};
@@ -100,6 +101,9 @@ static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
for (i = 0; i < touch; i++) {
report->touches[i].x = (bufptr[1] << 8) | bufptr[0];
report->touches[i].y = (bufptr[3] << 8) | bufptr[2];
+ touchscreen_apply_prop_to_x_y(&tsdata->prop,
+ &report->touches[i].x,
+ &report->touches[i].y);
if (chip->has_hw_ids) {
report->touches[i].id = bufptr[4];
@@ -515,7 +519,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
} else {
input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
- touchscreen_parse_properties(input, true, NULL);
+ touchscreen_parse_properties(input, true, &tsdata->prop);
if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
!input_abs_get_max(input, ABS_MT_POSITION_Y)) {
dev_err(dev, "Touchscreen size is not specified\n");
--
2.7.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH resend 2/4] touchscreen: ft5x06: Add support for axis inversion / swapping
2016-01-27 18:25 [PATCH resend 0/4] of_touchscreen-helpers: Add support for inverted / s Hans de Goede
@ 2016-01-27 18:25 ` Hans de Goede
0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-01-27 18:25 UTC (permalink / raw)
To: Dmitry Torokhov, Rob Herring
Cc: Maxime Ripard, Chen-Yu Tsai, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
Hans de Goede
Add support for axis inversion / swapping using the new
touchscreen_parse_properties and touchscreen_apply_prop_to_x_y
functionality.
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
drivers/input/touchscreen/edt-ft5x06.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index a97b54a..6fe8d51 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -86,6 +86,7 @@ struct edt_reg_addr {
struct edt_ft5x06_ts_data {
struct i2c_client *client;
struct input_dev *input;
+ struct touchscreen_properties prop;
u16 num_x;
u16 num_y;
@@ -173,7 +174,8 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
struct device *dev = &tsdata->client->dev;
u8 cmd;
u8 rdbuf[63];
- int i, type, x, y, id;
+ s16 x, y;
+ int i, type, id;
int offset, tplen, datalen, crclen;
int error;
@@ -246,6 +248,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
if (!down)
continue;
+ touchscreen_apply_prop_to_x_y(&tsdata->prop, &x, &y);
input_report_abs(tsdata->input, ABS_MT_POSITION_X, x);
input_report_abs(tsdata->input, ABS_MT_POSITION_Y, y);
}
@@ -966,7 +969,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_MT_POSITION_Y,
0, tsdata->num_y * 64 - 1, 0, 0);
- touchscreen_parse_properties(input, true, NULL);
+ touchscreen_parse_properties(input, true, &tsdata->prop);
error = input_mt_init_slots(input, tsdata->max_support_points,
INPUT_MT_DIRECT);
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH resend 2/4] touchscreen: ft5x06: Add support for axis inversion / swapping
@ 2016-01-27 18:25 ` Hans de Goede
0 siblings, 0 replies; 12+ messages in thread
From: Hans de Goede @ 2016-01-27 18:25 UTC (permalink / raw)
To: linux-arm-kernel
Add support for axis inversion / swapping using the new
touchscreen_parse_properties and touchscreen_apply_prop_to_x_y
functionality.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/input/touchscreen/edt-ft5x06.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index a97b54a..6fe8d51 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -86,6 +86,7 @@ struct edt_reg_addr {
struct edt_ft5x06_ts_data {
struct i2c_client *client;
struct input_dev *input;
+ struct touchscreen_properties prop;
u16 num_x;
u16 num_y;
@@ -173,7 +174,8 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
struct device *dev = &tsdata->client->dev;
u8 cmd;
u8 rdbuf[63];
- int i, type, x, y, id;
+ s16 x, y;
+ int i, type, id;
int offset, tplen, datalen, crclen;
int error;
@@ -246,6 +248,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
if (!down)
continue;
+ touchscreen_apply_prop_to_x_y(&tsdata->prop, &x, &y);
input_report_abs(tsdata->input, ABS_MT_POSITION_X, x);
input_report_abs(tsdata->input, ABS_MT_POSITION_Y, y);
}
@@ -966,7 +969,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
input_set_abs_params(input, ABS_MT_POSITION_Y,
0, tsdata->num_y * 64 - 1, 0, 0);
- touchscreen_parse_properties(input, true, NULL);
+ touchscreen_parse_properties(input, true, &tsdata->prop);
error = input_mt_init_slots(input, tsdata->max_support_points,
INPUT_MT_DIRECT);
--
2.5.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-03-29 8:29 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-29 8:29 [PATCH resend 0/4] of_touchscreen-helpers: Add support for inverted / swapped axis Hans de Goede
2016-03-29 8:29 ` Hans de Goede
[not found] ` <1459240169-11531-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-03-29 8:29 ` [PATCH resend 1/4] " Hans de Goede
2016-03-29 8:29 ` Hans de Goede
2016-03-29 8:29 ` [PATCH resend 2/4] touchscreen: ft5x06: Add support for axis inversion / swapping Hans de Goede
2016-03-29 8:29 ` Hans de Goede
2016-03-29 8:29 ` [PATCH resend 3/4] touchscreen: icn8318: Use parse_properties and apply_prop_to_x_y helpers Hans de Goede
2016-03-29 8:29 ` Hans de Goede
2016-03-29 8:29 ` [PATCH resend 4/4] touchscreen: pixcir_ts: Add support for axis inversion / swapping Hans de Goede
2016-03-29 8:29 ` Hans de Goede
-- strict thread matches above, loose matches on Subject: below --
2016-01-27 18:25 [PATCH resend 0/4] of_touchscreen-helpers: Add support for inverted / s Hans de Goede
[not found] ` <1453919124-3840-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 18:25 ` [PATCH resend 2/4] touchscreen: ft5x06: Add support for axis inversion / swapping Hans de Goede
2016-01-27 18:25 ` Hans de Goede
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.