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