Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _PSMOUSE_H |
| 2 | #define _PSMOUSE_H |
| 3 | |
| 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 |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 10 | #define PSMOUSE_CMD_POLL 0x00eb /* caller sets number of bytes to receive */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
| 17 | |
| 18 | #define PSMOUSE_RET_BAT 0xaa |
| 19 | #define PSMOUSE_RET_ID 0x00 |
| 20 | #define PSMOUSE_RET_ACK 0xfa |
| 21 | #define PSMOUSE_RET_NAK 0xfe |
| 22 | |
| 23 | enum psmouse_state { |
| 24 | PSMOUSE_IGNORE, |
| 25 | PSMOUSE_INITIALIZING, |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 26 | PSMOUSE_RESYNCING, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | PSMOUSE_CMD_MODE, |
| 28 | PSMOUSE_ACTIVATED, |
| 29 | }; |
| 30 | |
| 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; |
| 37 | |
| 38 | struct psmouse { |
| 39 | void *private; |
Dmitry Torokhov | 2e5b636 | 2005-09-15 02:01:44 -0500 | [diff] [blame] | 40 | struct input_dev *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | struct ps2dev ps2dev; |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 42 | struct work_struct resync_work; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | char *vendor; |
| 44 | char *name; |
| 45 | unsigned char packet[8]; |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 46 | unsigned char badbyte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | unsigned char pktcnt; |
| 48 | unsigned char pktsize; |
| 49 | unsigned char type; |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 50 | unsigned char acks_disable_command; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | unsigned int model; |
| 52 | unsigned long last; |
| 53 | unsigned long out_of_sync; |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 54 | unsigned long num_resyncs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | enum psmouse_state state; |
| 56 | char devname[64]; |
| 57 | char phys[32]; |
| 58 | |
| 59 | unsigned int rate; |
| 60 | unsigned int resolution; |
| 61 | unsigned int resetafter; |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 62 | unsigned int resync_time; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | unsigned int smartscroll; /* Logitech only */ |
| 64 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame^] | 65 | psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | void (*set_rate)(struct psmouse *psmouse, unsigned int rate); |
| 67 | void (*set_resolution)(struct psmouse *psmouse, unsigned int resolution); |
| 68 | |
| 69 | int (*reconnect)(struct psmouse *psmouse); |
| 70 | void (*disconnect)(struct psmouse *psmouse); |
Dmitry Torokhov | f0d5c6f4 | 2006-01-14 00:27:37 -0500 | [diff] [blame] | 71 | int (*poll)(struct psmouse *psmouse); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | void (*pt_activate)(struct psmouse *psmouse); |
| 74 | void (*pt_deactivate)(struct psmouse *psmouse); |
| 75 | }; |
| 76 | |
| 77 | enum psmouse_type { |
| 78 | PSMOUSE_NONE, |
| 79 | PSMOUSE_PS2, |
| 80 | PSMOUSE_PS2PP, |
| 81 | PSMOUSE_THINKPS, |
| 82 | PSMOUSE_GENPS, |
| 83 | PSMOUSE_IMPS, |
| 84 | PSMOUSE_IMEX, |
| 85 | PSMOUSE_SYNAPTICS, |
| 86 | PSMOUSE_ALPS, |
Kenan Esau | 02d7f58 | 2005-05-29 02:30:22 -0500 | [diff] [blame] | 87 | PSMOUSE_LIFEBOOK, |
Stephen Evanchik | 541e316 | 2005-08-08 01:26:18 -0500 | [diff] [blame] | 88 | PSMOUSE_TRACKPOINT, |
Dmitry Torokhov | dbf4ccd | 2005-06-01 02:40:01 -0500 | [diff] [blame] | 89 | PSMOUSE_AUTO /* This one should always be last */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); |
| 93 | int psmouse_reset(struct psmouse *psmouse); |
| 94 | void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); |
| 95 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
Dmitry Torokhov | cfe9e88 | 2005-09-04 01:40:20 -0500 | [diff] [blame] | 97 | struct psmouse_attribute { |
| 98 | struct device_attribute dattr; |
| 99 | void *data; |
| 100 | ssize_t (*show)(struct psmouse *psmouse, void *data, char *buf); |
| 101 | ssize_t (*set)(struct psmouse *psmouse, void *data, |
| 102 | const char *buf, size_t count); |
| 103 | }; |
| 104 | #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr) |
| 105 | |
| 106 | ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr, |
| 107 | char *buf); |
| 108 | ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *attr, |
| 109 | const char *buf, size_t count); |
| 110 | |
| 111 | #define PSMOUSE_DEFINE_ATTR(_name, _mode, _data, _show, _set) \ |
| 112 | static ssize_t _show(struct psmouse *, void *data, char *); \ |
| 113 | static ssize_t _set(struct psmouse *, void *data, const char *, size_t); \ |
| 114 | static struct psmouse_attribute psmouse_attr_##_name = { \ |
| 115 | .dattr = { \ |
| 116 | .attr = { \ |
| 117 | .name = __stringify(_name), \ |
| 118 | .mode = _mode, \ |
| 119 | .owner = THIS_MODULE, \ |
| 120 | }, \ |
| 121 | .show = psmouse_attr_show_helper, \ |
| 122 | .store = psmouse_attr_set_helper, \ |
| 123 | }, \ |
| 124 | .data = _data, \ |
| 125 | .show = _show, \ |
| 126 | .set = _set, \ |
| 127 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
| 129 | #endif /* _PSMOUSE_H */ |