All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9 v4] Synaptics image sensor support
@ 2011-08-18 11:27 Daniel Kurtz
  2011-08-18 11:28 ` [PATCH 1/9 v4] Input: synaptics - refactor y inversion Daniel Kurtz
                   ` (8 more replies)
  0 siblings, 9 replies; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-18 11:27 UTC (permalink / raw)
  To: chase.douglas, dmitry.torokhov, rydberg
  Cc: linux-input, linux-kernel, olofj, chris, Daniel Kurtz

Hello,

----
For v4:
  Patch 4 & 7:
     Per Henrik: Do not report synaptics 'w' as ABS_MT_TOUCH_MAJOR.  This has
                 the nice side affect of cleaning up slot reporting.

  Patch 6 (new):
     Per Chase: Document 'report more touches than slots' behavior.
----

This patch set (against next) is intended to add support for synaptics
"image sensor" touchpads.

Patches 1-3 clean up the current driver slightly and prepare for the image
sensor patches which follow.

Patches 4-7 add 3 finger support for image sensor touchpads.
Image sensors do not suffer from the finger tracking issues that plagued
the earlier "profile sensors", and which required the invention of "semi-mt"
(Semi-mt reports a bounding box around two fingers instead of the fingers
themselves).  Instead, the image sensors report the actual positions of two
fingers using the same "Advanced Gesture Mode".  This driver uses two MT-B slots
to report these two fingers to userspace.  In addition, it will also report
the total number of fingers using BTN_TOOL_*TAP EV_KEY events.  This behavior
is documented in the multi-touch-protocol document.

Userspace drivers should be aware that the number of fingers reported via
BTN_TOOL_*TAP can be greater than the total number MT-B slots with non-negative
track_ids.  Upon opening the device node, userspace should query the maximum
values supported ABS_MT_SLOT, and note the number of supported BTN_TOOL_*TAP
events.

Patches 7-8 add 4 and 5 finger support.
In fact, the image sensor touchpads actually track 5 fingers while reporting
just 2 finger positions.  These patches add support for properly tracking the
reported slots through 4 and 5 finger transitions, while always reporting two of
them via 2 MT-B slots.  In addition, a new event, EV_KEY/BTN_TOOL_QUINTTAP, is
added to the event subsystem to allow reporting up to 5 fingers.

These patches are similar to, and inspired by, a similar patchset recently
submitted by Derek Foreman and Daniel Stone.  However, it is not directly built
upon, nor is it compatible with, those patches.

Thanks,
Daniel


Daniel Kurtz (9):
  Input: synaptics - refactor y inversion
  Input: synaptics - refactor agm packet parsing
  Input: synaptics - refactor initialization of abs position axes
  Input: synaptics - add image sensor support
  Input: synaptics - decode AGM packet types
  Input: mt - document devices reporting more touches than slots
  Input: synaptics - process finger (<=3) transitions
  Input: add BTN_TOOL_QUINTTAP for reporting 5 fingers on touchpad
  Input: synaptics - process finger (<=5) transitions

 Documentation/input/multi-touch-protocol.txt |   14 +
 drivers/input/input-mt.c                     |    1 +
 drivers/input/mouse/synaptics.c              |  489 ++++++++++++++++++++++++--
 drivers/input/mouse/synaptics.h              |   27 ++-
 include/linux/input.h                        |    1 +
 5 files changed, 495 insertions(+), 37 deletions(-)

-- 
1.7.3.1


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

* [PATCH 1/9 v4] Input: synaptics - refactor y inversion
  2011-08-18 11:27 [PATCH 0/9 v4] Synaptics image sensor support Daniel Kurtz
@ 2011-08-18 11:28 ` Daniel Kurtz
  2011-08-18 11:28 ` [PATCH 2/9 v4] Input: synaptics - refactor agm packet parsing Daniel Kurtz
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-18 11:28 UTC (permalink / raw)
  To: chase.douglas, dmitry.torokhov, rydberg
  Cc: linux-input, linux-kernel, olofj, chris, Daniel Kurtz

Synaptics touchpads report increasing y from bottom to top.
This is inverted from normal userspace "top of screen is 0" coordinates.
Thus, the kernel driver reports inverted y coordinates to userspace.

This patch refactors this inversion.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
---
 drivers/input/mouse/synaptics.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 5538fc6..297e88f 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -44,6 +44,16 @@
 #define YMIN_NOMINAL 1408
 #define YMAX_NOMINAL 4448
 
+/*
+ * Synaptics touchpads report the y coordinate from bottom to top, which is
+ * opposite from what userspace expects.
+ * This function is used to invert y before reporting.
+ */
+static int invert_y(int y)
+{
+	return YMAX_NOMINAL + YMIN_NOMINAL - y;
+}
+
 
 /*****************************************************************************
  *	Stuff we need even when we do not want native Synaptics support
@@ -502,8 +512,7 @@ static void synaptics_report_semi_mt_slot(struct input_dev *dev, int slot,
 	input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
 	if (active) {
 		input_report_abs(dev, ABS_MT_POSITION_X, x);
-		input_report_abs(dev, ABS_MT_POSITION_Y,
-				 YMAX_NOMINAL + YMIN_NOMINAL - y);
+		input_report_abs(dev, ABS_MT_POSITION_Y, invert_y(y));
 	}
 }
 
@@ -597,7 +606,7 @@ static void synaptics_process_packet(struct psmouse *psmouse)
 
 	if (num_fingers > 0) {
 		input_report_abs(dev, ABS_X, hw.x);
-		input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - hw.y);
+		input_report_abs(dev, ABS_Y, invert_y(hw.y));
 	}
 	input_report_abs(dev, ABS_PRESSURE, hw.z);
 
-- 
1.7.3.1


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

* [PATCH 2/9 v4] Input: synaptics - refactor agm packet parsing
  2011-08-18 11:27 [PATCH 0/9 v4] Synaptics image sensor support Daniel Kurtz
  2011-08-18 11:28 ` [PATCH 1/9 v4] Input: synaptics - refactor y inversion Daniel Kurtz
@ 2011-08-18 11:28 ` Daniel Kurtz
  2011-08-18 11:28 ` [PATCH 3/9 v4] Input: synaptics - refactor initialization of abs position axes Daniel Kurtz
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-18 11:28 UTC (permalink / raw)
  To: chase.douglas, dmitry.torokhov, rydberg
  Cc: linux-input, linux-kernel, olofj, chris, Daniel Kurtz

When a Synaptics touchpad is in "AGM" mode, and multiple fingers are
detected, the touchpad sends alternating "Advanced Gesture Mode" (AGM) and
"Simple Gesture Mode" (SGM) packets.
  The AGM packets have w=2, and contain reduced resolution finger data.
  The SGM packets have w={0,1} and contain full resolution finger data.

Refactor the parsing of agm packets to its own function, and rename the
synaptics_data.mt field to .agm to indicate that it contains the contents of
the last agm packet.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
---
 drivers/input/mouse/synaptics.c |   19 ++++++++++++++-----
 drivers/input/mouse/synaptics.h |    6 +++++-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 297e88f..e966894 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -419,6 +419,17 @@ static void synaptics_pt_create(struct psmouse *psmouse)
  *	Functions to interpret the absolute mode packets
  ****************************************************************************/
 
+static void synaptics_parse_agm(const unsigned char buf[],
+				struct synaptics_data *priv)
+{
+	struct synaptics_hw_state *agm = &priv->agm;
+
+	/* Gesture packet: (x, y, z) at half resolution */
+	agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
+	agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
+	agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1;
+}
+
 static int synaptics_parse_hw_state(const unsigned char buf[],
 				    struct synaptics_data *priv,
 				    struct synaptics_hw_state *hw)
@@ -453,10 +464,7 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
 		}
 
 		if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) && hw->w == 2) {
-			/* Gesture packet: (x, y, z) at half resolution */
-			priv->mt.x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
-			priv->mt.y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
-			priv->mt.z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1;
+			synaptics_parse_agm(buf, priv);
 			return 1;
 		}
 
@@ -595,7 +603,8 @@ static void synaptics_process_packet(struct psmouse *psmouse)
 	}
 
 	if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c))
-		synaptics_report_semi_mt_data(dev, &hw, &priv->mt, num_fingers);
+		synaptics_report_semi_mt_data(dev, &hw, &priv->agm,
+					      num_fingers);
 
 	/* Post events
 	 * BTN_TOUCH has to be first as mousedev relies on it when doing
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index ca040aa..a9efbf3 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -146,7 +146,11 @@ struct synaptics_data {
 
 	struct serio *pt_port;			/* Pass-through serio port */
 
-	struct synaptics_hw_state mt;		/* current gesture packet */
+	/*
+	 * Last received Advanced Gesture Mode (AGM) packet. An AGM packet
+	 * contains position data for a second contact, at half resolution.
+	 */
+	struct synaptics_hw_state agm;
 };
 
 void synaptics_module_init(void);
