linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] zForce upstreaming
@ 2016-05-03 10:41 Dirk Behme
  2016-05-03 10:41 ` [PATCH v2 1/4] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received Dirk Behme
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Dirk Behme @ 2016-05-03 10:41 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Henrik Rydberg,
	Javier Martinez Canillas
  Cc: Oleksij Rempel

From: Oleksij Rempel <linux@rempel-privat.de>

Changelog:
v2
 - rename scan-freq-idle and scan-freq-finger
   to scan-idle-hz and scan-active-hz.
 - rebase with already acked "Input: zforce_ts: Fix dual touch recognition"
   from previous patchset.

Knut Wohlrab (2):
  Input: zforce_ts: Add device tree support for scanning frequency
  Input: zforce_ts: Add support for minimum touch size limit

Marcel Grosshans (1):
  Input: zforce_ts: Reinitialize touch controller when  BOOT_COMPLETE
    received

Oleksij Rempel (1):
  Input: zforce_ts: Reject open if initialization not finished

 .../bindings/input/touchscreen/zforce_ts.txt       |   6 +
 drivers/input/touchscreen/zforce_ts.c              | 175 ++++++++++++++++++---
 include/linux/platform_data/zforce_ts.h            |   3 +
 3 files changed, 158 insertions(+), 26 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/4] Input: zforce_ts: Reinitialize touch controller when  BOOT_COMPLETE received
  2016-05-03 10:41 [PATCH v2 0/4] zForce upstreaming Dirk Behme
@ 2016-05-03 10:41 ` Dirk Behme
  2016-05-03 10:41 ` [PATCH v2 2/4] Input: zforce_ts: Reject open if initialization not finished Dirk Behme
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Dirk Behme @ 2016-05-03 10:41 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Henrik Rydberg,
	Javier Martinez Canillas
  Cc: Marcel Grosshans, Knut Wohlrab, Oleksij Rempel

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 occures. 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>
---
 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 7b3845a..9839d86 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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/4] Input: zforce_ts: Reject open if initialization not finished
  2016-05-03 10:41 [PATCH v2 0/4] zForce upstreaming Dirk Behme
  2016-05-03 10:41 ` [PATCH v2 1/4] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received Dirk Behme
@ 2016-05-03 10:41 ` Dirk Behme
  2016-05-03 16:10   ` Dmitry Torokhov
  2016-05-03 10:41 ` [PATCH v2 3/4] Input: zforce_ts: Add device tree support for scanning frequency Dirk Behme
  2016-05-03 10:41 ` [PATCH v2 4/4] Input: zforce_ts: Add support for minimum touch size limit Dirk Behme
  3 siblings, 1 reply; 7+ messages in thread
From: Dirk Behme @ 2016-05-03 10:41 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Henrik Rydberg,
	Javier Martinez Canillas
  Cc: Oleksij Rempel, Oleksij Rempel, Knut Wohlrab

From: Oleksij Rempel <linux@rempel-privat.de>

Response EAGAIN when open 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>
---
 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 9839d86..fc0edd6 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;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/4] Input: zforce_ts: Add device tree support for scanning frequency
  2016-05-03 10:41 [PATCH v2 0/4] zForce upstreaming Dirk Behme
  2016-05-03 10:41 ` [PATCH v2 1/4] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received Dirk Behme
  2016-05-03 10:41 ` [PATCH v2 2/4] Input: zforce_ts: Reject open if initialization not finished Dirk Behme
@ 2016-05-03 10:41 ` Dirk Behme
  2016-05-03 10:41 ` [PATCH v2 4/4] Input: zforce_ts: Add support for minimum touch size limit Dirk Behme
  3 siblings, 0 replies; 7+ messages in thread
From: Dirk Behme @ 2016-05-03 10:41 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Henrik Rydberg,
	Javier Martinez Canillas
  Cc: Knut Wohlrab, Oleksij Rempel

From: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>

Add device tree support for idle and finger scanning frequency.

For usage details see documentation.

Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
 .../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..d8d57ba 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-idle-hz: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
+- scan-active-hz: touch scanning frequeny in Hz (0 - 65535 Hz; default 50 Hz)
 
 Example:
 
@@ -28,6 +30,8 @@ Example:
 
 			x-size = <800>;
 			y-size = <600>;
