4 #define PSMOUSE_CMD_SETSCALE11 0x00e6
5 #define PSMOUSE_CMD_SETSCALE21 0x00e7
6 #define PSMOUSE_CMD_SETRES 0x10e8
7 #define PSMOUSE_CMD_GETINFO 0x03e9
8 #define PSMOUSE_CMD_SETSTREAM 0x00ea
9 #define PSMOUSE_CMD_SETPOLL 0x00f0
10 #define PSMOUSE_CMD_POLL 0x00eb /* caller sets number of bytes to receive */
11 #define PSMOUSE_CMD_RESET_WRAP 0x00ec
12 #define PSMOUSE_CMD_GETID 0x02f2
13 #define PSMOUSE_CMD_SETRATE 0x10f3
14 #define PSMOUSE_CMD_ENABLE 0x00f4
15 #define PSMOUSE_CMD_DISABLE 0x00f5
16 #define PSMOUSE_CMD_RESET_DIS 0x00f6
17 #define PSMOUSE_CMD_RESET_BAT 0x02ff
19 #define PSMOUSE_RET_BAT 0xaa
20 #define PSMOUSE_RET_ID 0x00
21 #define PSMOUSE_RET_ACK 0xfa
22 #define PSMOUSE_RET_NAK 0xfe
32 /* psmouse protocol handler return codes */
46 struct input_dev *dev;
48 struct delayed_work resync_work;
51 unsigned char packet[8];
52 unsigned char badbyte;
54 unsigned char pktsize;
57 bool acks_disable_command;
60 unsigned long out_of_sync_cnt;
61 unsigned long num_resyncs;
62 enum psmouse_state state;
67 unsigned int resolution;
68 unsigned int resetafter;
69 unsigned int resync_time;
70 bool smartscroll; /* Logitech only */
72 psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse);
73 void (*set_rate)(struct psmouse *psmouse, unsigned int rate);
74 void (*set_resolution)(struct psmouse *psmouse, unsigned int resolution);
75 void (*set_scale)(struct psmouse *psmouse, enum psmouse_scale scale);
77 int (*reconnect)(struct psmouse *psmouse);
78 void (*disconnect)(struct psmouse *psmouse);
79 void (*cleanup)(struct psmouse *psmouse);
80 int (*poll)(struct psmouse *psmouse);
82 void (*pt_activate)(struct psmouse *psmouse);
83 void (*pt_deactivate)(struct psmouse *psmouse);
103 PSMOUSE_SYNAPTICS_RELATIVE,
106 PSMOUSE_AUTO /* This one should always be last */
109 void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
110 unsigned long delay);
111 int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
112 int psmouse_reset(struct psmouse *psmouse);
113 void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state);
114 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
115 psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse);
116 int psmouse_activate(struct psmouse *psmouse);
117 int psmouse_deactivate(struct psmouse *psmouse);
118 bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[]);
120 struct psmouse_attribute {
121 struct device_attribute dattr;
123 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf);
124 ssize_t (*set)(struct psmouse *psmouse, void *data,
125 const char *buf, size_t count);
128 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
130 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
132 ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr,
133 const char *buf, size_t count);
135 #define __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, _set, _protect) \
136 static struct psmouse_attribute psmouse_attr_##_name = { \
139 .name = __stringify(_name), \
142 .show = psmouse_attr_show_helper, \
143 .store = psmouse_attr_set_helper, \
148 .protect = _protect, \
151 #define __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, _protect) \
152 static ssize_t _show(struct psmouse *, void *, char *); \
153 static ssize_t _set(struct psmouse *, void *, const char *, size_t); \
154 __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, _set, _protect)
156 #define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \
157 __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, true)
159 #define PSMOUSE_DEFINE_RO_ATTR(_name, _mode, _data, _show) \
160 static ssize_t _show(struct psmouse *, void *, char *); \
161 __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, NULL, true)
163 #define PSMOUSE_DEFINE_WO_ATTR(_name, _mode, _data, _set) \
164 static ssize_t _set(struct psmouse *, void *, const char *, size_t); \
165 __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, NULL, _set, true)
168 #define psmouse_fmt(fmt) KBUILD_BASENAME ": " fmt
171 #define psmouse_dbg(psmouse, format, ...) \
172 dev_dbg(&(psmouse)->ps2dev.serio->dev, \
173 psmouse_fmt(format), ##__VA_ARGS__)
174 #define psmouse_info(psmouse, format, ...) \
175 dev_info(&(psmouse)->ps2dev.serio->dev, \
176 psmouse_fmt(format), ##__VA_ARGS__)
177 #define psmouse_warn(psmouse, format, ...) \
178 dev_warn(&(psmouse)->ps2dev.serio->dev, \
179 psmouse_fmt(format), ##__VA_ARGS__)
180 #define psmouse_err(psmouse, format, ...) \
181 dev_err(&(psmouse)->ps2dev.serio->dev, \
182 psmouse_fmt(format), ##__VA_ARGS__)
183 #define psmouse_notice(psmouse, format, ...) \
184 dev_notice(&(psmouse)->ps2dev.serio->dev, \
185 psmouse_fmt(format), ##__VA_ARGS__)
186 #define psmouse_printk(level, psmouse, format, ...) \
188 &(psmouse)->ps2dev.serio->dev, \
189 psmouse_fmt(format), ##__VA_ARGS__)
192 #endif /* _PSMOUSE_H */