]>
Commit | Line | Data |
---|---|---|
541e316a SE |
1 | /* |
2 | * Stephen Evanchik <evanchsa@gmail.com> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License version 2 as published by | |
6 | * the Free Software Foundation. | |
7 | * | |
8 | * Trademarks are the property of their respective owners. | |
9 | */ | |
10 | ||
5a0e3ad6 | 11 | #include <linux/slab.h> |
541e316a SE |
12 | #include <linux/delay.h> |
13 | #include <linux/serio.h> | |
14 | #include <linux/module.h> | |
541e316a SE |
15 | #include <linux/input.h> |
16 | #include <linux/libps2.h> | |
17 | #include <linux/proc_fs.h> | |
7c0f6ba6 | 18 | #include <linux/uaccess.h> |
541e316a SE |
19 | #include "psmouse.h" |
20 | #include "trackpoint.h" | |
21 | ||
203a6033 | 22 | static const char * const trackpoint_variants[] = { |
d7c3f9ff VH |
23 | [TP_VARIANT_IBM] = "IBM", |
24 | [TP_VARIANT_ALPS] = "ALPS", | |
25 | [TP_VARIANT_ELAN] = "Elan", | |
26 | [TP_VARIANT_NXP] = "NXP", | |
27 | [TP_VARIANT_JYT_SYNAPTICS] = "JYT_Synaptics", | |
28 | [TP_VARIANT_SYNAPTICS] = "Synaptics", | |
203a6033 DT |
29 | }; |
30 | ||
0c6a6165 SN |
31 | /* |
32 | * Power-on Reset: Resets all trackpoint parameters, including RAM values, | |
33 | * to defaults. | |
34 | * Returns zero on success, non-zero on failure. | |
35 | */ | |
36 | static int trackpoint_power_on_reset(struct ps2dev *ps2dev) | |
37 | { | |
203a6033 | 38 | u8 results[2]; |
0c6a6165 SN |
39 | int tries = 0; |
40 | ||
41 | /* Issue POR command, and repeat up to once if 0xFC00 received */ | |
42 | do { | |
43 | if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || | |
44 | ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 2, TP_POR))) | |
45 | return -1; | |
46 | } while (results[0] == 0xFC && results[1] == 0x00 && ++tries < 2); | |
47 | ||
48 | /* Check for success response -- 0xAA00 */ | |
49 | if (results[0] != 0xAA || results[1] != 0x00) | |
203a6033 | 50 | return -ENODEV; |
0c6a6165 SN |
51 | |
52 | return 0; | |
53 | } | |
54 | ||
541e316a SE |
55 | /* |
56 | * Device IO: read, write and toggle bit | |
57 | */ | |
203a6033 | 58 | static int trackpoint_read(struct ps2dev *ps2dev, u8 loc, u8 *results) |
541e316a SE |
59 | { |
60 | if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || | |
61 | ps2_command(ps2dev, results, MAKE_PS2_CMD(0, 1, loc))) { | |
62 | return -1; | |
63 | } | |
64 | ||
65 | return 0; | |
66 | } | |
67 | ||
203a6033 | 68 | static int trackpoint_write(struct ps2dev *ps2dev, u8 loc, u8 val) |
541e316a SE |
69 | { |
70 | if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || | |
71 | ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_WRITE_MEM)) || | |
72 | ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc)) || | |
73 | ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, val))) { | |
74 | return -1; | |
75 | } | |
76 | ||
77 | return 0; | |
78 | } | |
79 | ||
203a6033 | 80 | static int trackpoint_toggle_bit(struct ps2dev *ps2dev, u8 loc, u8 mask) |
541e316a SE |
81 | { |
82 | /* Bad things will happen if the loc param isn't in this range */ | |
83 | if (loc < 0x20 || loc >= 0x2F) | |
84 | return -1; | |
85 | ||
86 | if (ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_COMMAND)) || | |
87 | ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, TP_TOGGLE)) || | |
88 | ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, loc)) || | |
89 | ps2_command(ps2dev, NULL, MAKE_PS2_CMD(0, 0, mask))) { | |
90 | return -1; | |
91 | } | |
92 | ||
93 | return 0; | |
94 | } | |
95 | ||
203a6033 DT |
96 | static int trackpoint_update_bit(struct ps2dev *ps2dev, |
97 | u8 loc, u8 mask, u8 value) | |
0c6a6165 SN |
98 | { |
99 | int retval = 0; | |
203a6033 | 100 | u8 data; |
0c6a6165 SN |
101 | |
102 | trackpoint_read(ps2dev, loc, &data); | |
103 | if (((data & mask) == mask) != !!value) | |
104 | retval = trackpoint_toggle_bit(ps2dev, loc, mask); | |
105 | ||
106 | return retval; | |
107 | } | |
541e316a | 108 | |
cfe9e888 DT |
109 | /* |
110 | * Trackpoint-specific attributes | |
111 | */ | |
112 | struct trackpoint_attr_data { | |
113 | size_t field_offset; | |
203a6033 DT |
114 | u8 command; |
115 | u8 mask; | |
116 | bool inverted; | |
117 | u8 power_on_default; | |
cfe9e888 | 118 | }; |
541e316a | 119 | |
203a6033 DT |
120 | static ssize_t trackpoint_show_int_attr(struct psmouse *psmouse, |
121 | void *data, char *buf) | |
cfe9e888 DT |
122 | { |
123 | struct trackpoint_data *tp = psmouse->private; | |
124 | struct trackpoint_attr_data *attr = data; | |
203a6033 | 125 | u8 value = *(u8 *)((void *)tp + attr->field_offset); |
b8044c74 DT |
126 | |
127 | if (attr->inverted) | |
128 | value = !value; | |
541e316a | 129 | |
b8044c74 | 130 | return sprintf(buf, "%u\n", value); |
cfe9e888 | 131 | } |
541e316a | 132 | |
cfe9e888 DT |
133 | static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, |
134 | const char *buf, size_t count) | |
135 | { | |
136 | struct trackpoint_data *tp = psmouse->private; | |
137 | struct trackpoint_attr_data *attr = data; | |
203a6033 DT |
138 | u8 *field = (void *)tp + attr->field_offset; |
139 | u8 value; | |
76496e7a | 140 | int err; |
541e316a | 141 | |
76496e7a JD |
142 | err = kstrtou8(buf, 10, &value); |
143 | if (err) | |
144 | return err; | |
541e316a | 145 | |
cfe9e888 DT |
146 | *field = value; |
147 | trackpoint_write(&psmouse->ps2dev, attr->command, value); | |
541e316a | 148 | |
cfe9e888 DT |
149 | return count; |
150 | } | |
541e316a | 151 | |
0c6a6165 | 152 | #define TRACKPOINT_INT_ATTR(_name, _command, _default) \ |
cfe9e888 DT |
153 | static struct trackpoint_attr_data trackpoint_attr_##_name = { \ |
154 | .field_offset = offsetof(struct trackpoint_data, _name), \ | |
155 | .command = _command, \ | |
0c6a6165 | 156 | .power_on_default = _default, \ |
cfe9e888 DT |
157 | }; \ |
158 | PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ | |
159 | &trackpoint_attr_##_name, \ | |
160 | trackpoint_show_int_attr, trackpoint_set_int_attr) | |
161 | ||
162 | static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, | |
163 | const char *buf, size_t count) | |
164 | { | |
165 | struct trackpoint_data *tp = psmouse->private; | |
166 | struct trackpoint_attr_data *attr = data; | |
203a6033 DT |
167 | bool *field = (void *)tp + attr->field_offset; |
168 | bool value; | |
76496e7a JD |
169 | int err; |
170 | ||
203a6033 | 171 | err = kstrtobool(buf, &value); |
76496e7a JD |
172 | if (err) |
173 | return err; | |
cfe9e888 | 174 | |
b8044c74 DT |
175 | if (attr->inverted) |
176 | value = !value; | |
177 | ||
cfe9e888 DT |
178 | if (*field != value) { |
179 | *field = value; | |
180 | trackpoint_toggle_bit(&psmouse->ps2dev, attr->command, attr->mask); | |
181 | } | |
541e316a | 182 | |
cfe9e888 DT |
183 | return count; |
184 | } | |
541e316a | 185 | |
541e316a | 186 | |
0c6a6165 SN |
187 | #define TRACKPOINT_BIT_ATTR(_name, _command, _mask, _inv, _default) \ |
188 | static struct trackpoint_attr_data trackpoint_attr_##_name = { \ | |
189 | .field_offset = offsetof(struct trackpoint_data, \ | |
190 | _name), \ | |
191 | .command = _command, \ | |
192 | .mask = _mask, \ | |
193 | .inverted = _inv, \ | |
194 | .power_on_default = _default, \ | |
195 | }; \ | |
196 | PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \ | |
197 | &trackpoint_attr_##_name, \ | |
198 | trackpoint_show_int_attr, trackpoint_set_bit_attr) | |
199 | ||
0c6a6165 SN |
200 | TRACKPOINT_INT_ATTR(sensitivity, TP_SENS, TP_DEF_SENS); |
201 | TRACKPOINT_INT_ATTR(speed, TP_SPEED, TP_DEF_SPEED); | |
202 | TRACKPOINT_INT_ATTR(inertia, TP_INERTIA, TP_DEF_INERTIA); | |
203 | TRACKPOINT_INT_ATTR(reach, TP_REACH, TP_DEF_REACH); | |
204 | TRACKPOINT_INT_ATTR(draghys, TP_DRAGHYS, TP_DEF_DRAGHYS); | |
205 | TRACKPOINT_INT_ATTR(mindrag, TP_MINDRAG, TP_DEF_MINDRAG); | |
206 | TRACKPOINT_INT_ATTR(thresh, TP_THRESH, TP_DEF_THRESH); | |
207 | TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH, TP_DEF_UP_THRESH); | |
208 | TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME, TP_DEF_Z_TIME); | |
209 | TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV); | |
2ba35320 | 210 | TRACKPOINT_INT_ATTR(drift_time, TP_DRIFT_TIME, TP_DEF_DRIFT_TIME); |
0c6a6165 | 211 | |
203a6033 | 212 | TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, false, |
0c6a6165 | 213 | TP_DEF_PTSON); |
203a6033 | 214 | TRACKPOINT_BIT_ATTR(skipback, TP_TOGGLE_SKIPBACK, TP_MASK_SKIPBACK, false, |
0c6a6165 | 215 | TP_DEF_SKIPBACK); |
203a6033 | 216 | TRACKPOINT_BIT_ATTR(ext_dev, TP_TOGGLE_EXT_DEV, TP_MASK_EXT_DEV, true, |
0c6a6165 | 217 | TP_DEF_EXT_DEV); |
541e316a | 218 | |
203a6033 DT |
219 | static bool trackpoint_is_attr_available(struct psmouse *psmouse, |
220 | struct attribute *attr) | |
221 | { | |
222 | struct trackpoint_data *tp = psmouse->private; | |
223 | ||
224 | return tp->variant_id == TP_VARIANT_IBM || | |
225 | attr == &psmouse_attr_sensitivity.dattr.attr || | |
226 | attr == &psmouse_attr_press_to_select.dattr.attr; | |
227 | } | |
228 | ||
229 | static umode_t trackpoint_is_attr_visible(struct kobject *kobj, | |
230 | struct attribute *attr, int n) | |
231 | { | |
232 | struct device *dev = container_of(kobj, struct device, kobj); | |
233 | struct serio *serio = to_serio_port(dev); | |
234 | struct psmouse *psmouse = serio_get_drvdata(serio); | |
235 | ||
236 | return trackpoint_is_attr_available(psmouse, attr) ? attr->mode : 0; | |
237 | } | |
238 | ||
541e316a | 239 | static struct attribute *trackpoint_attrs[] = { |
cfe9e888 DT |
240 | &psmouse_attr_sensitivity.dattr.attr, |
241 | &psmouse_attr_speed.dattr.attr, | |
242 | &psmouse_attr_inertia.dattr.attr, | |
243 | &psmouse_attr_reach.dattr.attr, | |
244 | &psmouse_attr_draghys.dattr.attr, | |
245 | &psmouse_attr_mindrag.dattr.attr, | |
246 | &psmouse_attr_thresh.dattr.attr, | |
247 | &psmouse_attr_upthresh.dattr.attr, | |
248 | &psmouse_attr_ztime.dattr.attr, | |
249 | &psmouse_attr_jenks.dattr.attr, | |
2ba35320 | 250 | &psmouse_attr_drift_time.dattr.attr, |
cfe9e888 DT |
251 | &psmouse_attr_press_to_select.dattr.attr, |
252 | &psmouse_attr_skipback.dattr.attr, | |
253 | &psmouse_attr_ext_dev.dattr.attr, | |
541e316a SE |
254 | NULL |
255 | }; | |
256 | ||
257 | static struct attribute_group trackpoint_attr_group = { | |
203a6033 DT |
258 | .is_visible = trackpoint_is_attr_visible, |
259 | .attrs = trackpoint_attrs, | |
541e316a SE |
260 | }; |
261 | ||
203a6033 DT |
262 | #define TRACKPOINT_UPDATE(_power_on, _psmouse, _tp, _name) \ |
263 | do { \ | |
264 | struct trackpoint_attr_data *_attr = &trackpoint_attr_##_name; \ | |
265 | \ | |
266 | if ((!_power_on || _tp->_name != _attr->power_on_default) && \ | |
267 | trackpoint_is_attr_available(_psmouse, \ | |
268 | &psmouse_attr_##_name.dattr.attr)) { \ | |
269 | if (!_attr->mask) \ | |
270 | trackpoint_write(&_psmouse->ps2dev, \ | |
271 | _attr->command, _tp->_name); \ | |
272 | else \ | |
273 | trackpoint_update_bit(&_psmouse->ps2dev, \ | |
274 | _attr->command, _attr->mask, \ | |
275 | _tp->_name); \ | |
276 | } \ | |
277 | } while (0) | |
541e316a | 278 | |
203a6033 DT |
279 | #define TRACKPOINT_SET_POWER_ON_DEFAULT(_tp, _name) \ |
280 | do { \ | |
281 | _tp->_name = trackpoint_attr_##_name.power_on_default; \ | |
282 | } while (0) | |
184dd275 | 283 | |
203a6033 DT |
284 | static int trackpoint_start_protocol(struct psmouse *psmouse, |
285 | u8 *variant_id, u8 *firmware_id) | |
286 | { | |
287 | u8 param[2] = { 0 }; | |
288 | int error; | |
184dd275 | 289 | |
203a6033 DT |
290 | error = ps2_command(&psmouse->ps2dev, |
291 | param, MAKE_PS2_CMD(0, 2, TP_READ_ID)); | |
292 | if (error) | |
293 | return error; | |
294 | ||
295 | switch (param[0]) { | |
296 | case TP_VARIANT_IBM: | |
297 | case TP_VARIANT_ALPS: | |
298 | case TP_VARIANT_ELAN: | |
299 | case TP_VARIANT_NXP: | |
300 | if (variant_id) | |
301 | *variant_id = param[0]; | |
302 | if (firmware_id) | |
303 | *firmware_id = param[1]; | |
304 | return 0; | |
305 | } | |
184dd275 | 306 | |
203a6033 | 307 | return -ENODEV; |
541e316a SE |
308 | } |
309 | ||
0c6a6165 SN |
310 | /* |
311 | * Write parameters to trackpad. | |
312 | * in_power_on_state: Set to true if TP is in default / power-on state (ex. if | |
313 | * power-on reset was run). If so, values will only be | |
314 | * written to TP if they differ from power-on default. | |
315 | */ | |
316 | static int trackpoint_sync(struct psmouse *psmouse, bool in_power_on_state) | |
541e316a | 317 | { |
541e316a | 318 | struct trackpoint_data *tp = psmouse->private; |
541e316a | 319 | |
203a6033 | 320 | if (!in_power_on_state && tp->variant_id == TP_VARIANT_IBM) { |
0c6a6165 SN |
321 | /* |
322 | * Disable features that may make device unusable | |
323 | * with this driver. | |
324 | */ | |
325 | trackpoint_update_bit(&psmouse->ps2dev, TP_TOGGLE_TWOHAND, | |
326 | TP_MASK_TWOHAND, TP_DEF_TWOHAND); | |
541e316a | 327 | |
0c6a6165 SN |
328 | trackpoint_update_bit(&psmouse->ps2dev, TP_TOGGLE_SOURCE_TAG, |
329 | TP_MASK_SOURCE_TAG, TP_DEF_SOURCE_TAG); | |
541e316a | 330 | |
0c6a6165 SN |
331 | trackpoint_update_bit(&psmouse->ps2dev, TP_TOGGLE_MB, |
332 | TP_MASK_MB, TP_DEF_MB); | |
333 | } | |
541e316a | 334 | |
0c6a6165 SN |
335 | /* |
336 | * These properties can be changed in this driver. Only | |
337 | * configure them if the values are non-default or if the TP is in | |
338 | * an unknown state. | |
339 | */ | |
340 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, sensitivity); | |
341 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, inertia); | |
342 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, speed); | |
343 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, reach); | |
344 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, draghys); | |
345 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, mindrag); | |
346 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, thresh); | |
347 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, upthresh); | |
348 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ztime); | |
349 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, jenks); | |
2ba35320 | 350 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, drift_time); |
0c6a6165 SN |
351 | |
352 | /* toggles */ | |
353 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, press_to_select); | |
354 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, skipback); | |
355 | TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ext_dev); | |
541e316a SE |
356 | |
357 | return 0; | |
358 | } | |
359 | ||
360 | static void trackpoint_defaults(struct trackpoint_data *tp) | |
361 | { | |
0c6a6165 SN |
362 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, sensitivity); |
363 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, speed); | |
364 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, reach); | |
365 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, draghys); | |
366 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, mindrag); | |
367 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, thresh); | |
368 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, upthresh); | |
369 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ztime); | |
370 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, jenks); | |
2ba35320 | 371 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, drift_time); |
0c6a6165 SN |
372 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, inertia); |
373 | ||
374 | /* toggles */ | |
375 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, press_to_select); | |
376 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, skipback); | |
377 | TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ext_dev); | |
541e316a SE |
378 | } |
379 | ||
184dd275 DT |
380 | static void trackpoint_disconnect(struct psmouse *psmouse) |
381 | { | |
203a6033 DT |
382 | device_remove_group(&psmouse->ps2dev.serio->dev, |
383 | &trackpoint_attr_group); | |
184dd275 DT |
384 | |
385 | kfree(psmouse->private); | |
386 | psmouse->private = NULL; | |
387 | } | |
388 | ||
389 | static int trackpoint_reconnect(struct psmouse *psmouse) | |
390 | { | |
203a6033 DT |
391 | struct trackpoint_data *tp = psmouse->private; |
392 | int error; | |
393 | bool was_reset; | |
0c6a6165 | 394 | |
203a6033 DT |
395 | error = trackpoint_start_protocol(psmouse, NULL, NULL); |
396 | if (error) | |
397 | return error; | |
184dd275 | 398 | |
203a6033 DT |
399 | was_reset = tp->variant_id == TP_VARIANT_IBM && |
400 | trackpoint_power_on_reset(&psmouse->ps2dev) == 0; | |
401 | ||
402 | error = trackpoint_sync(psmouse, was_reset); | |
403 | if (error) | |
404 | return error; | |
184dd275 DT |
405 | |
406 | return 0; | |
407 | } | |
408 | ||
b7802c5c | 409 | int trackpoint_detect(struct psmouse *psmouse, bool set_properties) |
541e316a | 410 | { |
541e316a | 411 | struct ps2dev *ps2dev = &psmouse->ps2dev; |
203a6033 DT |
412 | struct trackpoint_data *tp; |
413 | u8 variant_id; | |
414 | u8 firmware_id; | |
415 | u8 button_info; | |
8ff22ea7 | 416 | int error; |
541e316a | 417 | |
203a6033 DT |
418 | error = trackpoint_start_protocol(psmouse, &variant_id, &firmware_id); |
419 | if (error) | |
420 | return error; | |
541e316a SE |
421 | |
422 | if (!set_properties) | |
423 | return 0; | |
424 | ||
203a6033 DT |
425 | tp = kzalloc(sizeof(*tp), GFP_KERNEL); |
426 | if (!tp) | |
6792cbbb | 427 | return -ENOMEM; |
541e316a | 428 | |
203a6033 DT |
429 | trackpoint_defaults(tp); |
430 | tp->variant_id = variant_id; | |
431 | tp->firmware_id = firmware_id; | |
432 | ||
433 | psmouse->private = tp; | |
434 | ||
435 | psmouse->vendor = trackpoint_variants[variant_id]; | |
541e316a SE |
436 | psmouse->name = "TrackPoint"; |
437 | ||
184dd275 | 438 | psmouse->reconnect = trackpoint_reconnect; |
541e316a SE |
439 | psmouse->disconnect = trackpoint_disconnect; |
440 | ||
203a6033 DT |
441 | if (variant_id != TP_VARIANT_IBM) { |
442 | /* Newer variants do not support extended button query. */ | |
443 | button_info = 0x33; | |
444 | } else { | |
445 | error = trackpoint_read(ps2dev, TP_EXT_BTN, &button_info); | |
446 | if (error) { | |
447 | psmouse_warn(psmouse, | |
448 | "failed to get extended button data, assuming 3 buttons\n"); | |
449 | button_info = 0x33; | |
450 | } else if (!button_info) { | |
451 | psmouse_warn(psmouse, | |
452 | "got 0 in extended button data, assuming 3 buttons\n"); | |
453 | button_info = 0x33; | |
454 | } | |
455 | } | |
456 | ||
315eb996 | 457 | if ((button_info & 0x0f) >= 3) |
203a6033 | 458 | input_set_capability(psmouse->dev, EV_KEY, BTN_MIDDLE); |
315eb996 | 459 | |
01d4cd5c | 460 | __set_bit(INPUT_PROP_POINTER, psmouse->dev->propbit); |
7611392f HG |
461 | __set_bit(INPUT_PROP_POINTING_STICK, psmouse->dev->propbit); |
462 | ||
203a6033 DT |
463 | if (variant_id != TP_VARIANT_IBM || |
464 | trackpoint_power_on_reset(ps2dev) != 0) { | |
465 | /* | |
466 | * Write defaults to TP if we did not reset the trackpoint. | |
467 | */ | |
0c6a6165 | 468 | trackpoint_sync(psmouse, false); |
203a6033 | 469 | } |
541e316a | 470 | |
203a6033 | 471 | error = device_add_group(&ps2dev->serio->dev, &trackpoint_attr_group); |
8ff22ea7 | 472 | if (error) { |
fb16395e JD |
473 | psmouse_err(psmouse, |
474 | "failed to create sysfs attributes, error: %d\n", | |
475 | error); | |
315eb996 DT |
476 | kfree(psmouse->private); |
477 | psmouse->private = NULL; | |
8ff22ea7 JG |
478 | return -1; |
479 | } | |
541e316a | 480 | |
fb16395e | 481 | psmouse_info(psmouse, |
203a6033 DT |
482 | "%s TrackPoint firmware: 0x%02x, buttons: %d/%d\n", |
483 | psmouse->vendor, firmware_id, | |
fb16395e | 484 | (button_info & 0xf0) >> 4, button_info & 0x0f); |
541e316a SE |
485 | |
486 | return 0; | |
487 | } | |
488 |