diff options
author | Daniel Kurtz <djkurtz@chromium.org> | 2011-08-24 02:00:33 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-08-24 02:08:01 -0400 |
commit | 7afdb842d9fa8cd62c33e76a1efc62c59772216d (patch) | |
tree | e24629a748d6a8f12bf9abecffbdb94295748867 | |
parent | 6de58dd625a7645008c5c450bf97a5793faf58c3 (diff) |
Input: synaptics - refactor agm packet parsing
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>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r-- | drivers/input/mouse/synaptics.c | 19 | ||||
-rw-r--r-- | 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 b0008bcb26fc..34bcc1fc59fd 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) | |||
419 | * Functions to interpret the absolute mode packets | 419 | * Functions to interpret the absolute mode packets |
420 | ****************************************************************************/ | 420 | ****************************************************************************/ |
421 | 421 | ||
422 | static void synaptics_parse_agm(const unsigned char buf[], | ||
423 | struct synaptics_data *priv) | ||
424 | { | ||
425 | struct synaptics_hw_state *agm = &priv->agm; | ||
426 | |||
427 | /* Gesture packet: (x, y, z) at half resolution */ | ||
428 | agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1; | ||
429 | agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1; | ||
430 | agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1; | ||
431 | } | ||
432 | |||
422 | static int synaptics_parse_hw_state(const unsigned char buf[], | 433 | static int synaptics_parse_hw_state(const unsigned char buf[], |
423 | struct synaptics_data *priv, | 434 | struct synaptics_data *priv, |
424 | struct synaptics_hw_state *hw) | 435 | struct synaptics_hw_state *hw) |
@@ -453,10 +464,7 @@ static int synaptics_parse_hw_state(const unsigned char buf[], | |||
453 | } | 464 | } |
454 | 465 | ||
455 | if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) && hw->w == 2) { | 466 | if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) && hw->w == 2) { |
456 | /* Gesture packet: (x, y, z) at half resolution */ | 467 | synaptics_parse_agm(buf, priv); |
457 | priv->mt.x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1; | ||
458 | priv->mt.y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1; | ||
459 | priv->mt.z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1; | ||
460 | return 1; | 468 | return 1; |
461 | } | 469 | } |
462 | 470 | ||
@@ -595,7 +603,8 @@ static void synaptics_process_packet(struct psmouse *psmouse) | |||
595 | } | 603 | } |
596 | 604 | ||
597 | if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) | 605 | if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) |
598 | synaptics_report_semi_mt_data(dev, &hw, &priv->mt, num_fingers); | 606 | synaptics_report_semi_mt_data(dev, &hw, &priv->agm, |
607 | num_fingers); | ||
599 | 608 | ||
600 | /* Post events | 609 | /* Post events |
601 | * BTN_TOUCH has to be first as mousedev relies on it when doing | 610 | * 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 ca040aa80fa7..a9efbf3e3ea1 100644 --- a/drivers/input/mouse/synaptics.h +++ b/drivers/input/mouse/synaptics.h | |||
@@ -146,7 +146,11 @@ struct synaptics_data { | |||
146 | 146 | ||
147 | struct serio *pt_port; /* Pass-through serio port */ | 147 | struct serio *pt_port; /* Pass-through serio port */ |
148 | 148 | ||
149 | struct synaptics_hw_state mt; /* current gesture packet */ | 149 | /* |
150 | * Last received Advanced Gesture Mode (AGM) packet. An AGM packet | ||
151 | * contains position data for a second contact, at half resolution. | ||
152 | */ | ||
153 | struct synaptics_hw_state agm; | ||
150 | }; | 154 | }; |
151 | 155 | ||
152 | void synaptics_module_init(void); | 156 | void synaptics_module_init(void); |