-- 
1.7.3.1


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

* [PATCH 3/9 v4] Input: synaptics - refactor initialization of abs position axes
  2011-08-18 11:27 [PATCH 0/9 v4] Synaptics image sensor support Daniel Kurtz
  2011-08-18 11:28 ` [PATCH 1/9 v4] Input: synaptics - refactor y inversion Daniel Kurtz
  2011-08-18 11:28 ` [PATCH 2/9 v4] Input: synaptics - refactor agm packet parsing Daniel Kurtz
@ 2011-08-18 11:28 ` Daniel Kurtz
  2011-08-18 11:28 ` [PATCH 4/9 v4] Input: synaptics - add image sensor support Daniel Kurtz
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-18 11:28 UTC (permalink / raw)
  To: chase.douglas, dmitry.torokhov, rydberg
  Cc: linux-input, linux-kernel, olofj, chris, Daniel Kurtz

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
---
 drivers/input/mouse/synaptics.c |   44 +++++++++++++++++---------------------
 1 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index e966894..30d05fd 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -712,39 +712,38 @@ static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse)
 /*****************************************************************************
  *	Driver initialization/cleanup functions
  ****************************************************************************/
+static void set_abs_position_params(struct input_dev *dev,
+				    struct synaptics_data *priv, int x_code,
+				    int y_code)
+{
+	int x_min = priv->x_min ?: XMIN_NOMINAL;
+	int x_max = priv->x_max ?: XMAX_NOMINAL;
+	int y_min = priv->y_min ?: YMIN_NOMINAL;
+	int y_max = priv->y_max ?: YMAX_NOMINAL;
+	int fuzz = SYN_CAP_REDUCED_FILTERING(priv->ext_cap_0c) ?
+			SYN_REDUCED_FILTER_FUZZ : 0;
+
+	input_set_abs_params(dev, x_code, x_min, x_max, fuzz, 0);
+	input_set_abs_params(dev, y_code, y_min, y_max, fuzz, 0);
+	input_abs_set_res(dev, x_code, priv->x_res);
+	input_abs_set_res(dev, y_code, priv->y_res);
+}
+
 static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
 {
 	int i;
-	int fuzz = SYN_CAP_REDUCED_FILTERING(priv->ext_cap_0c) ?
-			SYN_REDUCED_FILTER_FUZZ : 0;
 
 	__set_bit(INPUT_PROP_POINTER, dev->propbit);
 
 	__set_bit(EV_ABS, dev->evbit);
-	input_set_abs_params(dev, ABS_X,
-			     priv->x_min ?: XMIN_NOMINAL,
-			     priv->x_max ?: XMAX_NOMINAL,
-			     fuzz, 0);
-	input_set_abs_params(dev, ABS_Y,
-			     priv->y_min ?: YMIN_NOMINAL,
-			     priv->y_max ?: YMAX_NOMINAL,
-			     fuzz, 0);
+	set_abs_position_params(dev, priv, ABS_X, ABS_Y);
 	input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
 
 	if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) {
 		__set_bit(INPUT_PROP_SEMI_MT, dev->propbit);
 		input_mt_init_slots(dev, 2);
-		input_set_abs_params(dev, ABS_MT_POSITION_X,
-				     priv->x_min ?: XMIN_NOMINAL,
-				     priv->x_max ?: XMAX_NOMINAL,
-				     fuzz, 0);
-		input_set_abs_params(dev, ABS_MT_POSITION_Y,
-				     priv->y_min ?: YMIN_NOMINAL,
-				     priv->y_max ?: YMAX_NOMINAL,
-				     fuzz, 0);
-
-		input_abs_set_res(dev, ABS_MT_POSITION_X, priv->x_res);
-		input_abs_set_res(dev, ABS_MT_POSITION_Y, priv->y_res);
+		set_abs_position_params(dev, priv, ABS_MT_POSITION_X,
+					ABS_MT_POSITION_Y);
 	}
 
 	if (SYN_CAP_PALMDETECT(priv->capabilities))
@@ -777,9 +776,6 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
 	__clear_bit(REL_X, dev->relbit);
 	__clear_bit(REL_Y, dev->relbit);
 
-	input_abs_set_res(dev, ABS_X, priv->x_res);
-	input_abs_set_res(dev, ABS_Y, priv->y_res);
-
 	if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
 		__set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
 		/* Clickpads report only left button */
-- 
1.7.3.1


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

* [PATCH 4/9 v4] Input: synaptics - add image sensor support
  2011-08-18 11:27 [PATCH 0/9 v4] Synaptics image sensor support Daniel Kurtz
                   ` (2 preceding siblings ...)
  2011-08-18 11:28 ` [PATCH 3/9 v4] Input: synaptics - refactor initialization of abs position axes Daniel Kurtz
