aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/synaptics.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2014-08-30 16:51:06 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-09-09 19:52:28 -0400
commit5715fc764f7753d464dbe094b5ef9cffa6e479a4 (patch)
treeadac88364384f1481ff4c40e3f8203b2350eeda6 /drivers/input/mouse/synaptics.c
parent24e4d21c4252fb6d5a7e75d1e1ee47c2ce38ae99 (diff)
Input: synaptics - add support for ForcePads
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear. Cc: stable@vger.kernel.org Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/mouse/synaptics.c')
-rw-r--r--drivers/input/mouse/synaptics.c68
1 files changed, 52 insertions, 16 deletions
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index e8573c68f77e..fd23181c1fb7 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -629,10 +629,61 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
629 ((buf[0] & 0x04) >> 1) | 629 ((buf[0] & 0x04) >> 1) |
630 ((buf[3] & 0x04) >> 2)); 630 ((buf[3] & 0x04) >> 2));
631 631
632 if ((SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) ||
633 SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) &&
634 hw->w == 2) {
635 synaptics_parse_agm(buf, priv, hw);
636 return 1;
637 }
638
639 hw->x = (((buf[3] & 0x10) << 8) |
640 ((buf[1] & 0x0f) << 8) |
641 buf[4]);
642 hw->y = (((buf[3] & 0x20) << 7) |
643 ((buf[1] & 0xf0) << 4) |
644 buf[5]);
645 hw->z = buf[2];
646
632 hw->left = (buf[0] & 0x01) ? 1 : 0; 647 hw->left = (buf[0] & 0x01) ? 1 : 0;
633 hw->right = (buf[0] & 0x02) ? 1 : 0; 648 hw->right = (buf[0] & 0x02) ? 1 : 0;
634 649
635 if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) { 650 if (SYN_CAP_FORCEPAD(priv->ext_cap_0c)) {
651 /*
652 * ForcePads, like Clickpads, use middle button
653 * bits to report primary button clicks.
654 * Unfortunately they report primary button not
655 * only when user presses on the pad above certain
656 * threshold, but also when there are more than one
657 * finger on the touchpad, which interferes with
658 * out multi-finger gestures.
659 */
660 if (hw->z == 0) {
661 /* No contacts */
662 priv->press = priv->report_press = false;
663 } else if (hw->w >= 4 && ((buf[0] ^ buf[3]) & 0x01)) {
664 /*
665 * Single-finger touch with pressure above
666 * the threshold. If pressure stays long
667 * enough, we'll start reporting primary
668 * button. We rely on the device continuing
669 * sending data even if finger does not
670 * move.
671 */
672 if (!priv->press) {
673 priv->press_start = jiffies;
674 priv->press = true;
675 } else if (time_after(jiffies,
676 priv->press_start +
677 msecs_to_jiffies(50))) {
678 priv->report_press = true;
679 }
680 } else {
681 priv->press = false;
682 }
683
684 hw->left = priv->report_press;
685
686 } else if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
636 /* 687 /*
637 * Clickpad's button is transmitted as middle button, 688 * Clickpad's button is transmitted as middle button,
638 * however, since it is primary button, we will report 689 * however, since it is primary button, we will report
@@ -651,21 +702,6 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
651 hw->down = ((buf[0] ^ buf[3]) & 0x02) ? 1 : 0; 702 hw->down = ((buf[0] ^ buf[3]) & 0x02) ? 1 : 0;
652 } 703 }
653 704
654 if ((SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) ||
655 SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) &&
656 hw->w == 2) {
657 synaptics_parse_agm(buf, priv, hw);
658 return 1;
659 }
660
661 hw->x = (((buf[3] & 0x10) << 8) |
662 ((buf[1] & 0x0f) << 8) |
663 buf[4]);
664 hw->y = (((buf[3] & 0x20) << 7) |
665 ((buf[1] & 0xf0) << 4) |
666 buf[5]);
667 hw->z = buf[2];
668
669 if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) && 705 if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) &&
670 ((buf[0] ^ buf[3]) & 0x02)) { 706 ((buf[0] ^ buf[3]) & 0x02)) {
671 switch (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) { 707 switch (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) & ~0x01) {