Staging: hv: mousevsc: Cleanup and properly implement reportdesc_callback()
[zen-stable.git] / drivers / input / mouse / psmouse.h
blob593e910bfc7a8ebe4c3dce7b30474df274fb3cd9
1 #ifndef _PSMOUSE_H
2 #define _PSMOUSE_H
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_GETID 0x02f2
12 #define PSMOUSE_CMD_SETRATE 0x10f3
13 #define PSMOUSE_CMD_ENABLE 0x00f4
14 #define PSMOUSE_CMD_DISABLE 0x00f5
15 #define PSMOUSE_CMD_RESET_DIS 0x00f6
16 #define PSMOUSE_CMD_RESET_BAT 0x02ff
18 #define PSMOUSE_RET_BAT 0xaa
19 #define PSMOUSE_RET_ID 0x00
20 #define PSMOUSE_RET_ACK 0xfa
21 #define PSMOUSE_RET_NAK 0xfe
23 enum psmouse_state {
24 PSMOUSE_IGNORE,
25 PSMOUSE_INITIALIZING,
26 PSMOUSE_RESYNCING,
27 PSMOUSE_CMD_MODE,
28 PSMOUSE_ACTIVATED,
31 /* psmouse protocol handler return codes */
32 typedef enum {
33 PSMOUSE_BAD_DATA,
34 PSMOUSE_GOOD_DATA,
35 PSMOUSE_FULL_PACKET
36 } psmouse_ret_t;
38 struct psmouse {
39 void *private;
40 struct input_dev *dev;
41 struct ps2dev ps2dev;
42 struct delayed_work resync_work;
43 char *vendor;
44 char *name;
45 unsigned char packet[8];
46 unsigned char badbyte;
47 unsigned char pktcnt;
48 unsigned char pktsize;
49 unsigned char type;
50 bool ignore_parity;
51 bool acks_disable_command;
52 unsigned int model;
53 unsigned long last;
54 unsigned long out_of_sync_cnt;
55 unsigned long num_resyncs;
56 enum psmouse_state state;
57 char devname[64];
58 char phys[32];
60 unsigned int rate;
61 unsigned int resolution;
62 unsigned int resetafter;
63 unsigned int resync_time;
64 bool smartscroll; /* Logitech only */
66 psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse);
67 void (*set_rate)(struct psmouse *psmouse, unsigned int rate);
68 void (*set_resolution)(struct psmouse *psmouse, unsigned int resolution);
70 int (*reconnect)(struct psmouse *psmouse);
71 void (*disconnect)(struct psmouse *psmouse);
72 void (*cleanup)(struct psmouse *psmouse);
73 int (*poll)(struct psmouse *psmouse);
75 void (*pt_activate)(struct psmouse *psmouse);
76 void (*pt_deactivate)(struct psmouse *psmouse);
79 enum psmouse_type {
80 PSMOUSE_NONE,
81 PSMOUSE_PS2,
82 PSMOUSE_PS2PP,
83 PSMOUSE_THINKPS,
84 PSMOUSE_GENPS,
85 PSMOUSE_IMPS,
86 PSMOUSE_IMEX,
87 PSMOUSE_SYNAPTICS,
88 PSMOUSE_ALPS,
89 PSMOUSE_LIFEBOOK,
90 PSMOUSE_TRACKPOINT,
91 PSMOUSE_TOUCHKIT_PS2,
92 PSMOUSE_CORTRON,
93 PSMOUSE_HGPK,
94 PSMOUSE_ELANTECH,
95 PSMOUSE_FSP,
96 PSMOUSE_AUTO /* This one should always be last */
99 void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
100 unsigned long delay);
101 int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
102 int psmouse_reset(struct psmouse *psmouse);
103 void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state);
104 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
106 struct psmouse_attribute {
107 struct device_attribute dattr;
108 void *data;
109 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf);
110 ssize_t (*set)(struct psmouse *psmouse, void *data,
111 const char *buf, size_t count);
112 bool protect;
114 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
116 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
117 char *buf);
118 ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr,
119 const char *buf, size_t count);
121 #define __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, _set, _protect) \
122 static struct psmouse_attribute psmouse_attr_##_name = { \
123 .dattr = { \
124 .attr = { \
125 .name = __stringify(_name), \
126 .mode = _mode, \
127 }, \
128 .show = psmouse_attr_show_helper, \
129 .store = psmouse_attr_set_helper, \
130 }, \
131 .data = _data, \
132 .show = _show, \
133 .set = _set, \
134 .protect = _protect, \
137 #define __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, _protect) \
138 static ssize_t _show(struct psmouse *, void *, char *); \
139 static ssize_t _set(struct psmouse *, void *, const char *, size_t); \
140 __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, _set, _protect)
142 #define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \
143 __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, true)
145 #define PSMOUSE_DEFINE_RO_ATTR(_name, _mode, _data, _show) \
146 static ssize_t _show(struct psmouse *, void *, char *); \
147 __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, NULL, true)
149 #define PSMOUSE_DEFINE_WO_ATTR(_name, _mode, _data, _set) \
150 static ssize_t _set(struct psmouse *, void *, const char *, size_t); \
151 __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, NULL, _set, true)
153 #endif /* _PSMOUSE_H */