@ 2011-08-18 11:28 ` Daniel Kurtz
  2011-08-18 16:00   ` Chase Douglas
  2011-08-19 22:22   ` Dmitry Torokhov
  2011-08-18 11:28 ` [PATCH 5/9 v4] Input: synaptics - decode AGM packet types Daniel Kurtz
                   ` (4 subsequent siblings)
  8 siblings, 2 replies; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-18 11:28 UTC (permalink / raw)
  To: chase.douglas, dmitry.torokhov, rydberg
  Cc: linux-input, linux-kernel, olofj, chris, Daniel Kurtz

Synaptics makes (at least) two kinds of touchpad sensors:
 * Older pads use a profile sensor that could only infer the location
   of individual fingers based on the projection of their profiles
   onto row and column sensors.
 * Newer pads use an image sensor that can track true finger position
   using a two-dimensional sensor grid.

Both sensor types support an "Advanced Gesture Mode":
 When multiple fingers are detected, the touchpad sends alternating
 "Advanced Gesture Mode" (AGM) and "Simple Gesture Mode" (SGM)
 packets.
 The AGM packets have w=2, and contain reduced resolution finger data
 The SGM packets have w={0,1} and contain full resolution finger data

Profile sensors try to report the "upper" (larger y value) finger in
the SGM packet, and the lower (smaller y value) in the AGM packet.
However, due to the nature of the profile sensor, they easily get
confused when fingers cross, and can start reporting the x-coordinate
of one with the y-coordinate of the other.  Thus, for profile
sensors, "semi-mt" was created, which reports a "bounding box"
created by pairing min and max coordinates of the two pairs of
reported fingers.

Image sensors can report the actual coordinates of two of the fingers
present.  This patch detects if the touchpad is an image sensor and
reports finger data using the MT-B protocol.

NOTE: This patch only adds partial support for 2-finger gestures.
      The proper interpretation of the slot contents when more than
      two fingers are present is left to later patches.  Also,
      handling of 'number of fingers' transitions is incomplete.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
 drivers/input/mouse/synaptics.c |   86 +++++++++++++++++++++++++++++++++++++-
 drivers/input/mouse/synaptics.h |    3 +
 2 files changed, 86 insertions(+), 3 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 30d05fd..a49420f 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -304,7 +304,8 @@ static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
 	static unsigned char param = 0xc8;
 	struct synaptics_data *priv = psmouse->private;
 
-	if (!SYN_CAP_ADV_GESTURE(priv->ext_cap_0c))
+	if (!(SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) ||
+			SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)))
 		return 0;
 
 	if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL))
@@ -463,7 +464,9 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
 			hw->down = ((buf[0] ^ buf[3]) & 0x02) ? 1 : 0;
 		}
 
-		if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) && hw->w == 2) {
+		if ((SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)
+				|| SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c))
+				&& hw->w == 2) {
 			synaptics_parse_agm(buf, priv);
 			return 1;
 		}
@@ -543,6 +546,71 @@ static void synaptics_report_semi_mt_data(struct input_dev *dev,
 	}
 }
 
+static void synaptics_report_slot(struct input_dev *dev, int slot,
+				  const struct synaptics_hw_state *hw)
+{
+	input_mt_slot(dev, slot);
+	input_mt_report_slot_state(dev, MT_TOOL_FINGER, (hw != NULL));
+	if (!hw)
+		return;
+
+	input_report_abs(dev, ABS_MT_POSITION_X, hw->x);
+	input_report_abs(dev, ABS_MT_POSITION_Y, invert_y(hw->y));
+	input_report_abs(dev, ABS_MT_PRESSURE, hw->z);
+}
+
+static void synaptics_report_mt_data(struct psmouse *psmouse,
+				     int count,
+				     const struct synaptics_hw_state *sgm)
+{
+	struct input_dev *dev = psmouse->dev;
+	struct synaptics_data *priv = psmouse->private;
+	struct synaptics_hw_state *agm = &priv->agm;
+
+	switch (count) {
+	case 0:
+		synaptics_report_slot(dev, 0, NULL);
+		synaptics_report_slot(dev, 1, NULL);
+		break;
+	case 1:
+		synaptics_report_slot(dev, 0, sgm);
+		synaptics_report_slot(dev, 1, NULL);
+		break;
+	case 2:
+	case 3: /* Fall-through case */
+		synaptics_report_slot(dev, 0, sgm);
+		synaptics_report_slot(dev, 1, agm);
+		break;
+	}
+
+	/* Don't use active slot count to generate BTN_TOOL events. */
+	input_mt_report_pointer_emulation(dev, false);
+
+	/* Send the number of fingers reported by touchpad itself. */
+	input_mt_report_finger_count(dev, count);
+
+	input_report_key(dev, BTN_LEFT, sgm->left);
+	input_sync(dev);
+}
+
+static void synaptics_image_sensor_process(struct psmouse *psmouse,
+					   struct synaptics_hw_state *sgm)
+{
+	int count;
+
+	if (sgm->z == 0)
+		count = 0;
+	else if (sgm->w >= 4)
+		count = 1;
+	else if (sgm->w == 0)
+		count = 2;
+	else
+		count = 3;
+
+	/* Send resulting input events to user space */
+	synaptics_report_mt_data(psmouse, count, sgm);
+}
+
 /*
  *  called for each full received packet from the touchpad
  */
@@ -558,6 +626,11 @@ static void synaptics_process_packet(struct psmouse *psmouse)
 	if (synaptics_parse_hw_state(psmouse->packet, priv, &hw))
 		return;
 
+	if (SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) {
+		synaptics_image_sensor_process(psmouse, &hw);
+		return;
+	}
+
 	if (hw.scroll) {
 		priv->scroll += hw.scroll;
 
@@ -739,7 +812,14 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
 	set_abs_position_params(dev, priv, ABS_X, ABS_Y);
 	input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
 
-	if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) {
+	if (SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) {
+		input_mt_init_slots(dev, 2);
+		set_abs_position_params(dev, priv, ABS_MT_POSITION_X,
+					ABS_MT_POSITION_Y);
+		/* Image sensors can report per-contact pressure */
+		input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0);
+	} else if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) {
+		/* Non-image sensors with AGM use semi-mt */
 		__set_bit(INPUT_PROP_SEMI_MT, dev->propbit);
 		input_mt_init_slots(dev, 2);
 		set_abs_position_params(dev, priv, ABS_MT_POSITION_X,
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index a9efbf3..0ea7616 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -74,6 +74,8 @@
  * 2	0x04	reduced filtering	firmware does less filtering on
  *					position data, driver should watch
  *					for noise.
+ * 2	0x08	image sensor		image sensor tracks 5 fingers, but only
+ *					reports 2.
  * 2	0x20	report min		query 0x0f gives min coord reported
  */
 #define SYN_CAP_CLICKPAD(ex0c)		((ex0c) & 0x100000) /* 1-button ClickPad */
@@ -82,6 +84,7 @@
 #define SYN_CAP_MIN_DIMENSIONS(ex0c)	((ex0c) & 0x002000)
 #define SYN_CAP_ADV_GESTURE(ex0c)	((ex0c) & 0x080000)
 #define SYN_CAP_REDUCED_FILTERING(ex0c)	((ex0c) & 0x000400)
+#define SYN_CAP_IMAGE_SENSOR(ex0c)	((ex0c) & 0x000800)
 
 /* synaptics modes query bits */
 #define SYN_MODE_ABSOLUTE(m)		((m) & (1 << 7))
-- 
1.7.3.1


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

* [PATCH 5/9 v4] Input: synaptics - decode AGM packet types
  2011-08-18 11:27 [PATCH 0/9 v4] Synaptics image sensor support Daniel Kurtz
                   ` (3 preceding siblings ...)
  2011-08-18 11:28 ` [PATCH 4/9 v4] Input: synaptics - add image sensor support Daniel Kurtz
@ 2011-08-18 11:28 ` Daniel Kurtz
  2011-08-18 11:28 ` [PATCH 6/9 v4] Input: mt - document devices reporting more touches than slots Daniel Kurtz
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-18 11:28 UTC (permalink / raw)
  To: chase.douglas, dmitry.torokhov, rydberg
  Cc: linux-input, linux-kernel, olofj, chris, Daniel Kurtz

A Synaptics image sensor tracks 5 fingers, but can only report 2.

The algorithm for choosing which 2 fingers to report and in which packet:
  Touchpad maintains 5 slots, numbered 0 to 4
  Initially all slots are empty
  As new fingers are detected, assign them to the lowest available slots
  The touchpad always reports:
    SGM: lowest numbered non-empty slot
    AGM: highest numbered non-empty slot, if there is one

In addition, these touchpads have a special AGM packet type which reports
the number of fingers currently being tracked, and which finger is in
each of the two slots.  Unfortunately, these "TYPE=2" packets are only used
when more than 3 fingers are being tracked.  When less than 4 fingers
are present, the 'w' value must be used to track how many fingers are
present, and knowing which fingers are being reported is much more
difficult, if not impossible.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
---
 drivers/input/mouse/synaptics.c |   38 +++++++++++++++++++++++++++++++-------
 drivers/input/mouse/synaptics.h |   14 +++++++++++++-
 2 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index a49420f..ad0a5aa 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -420,15 +420,39 @@ static void synaptics_pt_create(struct psmouse *psmouse)
  *	Functions to interpret the absolute mode packets
  ****************************************************************************/
 
+static void synaptics_mt_state_set(struct synaptics_mt_state *state, int count,
+				   int sgm, int agm)
+{
+	state->count = count;
+	state->sgm = sgm;
+	state->agm = agm;
+}
+
 static void synaptics_parse_agm(const unsigned char buf[],
-				struct synaptics_data *priv)
+				struct synaptics_data *priv,
+				struct synaptics_hw_state *hw)
 {
 	struct synaptics_hw_state *agm = &priv->agm;
+	int agm_packet_type;
+
+	agm_packet_type = (buf[5] & 0x30) >> 4;
+	switch (agm_packet_type) {
+	case 1:
+		/* Gesture packet: (x, y, z) half resolution */
+		agm->w = hw->w;
+		agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
+		agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
+		agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1;
+		break;
 
-	/* Gesture packet: (x, y, z) at half resolution */
-	agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
-	agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
-	agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1;
+	case 2:
+		/* AGM-CONTACT packet: (count, sgm, agm) */
+		synaptics_mt_state_set(&agm->mt_state, buf[1], buf[2], buf[4]);
+		break;
+
+	default:
+		break;
+	}
 }
 
 static int synaptics_parse_hw_state(const unsigned char buf[],
@@ -467,7 +491,7 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
 		if ((SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)
 				|| SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c))
 				&& hw->w == 2) {
-			synaptics_parse_agm(buf, priv);
+			synaptics_parse_agm(buf, priv, hw);
 			return 1;
 		}
 
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 0ea7616..20f57df 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -115,9 +115,18 @@
 #define SYN_REDUCED_FILTER_FUZZ		8
 
 /*
- * A structure to describe the state of the touchpad hardware (buttons and pad)
+ * A structure to describe which internal touchpad finger slots are being
+ * reported in raw packets.
  */
+struct synaptics_mt_state {
+	int count;			/* num fingers being tracked */
+	int sgm;			/* which slot is reported by sgm pkt */
+	int agm;			/* which slot is reported by agm pkt*/
+};
 
+/*
+ * A structure to describe the state of the touchpad hardware (buttons and pad)
+ */
 struct synaptics_hw_state {
 	int x;
 	int y;
@@ -130,6 +139,9 @@ struct synaptics_hw_state {
 	unsigned int down:1;
 	unsigned char ext_buttons;
 	signed char scroll;
+
+	/* As reported in last AGM-CONTACT packets */
+	struct synaptics_mt_state mt_state;
 };
 
 struct synaptics_data {
-- 
1.7.3.1


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

* [PATCH 6/9 v4] Input: mt - document devices reporting more touches than slots
  2011-08-18 11:27 [PATCH 0/9 v4] Synaptics image sensor support Daniel Kurtz
                   ` (4 preceding siblings ...)
  2011-08-18 11:28 ` [PATCH 5/9 v4] Input: synaptics - decode AGM packet types Daniel Kurtz
@ 2011-08-18 11:28 ` Daniel Kurtz
  2011-08-18 16:01   ` Chase Douglas
  2011-08-18 11:28 ` [PATCH 7/9 v4] Input: synaptics - process finger (<=3) transitions Daniel Kurtz
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-18 11:28 UTC (permalink / raw)
  To: chase.douglas, dmitry.torokhov, rydberg
  Cc: linux-input, linux-kernel, olofj, chris, Daniel Kurtz

Some devices are capable of identifying and/or tracking more contacts than
they can report to the driver.  Document how a driver should handle this,
and what userspace should expect.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
 Documentation/input/multi-touch-protocol.txt |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Documentation/input/multi-touch-protocol.txt b/Documentation/input/multi-touch-protocol.txt
