]> code.ossystems Code Review - openembedded-core.git/blob
92bde9f8e552a5f273a7fe739f4113d12001b00d
[openembedded-core.git] /
1 From 5f57d67da87332a9a1ba8fa7a33bf0680e1c76e7 Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Mon, 19 Apr 2010 10:37:21 -0700
4 Subject: [PATCH 1/2] Input: Add support of Synaptics Clickpad device
5 Patch-mainline: 2.6.34
6 Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
7 Git-commit: 5f57d67da87332a9a1ba8fa7a33bf0680e1c76e7
8 References: BMC#99
9
10 The new type of touchpads can be detected via a new query command
11 0x0c. The clickpad flags are in cap[0]:4 and cap[1]:0 bits.
12
13 When the device is detected, the driver now reports only the left
14 button as the supported buttons so that X11 driver can detect that
15 the device is Clickpad. A Clickpad device gives the button events
16 only as the middle button. The kernel driver morphs to the left
17 button. The real handling of Clickpad is done rather in X driver
18 side.
19
20 Signed-off-by: Takashi Iwai <tiwai@suse.de>
21 Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
22 Acked-by: Jian-feng Ding <jian-feng.ding@intel.com>
23 ---
24  drivers/input/mouse/synaptics.c |   35 ++++++++++++++++++++++++++++++-----
25  drivers/input/mouse/synaptics.h |    4 ++++
26  2 files changed, 34 insertions(+), 5 deletions(-)
27
28 diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
29 index d3f5243..9ab9ff0 100644
30 --- a/drivers/input/mouse/synaptics.c
31 +++ b/drivers/input/mouse/synaptics.c
32 @@ -136,7 +136,8 @@ static int synaptics_capability(struct psmouse *psmouse)
33         if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap))
34                 return -1;
35         priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2];
36 -       priv->ext_cap = 0;
37 +       priv->ext_cap = priv->ext_cap_0c = 0;
38 +
39         if (!SYN_CAP_VALID(priv->capabilities))
40                 return -1;
41  
42 @@ -149,7 +150,7 @@ static int synaptics_capability(struct psmouse *psmouse)
43         if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 1) {
44                 if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) {
45                         printk(KERN_ERR "Synaptics claims to have extended capabilities,"
46 -                              " but I'm not able to read them.");
47 +                              " but I'm not able to read them.\n");
48                 } else {
49                         priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2];
50  
51 @@ -161,6 +162,16 @@ static int synaptics_capability(struct psmouse *psmouse)
52                                 priv->ext_cap &= 0xff0fff;
53                 }
54         }
55 +
56 +       if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 4) {
57 +               if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB_0C, cap)) {
58 +                       printk(KERN_ERR "Synaptics claims to have extended capability 0x0c,"
59 +                              " but I'm not able to read it.\n");
60 +               } else {
61 +                       priv->ext_cap_0c = (cap[0] << 16) | (cap[1] << 8) | cap[2];
62 +               }
63 +       }
64 +
65         return 0;
66  }
67  
68 @@ -347,7 +358,15 @@ static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data
69                 hw->left  = (buf[0] & 0x01) ? 1 : 0;
70                 hw->right = (buf[0] & 0x02) ? 1 : 0;
71  
72 -               if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) {
73 +               if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
74 +                       /*
75 +                        * Clickpad's button is transmitted as middle button,
76 +                        * however, since it is primary button, we will report
77 +                        * it as BTN_LEFT.
78 +                        */
79 +                       hw->left = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
80 +
81 +               } else if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) {
82                         hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
83                         if (hw->w == 2)
84                                 hw->scroll = (signed char)(buf[1]);
85 @@ -592,6 +611,12 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
86  
87         dev->absres[ABS_X] = priv->x_res;
88         dev->absres[ABS_Y] = priv->y_res;
89 +
90 +       if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
91 +               /* Clickpads report only left button */
92 +               __clear_bit(BTN_RIGHT, dev->keybit);
93 +               __clear_bit(BTN_MIDDLE, dev->keybit);
94 +       }
95  }
96  
97  static void synaptics_disconnect(struct psmouse *psmouse)
98 @@ -696,10 +721,10 @@ int synaptics_init(struct psmouse *psmouse)
99  
100         priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
101  
102 -       printk(KERN_INFO "Synaptics Touchpad, model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx\n",
103 +       printk(KERN_INFO "Synaptics Touchpad, model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx\n",
104                 SYN_ID_MODEL(priv->identity),
105                 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity),
106 -               priv->model_id, priv->capabilities, priv->ext_cap);
107 +               priv->model_id, priv->capabilities, priv->ext_cap, priv->ext_cap_0c);
108  
109         set_input_params(psmouse->dev, priv);
110  
111 diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
112 index f0f40a3..ae37c5d 100644
113 --- a/drivers/input/mouse/synaptics.h
114 +++ b/drivers/input/mouse/synaptics.h
115 @@ -18,6 +18,7 @@
116  #define SYN_QUE_SERIAL_NUMBER_SUFFIX   0x07
117  #define SYN_QUE_RESOLUTION             0x08
118  #define SYN_QUE_EXT_CAPAB              0x09
119 +#define SYN_QUE_EXT_CAPAB_0C           0x0c
120  
121  /* synatics modes */
122  #define SYN_BIT_ABSOLUTE_MODE          (1 << 7)
123 @@ -48,6 +49,8 @@
124  #define SYN_CAP_VALID(c)               ((((c) & 0x00ff00) >> 8) == 0x47)
125  #define SYN_EXT_CAP_REQUESTS(c)                (((c) & 0x700000) >> 20)
126  #define SYN_CAP_MULTI_BUTTON_NO(ec)    (((ec) & 0x00f000) >> 12)
127 +#define SYN_CAP_PRODUCT_ID(ec)         (((ec) & 0xff0000) >> 16)
128 +#define SYN_CAP_CLICKPAD(ex0c)         ((ex0c) & 0x100100)
129  
130  /* synaptics modes query bits */
131  #define SYN_MODE_ABSOLUTE(m)           ((m) & (1 << 7))
132 @@ -96,6 +99,7 @@ struct synaptics_data {
133         unsigned long int model_id;             /* Model-ID */
134         unsigned long int capabilities;         /* Capabilities */
135         unsigned long int ext_cap;              /* Extended Capabilities */
136 +       unsigned long int ext_cap_0c;           /* Ext Caps from 0x0c query */
137         unsigned long int identity;             /* Identification */
138         int x_res;                              /* X resolution in units/mm */
139         int y_res;                              /* Y resolution in units/mm */
140 -- 
141 1.6.3.3
142