Input: psmouse - use boolean type
[linux-2.6.git] / drivers / input / mouse / psmouse.h
index 4848be6..e053bdd 100644 (file)
@@ -7,7 +7,7 @@
 #define PSMOUSE_CMD_GETINFO    0x03e9
 #define PSMOUSE_CMD_SETSTREAM  0x00ea
 #define PSMOUSE_CMD_SETPOLL    0x00f0
-#define PSMOUSE_CMD_POLL       0x03eb
+#define PSMOUSE_CMD_POLL       0x00eb  /* caller sets number of bytes to receive */
 #define PSMOUSE_CMD_GETID      0x02f2
 #define PSMOUSE_CMD_SETRATE    0x10f3
 #define PSMOUSE_CMD_ENABLE     0x00f4
@@ -23,6 +23,7 @@
 enum psmouse_state {
        PSMOUSE_IGNORE,
        PSMOUSE_INITIALIZING,
+       PSMOUSE_RESYNCING,
        PSMOUSE_CMD_MODE,
        PSMOUSE_ACTIVATED,
 };
@@ -36,17 +37,21 @@ typedef enum {
 
 struct psmouse {
        void *private;
-       struct input_dev dev;
+       struct input_dev *dev;
        struct ps2dev ps2dev;
+       struct delayed_work resync_work;
        char *vendor;
        char *name;
        unsigned char packet[8];
+       unsigned char badbyte;
        unsigned char pktcnt;
        unsigned char pktsize;
        unsigned char type;
+       bool acks_disable_command;
        unsigned int model;
        unsigned long last;
-       unsigned long out_of_sync;
+       unsigned long out_of_sync_cnt;
+       unsigned long num_resyncs;
        enum psmouse_state state;
        char devname[64];
        char phys[32];
@@ -54,14 +59,17 @@ struct psmouse {
        unsigned int rate;
        unsigned int resolution;
        unsigned int resetafter;
-       unsigned int smartscroll;       /* Logitech only */
+       unsigned int resync_time;
+       bool smartscroll;       /* Logitech only */
 
-       psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse, struct pt_regs *regs);
+       psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse);
        void (*set_rate)(struct psmouse *psmouse, unsigned int rate);
        void (*set_resolution)(struct psmouse *psmouse, unsigned int resolution);
 
        int (*reconnect)(struct psmouse *psmouse);
        void (*disconnect)(struct psmouse *psmouse);
+       void (*cleanup)(struct psmouse *psmouse);
+       int (*poll)(struct psmouse *psmouse);
 
        void (*pt_activate)(struct psmouse *psmouse);
        void (*pt_deactivate)(struct psmouse *psmouse);
@@ -78,30 +86,67 @@ enum psmouse_type {
        PSMOUSE_SYNAPTICS,
        PSMOUSE_ALPS,
        PSMOUSE_LIFEBOOK,
+       PSMOUSE_TRACKPOINT,
+       PSMOUSE_TOUCHKIT_PS2,
+       PSMOUSE_CORTRON,
+       PSMOUSE_HGPK,
+       PSMOUSE_ELANTECH,
+       PSMOUSE_FSP,
+       PSMOUSE_AUTO            /* This one should always be last */
 };
 
+void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
+               unsigned long delay);
 int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
 int psmouse_reset(struct psmouse *psmouse);
+void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state);
 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
 
-ssize_t psmouse_attr_show_helper(struct device *dev, char *buf,
-                       ssize_t (*handler)(struct psmouse *, char *));
-ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count,
-                       ssize_t (*handler)(struct psmouse *, const char *, size_t));
-
-#define PSMOUSE_DEFINE_ATTR(_name)                                             \
-static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *);            \
-static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\
-static ssize_t psmouse_do_show_##_name(struct device *d, char *b)              \
-{                                                                              \
-       return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name);       \
-}                                                                              \
-static ssize_t psmouse_do_set_##_name(struct device *d, const char *b, size_t s)\
-{                                                                              \
-       return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name);      \
-}                                                                              \
-static struct device_attribute psmouse_attr_##_name =                          \
-       __ATTR(_name, S_IWUSR | S_IRUGO,                                        \
-               psmouse_do_show_##_name, psmouse_do_set_##_name);
+struct psmouse_attribute {
+       struct device_attribute dattr;
+       void *data;
+       ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf);
+       ssize_t (*set)(struct psmouse *psmouse, void *data,
+                       const char *buf, size_t count);
+       bool protect;
+};
+#define to_psmouse_attr(a)     container_of((a), struct psmouse_attribute, dattr)
+
+ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
+                                char *buf);
+ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr,
+                               const char *buf, size_t count);
+
+#define __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, _set, _protect)  \
+static struct psmouse_attribute psmouse_attr_##_name = {                       \
+       .dattr  = {                                                             \
+               .attr   = {                                                     \
+                       .name   = __stringify(_name),                           \
+                       .mode   = _mode,                                        \
+               },                                                              \
+               .show   = psmouse_attr_show_helper,                             \
+               .store  = psmouse_attr_set_helper,                              \
+       },                                                                      \
+       .data   = _data,                                                        \
+       .show   = _show,                                                        \
+       .set    = _set,                                                         \
+       .protect = _protect,                                                    \
+}
+
+#define __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, _protect)      \
+       static ssize_t _show(struct psmouse *, void *, char *);                 \
+       static ssize_t _set(struct psmouse *, void *, const char *, size_t);    \
+       __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, _set, _protect)
+
+#define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set)                  \
+       __PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set, true)
+
+#define PSMOUSE_DEFINE_RO_ATTR(_name, _mode, _data, _show)                     \
+       static ssize_t _show(struct psmouse *, void *, char *);                 \
+       __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, _show, NULL, true)
+
+#define PSMOUSE_DEFINE_WO_ATTR(_name, _mode, _data, _set)                      \
+       static ssize_t _set(struct psmouse *, void *, const char *, size_t);    \
+       __PSMOUSE_DEFINE_ATTR_VAR(_name, _mode, _data, NULL, _set, true)
 
 #endif /* _PSMOUSE_H */