index 71536e7..543101c 100644
--- a/Documentation/input/multi-touch-protocol.txt
+++ b/Documentation/input/multi-touch-protocol.txt
@@ -65,6 +65,20 @@ the full state of each initiated contact has to reside in the receiving
 end.  Upon receiving an MT event, one simply updates the appropriate
 attribute of the current slot.
 
+Some devices identify and/or track more contacts than they can report to the
+driver.  A driver for such a device should associate one type B slot with each
+contact that is reported by the hardware.  Whenever the identity of the
+contact associated with a slot changes, the driver should invalidate that
+slot by changing its ABS_MT_TRACKING_ID.  If the hardware signals that it is
+tracking more contacts than it is currently reporting, the driver should use
+a BTN_TOOL_*TAP event to inform userspace of the total number of contacts
+being tracked by the hardware at that moment.  The driver should do this by
+explicitly sending the corresponding BTN_TOOL_*TAP event and setting
+use_count to false when calling input_mt_report_pointer_emulation().
+The driver should only advertise as many slots as the hardware can report.
+Userspace can detect that a driver can report more total contacts than slots
+by noting that the largest supported BTN_TOOL_*TAP event is larger than the
+total number of type B slots reported in the absinfo for the ABS_MT_SLOT axis.
 
 Protocol Example A
 ------------------
-- 
1.7.3.1


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

* [PATCH 7/9 v4] Input: synaptics - process finger (<=3) transitions
  2011-08-18 11:27 [PATCH 0/9 v4] Synaptics image sensor support Daniel Kurtz
                   ` (5 preceding siblings ...)
  2011-08-18 11:28 ` [PATCH 6/9 v4] Input: mt - document devices reporting more touches than slots Daniel Kurtz
@ 2011-08-18 11:28 ` Daniel Kurtz
  2011-08-18 16:02   ` Chase Douglas
  2011-08-18 11:28 ` [PATCH 8/9 v4] Input: add BTN_TOOL_QUINTTAP for reporting 5 fingers on touchpad Daniel Kurtz
  2011-08-18 11:28 ` [PATCH 9/9 v4] Input: synaptics - process finger (<=5) transitions Daniel Kurtz
  8 siblings, 1 reply; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-18 11:28 UTC (permalink / raw)
  To: chase.douglas, dmitry.torokhov, rydberg
  Cc: linux-input, linux-kernel, olofj, chris, Daniel Kurtz

Synaptics image sensor touchpads track 5 fingers, but only report 2.
This patch attempts to deal with some idiosyncrasies of these touchpads:

 * When there are 3 or more fingers, only two are reported.
 * The touchpad tracks the 5 fingers in slot[0] through slot[4].
 * It always reports the lowest and highest valid slots in SGM and AGM
   packets, respectively.
 * The number of fingers is only reported in the SGM packet.  However,
   the number of fingers can change either before or after an AGM
   packet.
 * Thus, if an SGM reports a different number of fingers than the last
   SGM, it is impossible to tell whether the intervening AGM corresponds
   to the old number of fingers or the new number of fingers.
 * For example, when going from 2->3 fingers, it is not possible to tell
   whether tell AGM contains slot[1] (old 2nd finger) or slot[2] (new
   3rd finger).
 * When fingers are added one at at time, from 1->2->3, it is possible to
   track which slots are contained in the SGM and AGM packets:
     1 finger:  SGM = slot[0], no AGM
     2 fingers: SGM = slot[0], AGM = slot[1]
     3 fingers: SGM = slot[0], AGM = slot[2]
 * It is also possible to track which slot is contained in the SGM when 1
   of 2 fingers is removed.  This is because the touchpad sends a special
   (0,0,0) AGM packet whenever all fingers are removed except slot[0]:
     Last AGM == (0,0,0): SGM contains slot[1]
     Else: SGM contains slot[0]
 * However, once there are 3 fingers, if exactly 1 finger is removed, it
   is impossible to tell which 2 slots are contained in SGM and AGM.
   The (SGM,AGM) could be (0,1), (0,2), or (1,2). There is no way to know.
 * Similarly, if two fingers are simultaneously removed (3->1), then it
   is only possible to know if SGM still contains slot[0].
 * Since it is not possible to reliably track which slot is being
   reported, we invalidate the tracking_id every time the number of
   fingers changes until this ambiguity is resolved when:
     a) All fingers are removed.
     b) 4 or 5 fingers are touched, generates an AGM-CONTACT packet.
     c) All fingers are removed except slot[0].  In this special case, the
        ambiguity is resolved since by the (0,0,0) AGM packet.

Behavior of the driver:

When 2 or more fingers are present on the touchpad, the kernel reports
up to two MT-B slots containing the position data for two of the fingers
reported by the touchpad.  If the identity of a finger cannot be tracked
when the number-of-fingers changes, the corresponding MT-B slot will be
invalidated (track_id set to -1), and a new track_id will be assigned in
a subsequent input event report.

The driver always reports the total number of fingers using one of the
EV_KEY/BTN_TOOL_*TAP events. This could differ from the number of valid
MT-B slots for two reasons:
 a) There are more than 2 fingers on the pad.
 b) During ambiguous number-of-fingers transitions, the correct track_id
    for one or both of the slots cannot be determined, so the slots are
    invalidated.

Thus, this is a hybrid singletouch/MT-B scheme. Userspace can detect
this behavior by noting that the driver supports more EV_KEY/BTN_TOOL_*TAP
events than its maximum EV_ABS/ABS_MT_SLOT.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
 drivers/input/mouse/synaptics.c |  290 ++++++++++++++++++++++++++++++++++++--
 drivers/input/mouse/synaptics.h |    4 +
 2 files changed, 278 insertions(+), 16 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index ad0a5aa..3840cc7 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -453,6 +453,9 @@ static void synaptics_parse_agm(const unsigned char buf[],
 	default:
 		break;
 	}
