Merge branch '3.2-without-smb2' of git://git.samba.org/sfrench/cifs-2.6
[pandora-kernel.git] / drivers / input / mouse / elantech.h
1 /*
2  * Elantech Touchpad driver (v6)
3  *
4  * Copyright (C) 2007-2009 Arjan Opmeer <arjan@opmeer.net>
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  */
19 #define ETP_FW_ID_QUERY                 0x00
20 #define ETP_FW_VERSION_QUERY            0x01
21 #define ETP_CAPABILITIES_QUERY          0x02
22 #define ETP_SAMPLE_QUERY                0x03
23
24 /*
25  * Command values for register reading or writing
26  */
27 #define ETP_REGISTER_READ               0x10
28 #define ETP_REGISTER_WRITE              0x11
29 #define ETP_REGISTER_READWRITE          0x00
30
31 /*
32  * Hardware version 2 custom PS/2 command value
33  */
34 #define ETP_PS2_CUSTOM_COMMAND          0xf8
35
36 /*
37  * Times to retry a ps2_command and millisecond delay between tries
38  */
39 #define ETP_PS2_COMMAND_TRIES           3
40 #define ETP_PS2_COMMAND_DELAY           500
41
42 /*
43  * Times to try to read back a register and millisecond delay between tries
44  */
45 #define ETP_READ_BACK_TRIES             5
46 #define ETP_READ_BACK_DELAY             2000
47
48 /*
49  * Register bitmasks for hardware version 1
50  */
51 #define ETP_R10_ABSOLUTE_MODE           0x04
52 #define ETP_R11_4_BYTE_MODE             0x02
53
54 /*
55  * Capability bitmasks
56  */
57 #define ETP_CAP_HAS_ROCKER              0x04
58
59 /*
60  * One hard to find application note states that X axis range is 0 to 576
61  * and Y axis range is 0 to 384 for harware version 1.
62  * Edge fuzz might be necessary because of bezel around the touchpad
63  */
64 #define ETP_EDGE_FUZZ_V1                32
65
66 #define ETP_XMIN_V1                     (  0 + ETP_EDGE_FUZZ_V1)
67 #define ETP_XMAX_V1                     (576 - ETP_EDGE_FUZZ_V1)
68 #define ETP_YMIN_V1                     (  0 + ETP_EDGE_FUZZ_V1)
69 #define ETP_YMAX_V1                     (384 - ETP_EDGE_FUZZ_V1)
70
71 /*
72  * The resolution for older v2 hardware doubled.
73  * (newer v2's firmware provides command so we can query)
74  */
75 #define ETP_XMIN_V2                     0
76 #define ETP_XMAX_V2                     1152
77 #define ETP_YMIN_V2                     0
78 #define ETP_YMAX_V2                     768
79
80 #define ETP_PMIN_V2                     0
81 #define ETP_PMAX_V2                     255
82 #define ETP_WMIN_V2                     0
83 #define ETP_WMAX_V2                     15
84
85 /*
86  * v3 hardware has 2 kinds of packet types,
87  * v4 hardware has 3.
88  */
89 #define PACKET_UNKNOWN                  0x01
90 #define PACKET_DEBOUNCE                 0x02
91 #define PACKET_V3_HEAD                  0x03
92 #define PACKET_V3_TAIL                  0x04
93 #define PACKET_V4_HEAD                  0x05
94 #define PACKET_V4_MOTION                0x06
95 #define PACKET_V4_STATUS                0x07
96
97 /*
98  * track up to 5 fingers for v4 hardware
99  */
100 #define ETP_MAX_FINGERS                 5
101
102 /*
103  * weight value for v4 hardware
104  */
105 #define ETP_WEIGHT_VALUE                5
106
107 /*
108  * The base position for one finger, v4 hardware
109  */
110 struct finger_pos {
111         unsigned int x;
112         unsigned int y;
113 };
114
115 struct elantech_data {
116         unsigned char reg_07;
117         unsigned char reg_10;
118         unsigned char reg_11;
119         unsigned char reg_20;
120         unsigned char reg_21;
121         unsigned char reg_22;
122         unsigned char reg_23;
123         unsigned char reg_24;
124         unsigned char reg_25;
125         unsigned char reg_26;
126         unsigned char debug;
127         unsigned char capabilities[3];
128         bool paritycheck;
129         bool jumpy_cursor;
130         bool reports_pressure;
131         unsigned char hw_version;
132         unsigned int fw_version;
133         unsigned int single_finger_reports;
134         unsigned int y_max;
135         unsigned int width;
136         struct finger_pos mt[ETP_MAX_FINGERS];
137         unsigned char parity[256];
138 };
139
140 #ifdef CONFIG_MOUSE_PS2_ELANTECH
141 int elantech_detect(struct psmouse *psmouse, bool set_properties);
142 int elantech_init(struct psmouse *psmouse);
143 #else
144 static inline int elantech_detect(struct psmouse *psmouse, bool set_properties)
145 {
146         return -ENOSYS;
147 }
148 static inline int elantech_init(struct psmouse *psmouse)
149 {
150         return -ENOSYS;
151 }
152 #endif /* CONFIG_MOUSE_PS2_ELANTECH */
153
154 #endif