Use dentry_path() to create full path to inode object
[pohmelfs.git] / drivers / input / mouse / psmouse.h
blob6a417092d010f7afd62f0a95565ad008fb57f6b6
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_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
24 enum psmouse_state {
25 PSMOUSE_IGNORE,
26 PSMOUSE_INITIALIZING,
27 PSMOUSE_RESYNCING,
28 PSMOUSE_CMD_MODE,
29 PSMOUSE_ACTIVATED,
32 /* psmouse protocol handler return codes */
33 typedef enum {
34 PSMOUSE_BAD_DATA,
35 PSMOUSE_GOOD_DATA,
36 PSMOUSE_FULL_PACKET
37 } psmouse_ret_t;
39 struct psmouse {
40 void *private;
41 struct input_dev *dev;
42 struct ps2dev ps2dev;
43 struct delayed_work resync_work;
44 char *vendor;
45 char *name;
46 unsigned char packet[8];
47 unsigned char badbyte;
48 unsigned char pktcnt;
49 unsigned char pktsize;
50 unsigned char type;
51 bool ignore_parity;
52 bool acks_disable_command;
53 unsigned int model;
54 unsigned long last;
55 unsigned long out_of_sync_cnt;
56 unsigned long num_resyncs;
57 enum psmouse_state state;
58 char devname[64];
59 char phys[32];
61 unsigned int rate;
62 unsigned int resolution;
63 unsigned int resetafter;
64 unsigned int resync_time;
65 bool smartscroll; /* Logitech only */
67 psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse);
68 void (*set_rate)(struct psmouse *psmouse, unsigned int rate);
69 void (*set_resolution)(struct psmouse *psmouse, unsigned int resolution);
71 int (*reconnect)(struct psmouse *psmouse);
72 void (*disconnect)(struct psmouse *psmouse);
73 void (*cleanup)(struct psmouse *psmouse);
74 int (*poll)(struct psmouse *psmouse);
76 void (*pt_activate)(struct psmouse *psmouse);
77 void (*pt_deactivate)(struct psmouse *psmouse);
80 enum psmouse_type {
81 PSMOUSE_NONE,
82 PSMOUSE_PS2,
83 PSMOUSE_PS2PP,
84 PSMOUSE_THINKPS,
85 PSMOUSE_GENPS,
86 PSMOUSE_IMPS,
87 PSMOUSE_IMEX,
88 PSMOUSE_SYNAPTICS,
89 PSMOUSE_ALPS,
90 PSMOUSE_LIFEBOOK,
91 PSMOUSE_TRACKPOINT,
92 PSMOUSE_TOUCHKIT_PS2,
93 PSMOUSE_CORTRON,
94 PSMOUSE_HGPK,
95 PSMOUSE_ELANTECH,
96 PSMOUSE_FSP,
97 PSMOUSE_SYNAPTICS_RELATIVE,
98 PSMOUSE_AUTO /* This one should always be last */
101 void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
102 unsigned long delay);
103 int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
104 int psmouse_reset(struct psmouse *psmouse);
105 void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state);
106 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
107 psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse);
109 struct psmouse_attribute {
110 struct device_attribute dattr;
111 void *data;
112 ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf);
113 ssize_t (*set)(struct psmouse *psmouse, void *data,
114 const char *buf, size_t count);
115 bool protect;
117 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
119 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
120 char *buf);
121 ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr,
122 const char *buf, size_t count);
124 #define __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, _set, _protect) \
125 static struct psmouse_attribute psmouse_attr_##_name = { \
126 .dattr = { \
127 .attr = { \
128 .name = __stringify(_name), \
129 .mode = _mode, \
130 }, \
131 .show = psmouse_attr_show_helper, \
132 .store = psmouse_attr_set_helper, \
133 }, \
134 .data = _data, \
135 .show = _show, \
136 .set = _set, \
137 .protect = _protect, \
140 #define __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, _protect) \
141 static ssize_t _show(struct psmouse *, void *, char *); \
142 static ssize_t _set(struct psmouse *, void *, const char *, size_t); \
143 __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, _set, _protect)
145 #define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \
146 __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, true)
148 #define PSMOUSE_DEFINE_RO_ATTR(_name, _mode, _data, _show) \
149 static ssize_t _show(struct psmouse *, void *, char *); \
150 __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, NULL, true)
152 #define PSMOUSE_DEFINE_WO_ATTR(_name, _mode, _data, _set) \
153 static ssize_t _set(struct psmouse *, void *, const char *, size_t); \
154 __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, NULL, _set, true)
156 #ifndef psmouse_fmt
157 #define psmouse_fmt(fmt) KBUILD_BASENAME ": " fmt
158 #endif
160 #define psmouse_dbg(psmouse, format, ...) \
161 dev_dbg(&(psmouse)->ps2dev.serio->dev, \
162 psmouse_fmt(format), ##__VA_ARGS__)
163 #define psmouse_info(psmouse, format, ...) \
164 dev_info(&(psmouse)->ps2dev.serio->dev, \
165 psmouse_fmt(format), ##__VA_ARGS__)
166 #define psmouse_warn(psmouse, format, ...) \
167 dev_warn(&(psmouse)->ps2dev.serio->dev, \
168 psmouse_fmt(format), ##__VA_ARGS__)
169 #define psmouse_err(psmouse, format, ...) \
170 dev_err(&(psmouse)->ps2dev.serio->dev, \
171 psmouse_fmt(format), ##__VA_ARGS__)
172 #define psmouse_notice(psmouse, format, ...) \
173 dev_notice(&(psmouse)->ps2dev.serio->dev, \
174 psmouse_fmt(format), ##__VA_ARGS__)
175 #define psmouse_printk(level, psmouse, format, ...) \
176 dev_printk(level, \
177 &(psmouse)->ps2dev.serio->dev, \
178 psmouse_fmt(format), ##__VA_ARGS__)
181 #endif /* _PSMOUSE_H */