+
+	/* Record that at least one AGM has been received since last SGM */
+	priv->agm_pending = true;
 }
 
 static int synaptics_parse_hw_state(const unsigned char buf[],
@@ -584,26 +587,53 @@ static void synaptics_report_slot(struct input_dev *dev, int slot,
 }
 
 static void synaptics_report_mt_data(struct psmouse *psmouse,
-				     int count,
+				     struct synaptics_mt_state *mt_state,
 				     const struct synaptics_hw_state *sgm)
 {
 	struct input_dev *dev = psmouse->dev;
 	struct synaptics_data *priv = psmouse->private;
 	struct synaptics_hw_state *agm = &priv->agm;
+	struct synaptics_mt_state *old = &priv->mt_state;
 
-	switch (count) {
+	switch (mt_state->count) {
 	case 0:
 		synaptics_report_slot(dev, 0, NULL);
 		synaptics_report_slot(dev, 1, NULL);
 		break;
 	case 1:
-		synaptics_report_slot(dev, 0, sgm);
-		synaptics_report_slot(dev, 1, NULL);
+		if (mt_state->sgm == -1) {
+			synaptics_report_slot(dev, 0, NULL);
+			synaptics_report_slot(dev, 1, NULL);
+		} else if (mt_state->sgm == 0) {
+			synaptics_report_slot(dev, 0, sgm);
+			synaptics_report_slot(dev, 1, NULL);
+		} else {
+			synaptics_report_slot(dev, 0, NULL);
+			synaptics_report_slot(dev, 1, sgm);
+		}
 		break;
-	case 2:
-	case 3: /* Fall-through case */
-		synaptics_report_slot(dev, 0, sgm);
-		synaptics_report_slot(dev, 1, agm);
+	default:
+		/*
+		 * If the finger slot contained in SGM is valid, and either
+		 * hasn't changed, or is new, then report SGM in MTB slot 0.
+		 * Otherwise, empty MTB slot 0.
+		 */
+		if (mt_state->sgm != -1 &&
+		    (mt_state->sgm == old->sgm || old->sgm == -1))
+			synaptics_report_slot(dev, 0, sgm);
+		else
+			synaptics_report_slot(dev, 0, NULL);
+
+		/*
+		 * If the finger slot contained in AGM is valid, and either
+		 * hasn't changed, or is new, then report AGM in MTB slot 1.
+		 * Otherwise, empty MTB slot 1.
+		 */
+		if (mt_state->agm != -1 &&
+		    (mt_state->agm == old->agm || old->agm == -1))
+			synaptics_report_slot(dev, 1, agm);
+		else
+			synaptics_report_slot(dev, 1, NULL);
 		break;
 	}
 
@@ -611,28 +641,256 @@ static void synaptics_report_mt_data(struct psmouse *psmouse,
 	input_mt_report_pointer_emulation(dev, false);
 
 	/* Send the number of fingers reported by touchpad itself. */
-	input_mt_report_finger_count(dev, count);
+	input_mt_report_finger_count(dev, mt_state->count);
 
 	input_report_key(dev, BTN_LEFT, sgm->left);
 	input_sync(dev);
 }
 
+/* Handle case where mt_state->count = 0 */
+static void synaptics_image_sensor_0f(struct synaptics_data *priv,
+				      struct synaptics_mt_state *mt_state)
+{
+	synaptics_mt_state_set(mt_state, 0, -1, -1);
+	priv->mt_state_lost = false;
+}
+
+/* Handle case where mt_state->count = 1 */
+static void synaptics_image_sensor_1f(struct synaptics_data *priv,
+				      struct synaptics_mt_state *mt_state)
+{
+	struct synaptics_hw_state *agm = &priv->agm;
+	struct synaptics_mt_state *old = &priv->mt_state;
+
+	/*
+	 * If the last AGM was (0,0,0), and there is only one finger left,
+	 * then we absolutely know that SGM contains slot 0, and all other
+	 * fingers have been removed.
+	 */
+	if (priv->agm_pending && agm->z == 0) {
+		synaptics_mt_state_set(mt_state, 1, 0, -1);
+		priv->mt_state_lost = false;
+		return;
+	}
+
+	switch (old->count) {
+	case 0:
+		synaptics_mt_state_set(mt_state, 1, 0, -1);
+		break;
+	case 1:
+		/*
+		 * If mt_state_lost, then the previous transition was 3->1,
+		 * and SGM now contains either slot 0 or 1, but we don't know
+		 * which.  So, we just assume that the SGM now contains slot 1.
+		 *
+		 * If pending AGM and either:
+		 *   (a) the previous SGM slot contains slot 0, or
+		 *   (b) there was no SGM slot
+		 * then, the SGM now contains slot 1
+		 *
+		 * Case (a) happens with very rapid "drum roll" gestures, where
+		 * slot 0 finger is lifted and a new slot 1 finger touches
+		 * within one reporting interval.
+		 *
+		 * Case (b) happens if initially two or more fingers tap
+		 * briefly, and all but one lift before the end of the first
+		 * reporting interval.
+		 *
+		 * (In both these cases, slot 0 will becomes empty, so SGM
+		 * contains slot 1 with the new finger)
+		 *
+		 * Else, if there was no previous SGM, it now contains slot 0.
+		 *
+		 * Otherwise, SGM still contains the same slot.
+		 */
+		if (priv->mt_state_lost ||
+		    (priv->agm_pending && old->sgm <= 0))
+			synaptics_mt_state_set(mt_state, 1, 1, -1);
+		else if (old->sgm == -1)
+			synaptics_mt_state_set(mt_state, 1, 0, -1);
+		break;
+	case 2:
+		/*
+		 * If mt_state_lost, we don't know which finger SGM contains.
+		 *
+		 * So, report 1 finger, but with both slots empty.
+		 * We will use slot 1 on subsequent 1->1
+		 */
+		if (priv->mt_state_lost) {
+			synaptics_mt_state_set(mt_state, 1, -1, -1);
+			break;
+		}
+		/*
+		 * Since the last AGM was NOT (0,0,0), it was the finger in
+		 * slot 0 that has been removed.
+		 * So, SGM now contains previous AGM's slot, and AGM is now
+		 * empty.
+		 */
+		synaptics_mt_state_set(mt_state, 1, old->agm, -1);
+		break;
+	case 3:
+		/*
+		 * Since last AGM was not (0,0,0), we don't know which finger
+		 * is left.
+		 *
+		 * So, report 1 finger, but with both slots empty.
+		 * We will use slot 1 on subsequent 1->1
+		 */
+		synaptics_mt_state_set(mt_state, 1, -1, -1);
+		priv->mt_state_lost = true;
+		break;
+	}
+}
+
+/* Handle case where mt_state->count = 2 */
+static void synaptics_image_sensor_2f(struct synaptics_data *priv,
+				      struct synaptics_mt_state *mt_state)
+{
+	struct synaptics_mt_state *old = &priv->mt_state;
+
+	switch (old->count) {
+	case 0:
+		synaptics_mt_state_set(mt_state, 2, 0, 1);
+		break;
+	case 1:
+		/*
+		 * If previous SGM contained slot 1 or higher, SGM now contains
+		 * slot 0 (the newly touching finger) and AGM contains SGM's
+		 * previous slot.
+		 *
+		 * Otherwise, SGM still contains slot 0 and AGM now contains
+		 * slot 1.
+		 */
+		if (old->sgm >= 1)
+			synaptics_mt_state_set(mt_state, 2, 0, old->sgm);
+		else
+			synaptics_mt_state_set(mt_state, 2, 0, 1);
+		break;
+	case 2:
+		/*
+		 * If mt_state_lost, SGM now contains either finger 1 or 2, but
+		 * we don't know which.
+		 * So, we just assume that the SGM contains slot 0 and AGM 1.
+		 */
+		if (priv->mt_state_lost)
+			synaptics_mt_state_set(mt_state, 2, 0, 1);
+		/*
+		 * Otherwise, use the same mt_state, since it either hasn't
+		 * changed, or was updated by a recently received AGM-CONTACT
+		 * packet.
+		 */
+		break;
+	case 3:
+		/*
+		 * 3->2 transitions have two unsolvable problems:
+		 *  1) no indication is given which finger was removed
+		 *  2) no way to tell if agm packet was for finger 3
+		 *     before 3->2, or finger 2 after 3->2.
+		 *
+		 * So, report 2 fingers, but empty all slots.
+		 * We will guess slots [0,1] on subsequent 2->2.
+		 */
+		synaptics_mt_state_set(mt_state, 2, -1, -1);
+		priv->mt_state_lost = true;
+		break;
+	}
+}
+
+/* Handle case where mt_state->count = 3 */
+static void synaptics_image_sensor_3f(struct synaptics_data *priv,
+				      struct synaptics_mt_state *mt_state)
+{
+	struct synaptics_mt_state *old = &priv->mt_state;
+
+	switch (old->count) {
+	case 0:
+		synaptics_mt_state_set(mt_state, 3, 0, 2);
+		break;
+	case 1:
+		/*
+		 * If previous SGM contained slot 2 or higher, SGM now contains
+		 * slot 0 (one of the newly touching fingers) and AGM contains
+		 * SGM's previous slot.
+		 *
+		 * Otherwise, SGM now contains slot 0 and AGM contains slot 2.
+		 */
+		if (old->sgm >= 2)
+			synaptics_mt_state_set(mt_state, 3, 0, old->sgm);
+		else
+			synaptics_mt_state_set(mt_state, 3, 0, 2);
+		break;
+	case 2:
+		/*
+		 * After some 3->1 and all 3->2 transitions, we lose track
+		 * of which slot is reported by SGM and AGM.
+		 *
+		 * For 2->3 in this state, report 3 fingers, but empty all
+		 * slots, and we will guess (0,2) on a subsequent 0->3.
+		 *
+		 * To userspace, the resulting transition will look like:
+		 *    2:[0,1] -> 3:[-1,-1] -> 3:[0,2]
+		 */
+		if (priv->mt_state_lost) {
+			synaptics_mt_state_set(mt_state, 3, -1, -1);
+			break;
+		}
+
+		/*
+		 * If the (SGM,AGM) really previously contained slots (0, 1),
+		 * then we cannot know what slot was just reported by the AGM,
+		 * because the 2->3 transition can occur either before or after
+		 * the AGM packet. Thus, this most recent AGM could contain
+		 * either the same old slot 1 or the new slot 2.
+		 * Subsequent AGMs will be reporting slot 2.
+		 *
+		 * To userspace, the resulting transition will look like:
+		 *    2:[0,1] -> 3:[0,-1] -> 3:[0,2]
+		 */
+		synaptics_mt_state_set(mt_state, 3, 0, -1);
+		break;
+	case 3:
+		/*
+		 * If, for whatever reason, the previous agm was invalid,
+		 * Assume SGM now contains slot 0, AGM now contains slot 2.
+		 */
+		if (old->agm <= 2)
+			synaptics_mt_state_set(mt_state, 3, 0, 2);
+		/*
+		 * mt_state either hasn't changed, or was updated by a recently
+		 * received AGM-CONTACT packet.
+		 */
+		break;
+	}
+}
+
 static void synaptics_image_sensor_process(struct psmouse *psmouse,
 					   struct synaptics_hw_state *sgm)
 {
-	int count;
+	struct synaptics_data *priv = psmouse->private;
+	struct synaptics_hw_state *agm = &priv->agm;
+	struct synaptics_mt_state mt_state;
 
+	/* Initialize using current mt_state (as updated by last agm) */
+	mt_state = agm->mt_state;
+
+	/*
+	 * Update mt_state using the new finger count and current mt_state.
+	 */
 	if (sgm->z == 0)
-		count = 0;
+		synaptics_image_sensor_0f(priv, &mt_state);
 	else if (sgm->w >= 4)
-		count = 1;
+		synaptics_image_sensor_1f(priv, &mt_state);
 	else if (sgm->w == 0)
-		count = 2;
-	else
-		count = 3;
+		synaptics_image_sensor_2f(priv, &mt_state);
+	else if (sgm->w == 1)
+		synaptics_image_sensor_3f(priv, &mt_state);
 
 	/* Send resulting input events to user space */
-	synaptics_report_mt_data(psmouse, count, sgm);
+	synaptics_report_mt_data(psmouse, &mt_state, sgm);
+
+	/* Store updated mt_state */
+	priv->mt_state = agm->mt_state = mt_state;
+	priv->agm_pending = false;
 }
 
 /*
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 20f57df..622aea8 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -161,11 +161,15 @@ struct synaptics_data {
 
 	struct serio *pt_port;			/* Pass-through serio port */
 
+	struct synaptics_mt_state mt_state;	/* Current mt finger state */
+	bool mt_state_lost;			/* mt_state may be incorrect */
+
 	/*
 	 * Last received Advanced Gesture Mode (AGM) packet. An AGM packet
 	 * contains position data for a second contact, at half resolution.
 	 */
 	struct synaptics_hw_state agm;
+	bool agm_pending;			/* new AGM packet received */
 };
 
 void synaptics_module_init(void);
-- 
1.7.3.1


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

* [PATCH 8/9 v4] Input: add BTN_TOOL_QUINTTAP for reporting 5 fingers on touchpad
  2011-08-18 11:27 [PATCH 0/9 v4] Synaptics image sensor support Daniel Kurtz
                   ` (6 preceding siblings ...)
  2011-08-18 11:28 ` [PATCH 7/9 v4] Input: synaptics - process finger (<=3) transitions Daniel Kurtz
@ 2011-08-18 11:28 ` Daniel Kurtz
  2011-08-18 11:28 ` [PATCH 9/9 v4] Input: synaptics - process finger (<=5) transitions Daniel Kurtz
  8 siblings, 0 replies; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-18 11:28 UTC (permalink / raw)
  To: chase.douglas, dmitry.torokhov, rydberg
  Cc: linux-input, linux-kernel, olofj, chris, Daniel Kurtz

"4-finger scroll" is a gesture supported by some applications and
operating systems.

"Resting thumb" is when a clickpad user rests a finger (e.g., a
thumb), in a "click zone" (typically the bottom of the touchpad) in
anticipation of click+move=select gestures.

Thus, "4-finger scroll + resting thumb" is a 5-finger gesture.
To allow userspace to detect this gesture, we send BTN_TOOL_QUINTTAP.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
---
 drivers/input/input-mt.c |    1 +
 include/linux/input.h    |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index c48c81f..9150ee7 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -117,6 +117,7 @@ void input_mt_report_finger_count(struct input_dev *dev, int count)
 	input_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, count == 2);
 	input_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, count == 3);
 	input_event(dev, EV_KEY, BTN_TOOL_QUADTAP, count == 4);
