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