11 #include <linux/slab.h>
13 #include <linux/serio.h>
14 #include <linux/module.h>
15 #include <linux/input.h>
18 #include <asm/uaccess.h>
25 static int trackpoint_read(
struct ps2dev *
ps2dev,
unsigned char loc,
unsigned char *results)
35 static int trackpoint_write(
struct ps2dev *ps2dev,
unsigned char loc,
unsigned char val)
47 static int trackpoint_toggle_bit(
struct ps2dev *ps2dev,
unsigned char loc,
unsigned char mask)
50 if (loc < 0x20 || loc >= 0x2F)
83 return sprintf(buf,
"%u\n", value);
105 #define TRACKPOINT_INT_ATTR(_name, _command) \
106 static struct trackpoint_attr_data trackpoint_attr_##_name = { \
107 .field_offset = offsetof(struct trackpoint_data, _name), \
108 .command = _command, \
110 PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \
111 &trackpoint_attr_##_name, \
112 trackpoint_show_int_attr, trackpoint_set_int_attr)
114 static ssize_t trackpoint_set_bit_attr(
struct psmouse *psmouse,
void *data,
115 const char *buf,
size_t count)
119 unsigned char *field = (
unsigned char *)((
char *)tp + attr->
field_offset);
133 if (*field != value) {
142 #define TRACKPOINT_BIT_ATTR(_name, _command, _mask, _inv) \
143 static struct trackpoint_attr_data trackpoint_attr_##_name = { \
144 .field_offset = offsetof(struct trackpoint_data, _name), \
145 .command = _command, \
149 PSMOUSE_DEFINE_ATTR(_name, S_IWUSR | S_IRUGO, \
150 &trackpoint_attr_##_name, \
151 trackpoint_show_int_attr, trackpoint_set_bit_attr)
168 static struct attribute *trackpoint_attrs[] = {
169 &psmouse_attr_sensitivity.dattr.attr,
170 &psmouse_attr_speed.dattr.attr,
171 &psmouse_attr_inertia.dattr.attr,
172 &psmouse_attr_reach.dattr.attr,
173 &psmouse_attr_draghys.dattr.attr,
174 &psmouse_attr_mindrag.dattr.attr,
175 &psmouse_attr_thresh.dattr.attr,
176 &psmouse_attr_upthresh.dattr.attr,
177 &psmouse_attr_ztime.dattr.attr,
178 &psmouse_attr_jenks.dattr.attr,
179 &psmouse_attr_press_to_select.dattr.attr,
180 &psmouse_attr_skipback.dattr.attr,
181 &psmouse_attr_ext_dev.dattr.attr,
186 .attrs = trackpoint_attrs,
189 static int trackpoint_start_protocol(
struct psmouse *psmouse,
unsigned char *firmware_id)
191 unsigned char param[2] = { 0 };
200 *firmware_id = param[1];
205 static int trackpoint_sync(
struct psmouse *psmouse)
274 static void trackpoint_disconnect(
struct psmouse *psmouse)
282 static int trackpoint_reconnect(
struct psmouse *psmouse)
284 if (trackpoint_start_protocol(psmouse,
NULL))
287 if (trackpoint_sync(psmouse))
295 struct ps2dev *ps2dev = &psmouse->
ps2dev;
296 unsigned char firmware_id;
297 unsigned char button_info;
300 if (trackpoint_start_protocol(psmouse, &firmware_id))
307 psmouse_warn(psmouse,
"failed to get extended button data\n");
316 psmouse->
name =
"TrackPoint";
318 psmouse->
reconnect = trackpoint_reconnect;
321 if ((button_info & 0x0f) >= 3)
324 trackpoint_defaults(psmouse->
private);
325 trackpoint_sync(psmouse);
330 "failed to create sysfs attributes, error: %d\n",
338 "IBM TrackPoint firmware: 0x%02x, buttons: %d/%d\n",
340 (button_info & 0xf0) >> 4, button_info & 0x0f);