* [PATCH 1/5] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received
@ 2016-04-20 6:54 Dirk Behme
2016-04-20 6:54 ` [PATCH 2/5] Input: zforce_ts: Reject open if initialization not finished Dirk Behme
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Dirk Behme @ 2016-04-20 6:54 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Henrik Rydberg,
Javier Martinez Canillas
Cc: Marcel Grosshans, Knut Wohlrab, Oleksij Rempel, Dirk Behme
From: Marcel Grosshans <MarcelViktor.Grosshans@de.bosch.com>
Unexpected power interruption or reset of the touch controller may disable
touch panel function. To avoid this situation, the touch controller is
completely reinitialized if BOOT_COMPLETE notification occurs. To make
it possible we process reinitialization in a separate queue.
Signed-off-by: Marcel Grosshans <MarcelViktor.Grosshans@de.bosch.com>
Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
---
drivers/input/touchscreen/zforce_ts.c | 127 +++++++++++++++++++++++++++-------
1 file changed, 102 insertions(+), 25 deletions(-)
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index 9bbadaa..0c08220 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -31,6 +31,7 @@
#include <linux/platform_data/zforce_ts.h>
#include <linux/regulator/consumer.h>
#include <linux/of.h>
+#include <linux/workqueue.h>
#define WAIT_TIMEOUT msecs_to_jiffies(1000)
@@ -98,6 +99,12 @@ struct zforce_point {
int prblty;
};
+enum zforce_state {
+ ZF_STATE_UNINITIALZED = 0,
+ ZF_STATE_PROBE_COMPLETE,
+ ZF_STATE_DEV_OPENED,
+};
+
/*
* @client the i2c_client
* @input the input device
@@ -138,6 +145,11 @@ struct zforce_ts {
struct mutex command_mutex;
int command_waiting;
int command_result;
+
+ struct work_struct ts_workq;
+ int notification;
+
+ enum zforce_state state;
};
static int zforce_command(struct zforce_ts *ts, u8 cmd)
@@ -188,6 +200,7 @@ static int zforce_send_wait(struct zforce_ts *ts, const char *buf, int len)
buf[1], buf[2]);
ts->command_waiting = buf[2];
+ reinit_completion(&ts->command_done);
mutex_lock(&ts->access_mutex);
ret = i2c_master_send(client, buf, len);
@@ -471,6 +484,15 @@ static void zforce_complete(struct zforce_ts *ts, int cmd, int result)
dev_dbg(&client->dev, "completing command 0x%x\n", cmd);
ts->command_result = result;
complete(&ts->command_done);
+ } else if (cmd == NOTIFICATION_BOOTCOMPLETE) {
+ dev_dbg(&client->dev, "got notification 0x%x\n", cmd);
+
+ /* abourt previous waiting command if any available */
+ ts->command_result = -ECONNABORTED;
+ ts->notification = cmd;
+ complete(&ts->command_done);
+
+ queue_work(system_long_wq, &ts->ts_workq);
} else {
dev_dbg(&client->dev, "command %d not for us\n", cmd);
}
@@ -596,11 +618,85 @@ static irqreturn_t zforce_irq_thread(int irq, void *dev_id)
return IRQ_HANDLED;
}
+/*
+ * This device is used in automotive environment. In this
+ * we should never fail. Some connection issues caused by vibration
+ * should be ignored and can be recoverable.
+ */
+static void zforce_boot(struct zforce_ts *ts)
+{
+ struct device *dev = &ts->client->dev;
+ int ret;
+
+ /* need to start device to get version information */
+ ret = zforce_command_wait(ts, COMMAND_INITIALIZE);
+ if (ret)
+ dev_err(dev, "unable to initialize, %d\n", ret);
+
+ switch (ts->state) {
+ case ZF_STATE_UNINITIALZED:
+ ret = zforce_command_wait(ts, COMMAND_STATUS);
+ if (ret)
+ dev_err(dev, "couldn't get status, %d\n", ret);
+ /* fallthrough, we need zforce_stop to complete. */
+ case ZF_STATE_PROBE_COMPLETE:
+ /* stop device and put it into sleep until it is opened */
+ ret = zforce_stop(ts);
+ if (ret)
+ dev_err(dev, "couldn't stop zforce, %d\n", ret);
+
+ ts->state = ZF_STATE_PROBE_COMPLETE;
+ break;
+ case ZF_STATE_DEV_OPENED:
+ ret = zforce_start(ts);
+ if (ret)
+ dev_err(dev, "Failed to restart, %d\n", ret);
+ break;
+ }
+}
+
+static void zforce_notification_queue(struct work_struct *work)
+{
+ struct zforce_ts *ts = container_of(work, struct zforce_ts, ts_workq);
+ struct i2c_client *client = ts->client;
+ struct input_dev *input = ts->input;
+
+ if (device_may_wakeup(&client->dev)) {
+ if (!ts->suspending)
+ pm_stay_awake(&client->dev);
+ else
+ pm_wakeup_event(&client->dev, 500);
+ }
+
+ mutex_lock(&input->mutex);
+
+ switch (ts->notification) {
+ case NOTIFICATION_BOOTCOMPLETE:
+ zforce_boot(ts);
+ break;
+ default:
+ dev_err(&client->dev,
+ "unknown notification: %#x\n", ts->notification);
+ }
+
+ mutex_unlock(&input->mutex);
+
+ if (!ts->suspending && device_may_wakeup(&client->dev))
+ pm_relax(&client->dev);
+}
+
static int zforce_input_open(struct input_dev *dev)
{
struct zforce_ts *ts = input_get_drvdata(dev);
+ int ret;
+
+ ret = zforce_start(ts);
+ if (ret)
+ return ret;
- return zforce_start(ts);
+ ts->state = ZF_STATE_DEV_OPENED;
+
+ return 0;
}
static void zforce_input_close(struct input_dev *dev)
@@ -613,6 +709,8 @@ static void zforce_input_close(struct input_dev *dev)
if (ret)
dev_warn(&client->dev, "stopping zforce failed\n");
+ ts->state = ZF_STATE_PROBE_COMPLETE;
+
return;
}
@@ -875,6 +973,7 @@ static int zforce_probe(struct i2c_client *client,
input_set_drvdata(ts->input, ts);
init_completion(&ts->command_done);
+ INIT_WORK(&ts->ts_workq, zforce_notification_queue);
/*
* The zforce pulls the interrupt low when it has data ready.
@@ -894,33 +993,11 @@ static int zforce_probe(struct i2c_client *client,
i2c_set_clientdata(client, ts);
+ ts->state = ZF_STATE_UNINITIALZED;
+
/* let the controller boot */
zforce_reset_deassert(ts);
- ts->command_waiting = NOTIFICATION_BOOTCOMPLETE;
- if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0)
- dev_warn(&client->dev, "bootcomplete timed out\n");
-
- /* need to start device to get version information */
- ret = zforce_command_wait(ts, COMMAND_INITIALIZE);
- if (ret) {
- dev_err(&client->dev, "unable to initialize, %d\n", ret);
- return ret;
- }
-
- /* this gets the firmware version among other information */
- ret = zforce_command_wait(ts, COMMAND_STATUS);
- if (ret < 0) {
- dev_err(&client->dev, "couldn't get status, %d\n", ret);
- zforce_stop(ts);
- return ret;
- }
-
- /* stop device and put it into sleep until it is opened */
- ret = zforce_stop(ts);
- if (ret < 0)
- return ret;
-
device_set_wakeup_capable(&client->dev, true);
ret = input_register_device(input_dev);
--
2.8.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/5] Input: zforce_ts: Reject open if initialization not finished
2016-04-20 6:54 [PATCH 1/5] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received Dirk Behme
@ 2016-04-20 6:54 ` Dirk Behme
2016-04-20 6:54 ` [PATCH 3/5] Input: zforce_ts: Add device tree support for scanning frequency Dirk Behme
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Dirk Behme @ 2016-04-20 6:54 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Henrik Rydberg,
Javier Martinez Canillas
Cc: Oleksij Rempel, Oleksij Rempel, Knut Wohlrab, Dirk Behme
From: Oleksij Rempel <linux@rempel-privat.de>
Response EAGAIN when opening the device while BOOT_COMPLETE
notification is not received and initialization of the zForce touch
controller is not finished.
Signed-off-by: Oleksij Rempel <fixed-term.Oleksij.Rempel@de.bosch.com>
Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
---
drivers/input/touchscreen/zforce_ts.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index 0c08220..ddfc120 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -690,6 +690,10 @@ static int zforce_input_open(struct input_dev *dev)
struct zforce_ts *ts = input_get_drvdata(dev);
int ret;
+ /* if not probed try again later */
+ if (ts->state == ZF_STATE_UNINITIALZED)
+ return -EAGAIN;
+
ret = zforce_start(ts);
if (ret)
return ret;
--
2.8.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/5] Input: zforce_ts: Add device tree support for scanning frequency
2016-04-20 6:54 [PATCH 1/5] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received Dirk Behme
2016-04-20 6:54 ` [PATCH 2/5] Input: zforce_ts: Reject open if initialization not finished Dirk Behme
@ 2016-04-20 6:54 ` Dirk Behme
2016-04-25 21:11 ` Dmitry Torokhov
2016-04-20 6:54 ` [PATCH 4/5] Input: zforce_ts: Add support for minimum touch size limit Dirk Behme
2016-04-20 6:54 ` [PATCH 5/5] Input: zforce_ts: Fix dual touch recognition Dirk Behme
3 siblings, 1 reply; 9+ messages in thread
From: Dirk Behme @ 2016-04-20 6:54 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Henrik Rydberg,
Javier Martinez Canillas
Cc: Knut Wohlrab, Oleksij Rempel, Dirk Behme
From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
Add device tree support for idle and finger scanning frequency.
Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
---
.../devicetree/bindings/input/touchscreen/zforce_ts.txt | 4 ++++
drivers/input/touchscreen/zforce_ts.c | 15 ++++++++++++++-
include/linux/platform_data/zforce_ts.h | 2 ++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
index e3c27c4..09ead84 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
@@ -11,6 +11,8 @@ Required properties:
Optional properties:
- irq-gpios : interrupt gpio the chip is connected to
- vdd-supply: Regulator controlling the controller supply
+- scan-freq-idle: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
+- scan-freq-finger: touch scanning frequeny in Hz (0 - 65535 Hz; default 50 Hz)
Example:
@@ -28,6 +30,8 @@ Example:
x-size = <800>;
y-size = <600>;
+ scan-freq-idle = <50>;
+ scan-freq-finger = <250>;
};
/* ... */
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index ddfc120..51fe2de 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -87,6 +87,9 @@
#define SETCONFIG_DUALTOUCH (1 << 0)
+#define SCAN_FREQ_DEFAULT_IDLE 10
+#define SCAN_FREQ_DEFAULT_FINGER 50
+
struct zforce_point {
int coord_x;
int coord_y;
@@ -304,7 +307,9 @@ static int zforce_start(struct zforce_ts *ts)
goto error;
}
- ret = zforce_scan_frequency(ts, 10, 50, 50);
+ ret = zforce_scan_frequency(ts, pdata->scan_freq_idle,
+ pdata->scan_freq_finger,
+ pdata->scan_freq_finger);
if (ret) {
dev_err(&client->dev, "Unable to set scan frequency, %d\n",
ret);
@@ -839,6 +844,14 @@ static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
return ERR_PTR(-EINVAL);
}
+ if (of_property_read_u16(np, "scan-freq-idle",
+ &pdata->scan_freq_idle))
+ pdata->scan_freq_idle = SCAN_FREQ_DEFAULT_IDLE;
+
+ if (of_property_read_u16(np, "scan-freq-finger",
+ &pdata->scan_freq_finger))
+ pdata->scan_freq_finger = SCAN_FREQ_DEFAULT_FINGER;
+
return pdata;
}
diff --git a/include/linux/platform_data/zforce_ts.h b/include/linux/platform_data/zforce_ts.h
index 7bdece8..90a1181 100644
--- a/include/linux/platform_data/zforce_ts.h
+++ b/include/linux/platform_data/zforce_ts.h
@@ -18,6 +18,8 @@
struct zforce_ts_platdata {
unsigned int x_max;
unsigned int y_max;
+ u16 scan_freq_idle;
+ u16 scan_freq_finger;
};
#endif /* _LINUX_INPUT_ZFORCE_TS_H */
--
2.8.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 3/5] Input: zforce_ts: Add device tree support for scanning frequency
2016-04-20 6:54 ` [PATCH 3/5] Input: zforce_ts: Add device tree support for scanning frequency Dirk Behme
@ 2016-04-25 21:11 ` Dmitry Torokhov
2016-04-27 14:44 ` Rob Herring
0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Torokhov @ 2016-04-25 21:11 UTC (permalink / raw)
To: Dirk Behme
Cc: linux-input, Henrik Rydberg, Javier Martinez Canillas,
Knut Wohlrab, Oleksij Rempel, Rob Herring, devicetree
Adding devicetree overlords...
On Wed, Apr 20, 2016 at 08:54:43AM +0200, Dirk Behme wrote:
> From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
>
> Add device tree support for idle and finger scanning frequency.
>
> Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
> ---
> .../devicetree/bindings/input/touchscreen/zforce_ts.txt | 4 ++++
> drivers/input/touchscreen/zforce_ts.c | 15 ++++++++++++++-
> include/linux/platform_data/zforce_ts.h | 2 ++
> 3 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
> index e3c27c4..09ead84 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
> @@ -11,6 +11,8 @@ Required properties:
> Optional properties:
> - irq-gpios : interrupt gpio the chip is connected to
> - vdd-supply: Regulator controlling the controller supply
> +- scan-freq-idle: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
> +- scan-freq-finger: touch scanning frequeny in Hz (0 - 65535 Hz; default 50 Hz)
Should we cal it scan-freq-active instead?
>
> Example:
>
> @@ -28,6 +30,8 @@ Example:
>
> x-size = <800>;
> y-size = <600>;
> + scan-freq-idle = <50>;
> + scan-freq-finger = <250>;
> };
>
> /* ... */
> diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
> index ddfc120..51fe2de 100644
> --- a/drivers/input/touchscreen/zforce_ts.c
> +++ b/drivers/input/touchscreen/zforce_ts.c
> @@ -87,6 +87,9 @@
>
> #define SETCONFIG_DUALTOUCH (1 << 0)
>
> +#define SCAN_FREQ_DEFAULT_IDLE 10
> +#define SCAN_FREQ_DEFAULT_FINGER 50
> +
> struct zforce_point {
> int coord_x;
> int coord_y;
> @@ -304,7 +307,9 @@ static int zforce_start(struct zforce_ts *ts)
> goto error;
> }
>
> - ret = zforce_scan_frequency(ts, 10, 50, 50);
> + ret = zforce_scan_frequency(ts, pdata->scan_freq_idle,
> + pdata->scan_freq_finger,
> + pdata->scan_freq_finger);
> if (ret) {
> dev_err(&client->dev, "Unable to set scan frequency, %d\n",
> ret);
> @@ -839,6 +844,14 @@ static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
> return ERR_PTR(-EINVAL);
> }
>
> + if (of_property_read_u16(np, "scan-freq-idle",
> + &pdata->scan_freq_idle))
> + pdata->scan_freq_idle = SCAN_FREQ_DEFAULT_IDLE;
> +
> + if (of_property_read_u16(np, "scan-freq-finger",
> + &pdata->scan_freq_finger))
> + pdata->scan_freq_finger = SCAN_FREQ_DEFAULT_FINGER;
> +
> return pdata;
> }
>
> diff --git a/include/linux/platform_data/zforce_ts.h b/include/linux/platform_data/zforce_ts.h
> index 7bdece8..90a1181 100644
> --- a/include/linux/platform_data/zforce_ts.h
> +++ b/include/linux/platform_data/zforce_ts.h
> @@ -18,6 +18,8 @@
> struct zforce_ts_platdata {
> unsigned int x_max;
> unsigned int y_max;
> + u16 scan_freq_idle;
> + u16 scan_freq_finger;
> };
>
> #endif /* _LINUX_INPUT_ZFORCE_TS_H */
> --
> 2.8.0
>
--
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/5] Input: zforce_ts: Add device tree support for scanning frequency
2016-04-25 21:11 ` Dmitry Torokhov
@ 2016-04-27 14:44 ` Rob Herring
0 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2016-04-27 14:44 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Dirk Behme, linux-input@vger.kernel.org, Henrik Rydberg,
Javier Martinez Canillas, Knut Wohlrab, Oleksij Rempel,
devicetree@vger.kernel.org
On Mon, Apr 25, 2016 at 4:11 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Adding devicetree overlords...
>
> On Wed, Apr 20, 2016 at 08:54:43AM +0200, Dirk Behme wrote:
>> From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
>>
>> Add device tree support for idle and finger scanning frequency.
>>
>> Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
>> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
>> Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
>> ---
>> .../devicetree/bindings/input/touchscreen/zforce_ts.txt | 4 ++++
>> drivers/input/touchscreen/zforce_ts.c | 15 ++++++++++++++-
>> include/linux/platform_data/zforce_ts.h | 2 ++
>> 3 files changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
>> index e3c27c4..09ead84 100644
>> --- a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
>> +++ b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
>> @@ -11,6 +11,8 @@ Required properties:
>> Optional properties:
>> - irq-gpios : interrupt gpio the chip is connected to
BTW, this should really be an "interrupts" property
>> - vdd-supply: Regulator controlling the controller supply
>> +- scan-freq-idle: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
>> +- scan-freq-finger: touch scanning frequeny in Hz (0 - 65535 Hz; default 50 Hz)
I use my toes for touchscreens.
Can you really scan at 65kHz?
a typo here as well.
> Should we cal it scan-freq-active instead?
Don't we have a standard property for this? These should really have
-hz appended. So scan-idle-hz and scan-active-hz, but at least the
active case should be common IMO. Idle scan seems a bit unusual unless
you don't have an interrupt.
Rob
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/5] Input: zforce_ts: Add support for minimum touch size limit
2016-04-20 6:54 [PATCH 1/5] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received Dirk Behme
2016-04-20 6:54 ` [PATCH 2/5] Input: zforce_ts: Reject open if initialization not finished Dirk Behme
2016-04-20 6:54 ` [PATCH 3/5] Input: zforce_ts: Add device tree support for scanning frequency Dirk Behme
@ 2016-04-20 6:54 ` Dirk Behme
2016-04-25 21:12 ` Dmitry Torokhov
2016-04-20 6:54 ` [PATCH 5/5] Input: zforce_ts: Fix dual touch recognition Dirk Behme
3 siblings, 1 reply; 9+ messages in thread
From: Dirk Behme @ 2016-04-20 6:54 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Henrik Rydberg,
Javier Martinez Canillas
Cc: Knut Wohlrab, Oleksij Rempel, Dirk Behme
From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
The minimum touch size can be set to support more reliable touch
detection under difficult conditions (e.g. dust on touch panel surface).
Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
---
.../bindings/input/touchscreen/zforce_ts.txt | 2 ++
drivers/input/touchscreen/zforce_ts.c | 29 ++++++++++++++++++++++
include/linux/platform_data/zforce_ts.h | 1 +
3 files changed, 32 insertions(+)
diff --git a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
index 09ead84..2c5babd 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
@@ -13,6 +13,7 @@ Optional properties:
- vdd-supply: Regulator controlling the controller supply
- scan-freq-idle: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
- scan-freq-finger: touch scanning frequeny in Hz (0 - 65535 Hz; default 50 Hz)
+- touch-size-min: minimun touch size limit in mm (0 - 255 mm; 0 = no limit (default))
Example:
@@ -32,6 +33,7 @@ Example:
y-size = <600>;
scan-freq-idle = <50>;
scan-freq-finger = <250>;
+ touch-size-min = <5>;
};
/* ... */
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index 51fe2de..fd435fe 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -54,6 +54,7 @@
#define COMMAND_SETCONFIG 0x03
#define COMMAND_DATAREQUEST 0x04
#define COMMAND_SCANFREQ 0x08
+#define COMMAND_TOUCH_SIZE 0x09
#define COMMAND_STATUS 0X1e
/*
@@ -65,6 +66,7 @@
#define RESPONSE_RESOLUTION 0x02
#define RESPONSE_SETCONFIG 0x03
#define RESPONSE_SCANFREQ 0x08
+#define RESPONSE_TOUCH_SIZE 0x09
#define RESPONSE_STATUS 0X1e
/*
@@ -276,6 +278,21 @@ static int zforce_scan_frequency(struct zforce_ts *ts, u16 idle, u16 finger,
return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf));
}
+static int zforce_touch_size_limit(struct zforce_ts *ts, u8 limit)
+{
+ struct i2c_client *client = ts->client;
+ u8 buf[] = { FRAME_START, 5, COMMAND_TOUCH_SIZE,
+ 0, 0, /* maximum size limit off */
+ 1, limit }; /* set minimum size limit */
+
+ if (!limit)
+ return 0;
+
+ dev_dbg(&client->dev, "set min. touch size limit to %d mm\n", limit);
+
+ return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf));
+}
+
static int zforce_setconfig(struct zforce_ts *ts, char b1)
{
struct i2c_client *client = ts->client;
@@ -316,6 +333,13 @@ static int zforce_start(struct zforce_ts *ts)
goto error;
}
+ ret = zforce_touch_size_limit(ts, pdata->touch_size_min);
+ if (ret) {
+ dev_err(&client->dev, "Unable to set min. touch size, %d\n",
+ ret);
+ goto error;
+ }
+
ret = zforce_setconfig(ts, SETCONFIG_DUALTOUCH);
if (ret) {
dev_err(&client->dev, "Unable to set config\n");
@@ -577,6 +601,7 @@ static irqreturn_t zforce_irq_thread(int irq, void *dev_id)
case RESPONSE_SETCONFIG:
case RESPONSE_RESOLUTION:
case RESPONSE_SCANFREQ:
+ case RESPONSE_TOUCH_SIZE:
zforce_complete(ts, payload[RESPONSE_ID],
payload[RESPONSE_DATA]);
break;
@@ -852,6 +877,10 @@ static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
&pdata->scan_freq_finger))
pdata->scan_freq_finger = SCAN_FREQ_DEFAULT_FINGER;
+ if (of_property_read_u8(np, "touch-size-min",
+ &pdata->touch_size_min))
+ pdata->touch_size_min = 0;
+
return pdata;
}
diff --git a/include/linux/platform_data/zforce_ts.h b/include/linux/platform_data/zforce_ts.h
index 90a1181..75e1a49 100644
--- a/include/linux/platform_data/zforce_ts.h
+++ b/include/linux/platform_data/zforce_ts.h
@@ -20,6 +20,7 @@ struct zforce_ts_platdata {
unsigned int y_max;
u16 scan_freq_idle;
u16 scan_freq_finger;
+ u8 touch_size_min;
};
#endif /* _LINUX_INPUT_ZFORCE_TS_H */
--
2.8.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 4/5] Input: zforce_ts: Add support for minimum touch size limit
2016-04-20 6:54 ` [PATCH 4/5] Input: zforce_ts: Add support for minimum touch size limit Dirk Behme
@ 2016-04-25 21:12 ` Dmitry Torokhov
0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2016-04-25 21:12 UTC (permalink / raw)
To: Dirk Behme
Cc: linux-input, Henrik Rydberg, Javier Martinez Canillas,
Knut Wohlrab, Oleksij Rempel, Rob Herring, devicetree
Adding devicetree folks...
On Wed, Apr 20, 2016 at 08:54:44AM +0200, Dirk Behme wrote:
> From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
>
> The minimum touch size can be set to support more reliable touch
> detection under difficult conditions (e.g. dust on touch panel surface).
>
> Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
> ---
> .../bindings/input/touchscreen/zforce_ts.txt | 2 ++
> drivers/input/touchscreen/zforce_ts.c | 29 ++++++++++++++++++++++
> include/linux/platform_data/zforce_ts.h | 1 +
> 3 files changed, 32 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
> index 09ead84..2c5babd 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/zforce_ts.txt
> @@ -13,6 +13,7 @@ Optional properties:
> - vdd-supply: Regulator controlling the controller supply
> - scan-freq-idle: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
> - scan-freq-finger: touch scanning frequeny in Hz (0 - 65535 Hz; default 50 Hz)
> +- touch-size-min: minimun touch size limit in mm (0 - 255 mm; 0 = no limit (default))
>
> Example:
>
> @@ -32,6 +33,7 @@ Example:
> y-size = <600>;
> scan-freq-idle = <50>;
> scan-freq-finger = <250>;
> + touch-size-min = <5>;
> };
>
> /* ... */
> diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
> index 51fe2de..fd435fe 100644
> --- a/drivers/input/touchscreen/zforce_ts.c
> +++ b/drivers/input/touchscreen/zforce_ts.c
> @@ -54,6 +54,7 @@
> #define COMMAND_SETCONFIG 0x03
> #define COMMAND_DATAREQUEST 0x04
> #define COMMAND_SCANFREQ 0x08
> +#define COMMAND_TOUCH_SIZE 0x09
> #define COMMAND_STATUS 0X1e
>
> /*
> @@ -65,6 +66,7 @@
> #define RESPONSE_RESOLUTION 0x02
> #define RESPONSE_SETCONFIG 0x03
> #define RESPONSE_SCANFREQ 0x08
> +#define RESPONSE_TOUCH_SIZE 0x09
> #define RESPONSE_STATUS 0X1e
>
> /*
> @@ -276,6 +278,21 @@ static int zforce_scan_frequency(struct zforce_ts *ts, u16 idle, u16 finger,
> return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf));
> }
>
> +static int zforce_touch_size_limit(struct zforce_ts *ts, u8 limit)
> +{
> + struct i2c_client *client = ts->client;
> + u8 buf[] = { FRAME_START, 5, COMMAND_TOUCH_SIZE,
> + 0, 0, /* maximum size limit off */
> + 1, limit }; /* set minimum size limit */
> +
> + if (!limit)
> + return 0;
> +
> + dev_dbg(&client->dev, "set min. touch size limit to %d mm\n", limit);
> +
> + return zforce_send_wait(ts, &buf[0], ARRAY_SIZE(buf));
> +}
> +
> static int zforce_setconfig(struct zforce_ts *ts, char b1)
> {
> struct i2c_client *client = ts->client;
> @@ -316,6 +333,13 @@ static int zforce_start(struct zforce_ts *ts)
> goto error;
> }
>
> + ret = zforce_touch_size_limit(ts, pdata->touch_size_min);
> + if (ret) {
> + dev_err(&client->dev, "Unable to set min. touch size, %d\n",
> + ret);
> + goto error;
> + }
> +
> ret = zforce_setconfig(ts, SETCONFIG_DUALTOUCH);
> if (ret) {
> dev_err(&client->dev, "Unable to set config\n");
> @@ -577,6 +601,7 @@ static irqreturn_t zforce_irq_thread(int irq, void *dev_id)
> case RESPONSE_SETCONFIG:
> case RESPONSE_RESOLUTION:
> case RESPONSE_SCANFREQ:
> + case RESPONSE_TOUCH_SIZE:
> zforce_complete(ts, payload[RESPONSE_ID],
> payload[RESPONSE_DATA]);
> break;
> @@ -852,6 +877,10 @@ static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev)
> &pdata->scan_freq_finger))
> pdata->scan_freq_finger = SCAN_FREQ_DEFAULT_FINGER;
>
> + if (of_property_read_u8(np, "touch-size-min",
> + &pdata->touch_size_min))
> + pdata->touch_size_min = 0;
> +
> return pdata;
> }
>
> diff --git a/include/linux/platform_data/zforce_ts.h b/include/linux/platform_data/zforce_ts.h
> index 90a1181..75e1a49 100644
> --- a/include/linux/platform_data/zforce_ts.h
> +++ b/include/linux/platform_data/zforce_ts.h
> @@ -20,6 +20,7 @@ struct zforce_ts_platdata {
> unsigned int y_max;
> u16 scan_freq_idle;
> u16 scan_freq_finger;
> + u8 touch_size_min;
> };
>
> #endif /* _LINUX_INPUT_ZFORCE_TS_H */
> --
> 2.8.0
>
--
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/5] Input: zforce_ts: Fix dual touch recognition
2016-04-20 6:54 [PATCH 1/5] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received Dirk Behme
` (2 preceding siblings ...)
2016-04-20 6:54 ` [PATCH 4/5] Input: zforce_ts: Add support for minimum touch size limit Dirk Behme
@ 2016-04-20 6:54 ` Dirk Behme
2016-04-25 21:08 ` Dmitry Torokhov
3 siblings, 1 reply; 9+ messages in thread
From: Dirk Behme @ 2016-04-20 6:54 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Henrik Rydberg,
Javier Martinez Canillas
Cc: Knut Wohlrab, Oleksij Rempel, Dirk Behme
From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
A wrong decoding of the touch coordinate message causes a wrong touch
ID. Touch ID for dual touch must be 0 or 1.
According to the actual Neonode nine byte touch coordinate coding,
the state is transported in the lower nibble and the touch ID in
the higher nibble of payload byte five.
Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
---
drivers/input/touchscreen/zforce_ts.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index fd435fe..9790d7a 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -412,8 +412,8 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
point.coord_x = point.coord_y = 0;
}
- point.state = payload[9 * i + 5] & 0x03;
- point.id = (payload[9 * i + 5] & 0xfc) >> 2;
+ point.state = payload[9 * i + 5] & 0x0f;
+ point.id = (payload[9 * i + 5] & 0xf0) >> 4;
/* determine touch major, minor and orientation */
point.area_major = max(payload[9 * i + 6],
--
2.8.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 5/5] Input: zforce_ts: Fix dual touch recognition
2016-04-20 6:54 ` [PATCH 5/5] Input: zforce_ts: Fix dual touch recognition Dirk Behme
@ 2016-04-25 21:08 ` Dmitry Torokhov
0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2016-04-25 21:08 UTC (permalink / raw)
To: Dirk Behme
Cc: linux-input, Henrik Rydberg, Javier Martinez Canillas,
Knut Wohlrab, Oleksij Rempel
On Wed, Apr 20, 2016 at 08:54:45AM +0200, Dirk Behme wrote:
> From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
>
> A wrong decoding of the touch coordinate message causes a wrong touch
> ID. Touch ID for dual touch must be 0 or 1.
>
> According to the actual Neonode nine byte touch coordinate coding,
> the state is transported in the lower nibble and the touch ID in
> the higher nibble of payload byte five.
>
> Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Applied, thank you.
> ---
> drivers/input/touchscreen/zforce_ts.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
> index fd435fe..9790d7a 100644
> --- a/drivers/input/touchscreen/zforce_ts.c
> +++ b/drivers/input/touchscreen/zforce_ts.c
> @@ -412,8 +412,8 @@ static int zforce_touch_event(struct zforce_ts *ts, u8 *payload)
> point.coord_x = point.coord_y = 0;
> }
>
> - point.state = payload[9 * i + 5] & 0x03;
> - point.id = (payload[9 * i + 5] & 0xfc) >> 2;
> + point.state = payload[9 * i + 5] & 0x0f;
> + point.id = (payload[9 * i + 5] & 0xf0) >> 4;
>
> /* determine touch major, minor and orientation */
> point.area_major = max(payload[9 * i + 6],
> --
> 2.8.0
>
--
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-04-27 14:44 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-20 6:54 [PATCH 1/5] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received Dirk Behme
2016-04-20 6:54 ` [PATCH 2/5] Input: zforce_ts: Reject open if initialization not finished Dirk Behme
2016-04-20 6:54 ` [PATCH 3/5] Input: zforce_ts: Add device tree support for scanning frequency Dirk Behme
2016-04-25 21:11 ` Dmitry Torokhov
2016-04-27 14:44 ` Rob Herring
2016-04-20 6:54 ` [PATCH 4/5] Input: zforce_ts: Add support for minimum touch size limit Dirk Behme
2016-04-25 21:12 ` Dmitry Torokhov
2016-04-20 6:54 ` [PATCH 5/5] Input: zforce_ts: Fix dual touch recognition Dirk Behme
2016-04-25 21:08 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).