+	input_event(dev, EV_KEY, BTN_TOOL_QUINTTAP, count == 5);
 }
 EXPORT_SYMBOL(input_mt_report_finger_count);
 
diff --git a/include/linux/input.h b/include/linux/input.h
index 068784e..4de4b46 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -503,6 +503,7 @@ struct input_keymap_entry {
 #define BTN_TOOL_FINGER		0x145
 #define BTN_TOOL_MOUSE		0x146
 #define BTN_TOOL_LENS		0x147
+#define BTN_TOOL_QUINTTAP	0x148	/* Five fingers on trackpad */
 #define BTN_TOUCH		0x14a
 #define BTN_STYLUS		0x14b
 #define BTN_STYLUS2		0x14c
-- 
1.7.3.1


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

* [PATCH 9/9 v4] Input: synaptics - process finger (<=5) transitions
  2011-08-18 11:27 [PATCH 0/9 v4] Synaptics image sensor support Daniel Kurtz
                   ` (7 preceding siblings ...)
  2011-08-18 11:28 ` [PATCH 8/9 v4] Input: add BTN_TOOL_QUINTTAP for reporting 5 fingers on touchpad Daniel Kurtz
@ 2011-08-18 11:28 ` Daniel Kurtz
  8 siblings, 0 replies; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-18 11:28 UTC (permalink / raw)
  To: chase.douglas, dmitry.torokhov, rydberg
  Cc: linux-input, linux-kernel, olofj, chris, Daniel Kurtz

Synaptics image sensor touchpads track up to 5 fingers, but only report 2.
They use a special "TYPE=2" (AGM-CONTACT) packet type that reports
the number of tracked fingers and which finger is reported in the SGM
and AGM packets.

With this new packet type, it is possible to tell userspace when 4 or 5
fingers are touching.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
---
 drivers/input/mouse/synaptics.c |   45 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 3840cc7..4e9bc4a 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -739,6 +739,10 @@ static void synaptics_image_sensor_1f(struct synaptics_data *priv,
 		synaptics_mt_state_set(mt_state, 1, -1, -1);
 		priv->mt_state_lost = true;
 		break;
+	case 4:
+	case 5:
+		/* mt_state was updated by AGM-CONTACT packet */
+		break;
 	}
 }
 
@@ -793,6 +797,10 @@ static void synaptics_image_sensor_2f(struct synaptics_data *priv,
 		synaptics_mt_state_set(mt_state, 2, -1, -1);
 		priv->mt_state_lost = true;
 		break;
+	case 4:
+	case 5:
+		/* mt_state was updated by AGM-CONTACT packet */
+		break;
 	}
 }
 
@@ -821,6 +829,22 @@ static void synaptics_image_sensor_3f(struct synaptics_data *priv,
 		break;
 	case 2:
 		/*
+		 * If the AGM previously contained slot 3 or higher, then the
+		 * newly touching finger is in the lowest available slot.
+		 *
+		 * If SGM was previously 1 or higher, then the new SGM is
+		 * now slot 0 (with a new finger), otherwise, the new finger
+		 * is now in a hidden slot between 0 and AGM's slot.
+		 *
+		 * In all such cases, the SGM now contains slot 0, and the AGM
+		 * continues to contain the same slot as before.
+		 */
+		if (old->agm >= 3) {
+			synaptics_mt_state_set(mt_state, 3, 0, old->agm);
+			break;
+		}
+
+		/*
 		 * After some 3->1 and all 3->2 transitions, we lose track
 		 * of which slot is reported by SGM and AGM.
 		 *
@@ -860,9 +884,22 @@ static void synaptics_image_sensor_3f(struct synaptics_data *priv,
 		 * received AGM-CONTACT packet.
 		 */
 		break;
+
+	case 4:
+	case 5:
+		/* mt_state was updated by AGM-CONTACT packet */
+		break;
 	}
 }
 
+/* Handle case where mt_state->count = 4, or = 5 */
+static void synaptics_image_sensor_45f(struct synaptics_data *priv,
+				       struct synaptics_mt_state *mt_state)
+{
+	/* mt_state was updated correctly by AGM-CONTACT packet */
+	priv->mt_state_lost = false;
+}
+
 static void synaptics_image_sensor_process(struct psmouse *psmouse,
 					   struct synaptics_hw_state *sgm)
 {
@@ -882,8 +919,10 @@ static void synaptics_image_sensor_process(struct psmouse *psmouse,
 		synaptics_image_sensor_1f(priv, &mt_state);
 	else if (sgm->w == 0)
 		synaptics_image_sensor_2f(priv, &mt_state);
-	else if (sgm->w == 1)
+	else if (sgm->w == 1 && mt_state.count <= 3)
 		synaptics_image_sensor_3f(priv, &mt_state);
+	else
+		synaptics_image_sensor_45f(priv, &mt_state);
 
 	/* Send resulting input events to user space */
 	synaptics_report_mt_data(psmouse, &mt_state, sgm);
@@ -1100,6 +1139,10 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
 					ABS_MT_POSITION_Y);
 		/* Image sensors can report per-contact pressure */
 		input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0);
+
+		/* Image sensors can signal 4 and 5 finger clicks */
+		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
+		__set_bit(BTN_TOOL_QUINTTAP, dev->keybit);
 	} else if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) {
 		/* Non-image sensors with AGM use semi-mt */
 		__set_bit(INPUT_PROP_SEMI_MT, dev->propbit);
-- 
1.7.3.1


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

* Re: [PATCH 4/9 v4] Input: synaptics - add image sensor support
  2011-08-18 11:28 ` [PATCH 4/9 v4] Input: synaptics - add image sensor support Daniel Kurtz
@ 2011-08-18 16:00   ` Chase Douglas
  2011-08-19 22:22   ` Dmitry Torokhov
  1 sibling, 0 replies; 18+ messages in thread
From: Chase Douglas @ 2011-08-18 16:00 UTC (permalink / raw)
  To: Daniel Kurtz
  Cc: dmitry.torokhov, rydberg, linux-input, linux-kernel, olofj, chris

On 08/18/2011 04:28 AM, Daniel Kurtz wrote:
> Synaptics makes (at least) two kinds of touchpad sensors:
>  * Older pads use a profile sensor that could only infer the location
>    of individual fingers based on the projection of their profiles
>    onto row and column sensors.
>  * Newer pads use an image sensor that can track true finger position
>    using a two-dimensional sensor grid.
> 
> Both sensor types support an "Advanced Gesture Mode":
>  When multiple fingers are detected, the touchpad sends alternating
>  "Advanced Gesture Mode" (AGM) and "Simple Gesture Mode" (SGM)
>  packets.
>  The AGM packets have w=2, and contain reduced resolution finger data
>  The SGM packets have w={0,1} and contain full resolution finger data
> 
> Profile sensors try to report the "upper" (larger y value) finger in
> the SGM packet, and the lower (smaller y value) in the AGM packet.
> However, due to the nature of the profile sensor, they easily get
> confused when fingers cross, and can start reporting the x-coordinate
> of one with the y-coordinate of the other.  Thus, for profile
> sensors, "semi-mt" was created, which reports a "bounding box"
> created by pairing min and max coordinates of the two pairs of
> reported fingers.
> 
> Image sensors can report the actual coordinates of two of the fingers
> present.  This patch detects if the touchpad is an image sensor and
> reports finger data using the MT-B protocol.
> 
> NOTE: This patch only adds partial support for 2-finger gestures.
>       The proper interpretation of the slot contents when more than
>       two fingers are present is left to later patches.  Also,
>       handling of 'number of fingers' transitions is incomplete.
> 
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>

Acked-by: Chase Douglas <chase.douglas@canonical.com>

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

* Re: [PATCH 6/9 v4] Input: mt - document devices reporting more touches than slots
  2011-08-18 11:28 ` [PATCH 6/9 v4] Input: mt - document devices reporting more touches than slots Daniel Kurtz
@ 2011-08-18 16:01   ` Chase Douglas
  0 siblings, 0 replies; 18+ messages in thread
From: Chase Douglas @ 2011-08-18 16:01 UTC (permalink / raw)
  To: Daniel Kurtz
  Cc: dmitry.torokhov, rydberg, linux-input, linux-kernel, olofj, chris

On 08/18/2011 04:28 AM, Daniel Kurtz wrote:
> Some devices are capable of identifying and/or tracking more contacts than
> they can report to the driver.  Document how a driver should handle this,
> and what userspace should expect.
> 
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
> ---
>  Documentation/input/multi-touch-protocol.txt |   14 ++++++++++++++
>  1 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/input/multi-touch-protocol.txt b/Documentation/input/multi-touch-protocol.txt
> index 71536e7..543101c 100644
> --- a/Documentation/input/multi-touch-protocol.txt
> +++ b/Documentation/input/multi-touch-protocol.txt
> @@ -65,6 +65,20 @@ the full state of each initiated contact has to reside in the receiving
>  end.  Upon receiving an MT event, one simply updates the appropriate
>  attribute of the current slot.
>  
> +Some devices identify and/or track more contacts than they can report to the
> +driver.  A driver for such a device should associate one type B slot with each
> +contact that is reported by the hardware.  Whenever the identity of the
> +contact associated with a slot changes, the driver should invalidate that
> +slot by changing its ABS_MT_TRACKING_ID.  If the hardware signals that it is
> +tracking more contacts than it is currently reporting, the driver should use
> +a BTN_TOOL_*TAP event to inform userspace of the total number of contacts
> +being tracked by the hardware at that moment.  The driver should do this by
> +explicitly sending the corresponding BTN_TOOL_*TAP event and setting
> +use_count to false when calling input_mt_report_pointer_emulation().
> +The driver should only advertise as many slots as the hardware can report.
> +Userspace can detect that a driver can report more total contacts than slots
> +by noting that the largest supported BTN_TOOL_*TAP event is larger than the
> +total number of type B slots reported in the absinfo for the ABS_MT_SLOT axis.
>  
>  Protocol Example A
>  ------------------

Acked-by: Chase Douglas <chase.douglas@canonical.com>

Thanks a bunch Daniel!

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

* Re: [PATCH 7/9 v4] Input: synaptics - process finger (<=3) transitions
  2011-08-18 11:28 ` [PATCH 7/9 v4] Input: synaptics - process finger (<=3) transitions Daniel Kurtz
@ 2011-08-18 16:02   ` Chase Douglas
  0 siblings, 0 replies; 18+ messages in thread
From: Chase Douglas @ 2011-08-18 16:02 UTC (permalink / raw)
  To: Daniel Kurtz
  Cc: dmitry.torokhov, rydberg, linux-input, linux-kernel, olofj, chris

On 08/18/2011 04:28 AM, Daniel Kurtz wrote:
> Synaptics image sensor touchpads track 5 fingers, but only report 2.
> This patch attempts to deal with some idiosyncrasies of these touchpads:
> 
>  * When there are 3 or more fingers, only two are reported.
>  * The touchpad tracks the 5 fingers in slot[0] through slot[4].
>  * It always reports the lowest and highest valid slots in SGM and AGM
>    packets, respectively.
>  * The number of fingers is only reported in the SGM packet.  However,
>    the number of fingers can change either before or after an AGM
>    packet.
>  * Thus, if an SGM reports a different number of fingers than the last
>    SGM, it is impossible to tell whether the intervening AGM corresponds
>    to the old number of fingers or the new number of fingers.
>  * For example, when going from 2->3 fingers, it is not possible to tell
>    whether tell AGM contains slot[1] (old 2nd finger) or slot[2] (new
>    3rd finger).
>  * When fingers are added one at at time, from 1->2->3, it is possible to
>    track which slots are contained in the SGM and AGM packets:
>      1 finger:  SGM = slot[0], no AGM
>      2 fingers: SGM = slot[0], AGM = slot[1]
>      3 fingers: SGM = slot[0], AGM = slot[2]
>  * It is also possible to track which slot is contained in the SGM when 1
>    of 2 fingers is removed.  This is because the touchpad sends a special
>    (0,0,0) AGM packet whenever all fingers are removed except slot[0]:
>      Last AGM == (0,0,0): SGM contains slot[1]
>      Else: SGM contains slot[0]
>  * However, once there are 3 fingers, if exactly 1 finger is removed, it
>    is impossible to tell which 2 slots are contained in SGM and AGM.
>    The (SGM,AGM) could be (0,1), (0,2), or (1,2). There is no way to know.
>  * Similarly, if two fingers are simultaneously removed (3->1), then it
>    is only possible to know if SGM still contains slot[0].
>  * Since it is not possible to reliably track which slot is being
>    reported, we invalidate the tracking_id every time the number of
>    fingers changes until this ambiguity is resolved when:
>      a) All fingers are removed.
>      b) 4 or 5 fingers are touched, generates an AGM-CONTACT packet.
>      c) All fingers are removed except slot[0].  In this special case, the
>         ambiguity is resolved since by the (0,0,0) AGM packet.
> 
> Behavior of the driver:
> 
> When 2 or more fingers are present on the touchpad, the kernel reports
> up to two MT-B slots containing the position data for two of the fingers
> reported by the touchpad.  If the identity of a finger cannot be tracked
> when the number-of-fingers changes, the corresponding MT-B slot will be
> invalidated (track_id set to -1), and a new track_id will be assigned in
> a subsequent input event report.
> 
> The driver always reports the total number of fingers using one of the
> EV_KEY/BTN_TOOL_*TAP events. This could differ from the number of valid
> MT-B slots for two reasons:
>  a) There are more than 2 fingers on the pad.
>  b) During ambiguous number-of-fingers transitions, the correct track_id
>     for one or both of the slots cannot be determined, so the slots are
>     invalidated.
> 
> Thus, this is a hybrid singletouch/MT-B scheme. Userspace can detect
> this behavior by noting that the driver supports more EV_KEY/BTN_TOOL_*TAP
> events than its maximum EV_ABS/ABS_MT_SLOT.
> 
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>