+			scan-idle-hz = <50>;
+			scan-active-hz = <250>;
 		};
 
 		/* ... */
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index fc0edd6..2a818d4 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-idle-hz",
+				 &pdata->scan_freq_idle))
+		pdata->scan_freq_idle = SCAN_FREQ_DEFAULT_IDLE;
+
+	if (of_property_read_u16(np, "scan-active-hz",
+				 &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 */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 4/4] Input: zforce_ts: Add support for minimum touch size limit
  2016-05-03 10:41 [PATCH v2 0/4] zForce upstreaming Dirk Behme
                   ` (2 preceding siblings ...)
  2016-05-03 10:41 ` [PATCH v2 3/4] Input: zforce_ts: Add device tree support for scanning frequency Dirk Behme
@ 2016-05-03 10:41 ` Dirk Behme
  2016-05-03 16:12   ` Dmitry Torokhov
  3 siblings, 1 reply; 7+ messages in thread
From: Dirk Behme @ 2016-05-03 10:41 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Henrik Rydberg,
	Javier Martinez Canillas
  Cc: Knut Wohlrab, Oleksij Rempel

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).

For usage details see documentation.

Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
 .../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 d8d57ba..60dd78b 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-idle-hz: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
 - scan-active-hz: 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-idle-hz = <50>;
 			scan-active-hz = <250>;
+			touch-size-min = <5>;
 		};
 
 		/* ... */
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index 2a818d4..99fe7b6 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 */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/4] Input: zforce_ts: Reject open if initialization not finished
  2016-05-03 10:41 ` [PATCH v2 2/4] Input: zforce_ts: Reject open if initialization not finished Dirk Behme
@ 2016-05-03 16:10   ` Dmitry Torokhov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2016-05-03 16:10 UTC (permalink / raw)
  To: Dirk Behme
  Cc: linux-input, Henrik Rydberg, Javier Martinez Canillas,
	Oleksij Rempel, Oleksij Rempel, Knut Wohlrab

On Tue, May 03, 2016 at 12:41:48PM +0200, Dirk Behme wrote:
> From: Oleksij Rempel <linux@rempel-privat.de>
> 
> Response EAGAIN when open the device while BOOT_COMPLETE
> notification is not received and initialization of the zForce touch
> controller is not finished.

Hmm, why not allow open to complete, but check the open count when we
receive boot completion status and call zforce_start() there if open
count is not 0?

Thanks.

> 
> Signed-off-by: Oleksij Rempel <fixed-term.Oleksij.Rempel@de.bosch.com>
> Signed-off-by: Knut Wohlrab <Knut.Wohlrab@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 9839d86..fc0edd6 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;
> -- 
> 1.9.1
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 4/4] Input: zforce_ts: Add support for minimum touch size limit
  2016-05-03 10:41 ` [PATCH v2 4/4] Input: zforce_ts: Add support for minimum touch size limit Dirk Behme
@ 2016-05-03 16:12   ` Dmitry Torokhov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2016-05-03 16:12 UTC (permalink / raw)
  To: Dirk Behme
  Cc: linux-input, Henrik Rydberg, Javier Martinez Canillas,
	Knut Wohlrab, Oleksij Rempel

On Tue, May 03, 2016 at 12:41:50PM +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).
> 
> For usage details see documentation.
> 
> Signed-off-by: Knut Wohlrab <Knut.Wohlrab@de.bosch.com>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
>  .../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 d8d57ba..60dd78b 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-idle-hz: idle scanning frequency in Hz (0 - 65535 Hz; default 10 Hz)
>  - scan-active-hz: 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))

minimum

Also it should probably be touch-size-min-mm if I understand devicetree
guys.

>  
>  Example:
>  
> @@ -32,6 +33,7 @@ Example:
>  			y-size = <600>;
>  			scan-idle-hz = <50>;
>  			scan-active-hz = <250>;
> +			touch-size-min = <5>;
>  		};
>  
>  		/* ... */
> diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
> index 2a818d4..99fe7b6 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 */
> -- 
> 1.9.1
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-05-03 16:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-03 10:41 [PATCH v2 0/4] zForce upstreaming Dirk Behme
2016-05-03 10:41 ` [PATCH v2 1/4] Input: zforce_ts: Reinitialize touch controller when BOOT_COMPLETE received Dirk Behme
2016-05-03 10:41 ` [PATCH v2 2/4] Input: zforce_ts: Reject open if initialization not finished Dirk Behme
2016-05-03 16:10   ` Dmitry Torokhov
2016-05-03 10:41 ` [PATCH v2 3/4] Input: zforce_ts: Add device tree support for scanning frequency Dirk Behme
2016-05-03 10:41 ` [PATCH v2 4/4] Input: zforce_ts: Add support for minimum touch size limit Dirk Behme
2016-05-03 16:12   ` 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).