aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/mouse/synaptics.c88
-rw-r--r--drivers/input/mouse/synaptics.h3
2 files changed, 88 insertions, 3 deletions
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 8997cbc69dcc..6514928fd35f 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -25,7 +25,7 @@
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/dmi.h> 27#include <linux/dmi.h>
28#include <linux/input.h> 28#include <linux/input/mt.h>
29#include <linux/serio.h> 29#include <linux/serio.h>
30#include <linux/libps2.h> 30#include <linux/libps2.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
@@ -279,6 +279,25 @@ static void synaptics_set_rate(struct psmouse *psmouse, unsigned int rate)
279 synaptics_mode_cmd(psmouse, priv->mode); 279 synaptics_mode_cmd(psmouse, priv->mode);
280} 280}
281 281
282static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
283{
284 static unsigned char param = 0xc8;
285 struct synaptics_data *priv = psmouse->private;
286
287 if (!SYN_CAP_ADV_GESTURE(priv->ext_cap_0c))
288 return 0;
289
290 if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL))
291 return -1;
292 if (ps2_command(&psmouse->ps2dev, &param, PSMOUSE_CMD_SETRATE))
293 return -1;
294
295 /* Advanced gesture mode also sends multi finger data */
296 priv->capabilities |= BIT(1);
297
298 return 0;
299}
300
282/***************************************************************************** 301/*****************************************************************************
283 * Synaptics pass-through PS/2 port support 302 * Synaptics pass-through PS/2 port support
284 ****************************************************************************/ 303 ****************************************************************************/
@@ -380,7 +399,9 @@ static void synaptics_pt_create(struct psmouse *psmouse)
380 * Functions to interpret the absolute mode packets 399 * Functions to interpret the absolute mode packets
381 ****************************************************************************/ 400 ****************************************************************************/
382 401
383static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data *priv, struct synaptics_hw_state *hw) 402static int synaptics_parse_hw_state(const unsigned char buf[],
403 struct synaptics_data *priv,
404 struct synaptics_hw_state *hw)
384{ 405{
385 memset(hw, 0, sizeof(struct synaptics_hw_state)); 406 memset(hw, 0, sizeof(struct synaptics_hw_state));
386 407
@@ -397,6 +418,14 @@ static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data
397 ((buf[0] & 0x04) >> 1) | 418 ((buf[0] & 0x04) >> 1) |
398 ((buf[3] & 0x04) >> 2)); 419 ((buf[3] & 0x04) >> 2));
399 420
421 if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) && hw->w == 2) {
422 /* Gesture packet: (x, y, z) at half resolution */
423 priv->mt.x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1;
424 priv->mt.y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1;
425 priv->mt.z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 1;
426 return 1;
427 }
428
400 hw->left = (buf[0] & 0x01) ? 1 : 0; 429 hw->left = (buf[0] & 0x01) ? 1 : 0;
401 hw->right = (buf[0] & 0x02) ? 1 : 0; 430 hw->right = (buf[0] & 0x02) ? 1 : 0;
402 431
@@ -452,6 +481,36 @@ static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data
452 hw->left = (buf[0] & 0x01) ? 1 : 0; 481 hw->left = (buf[0] & 0x01) ? 1 : 0;
453 hw->right = (buf[0] & 0x02) ? 1 : 0; 482 hw->right = (buf[0] & 0x02) ? 1 : 0;
454 } 483 }
484
485 return 0;
486}
487
488static void set_slot(struct input_dev *dev, int slot, bool active, int x, int y)
489{
490 input_mt_slot(dev, slot);
491 input_mt_report_slot_state(dev, MT_TOOL_FINGER, active);
492 if (active) {
493 input_report_abs(dev, ABS_MT_POSITION_X, x);
494 input_report_abs(dev, ABS_MT_POSITION_Y,
495 YMAX_NOMINAL + YMIN_NOMINAL - y);
496 }
497}
498
499static void synaptics_report_semi_mt_data(struct input_dev *dev,
500 const struct synaptics_hw_state *a,
501 const struct synaptics_hw_state *b,
502 int num_fingers)
503{
504 if (num_fingers >= 2) {
505 set_slot(dev, 0, true, min(a->x, b->x), min(a->y, b->y));
506 set_slot(dev, 1, true, max(a->x, b->x), max(a->y, b->y));
507 } else if (num_fingers == 1) {
508 set_slot(dev, 0, true, a->x, a->y);
509 set_slot(dev, 1, false, 0, 0);
510 } else {
511 set_slot(dev, 0, false, 0, 0);
512 set_slot(dev, 1, false, 0, 0);
513 }
455} 514}
456 515
457/* 516/*
@@ -466,7 +525,8 @@ static void synaptics_process_packet(struct psmouse *psmouse)
466 int finger_width; 525 int finger_width;
467 int i; 526 int i;
468 527
469 synaptics_parse_hw_state(psmouse->packet, priv, &hw); 528 if (synaptics_parse_hw_state(psmouse->packet, priv, &hw))
529 return;
470 530
471 if (hw.scroll) { 531 if (hw.scroll) {
472 priv->scroll += hw.scroll; 532 priv->scroll += hw.scroll;
@@ -512,6 +572,9 @@ static void synaptics_process_packet(struct psmouse *psmouse)
512 finger_width = 0; 572 finger_width = 0;
513 } 573 }
514 574
575 if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c))
576 synaptics_report_semi_mt_data(dev, &hw, &priv->mt, num_fingers);
577
515 /* Post events 578 /* Post events
516 * BTN_TOUCH has to be first as mousedev relies on it when doing 579 * BTN_TOUCH has to be first as mousedev relies on it when doing
517 * absolute -> relative conversion 580 * absolute -> relative conversion
@@ -631,6 +694,15 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
631 YMIN_NOMINAL, priv->y_max ?: YMAX_NOMINAL, 0, 0); 694 YMIN_NOMINAL, priv->y_max ?: YMAX_NOMINAL, 0, 0);
632 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); 695 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
633 696
697 if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) {
698 __set_bit(INPUT_PROP_SEMI_MT, dev->propbit);
699 input_mt_init_slots(dev, 2);
700 input_set_abs_params(dev, ABS_MT_POSITION_X, XMIN_NOMINAL,
701 priv->x_max ?: XMAX_NOMINAL, 0, 0);
702 input_set_abs_params(dev, ABS_MT_POSITION_Y, YMIN_NOMINAL,
703 priv->y_max ?: YMAX_NOMINAL, 0, 0);
704 }
705
634 if (SYN_CAP_PALMDETECT(priv->capabilities)) 706 if (SYN_CAP_PALMDETECT(priv->capabilities))
635 input_set_abs_params(dev, ABS_TOOL_WIDTH, 0, 15, 0, 0); 707 input_set_abs_params(dev, ABS_TOOL_WIDTH, 0, 15, 0, 0);
636 708
@@ -705,6 +777,11 @@ static int synaptics_reconnect(struct psmouse *psmouse)
705 return -1; 777 return -1;
706 } 778 }
707 779
780 if (synaptics_set_advanced_gesture_mode(psmouse)) {
781 printk(KERN_ERR "Advanced gesture mode reconnect failed.\n");
782 return -1;
783 }
784
708 return 0; 785 return 0;
709} 786}
710 787
@@ -772,6 +849,11 @@ int synaptics_init(struct psmouse *psmouse)
772 goto init_fail; 849 goto init_fail;
773 } 850 }
774 851
852 if (synaptics_set_advanced_gesture_mode(psmouse)) {
853 printk(KERN_ERR "Advanced gesture mode init failed.\n");
854 goto init_fail;
855 }
856
775 priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS; 857 priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
776 858
777 printk(KERN_INFO "Synaptics Touchpad, model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx\n", 859 printk(KERN_INFO "Synaptics Touchpad, model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx\n",
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 613a3652f98f..50e20e9da442 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -53,6 +53,7 @@
53#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16) 53#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16)
54#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100) 54#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100)
55#define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000) 55#define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000)
56#define SYN_CAP_ADV_GESTURE(ex0c) ((ex0c) & 0x080000)
56 57
57/* synaptics modes query bits */ 58/* synaptics modes query bits */
58#define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7)) 59#define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7))
@@ -112,6 +113,8 @@ struct synaptics_data {
112 int scroll; 113 int scroll;
113 114
114 struct serio *pt_port; /* Pass-through serio port */ 115 struct serio *pt_port; /* Pass-through serio port */
116
117 struct synaptics_hw_state mt; /* current gesture packet */
115}; 118};
116 119
117void synaptics_module_init(void); 120void synaptics_module_init(void);