Acked-by: Chase Douglas <chase.douglas@canonical.com>

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

* Re: [PATCH 4/9 v4] Input: synaptics - add image sensor support
  2011-08-18 11:28 ` [PATCH 4/9 v4] Input: synaptics - add image sensor support Daniel Kurtz
  2011-08-18 16:00   ` Chase Douglas
@ 2011-08-19 22:22   ` Dmitry Torokhov
  2011-08-20  7:07       ` Daniel Kurtz
  1 sibling, 1 reply; 18+ messages in thread
From: Dmitry Torokhov @ 2011-08-19 22:22 UTC (permalink / raw)
  To: Daniel Kurtz
  Cc: chase.douglas, rydberg, linux-input, linux-kernel, olofj, chris

Hi Daniel,

On Thu, Aug 18, 2011 at 07:28:03PM +0800, Daniel Kurtz wrote:
> @@ -558,6 +626,11 @@ static void synaptics_process_packet(struct psmouse *psmouse)
>  	if (synaptics_parse_hw_state(psmouse->packet, priv, &hw))
>  		return;
>  
> +	if (SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) {
> +		synaptics_image_sensor_process(psmouse, &hw);
> +		return;
> +	}
> +

So what about the rest of the SYnaptics processing (wheel, additional
buttons, etc)?  Are we sure that touchpads with image sensors will never
implement them?
 
