aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPing Cheng <pingc@wacom.com>2008-05-05 11:36:41 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2008-05-16 14:49:32 -0400
commite34b9d2f46590e3be64466b4095118283745d050 (patch)
tree61f97d0a507e1e301af5b06e06327d29f1592240
parentea3e6c59266b783b103c0f42a8de5dbe565a43d4 (diff)
Input: wacom - cleanup handling of tablet IDs
Signed-off-by: Ping Cheng <pingc@wacom.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/tablet/wacom_wac.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 192513e1f04c..bf3d9a8b2c1b 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -56,7 +56,7 @@ static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
56static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo) 56static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
57{ 57{
58 unsigned char *data = wacom->data; 58 unsigned char *data = wacom->data;
59 int prox, id, pressure; 59 int prox, pressure;
60 60
61 if (data[0] != 2) { 61 if (data[0] != 2) {
62 dbg("wacom_pl_irq: received unknown report #%d", data[0]); 62 dbg("wacom_pl_irq: received unknown report #%d", data[0]);
@@ -65,7 +65,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
65 65
66 prox = data[1] & 0x40; 66 prox = data[1] & 0x40;
67 67
68 id = ERASER_DEVICE_ID; 68 wacom->id[0] = ERASER_DEVICE_ID;
69 if (prox) { 69 if (prox) {
70 70
71 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); 71 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
@@ -99,10 +99,10 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
99 if (wacom->tool[1] != BTN_TOOL_RUBBER) { 99 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
100 /* Unknown tool selected default to pen tool */ 100 /* Unknown tool selected default to pen tool */
101 wacom->tool[1] = BTN_TOOL_PEN; 101 wacom->tool[1] = BTN_TOOL_PEN;
102 id = STYLUS_DEVICE_ID; 102 wacom->id[0] = STYLUS_DEVICE_ID;
103 } 103 }
104 wacom_report_key(wcombo, wacom->tool[1], prox); /* report in proximity for tool */ 104 wacom_report_key(wcombo, wacom->tool[1], prox); /* report in proximity for tool */
105 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */ 105 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
106 wacom_report_abs(wcombo, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); 106 wacom_report_abs(wcombo, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
107 wacom_report_abs(wcombo, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); 107 wacom_report_abs(wcombo, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
108 wacom_report_abs(wcombo, ABS_PRESSURE, pressure); 108 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
@@ -127,7 +127,6 @@ static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
127static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo) 127static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
128{ 128{
129 unsigned char *data = wacom->data; 129 unsigned char *data = wacom->data;
130 int id;
131 130
132 if (data[0] != 2) { 131 if (data[0] != 2) {
133 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]); 132 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
@@ -137,13 +136,13 @@ static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
137 if (data[1] & 0x04) { 136 if (data[1] & 0x04) {
138 wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20); 137 wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20);
139 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08); 138 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08);
140 id = ERASER_DEVICE_ID; 139 wacom->id[0] = ERASER_DEVICE_ID;
141 } else { 140 } else {
142 wacom_report_key(wcombo, BTN_TOOL_PEN, data[1] & 0x20); 141 wacom_report_key(wcombo, BTN_TOOL_PEN, data[1] & 0x20);
143 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01); 142 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
144 id = STYLUS_DEVICE_ID; 143 wacom->id[0] = STYLUS_DEVICE_ID;
145 } 144 }
146 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */ 145 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
147 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2])); 146 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
148 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4])); 147 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
149 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6])); 148 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
@@ -155,27 +154,26 @@ static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
155static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo) 154static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
156{ 155{
157 unsigned char *data = wacom->data; 156 unsigned char *data = wacom->data;
158 int x, y, id, rw; 157 int x, y, rw;
159 158
160 if (data[0] != 2) { 159 if (data[0] != 2) {
161 dbg("wacom_graphire_irq: received unknown report #%d", data[0]); 160 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
162 return 0; 161 return 0;
163 } 162 }
164 163
165 id = STYLUS_DEVICE_ID; 164 if (data[1] & 0x80) {
166 if ((data[1] & 0x80) && ((data[1] & 0x07) || data[2] || data[3] || data[4]
167 || data[5] || data[6] || (data[7] & 0x07))) {
168 /* in prox and not a pad data */ 165 /* in prox and not a pad data */
169 166
170 switch ((data[1] >> 5) & 3) { 167 switch ((data[1] >> 5) & 3) {
171 168
172 case 0: /* Pen */ 169 case 0: /* Pen */
173 wacom->tool[0] = BTN_TOOL_PEN; 170 wacom->tool[0] = BTN_TOOL_PEN;
171 wacom->id[0] = STYLUS_DEVICE_ID;
174 break; 172 break;
175 173
176 case 1: /* Rubber */ 174 case 1: /* Rubber */
177 wacom->tool[0] = BTN_TOOL_RUBBER; 175 wacom->tool[0] = BTN_TOOL_RUBBER;
178 id = ERASER_DEVICE_ID; 176 wacom->id[0] = ERASER_DEVICE_ID;
179 break; 177 break;
180 178
181 case 2: /* Mouse with wheel */ 179 case 2: /* Mouse with wheel */
@@ -190,7 +188,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
190 188
191 case 3: /* Mouse without wheel */ 189 case 3: /* Mouse without wheel */
192 wacom->tool[0] = BTN_TOOL_MOUSE; 190 wacom->tool[0] = BTN_TOOL_MOUSE;
193 id = CURSOR_DEVICE_ID; 191 wacom->id[0] = CURSOR_DEVICE_ID;
194 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01); 192 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
195 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02); 193 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
196 if (wacom->features->type == WACOM_G4 || 194 if (wacom->features->type == WACOM_G4 ||
@@ -210,9 +208,9 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
210 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); 208 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
211 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04); 209 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04);
212 } 210 }
213 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */ 211 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
214 wacom_report_key(wcombo, wacom->tool[0], 1); 212 wacom_report_key(wcombo, wacom->tool[0], 1);
215 } else if (!(data[1] & 0x90)) { 213 } else if (wacom->id[0]) {
216 wacom_report_abs(wcombo, ABS_X, 0); 214 wacom_report_abs(wcombo, ABS_X, 0);
217 wacom_report_abs(wcombo, ABS_Y, 0); 215 wacom_report_abs(wcombo, ABS_Y, 0);
218 if (wacom->tool[0] == BTN_TOOL_MOUSE) { 216 if (wacom->tool[0] == BTN_TOOL_MOUSE) {
@@ -225,6 +223,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
225 wacom_report_key(wcombo, BTN_STYLUS, 0); 223 wacom_report_key(wcombo, BTN_STYLUS, 0);
226 wacom_report_key(wcombo, BTN_STYLUS2, 0); 224 wacom_report_key(wcombo, BTN_STYLUS2, 0);
227 } 225 }
226 wacom->id[0] = 0;
228 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */ 227 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
229 wacom_report_key(wcombo, wacom->tool[0], 0); 228 wacom_report_key(wcombo, wacom->tool[0], 0);
230 } 229 }
@@ -234,13 +233,13 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
234 case WACOM_G4: 233 case WACOM_G4:
235 if (data[7] & 0xf8) { 234 if (data[7] & 0xf8) {
236 wacom_input_sync(wcombo); /* sync last event */ 235 wacom_input_sync(wcombo); /* sync last event */
237 wacom->id[1] = 1; 236 wacom->id[1] = PAD_DEVICE_ID;
238 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40)); 237 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
239 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80)); 238 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
240 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3); 239 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
241 wacom_report_rel(wcombo, REL_WHEEL, rw); 240 wacom_report_rel(wcombo, REL_WHEEL, rw);
242 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0); 241 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
243 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID); 242 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
244 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 243 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
245 } else if (wacom->id[1]) { 244 } else if (wacom->id[1]) {
246 wacom_input_sync(wcombo); /* sync last event */ 245 wacom_input_sync(wcombo); /* sync last event */
@@ -255,14 +254,14 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
255 case WACOM_MO: 254 case WACOM_MO:
256 if ((data[7] & 0xf8) || (data[8] & 0xff)) { 255 if ((data[7] & 0xf8) || (data[8] & 0xff)) {
257 wacom_input_sync(wcombo); /* sync last event */ 256 wacom_input_sync(wcombo); /* sync last event */
258 wacom->id[1] = 1; 257 wacom->id[1] = PAD_DEVICE_ID;
259 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08)); 258 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
260 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20)); 259 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
261 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10)); 260 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
262 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40)); 261 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
263 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f)); 262 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
264 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0); 263 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
265 wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID); 264 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
266 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 265 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
267 } else if (wacom->id[1]) { 266 } else if (wacom->id[1]) {
268 wacom_input_sync(wcombo); /* sync last event */ 267 wacom_input_sync(wcombo); /* sync last event */