Commit | Line | Data |
---|---|---|
2a0bd75e | 1 | /* |
3f8c0df4 | 2 | * Elantech Touchpad driver (v6) |
2a0bd75e | 3 | * |
3f8c0df4 | 4 | * Copyright (C) 2007-2009 Arjan Opmeer <arjan@opmeer.net> |
2a0bd75e AO |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License version 2 as published | |
8 | * by the Free Software Foundation. | |
9 | * | |
10 | * Trademarks are the property of their respective owners. | |
11 | */ | |
12 | ||
13 | #ifndef _ELANTECH_H | |
14 | #define _ELANTECH_H | |
15 | ||
16 | /* | |
17 | * Command values for Synaptics style queries | |
18 | */ | |
28f49616 | 19 | #define ETP_FW_ID_QUERY 0x00 |
2a0bd75e AO |
20 | #define ETP_FW_VERSION_QUERY 0x01 |
21 | #define ETP_CAPABILITIES_QUERY 0x02 | |
84a90b61 | 22 | #define ETP_SAMPLE_QUERY 0x03 |
3d95fd6a | 23 | #define ETP_RESOLUTION_QUERY 0x04 |
2a0bd75e AO |
24 | |
25 | /* | |
26 | * Command values for register reading or writing | |
27 | */ | |
28 | #define ETP_REGISTER_READ 0x10 | |
29 | #define ETP_REGISTER_WRITE 0x11 | |
28f49616 | 30 | #define ETP_REGISTER_READWRITE 0x00 |
2a0bd75e AO |
31 | |
32 | /* | |
33 | * Hardware version 2 custom PS/2 command value | |
34 | */ | |
35 | #define ETP_PS2_CUSTOM_COMMAND 0xf8 | |
36 | ||
37 | /* | |
38 | * Times to retry a ps2_command and millisecond delay between tries | |
39 | */ | |
40 | #define ETP_PS2_COMMAND_TRIES 3 | |
41 | #define ETP_PS2_COMMAND_DELAY 500 | |
42 | ||
43 | /* | |
44 | * Times to try to read back a register and millisecond delay between tries | |
45 | */ | |
46 | #define ETP_READ_BACK_TRIES 5 | |
47 | #define ETP_READ_BACK_DELAY 2000 | |
48 | ||
49 | /* | |
50 | * Register bitmasks for hardware version 1 | |
51 | */ | |
52 | #define ETP_R10_ABSOLUTE_MODE 0x04 | |
53 | #define ETP_R11_4_BYTE_MODE 0x02 | |
54 | ||
55 | /* | |
56 | * Capability bitmasks | |
57 | */ | |
58 | #define ETP_CAP_HAS_ROCKER 0x04 | |
59 | ||
60 | /* | |
61 | * One hard to find application note states that X axis range is 0 to 576 | |
62 | * and Y axis range is 0 to 384 for harware version 1. | |
63 | * Edge fuzz might be necessary because of bezel around the touchpad | |
64 | */ | |
65 | #define ETP_EDGE_FUZZ_V1 32 | |
66 | ||
67 | #define ETP_XMIN_V1 ( 0 + ETP_EDGE_FUZZ_V1) | |
68 | #define ETP_XMAX_V1 (576 - ETP_EDGE_FUZZ_V1) | |
69 | #define ETP_YMIN_V1 ( 0 + ETP_EDGE_FUZZ_V1) | |
70 | #define ETP_YMAX_V1 (384 - ETP_EDGE_FUZZ_V1) | |
71 | ||
72 | /* | |
8a360d09 JD |
73 | * The resolution for older v2 hardware doubled. |
74 | * (newer v2's firmware provides command so we can query) | |
2a0bd75e | 75 | */ |
8a360d09 JD |
76 | #define ETP_XMIN_V2 0 |
77 | #define ETP_XMAX_V2 1152 | |
78 | #define ETP_YMIN_V2 0 | |
79 | #define ETP_YMAX_V2 768 | |
2a0bd75e | 80 | |
f941c705 ÉP |
81 | #define ETP_PMIN_V2 0 |
82 | #define ETP_PMAX_V2 255 | |
83 | #define ETP_WMIN_V2 0 | |
84 | #define ETP_WMAX_V2 15 | |
85 | ||
28f49616 | 86 | /* |
1dc6edec JD |
87 | * v3 hardware has 2 kinds of packet types, |
88 | * v4 hardware has 3. | |
28f49616 JD |
89 | */ |
90 | #define PACKET_UNKNOWN 0x01 | |
91 | #define PACKET_DEBOUNCE 0x02 | |
92 | #define PACKET_V3_HEAD 0x03 | |
93 | #define PACKET_V3_TAIL 0x04 | |
1dc6edec JD |
94 | #define PACKET_V4_HEAD 0x05 |
95 | #define PACKET_V4_MOTION 0x06 | |
96 | #define PACKET_V4_STATUS 0x07 | |
a2418fc4 | 97 | #define PACKET_TRACKPOINT 0x08 |
1dc6edec JD |
98 | |
99 | /* | |
100 | * track up to 5 fingers for v4 hardware | |
101 | */ | |
102 | #define ETP_MAX_FINGERS 5 | |
103 | ||
104 | /* | |
105 | * weight value for v4 hardware | |
106 | */ | |
107 | #define ETP_WEIGHT_VALUE 5 | |
108 | ||
21c48dbd BT |
109 | /* |
110 | * Bus information on 3rd byte of query ETP_RESOLUTION_QUERY(0x04) | |
111 | */ | |
112 | #define ETP_BUS_PS2_ONLY 0 | |
113 | #define ETP_BUS_SMB_ALERT_ONLY 1 | |
114 | #define ETP_BUS_SMB_HST_NTFY_ONLY 2 | |
115 | #define ETP_BUS_PS2_SMB_ALERT 3 | |
116 | #define ETP_BUS_PS2_SMB_HST_NTFY 4 | |
117 | ||
df077237 BT |
118 | /* |
119 | * New ICs are either using SMBus Host Notify or just plain PS2. | |
120 | * | |
121 | * ETP_FW_VERSION_QUERY is: | |
122 | * Byte 1: | |
123 | * - bit 0..3: IC BODY | |
124 | * Byte 2: | |
125 | * - bit 4: HiddenButton | |
126 | * - bit 5: PS2_SMBUS_NOTIFY | |
127 | * - bit 6: PS2CRCCheck | |
128 | */ | |
129 | #define ETP_NEW_IC_SMBUS_HOST_NOTIFY(fw_version) \ | |
130 | ((((fw_version) & 0x0f2000) == 0x0f2000) && \ | |
131 | ((fw_version) & 0x0000ff) > 0) | |
132 | ||
1dc6edec JD |
133 | /* |
134 | * The base position for one finger, v4 hardware | |
135 | */ | |
136 | struct finger_pos { | |
137 | unsigned int x; | |
138 | unsigned int y; | |
139 | }; | |
28f49616 | 140 | |
f0787592 BT |
141 | struct elantech_device_info { |
142 | unsigned char capabilities[3]; | |
143 | unsigned char samples[3]; | |
144 | unsigned char debug; | |
145 | unsigned char hw_version; | |
146 | unsigned int fw_version; | |
80212ed7 BT |
147 | unsigned int x_res; |
148 | unsigned int y_res; | |
21c48dbd | 149 | unsigned int bus; |
f0787592 BT |
150 | bool paritycheck; |
151 | bool jumpy_cursor; | |
152 | bool reports_pressure; | |
153 | bool crc_enabled; | |
154 | bool set_hw_resolution; | |
155 | bool has_trackpoint; | |
156 | int (*send_cmd)(struct psmouse *psmouse, unsigned char c, | |
157 | unsigned char *param); | |
158 | }; | |
159 | ||
2a0bd75e | 160 | struct elantech_data { |
a2418fc4 UDB |
161 | struct input_dev *tp_dev; /* Relative device for trackpoint */ |
162 | char tp_phys[32]; | |
1dc6edec | 163 | unsigned char reg_07; |
2a0bd75e AO |
164 | unsigned char reg_10; |
165 | unsigned char reg_11; | |
166 | unsigned char reg_20; | |
167 | unsigned char reg_21; | |
168 | unsigned char reg_22; | |
169 | unsigned char reg_23; | |
170 | unsigned char reg_24; | |
171 | unsigned char reg_25; | |
172 | unsigned char reg_26; | |
7f29f17b | 173 | unsigned int single_finger_reports; |
230282a7 | 174 | unsigned int y_max; |
1dc6edec JD |
175 | unsigned int width; |
176 | struct finger_pos mt[ETP_MAX_FINGERS]; | |
2a0bd75e | 177 | unsigned char parity[256]; |
f0787592 | 178 | struct elantech_device_info info; |
bd884149 | 179 | void (*original_set_rate)(struct psmouse *psmouse, unsigned int rate); |
2a0bd75e AO |
180 | }; |
181 | ||
182 | #ifdef CONFIG_MOUSE_PS2_ELANTECH | |
b7802c5c | 183 | int elantech_detect(struct psmouse *psmouse, bool set_properties); |
21c48dbd | 184 | int elantech_init_ps2(struct psmouse *psmouse); |
2a0bd75e AO |
185 | int elantech_init(struct psmouse *psmouse); |
186 | #else | |
b7802c5c | 187 | static inline int elantech_detect(struct psmouse *psmouse, bool set_properties) |
2a0bd75e AO |
188 | { |
189 | return -ENOSYS; | |
190 | } | |
191 | static inline int elantech_init(struct psmouse *psmouse) | |
192 | { | |
193 | return -ENOSYS; | |
194 | } | |
21c48dbd BT |
195 | static inline int elantech_init_ps2(struct psmouse *psmouse) |
196 | { | |
197 | return -ENOSYS; | |
198 | } | |
2a0bd75e AO |
199 | #endif /* CONFIG_MOUSE_PS2_ELANTECH */ |
200 | ||
21c48dbd BT |
201 | #if defined(CONFIG_MOUSE_PS2_ELANTECH_SMBUS) |
202 | int elantech_init_smbus(struct psmouse *psmouse); | |
203 | #else | |
204 | static inline int elantech_init_smbus(struct psmouse *psmouse) | |
205 | { | |
206 | return -ENOSYS; | |
207 | } | |
208 | #endif /* CONFIG_MOUSE_PS2_ELANTECH_SMBUS */ | |
209 | ||
2a0bd75e | 210 | #endif |