-- 
Dmitry

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

* Re: [PATCH 4/9 v4] Input: synaptics - add image sensor support
  2011-08-19 22:22   ` Dmitry Torokhov
@ 2011-08-20  7:07       ` Daniel Kurtz
  0 siblings, 0 replies; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-20  7:07 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: chase.douglas, rydberg, linux-input, linux-kernel, olofj, chris

On Sat, Aug 20, 2011 at 6:22 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Daniel,
>
> On Thu, Aug 18, 2011 at 07:28:03PM +0800, Daniel Kurtz wrote:
>> @@ -558,6 +626,11 @@ static void synaptics_process_packet(struct psmouse *psmouse)
>>       if (synaptics_parse_hw_state(psmouse->packet, priv, &hw))
>>               return;
>>
>> +     if (SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) {
>> +             synaptics_image_sensor_process(psmouse, &hw);
>> +             return;
>> +     }
>> +
>
> So what about the rest of the SYnaptics processing (wheel, additional
> buttons, etc)?  Are we sure that touchpads with image sensors will never
> implement them?
>
> --
> Dmitry
>

All image sensors that I am aware of are clickpads, with one button
integrated under the pad, which is reported as the middle button.

We could report right, middle, up, down, and ext_buttons (scroll is
not possible, since w=2;buf[1] is used for x for devices that send agm
packets).
However, I have no way of knowing if this added complexity is
necessary, nor any way of testing it.

-Dan

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

* Re: [PATCH 4/9 v4] Input: synaptics - add image sensor support
@ 2011-08-20  7:07       ` Daniel Kurtz
  0 siblings, 0 replies; 18+ messages in thread
From: Daniel Kurtz @ 2011-08-20  7:07 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: chase.douglas, rydberg, linux-input, linux-kernel, olofj, chris

On Sat, Aug 20, 2011 at 6:22 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Daniel,
>
> On Thu, Aug 18, 2011 at 07:28:03PM +0800, Daniel Kurtz wrote:
>> @@ -558,6 +626,11 @@ static void synaptics_process_packet(struct psmouse *psmouse)
>>       if (synaptics_parse_hw_state(psmouse->packet, priv, &hw))
>>               return;
>>
>> +     if (SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) {
>> +             synaptics_image_sensor_process(psmouse, &hw);
>> +             return;
>> +     }
>> +
>
> So what about the rest of the SYnaptics processing (wheel, additional
> buttons, etc)?  Are we sure that touchpads with image sensors will never
> implement them?
>
> --
> Dmitry
>

All image sensors that I am aware of are clickpads, with one button
integrated under the pad, which is reported as the middle button.

We could report right, middle, up, down, and ext_buttons (scroll is
not possible, since w=2;buf[1] is used for x for devices that send agm
packets).
However, I have no way of knowing if this added complexity is
necessary, nor any way of testing it.

-Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-input" 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] 18+ messages in thread

* Re: [PATCH 4/9 v4] Input: synaptics - add image sensor support
  2011-08-20  7:07       ` Daniel Kurtz
@ 2011-08-22  4:28         ` Dmitry Torokhov
  -1 siblings, 0 replies; 18+ messages in thread
From: Dmitry Torokhov @ 2011-08-22  4:28 UTC (permalink / raw)
  To: Daniel Kurtz
  Cc: chase.douglas, rydberg, linux-input, linux-kernel, olofj, chris

On Sat, Aug 20, 2011 at 03:07:41PM +0800, Daniel Kurtz wrote:
> On Sat, Aug 20, 2011 at 6:22 AM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > Hi Daniel,
> >
> > On Thu, Aug 18, 2011 at 07:28:03PM +0800, Daniel Kurtz wrote:
> >> @@ -558,6 +626,11 @@ static void synaptics_process_packet(struct psmouse *psmouse)
> >>       if (synaptics_parse_hw_state(psmouse->packet, priv, &hw))
> >>               return;
> >>
> >> +     if (SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) {
> >> +             synaptics_image_sensor_process(psmouse, &hw);
> >> +             return;
> >> +     }
> >> +
> >
> > So what about the rest of the SYnaptics processing (wheel, additional
> > buttons, etc)?  Are we sure that touchpads with image sensors will never
> > implement them?
> >
> > --
> > Dmitry
> >
> 
> All image sensors that I am aware of are clickpads, with one button
> integrated under the pad, which is reported as the middle button.
> 
> We could report right, middle, up, down, and ext_buttons (scroll is
> not possible, since w=2;buf[1] is used for x for devices that send agm
> packets).
> However, I have no way of knowing if this added complexity is
> necessary

I would prefer us supporting full protocol so if some vendor does add
additional buttons we have everything in place.

> , nor any way of testing it.

As long as your case still works I think it will be good enough.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 4/9 v4] Input: synaptics - add image sensor support
@ 2011-08-22  4:28         ` Dmitry Torokhov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Torokhov @ 2011-08-22  4:28 UTC (permalink / raw)
  To: Daniel Kurtz
  Cc: chase.douglas, rydberg, linux-input, linux-kernel, olofj, chris

On Sat, Aug 20, 2011 at 03:07:41PM +0800, Daniel Kurtz wrote:
> On Sat, Aug 20, 2011 at 6:22 AM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > Hi Daniel,
> >
> > On Thu, Aug 18, 2011 at 07:28:03PM +0800, Daniel Kurtz wrote:
> >> @@ -558,6 +626,11 @@ static void synaptics_process_packet(struct psmouse *psmouse)
> >>       if (synaptics_parse_hw_state(psmouse->packet, priv, &hw))
> >>               return;
> >>
> >> +     if (SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) {
> >> +             synaptics_image_sensor_process(psmouse, &hw);
> >> +             return;
> >> +     }
> >> +
> >
> > So what about the rest of the SYnaptics processing (wheel, additional
> > buttons, etc)?  Are we sure that touchpads with image sensors will never
> > implement them?
> >
> > --
> > Dmitry
> >
> 
> All image sensors that I am aware of are clickpads, with one button
> integrated under the pad, which is reported as the middle button.
> 
> We could report right, middle, up, down, and ext_buttons (scroll is
> not possible, since w=2;buf[1] is used for x for devices that send agm
> packets).
> However, I have no way of knowing if this added complexity is
> necessary

I would prefer us supporting full protocol so if some vendor does add
additional buttons we have everything in place.

> , nor any way of testing it.

As long as your case still works I think it will be good enough.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" 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] 18+ messages in thread

end of thread, other threads:[~2011-08-22  4:28 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-18 11:27 [PATCH 0/9 v4] Synaptics image sensor support Daniel Kurtz
2011-08-18 11:28 ` [PATCH 1/9 v4] Input: synaptics - refactor y inversion Daniel Kurtz
2011-08-18 11:28 ` [PATCH 2/9 v4] Input: synaptics - refactor agm packet parsing Daniel Kurtz
2011-08-18 11:28 ` [PATCH 3/9 v4] Input: synaptics - refactor initialization of abs position axes Daniel Kurtz
2011-08-18 11:28 ` [PATCH 4/9 v4] Input: synaptics - add image sensor support Daniel Kurtz
2011-08-18 16:00   ` Chase Douglas
2011-08-19 22:22   ` Dmitry Torokhov
2011-08-20  7:07     ` Daniel Kurtz
2011-08-20  7:07       ` Daniel Kurtz
2011-08-22  4:28       ` Dmitry Torokhov
2011-08-22  4:28         ` Dmitry Torokhov
2011-08-18 11:28 ` [PATCH 5/9 v4] Input: synaptics - decode AGM packet types Daniel Kurtz
2011-08-18 11:28 ` [PATCH 6/9 v4] Input: mt - document devices reporting more touches than slots Daniel Kurtz
2011-08-18 16:01   ` Chase Douglas
2011-08-18 11:28 ` [PATCH 7/9 v4] Input: synaptics - process finger (<=3) transitions Daniel Kurtz
2011-08-18 16:02   ` Chase Douglas
2011-08-18 11:28 ` [PATCH 8/9 v4] Input: add BTN_TOOL_QUINTTAP for reporting 5 fingers on touchpad Daniel Kurtz
2011-08-18 11:28 ` [PATCH 9/9 v4] Input: synaptics - process finger (<=5) transitions Daniel Kurtz

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.