Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * ALPS touchpad PS/2 mouse driver | |
3 | * | |
4 | * Copyright (c) 2003 Peter Osterlund <petero2@telia.com> | |
5 | * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License version 2 as published by | |
9 | * the Free Software Foundation. | |
10 | */ | |
11 | ||
12 | #ifndef _ALPS_H | |
13 | #define _ALPS_H | |
14 | ||
02d04254 HG |
15 | #include <linux/input/mt.h> |
16 | ||
b5d6b851 KC |
17 | #define ALPS_PROTO_V1 1 |
18 | #define ALPS_PROTO_V2 2 | |
19 | #define ALPS_PROTO_V3 3 | |
20 | #define ALPS_PROTO_V4 4 | |
75af9e56 | 21 | #define ALPS_PROTO_V5 5 |
95f75e91 | 22 | #define ALPS_PROTO_V6 6 |
3808843c | 23 | #define ALPS_PROTO_V7 7 /* t3btl t4s */ |
fa629ef5 | 24 | |
02d04254 HG |
25 | #define MAX_TOUCHES 2 |
26 | ||
ee65d4b3 YT |
27 | #define DOLPHIN_COUNT_PER_ELECTRODE 64 |
28 | #define DOLPHIN_PROFILE_XOFFSET 8 /* x-electrode offset */ | |
29 | #define DOLPHIN_PROFILE_YOFFSET 1 /* y-electrode offset */ | |
30 | ||
3808843c YT |
31 | /* |
32 | * enum V7_PACKET_ID - defines the packet type for V7 | |
33 | * V7_PACKET_ID_IDLE: There's no finger and no button activity. | |
34 | * V7_PACKET_ID_TWO: There's one or two non-resting fingers on touchpad | |
35 | * or there's button activities. | |
36 | * V7_PACKET_ID_MULTI: There are at least three non-resting fingers. | |
37 | * V7_PACKET_ID_NEW: The finger position in slot is not continues from | |
38 | * previous packet. | |
39 | */ | |
40 | enum V7_PACKET_ID { | |
41 | V7_PACKET_ID_IDLE, | |
42 | V7_PACKET_ID_TWO, | |
43 | V7_PACKET_ID_MULTI, | |
44 | V7_PACKET_ID_NEW, | |
45 | V7_PACKET_ID_UNKNOWN, | |
46 | }; | |
47 | ||
88a80348 KC |
48 | /** |
49 | * struct alps_model_info - touchpad ID table | |
50 | * @signature: E7 response string to match. | |
51 | * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response | |
52 | * (aka command mode response) identifies the firmware minor version. This | |
53 | * can be used to distinguish different hardware models which are not | |
54 | * uniquely identifiable through their E7 responses. | |
55 | * @proto_version: Indicates V1/V2/V3/... | |
56 | * @byte0: Helps figure out whether a position report packet matches the | |
57 | * known format for this model. The first byte of the report, ANDed with | |
58 | * mask0, should match byte0. | |
59 | * @mask0: The mask used to check the first byte of the report. | |
60 | * @flags: Additional device capabilities (passthrough port, trackstick, etc.). | |
61 | * | |
62 | * Many (but not all) ALPS touchpads can be identified by looking at the | |
63 | * values returned in the "E7 report" and/or the "EC report." This table | |
64 | * lists a number of such touchpads. | |
65 | */ | |
1da177e4 | 66 | struct alps_model_info { |
88a80348 KC |
67 | unsigned char signature[3]; |
68 | unsigned char command_mode_resp; | |
fa629ef5 | 69 | unsigned char proto_version; |
88a80348 | 70 | unsigned char byte0, mask0; |
40e8f53b | 71 | int flags; |
1da177e4 LT |
72 | }; |
73 | ||
88a80348 KC |
74 | /** |
75 | * struct alps_nibble_commands - encodings for register accesses | |
76 | * @command: PS/2 command used for the nibble | |
77 | * @data: Data supplied as an argument to the PS/2 command, if applicable | |
78 | * | |
79 | * The ALPS protocol uses magic sequences to transmit binary data to the | |
80 | * touchpad, as it is generally not OK to send arbitrary bytes out the | |
81 | * PS/2 port. Each of the sequences in this table sends one nibble of the | |
82 | * register address or (write) data. Different versions of the ALPS protocol | |
83 | * use slightly different encodings. | |
84 | */ | |
25bded7c SF |
85 | struct alps_nibble_commands { |
86 | int command; | |
87 | unsigned char data; | |
88 | }; | |
89 | ||
036e6c7b HG |
90 | struct alps_bitmap_point { |
91 | int start_bit; | |
92 | int num_bits; | |
93 | }; | |
94 | ||
f85e5001 KC |
95 | /** |
96 | * struct alps_fields - decoded version of the report packet | |
97 | * @x_map: Bitmap of active X positions for MT. | |
98 | * @y_map: Bitmap of active Y positions for MT. | |
99 | * @fingers: Number of fingers for MT. | |
02d04254 HG |
100 | * @pressure: Pressure. |
101 | * @st: position for ST. | |
102 | * @mt: position for MT. | |
f85e5001 KC |
103 | * @first_mp: Packet is the first of a multi-packet report. |
104 | * @is_mp: Packet is part of a multi-packet report. | |
105 | * @left: Left touchpad button is active. | |
106 | * @right: Right touchpad button is active. | |
107 | * @middle: Middle touchpad button is active. | |
108 | * @ts_left: Left trackstick button is active. | |
109 | * @ts_right: Right trackstick button is active. | |
110 | * @ts_middle: Middle trackstick button is active. | |
111 | */ | |
112 | struct alps_fields { | |
113 | unsigned int x_map; | |
114 | unsigned int y_map; | |
115 | unsigned int fingers; | |
02d04254 HG |
116 | |
117 | int pressure; | |
118 | struct input_mt_pos st; | |
119 | struct input_mt_pos mt[MAX_TOUCHES]; | |
120 | ||
f85e5001 KC |
121 | unsigned int first_mp:1; |
122 | unsigned int is_mp:1; | |
123 | ||
124 | unsigned int left:1; | |
125 | unsigned int right:1; | |
126 | unsigned int middle:1; | |
127 | ||
128 | unsigned int ts_left:1; | |
129 | unsigned int ts_right:1; | |
130 | unsigned int ts_middle:1; | |
131 | }; | |
132 | ||
88a80348 KC |
133 | /** |
134 | * struct alps_data - private data structure for the ALPS driver | |
135 | * @dev2: "Relative" device used to report trackstick or mouse activity. | |
136 | * @phys: Physical path for the relative device. | |
88a80348 KC |
137 | * @nibble_commands: Command mapping used for touchpad register accesses. |
138 | * @addr_command: Command used to tell the touchpad that a register address | |
139 | * follows. | |
99df65e7 KC |
140 | * @proto_version: Indicates V1/V2/V3/... |
141 | * @byte0: Helps figure out whether a position report packet matches the | |
142 | * known format for this model. The first byte of the report, ANDed with | |
143 | * mask0, should match byte0. | |
144 | * @mask0: The mask used to check the first byte of the report. | |
c0cd17f6 | 145 | * @fw_ver: cached copy of firmware version (EC report) |
99df65e7 | 146 | * @flags: Additional device capabilities (passthrough port, trackstick, etc.). |
7a9f73e7 KC |
147 | * @x_max: Largest possible X position value. |
148 | * @y_max: Largest possible Y position value. | |
149 | * @x_bits: Number of X bits in the MT bitmap. | |
150 | * @y_bits: Number of Y bits in the MT bitmap. | |
24af5cb9 KC |
151 | * @hw_init: Protocol-specific hardware init function. |
152 | * @process_packet: Protocol-specific function to process a report packet. | |
f85e5001 | 153 | * @decode_fields: Protocol-specific function to read packet bitfields. |
24af5cb9 | 154 | * @set_abs_params: Protocol-specific function to configure the input_dev. |
88a80348 KC |
155 | * @prev_fin: Finger bit from previous packet. |
156 | * @multi_packet: Multi-packet data in progress. | |
157 | * @multi_data: Saved multi-packet data. | |
02d04254 | 158 | * @f: Decoded packet data fields. |
88a80348 KC |
159 | * @quirks: Bitmap of ALPS_QUIRK_*. |
160 | * @timer: Timer for flushing out the final report packet in the stream. | |
161 | */ | |
1da177e4 | 162 | struct alps_data { |
88a80348 KC |
163 | struct input_dev *dev2; |
164 | char phys[32]; | |
99df65e7 KC |
165 | |
166 | /* these are autodetected when the device is identified */ | |
25bded7c | 167 | const struct alps_nibble_commands *nibble_commands; |
88a80348 | 168 | int addr_command; |
99df65e7 KC |
169 | unsigned char proto_version; |
170 | unsigned char byte0, mask0; | |
c0cd17f6 | 171 | unsigned char fw_ver[3]; |
40e8f53b | 172 | int flags; |
7a9f73e7 KC |
173 | int x_max; |
174 | int y_max; | |
175 | int x_bits; | |
176 | int y_bits; | |
f3f33c67 HG |
177 | unsigned int x_res; |
178 | unsigned int y_res; | |
99df65e7 | 179 | |
24af5cb9 KC |
180 | int (*hw_init)(struct psmouse *psmouse); |
181 | void (*process_packet)(struct psmouse *psmouse); | |
38c11eaa | 182 | int (*decode_fields)(struct alps_fields *f, unsigned char *p, |
ee65d4b3 | 183 | struct psmouse *psmouse); |
24af5cb9 KC |
184 | void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1); |
185 | ||
88a80348 KC |
186 | int prev_fin; |
187 | int multi_packet; | |
188 | unsigned char multi_data[6]; | |
02d04254 | 189 | struct alps_fields f; |
25bded7c | 190 | u8 quirks; |
1d9f2626 | 191 | struct timer_list timer; |
1da177e4 LT |
192 | }; |
193 | ||
25bded7c SF |
194 | #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */ |
195 | ||
55e3d922 | 196 | #ifdef CONFIG_MOUSE_PS2_ALPS |
b7802c5c | 197 | int alps_detect(struct psmouse *psmouse, bool set_properties); |
55e3d922 AS |
198 | int alps_init(struct psmouse *psmouse); |
199 | #else | |
b7802c5c | 200 | inline int alps_detect(struct psmouse *psmouse, bool set_properties) |
55e3d922 AS |
201 | { |
202 | return -ENOSYS; | |
203 | } | |
204 | inline int alps_init(struct psmouse *psmouse) | |
205 | { | |
206 | return -ENOSYS; | |
207 | } | |
208 | #endif /* CONFIG_MOUSE_PS2_ALPS */ | |
209 | ||
1da177e4 | 210 | #endif |