* [PATCH 2/7] touchscreen: ft5x06: Add support for axis inversion / swapping
[not found] ` <1448018233-27824-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2015-11-20 11:17 ` Hans de Goede
2015-11-20 11:17 ` [PATCH 3/7] touchscreen: icn8318: Use parse_properties and apply_prop_to_x_y helpers Hans de Goede
` (5 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Hans de Goede @ 2015-11-20 11:17 UTC (permalink / raw)
To: Dmitry Torokhov, Maxime Ripard
Cc: Sander Vermin, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, 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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/7] touchscreen: icn8318: Use parse_properties and apply_prop_to_x_y helpers
[not found] ` <1448018233-27824-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-20 11:17 ` [PATCH 2/7] touchscreen: ft5x06: Add support for axis inversion / swapping Hans de Goede
@ 2015-11-20 11:17 ` Hans de Goede
2015-11-20 11:17 ` [PATCH 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios Hans de Goede
` (4 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Hans de Goede @ 2015-11-20 11:17 UTC (permalink / raw)
To: Dmitry Torokhov, Maxime Ripard
Cc: Sander Vermin, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
drivers/input/touchscreen/chipone_icn8318.c | 56 +++++++----------------------
1 file changed, 12 insertions(+), 44 deletions(-)
diff --git a/drivers/input/touchscreen/chipone_icn8318.c b/drivers/input/touchscreen/chipone_icn8318.c
index 22a6fea..d0ffeba 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,11 @@ 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);
+ 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.5.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios
[not found] ` <1448018233-27824-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-20 11:17 ` [PATCH 2/7] touchscreen: ft5x06: Add support for axis inversion / swapping Hans de Goede
2015-11-20 11:17 ` [PATCH 3/7] touchscreen: icn8318: Use parse_properties and apply_prop_to_x_y helpers Hans de Goede
@ 2015-11-20 11:17 ` Hans de Goede
2015-11-20 14:43 ` Rob Herring
[not found] ` <1448018233-27824-5-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-20 11:17 ` [PATCH 5/7] touchscreen: pixcir_ts: Add support for axis inversion / swapping Hans de Goede
` (3 subsequent siblings)
6 siblings, 2 replies; 13+ messages in thread
From: Hans de Goede @ 2015-11-20 11:17 UTC (permalink / raw)
To: Dmitry Torokhov, Maxime Ripard
Cc: Sander Vermin, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Hans de Goede
From: Sander Vermin <sander-wENMetUwf8VmR6Xm/wNWPw@public.gmane.org>
On some devices the wake and enable pins of the pixcir touchscreen
controller are connected to gpios and these must be controlled by the
driver for the device to operate properly.
Signed-off-by: Sander Vermin <sander-wENMetUwf8VmR6Xm/wNWPw@public.gmane.org>
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
Changes in v2 (Hans de Goede):
-Split the changes for dealing with inverted / swapped axis out into a
separate patch
-Remove a bunch of dev_info calls to make the driver less chatty
-Use devm_gpiod_get_optional as these new gpios are optional
-Only msleep after setting enable high if we have an enable pin
---
.../bindings/input/touchscreen/pixcir_i2c_ts.txt | 2 +
drivers/input/touchscreen/pixcir_i2c_ts.c | 46 ++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
index 8eb240a..72ca5ec 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
@@ -10,6 +10,8 @@ Required properties:
Optional properties:
- reset-gpio: GPIO connected to the RESET line of the chip
+- enable-gpios: GPIO connected to the ENABLE line of the chip
+- wake-gpios: GPIO connected to the WAKE line of the chip
Example:
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 211408c..b75ef65 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
struct input_dev *input;
struct gpio_desc *gpio_attb;
struct gpio_desc *gpio_reset;
+ struct gpio_desc *gpio_enable;
+ struct gpio_desc *gpio_wake;
const struct pixcir_i2c_chip_data *chip;
int max_fingers; /* Max fingers supported in this instance */
bool running;
@@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct pixcir_i2c_ts_data *ts,
struct device *dev = &ts->client->dev;
int ret;
+ if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
+ if (!IS_ERR_OR_NULL(ts->gpio_wake))
+ gpiod_set_value_cansleep(ts->gpio_wake, 1);
+ }
+
ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_POWER_MODE);
if (ret < 0) {
dev_err(dev, "%s: can't read reg 0x%x : %d\n",
@@ -228,6 +235,11 @@ static int pixcir_set_power_mode(struct pixcir_i2c_ts_data *ts,
return ret;
}
+ if (mode == PIXCIR_POWER_HALT) {
+ if (!IS_ERR_OR_NULL(ts->gpio_wake))
+ gpiod_set_value_cansleep(ts->gpio_wake, 0);
+ }
+
return 0;
}
@@ -302,6 +314,11 @@ static int pixcir_start(struct pixcir_i2c_ts_data *ts)
struct device *dev = &ts->client->dev;
int error;
+ if (!IS_ERR_OR_NULL(ts->gpio_enable)) {
+ gpiod_set_value_cansleep(ts->gpio_enable, 1);
+ msleep(100);
+ }
+
/* LEVEL_TOUCH interrupt with active low polarity */
error = pixcir_set_int_mode(ts, PIXCIR_INT_LEVEL_TOUCH, 0);
if (error) {
@@ -343,6 +360,9 @@ static int pixcir_stop(struct pixcir_i2c_ts_data *ts)
/* Wait till running ISR is complete */
synchronize_irq(ts->client->irq);
+ if (!IS_ERR_OR_NULL(ts->gpio_enable))
+ gpiod_set_value_cansleep(ts->gpio_enable, 0);
+
return 0;
}
@@ -534,6 +554,24 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
return error;
}
+ tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake",
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(tsdata->gpio_wake)) {
+ error = PTR_ERR(tsdata->gpio_wake);
+ if (error != -EPROBE_DEFER)
+ dev_err(dev, "Failed to get wake gpio: %d\n", error);
+ return error;
+ }
+
+ tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable",
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(tsdata->gpio_enable)) {
+ error = PTR_ERR(tsdata->gpio_enable);
+ if (error != -EPROBE_DEFER)
+ dev_err(dev, "Failed to get enable gpio: %d\n", error);
+ return error;
+ }
+
error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
client->name, tsdata);
@@ -542,6 +580,14 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
return error;
}
+ if (!IS_ERR_OR_NULL(tsdata->gpio_wake))
+ gpiod_set_value_cansleep(tsdata->gpio_wake, 1);
+
+ if (!IS_ERR_OR_NULL(tsdata->gpio_enable)) {
+ gpiod_set_value_cansleep(tsdata->gpio_enable, 1);
+ msleep(100);
+ }
+
pixcir_reset(tsdata);
/* Always be in IDLE mode to save power, device supports auto wake */
--
2.5.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios
2015-11-20 11:17 ` [PATCH 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios Hans de Goede
@ 2015-11-20 14:43 ` Rob Herring
[not found] ` <1448018233-27824-5-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
1 sibling, 0 replies; 13+ messages in thread
From: Rob Herring @ 2015-11-20 14:43 UTC (permalink / raw)
To: Hans de Goede
Cc: Dmitry Torokhov, Maxime Ripard, Sander Vermin, linux-input,
linux-arm-kernel, devicetree, linux-sunxi
On Fri, Nov 20, 2015 at 12:17:10PM +0100, Hans de Goede wrote:
> From: Sander Vermin <sander@vermin.nl>
>
> On some devices the wake and enable pins of the pixcir touchscreen
> controller are connected to gpios and these must be controlled by the
> driver for the device to operate properly.
>
> Signed-off-by: Sander Vermin <sander@vermin.nl>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v2 (Hans de Goede):
> -Split the changes for dealing with inverted / swapped axis out into a
> separate patch
> -Remove a bunch of dev_info calls to make the driver less chatty
> -Use devm_gpiod_get_optional as these new gpios are optional
> -Only msleep after setting enable high if we have an enable pin
> ---
> .../bindings/input/touchscreen/pixcir_i2c_ts.txt | 2 +
For the binding:
Acked-by: Rob Herring <robh@kernel.org>
> drivers/input/touchscreen/pixcir_i2c_ts.c | 46 ++++++++++++++++++++++
> 2 files changed, 48 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> index 8eb240a..72ca5ec 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> @@ -10,6 +10,8 @@ Required properties:
>
> Optional properties:
> - reset-gpio: GPIO connected to the RESET line of the chip
> +- enable-gpios: GPIO connected to the ENABLE line of the chip
> +- wake-gpios: GPIO connected to the WAKE line of the chip
>
> Example:
>
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 211408c..b75ef65 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
> struct input_dev *input;
> struct gpio_desc *gpio_attb;
> struct gpio_desc *gpio_reset;
> + struct gpio_desc *gpio_enable;
> + struct gpio_desc *gpio_wake;
> const struct pixcir_i2c_chip_data *chip;
> int max_fingers; /* Max fingers supported in this instance */
> bool running;
> @@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct pixcir_i2c_ts_data *ts,
> struct device *dev = &ts->client->dev;
> int ret;
>
> + if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
> + if (!IS_ERR_OR_NULL(ts->gpio_wake))
> + gpiod_set_value_cansleep(ts->gpio_wake, 1);
> + }
> +
> ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_POWER_MODE);
> if (ret < 0) {
> dev_err(dev, "%s: can't read reg 0x%x : %d\n",
> @@ -228,6 +235,11 @@ static int pixcir_set_power_mode(struct pixcir_i2c_ts_data *ts,
> return ret;
> }
>
> + if (mode == PIXCIR_POWER_HALT) {
> + if (!IS_ERR_OR_NULL(ts->gpio_wake))
> + gpiod_set_value_cansleep(ts->gpio_wake, 0);
> + }
> +
> return 0;
> }
>
> @@ -302,6 +314,11 @@ static int pixcir_start(struct pixcir_i2c_ts_data *ts)
> struct device *dev = &ts->client->dev;
> int error;
>
> + if (!IS_ERR_OR_NULL(ts->gpio_enable)) {
> + gpiod_set_value_cansleep(ts->gpio_enable, 1);
> + msleep(100);
> + }
> +
> /* LEVEL_TOUCH interrupt with active low polarity */
> error = pixcir_set_int_mode(ts, PIXCIR_INT_LEVEL_TOUCH, 0);
> if (error) {
> @@ -343,6 +360,9 @@ static int pixcir_stop(struct pixcir_i2c_ts_data *ts)
> /* Wait till running ISR is complete */
> synchronize_irq(ts->client->irq);
>
> + if (!IS_ERR_OR_NULL(ts->gpio_enable))
> + gpiod_set_value_cansleep(ts->gpio_enable, 0);
> +
> return 0;
> }
>
> @@ -534,6 +554,24 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
> return error;
> }
>
> + tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake",
> + GPIOD_OUT_HIGH);
> + if (IS_ERR(tsdata->gpio_wake)) {
> + error = PTR_ERR(tsdata->gpio_wake);
> + if (error != -EPROBE_DEFER)
> + dev_err(dev, "Failed to get wake gpio: %d\n", error);
> + return error;
> + }
> +
> + tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable",
> + GPIOD_OUT_HIGH);
> + if (IS_ERR(tsdata->gpio_enable)) {
> + error = PTR_ERR(tsdata->gpio_enable);
> + if (error != -EPROBE_DEFER)
> + dev_err(dev, "Failed to get enable gpio: %d\n", error);
> + return error;
> + }
> +
> error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr,
> IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> client->name, tsdata);
> @@ -542,6 +580,14 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
> return error;
> }
>
> + if (!IS_ERR_OR_NULL(tsdata->gpio_wake))
> + gpiod_set_value_cansleep(tsdata->gpio_wake, 1);
> +
> + if (!IS_ERR_OR_NULL(tsdata->gpio_enable)) {
> + gpiod_set_value_cansleep(tsdata->gpio_enable, 1);
> + msleep(100);
> + }
> +
> pixcir_reset(tsdata);
>
> /* Always be in IDLE mode to save power, device supports auto wake */
> --
> 2.5.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <1448018233-27824-5-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios
[not found] ` <1448018233-27824-5-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2015-11-20 17:27 ` Dmitry Torokhov
2015-11-20 18:22 ` [linux-sunxi] " Hans de Goede
0 siblings, 1 reply; 13+ messages in thread
From: Dmitry Torokhov @ 2015-11-20 17:27 UTC (permalink / raw)
To: Hans de Goede
Cc: Maxime Ripard, Sander Vermin, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
On Fri, Nov 20, 2015 at 12:17:10PM +0100, Hans de Goede wrote:
> From: Sander Vermin <sander-wENMetUwf8VmR6Xm/wNWPw@public.gmane.org>
>
> On some devices the wake and enable pins of the pixcir touchscreen
> controller are connected to gpios and these must be controlled by the
> driver for the device to operate properly.
>
> Signed-off-by: Sander Vermin <sander-wENMetUwf8VmR6Xm/wNWPw@public.gmane.org>
> Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> Changes in v2 (Hans de Goede):
> -Split the changes for dealing with inverted / swapped axis out into a
> separate patch
> -Remove a bunch of dev_info calls to make the driver less chatty
> -Use devm_gpiod_get_optional as these new gpios are optional
> -Only msleep after setting enable high if we have an enable pin
> ---
> .../bindings/input/touchscreen/pixcir_i2c_ts.txt | 2 +
> drivers/input/touchscreen/pixcir_i2c_ts.c | 46 ++++++++++++++++++++++
> 2 files changed, 48 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> index 8eb240a..72ca5ec 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> @@ -10,6 +10,8 @@ Required properties:
>
> Optional properties:
> - reset-gpio: GPIO connected to the RESET line of the chip
> +- enable-gpios: GPIO connected to the ENABLE line of the chip
> +- wake-gpios: GPIO connected to the WAKE line of the chip
>
> Example:
>
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 211408c..b75ef65 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
> struct input_dev *input;
> struct gpio_desc *gpio_attb;
> struct gpio_desc *gpio_reset;
> + struct gpio_desc *gpio_enable;
> + struct gpio_desc *gpio_wake;
> const struct pixcir_i2c_chip_data *chip;
> int max_fingers; /* Max fingers supported in this instance */
> bool running;
> @@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct pixcir_i2c_ts_data *ts,
> struct device *dev = &ts->client->dev;
> int ret;
>
> + if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
> + if (!IS_ERR_OR_NULL(ts->gpio_wake))
> + gpiod_set_value_cansleep(ts->gpio_wake, 1);
I believe you error out in case when IS_ERR(ts->gpio_wake) is true, so I
wonder if we should simply use
if (ts->gpio_wake)
gpiod_set_value_cansleep(ts->gpio_wake, 1);
here and elsewhere.
No need to resubmit, just let me know.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [linux-sunxi] Re: [PATCH 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios
2015-11-20 17:27 ` Dmitry Torokhov
@ 2015-11-20 18:22 ` Hans de Goede
0 siblings, 0 replies; 13+ messages in thread
From: Hans de Goede @ 2015-11-20 18:22 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Maxime Ripard, Sander Vermin, linux-input, linux-arm-kernel,
devicetree, linux-sunxi
Hi,
On 20-11-15 18:27, Dmitry Torokhov wrote:
> On Fri, Nov 20, 2015 at 12:17:10PM +0100, Hans de Goede wrote:
>> From: Sander Vermin <sander@vermin.nl>
>>
>> On some devices the wake and enable pins of the pixcir touchscreen
>> controller are connected to gpios and these must be controlled by the
>> driver for the device to operate properly.
>>
>> Signed-off-by: Sander Vermin <sander@vermin.nl>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> Changes in v2 (Hans de Goede):
>> -Split the changes for dealing with inverted / swapped axis out into a
>> separate patch
>> -Remove a bunch of dev_info calls to make the driver less chatty
>> -Use devm_gpiod_get_optional as these new gpios are optional
>> -Only msleep after setting enable high if we have an enable pin
>> ---
>> .../bindings/input/touchscreen/pixcir_i2c_ts.txt | 2 +
>> drivers/input/touchscreen/pixcir_i2c_ts.c | 46 ++++++++++++++++++++++
>> 2 files changed, 48 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
>> index 8eb240a..72ca5ec 100644
>> --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
>> +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
>> @@ -10,6 +10,8 @@ Required properties:
>>
>> Optional properties:
>> - reset-gpio: GPIO connected to the RESET line of the chip
>> +- enable-gpios: GPIO connected to the ENABLE line of the chip
>> +- wake-gpios: GPIO connected to the WAKE line of the chip
>>
>> Example:
>>
>> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
>> index 211408c..b75ef65 100644
>> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
>> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
>> @@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
>> struct input_dev *input;
>> struct gpio_desc *gpio_attb;
>> struct gpio_desc *gpio_reset;
>> + struct gpio_desc *gpio_enable;
>> + struct gpio_desc *gpio_wake;
>> const struct pixcir_i2c_chip_data *chip;
>> int max_fingers; /* Max fingers supported in this instance */
>> bool running;
>> @@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct pixcir_i2c_ts_data *ts,
>> struct device *dev = &ts->client->dev;
>> int ret;
>>
>> + if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
>> + if (!IS_ERR_OR_NULL(ts->gpio_wake))
>> + gpiod_set_value_cansleep(ts->gpio_wake, 1);
>
> I believe you error out in case when IS_ERR(ts->gpio_wake) is true, so I
> wonder if we should simply use
>
> if (ts->gpio_wake)
> gpiod_set_value_cansleep(ts->gpio_wake, 1);
>
> here and elsewhere.
Yes that will work fine, I believe Sander went with his version because that
is what the existing gpio code (for the also optional reset pin) already does.
So from a consistency pov it is better to keep this patch as is.
> No need to resubmit, just let me know.
Ok, either way is fine with me.
Regards,
Hans
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 5/7] touchscreen: pixcir_ts: Add support for axis inversion / swapping
[not found] ` <1448018233-27824-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
` (2 preceding siblings ...)
2015-11-20 11:17 ` [PATCH 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios Hans de Goede
@ 2015-11-20 11:17 ` Hans de Goede
2015-11-20 11:17 ` [PATCH 6/7] ARM: dts: sun4i: Add touchscreen node to iNet1 tablet Hans de Goede
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Hans de Goede @ 2015-11-20 11:17 UTC (permalink / raw)
To: Dmitry Torokhov, Maxime Ripard
Cc: Sander Vermin, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, 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/pixcir_i2c_ts.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index b75ef65..e310154 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,8 @@ 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(&report->touches[i].x,
+ &report->touches[i].y);
if (chip->has_hw_ids) {
report->touches[i].id = bufptr[4];
@@ -515,7 +518,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.5.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/7] ARM: dts: sun4i: Add touchscreen node to iNet1 tablet
[not found] ` <1448018233-27824-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
` (3 preceding siblings ...)
2015-11-20 11:17 ` [PATCH 5/7] touchscreen: pixcir_ts: Add support for axis inversion / swapping Hans de Goede
@ 2015-11-20 11:17 ` Hans de Goede
2015-11-20 11:17 ` [PATCH 7/7] ARM: dts: sun4i: Add touchscreen node to pov protab2-ips9 tablet Hans de Goede
2015-11-20 11:22 ` [PATCH 0/7] Various touchscreens: Support axis inversion / swapping / extra gpios Russell King - ARM Linux
6 siblings, 0 replies; 13+ messages in thread
From: Hans de Goede @ 2015-11-20 11:17 UTC (permalink / raw)
To: Dmitry Torokhov, Maxime Ripard
Cc: Sander Vermin, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Hans de Goede
Add a node describing the touchscreen controller used on the iNet1 tablet.
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
arch/arm/boot/dts/sun4i-a10-inet1.dts | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/arm/boot/dts/sun4i-a10-inet1.dts b/arch/arm/boot/dts/sun4i-a10-inet1.dts
index 487ce63..703d756 100644
--- a/arch/arm/boot/dts/sun4i-a10-inet1.dts
+++ b/arch/arm/boot/dts/sun4i-a10-inet1.dts
@@ -104,6 +104,19 @@
pinctrl-names = "default";
pinctrl-0 = <&i2c2_pins_a>;
status = "okay";
+
+ ft5x: touchscreen@38 {
+ compatible = "edt,edt-ft5406";
+ reg = <0x38>;
+ interrupt-parent = <&pio>;
+ interrupts = <7 21 IRQ_TYPE_EDGE_FALLING>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&touchscreen_wake_pin>;
+ wake-gpios = <&pio 1 13 GPIO_ACTIVE_HIGH>; /* PB13 */
+ touchscreen-size-x = <600>;
+ touchscreen-size-y = <1024>;
+ touchscreen-swapped-x-y;
+ };
};
&lradc {
@@ -151,6 +164,13 @@
};
&pio {
+ touchscreen_wake_pin: touchscreen_wake_pin@0 {
+ allwinner,pins = "PB13";
+ allwinner,function = "gpio_out";
+ allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+ };
+
usb0_id_detect_pin: usb0_id_detect_pin@0 {
allwinner,pins = "PH4";
allwinner,function = "gpio_in";
--
2.5.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/7] ARM: dts: sun4i: Add touchscreen node to pov protab2-ips9 tablet
[not found] ` <1448018233-27824-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
` (4 preceding siblings ...)
2015-11-20 11:17 ` [PATCH 6/7] ARM: dts: sun4i: Add touchscreen node to iNet1 tablet Hans de Goede
@ 2015-11-20 11:17 ` Hans de Goede
2015-11-20 11:22 ` [PATCH 0/7] Various touchscreens: Support axis inversion / swapping / extra gpios Russell King - ARM Linux
6 siblings, 0 replies; 13+ messages in thread
From: Hans de Goede @ 2015-11-20 11:17 UTC (permalink / raw)
To: Dmitry Torokhov, Maxime Ripard
Cc: Sander Vermin, linux-input-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Hans de Goede
Add a node describing the touchscreen found on the pov protab2-ips9
tablet.
Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
arch/arm/boot/dts/sun4i-a10-pov-protab2-ips9.dts | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/arch/arm/boot/dts/sun4i-a10-pov-protab2-ips9.dts b/arch/arm/boot/dts/sun4i-a10-pov-protab2-ips9.dts
index 82e69c3..0e5124f 100644
--- a/arch/arm/boot/dts/sun4i-a10-pov-protab2-ips9.dts
+++ b/arch/arm/boot/dts/sun4i-a10-pov-protab2-ips9.dts
@@ -93,6 +93,22 @@
pinctrl-names = "default";
pinctrl-0 = <&i2c2_pins_a>;
status = "okay";
+
+ pixcir_ts@5c {
+ pinctrl-names = "default";
+ pinctrl-0 = <&touchscreen_pins>;
+ compatible = "pixcir,pixcir_tangoc";
+ reg = <0x5c>;
+ interrupt-parent = <&pio>;
+ interrupts = <7 21 IRQ_TYPE_EDGE_FALLING>; /* EINT21 (PH21) */
+ attb-gpio = <&pio 7 21 GPIO_ACTIVE_HIGH>; /* PH21 */
+ enable-gpios = <&pio 0 5 GPIO_ACTIVE_LOW>;
+ wake-gpios = <&pio 1 13 GPIO_ACTIVE_LOW>;
+ touchscreen-size-x = <1024>;
+ touchscreen-size-y = <768>;
+ touchscreen-inverted-x;
+ touchscreen-inverted-y;
+ };
};
&lradc {
@@ -129,6 +145,13 @@
};
&pio {
+ touchscreen_pins: touchscreen_pins@0 {
+ allwinner,pins = "PA5", "PB13";
+ allwinner,function = "gpio_out";
+ allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+ };
+
usb0_id_detect_pin: usb0_id_detect_pin@0 {
allwinner,pins = "PH4";
allwinner,function = "gpio_in";
--
2.5.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 0/7] Various touchscreens: Support axis inversion / swapping / extra gpios
[not found] ` <1448018233-27824-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
` (5 preceding siblings ...)
2015-11-20 11:17 ` [PATCH 7/7] ARM: dts: sun4i: Add touchscreen node to pov protab2-ips9 tablet Hans de Goede
@ 2015-11-20 11:22 ` Russell King - ARM Linux
[not found] ` <20151120112245.GC8644-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
6 siblings, 1 reply; 13+ messages in thread
From: Russell King - ARM Linux @ 2015-11-20 11:22 UTC (permalink / raw)
To: Hans de Goede
Cc: Dmitry Torokhov, Maxime Ripard, devicetree,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, Sander Vermin,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-input-u79uwXL29TY76Z2rM5mHXA
On Fri, Nov 20, 2015 at 12:17:06PM +0100, Hans de Goede wrote:
> This patch-set extends the of_touchscreen.c helpers to (optionally) also
> deal with axis inversion / swapping, and patches a bunch of drivers to use
> this new functionality.
What's wrong with using tslib? tslib supports axis transformations in
userspace via a set of filters.
--
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply [flat|nested] 13+ messages in thread