Skip to content

Commit

Permalink
CHROMIUM: Input: synaptics - process finger (<=5) transitions
Browse files Browse the repository at this point in the history
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>

Change-Id: I58f39a14e808ba865e5c39dfdf72e7b6da112395
BUG=chromium-os:19094
TEST=builds clean; evtest to confirm raw events
     confirm motion, 2f-tap, 2f-scroll, using xf86-input-cmt
Reviewed-on: http://gerrit.chromium.org/gerrit/4259
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
  • Loading branch information
djkurtz committed Aug 18, 2011
1 parent 3defe34 commit e5c9a6c
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion drivers/input/mouse/synaptics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -820,6 +828,22 @@ static void synaptics_image_sensor_3f(struct synaptics_data *priv,
synaptics_mt_state_set(mt_state, 3, 0, 2);
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.
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e5c9a6c

Please sign in to comment.