All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Kurtz <djkurtz@chromium.org>
To: chase.douglas@canonical.com, dmitry.torokhov@gmail.com,
	rydberg@euromail.se
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	olofj@chromium.org, chris@cnpbagwell.com,
	Daniel Kurtz <djkurtz@chromium.org>
Subject: [PATCH 8/8 v3] Input: synaptics - process finger (<=5) transitions
Date: Sat, 13 Aug 2011 01:16:47 +0800	[thread overview]
Message-ID: <1313169407-4358-9-git-send-email-djkurtz@chromium.org> (raw)
In-Reply-To: <1313169407-4358-1-git-send-email-djkurtz@chromium.org>

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>
---
 drivers/input/mouse/synaptics.c |   44 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 57104ed..6f71cb7 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -755,6 +755,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;
 	}
 }
 
@@ -809,6 +813,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;
 	}
 }
 
@@ -837,6 +845,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.
 		 *
@@ -876,9 +900,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)
 {
@@ -898,8 +935,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(psmouse, &mt_state, sgm);
@@ -1118,6 +1157,9 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
 		input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0);
 		/* Image sensors can sometimes report per-contact width */
 		input_set_abs_params(dev, ABS_MT_TOUCH_MAJOR, 4, 15, 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


  parent reply	other threads:[~2011-08-12 17:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-12 17:16 [PATCH 0/8 v3] Synaptics image sensor support Daniel Kurtz
2011-08-12 17:16 ` [PATCH 1/8 v3] Input: synaptics - refactor y inversion Daniel Kurtz
2011-08-12 17:16 ` [PATCH 2/8 v3] Input: synaptics - refactor agm packet parsing Daniel Kurtz
2011-08-12 17:16 ` [PATCH 3/8 v3] Input: synaptics - refactor initialization of abs position axes Daniel Kurtz
2011-08-12 17:16 ` [PATCH 4/8 v3] Input: synaptics - add image sensor support Daniel Kurtz
2011-08-12 21:09   ` Henrik Rydberg
2011-08-15  7:17     ` Daniel Kurtz
2011-08-15  7:17       ` Daniel Kurtz
2011-08-17 14:05       ` Daniel Kurtz
2011-08-17 16:32         ` Dmitry Torokhov
2011-08-17 16:32           ` Dmitry Torokhov
2011-08-17 16:47           ` Daniel Kurtz
2011-08-17 16:47             ` Daniel Kurtz
     [not found]           ` <CAGS+omAR1uxS_RA=axmWzwZUgkhZEW+9W8Zk=LHPtALqA990+w@mail.gmail.com>
2011-08-17 17:34             ` Dmitry Torokhov
2011-08-12 17:16 ` [PATCH 5/8 v3] Input: synaptics - decode AGM packet types Daniel Kurtz
2011-08-12 17:16 ` [PATCH 6/8 v3] Input: synaptics - process finger (<=3) transitions Daniel Kurtz
2011-08-12 21:52   ` Henrik Rydberg
2011-08-15  7:46     ` Daniel Kurtz
2011-08-12 17:16 ` [PATCH 7/8 v3] Input: add BTN_TOOL_QUINTTAP for reporting 5 fingers on touchpad Daniel Kurtz
2011-08-12 17:16 ` Daniel Kurtz [this message]
2011-08-16 17:41 ` [PATCH 0/8 v3] Synaptics image sensor support Chase Douglas
2011-08-16 22:20   ` Chase Douglas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1313169407-4358-9-git-send-email-djkurtz@chromium.org \
    --to=djkurtz@chromium.org \
    --cc=chase.douglas@canonical.com \
    --cc=chris@cnpbagwell.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olofj@chromium.org \
    --cc=rydberg@euromail.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.