blob: 236c33cdc708d6ab6cb768fe790ca765682dcfbe [file] [log] [blame]
Arjan Opmeer2a0bd752008-10-16 22:10:19 -04001/*
Arjan Opmeer3f8c0df2009-04-18 19:05:40 -07002 * Elantech Touchpad driver (v6)
Arjan Opmeer2a0bd752008-10-16 22:10:19 -04003 *
Arjan Opmeer3f8c0df2009-04-18 19:05:40 -07004 * Copyright (C) 2007-2009 Arjan Opmeer <arjan@opmeer.net>
Arjan Opmeer2a0bd752008-10-16 22:10:19 -04005 *
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 */
JJ Ding28f49612011-09-09 10:30:31 -070019#define ETP_FW_ID_QUERY 0x00
Arjan Opmeer2a0bd752008-10-16 22:10:19 -040020#define ETP_FW_VERSION_QUERY 0x01
21#define ETP_CAPABILITIES_QUERY 0x02
22
23/*
24 * Command values for register reading or writing
25 */
26#define ETP_REGISTER_READ 0x10
27#define ETP_REGISTER_WRITE 0x11
JJ Ding28f49612011-09-09 10:30:31 -070028#define ETP_REGISTER_READWRITE 0x00
Arjan Opmeer2a0bd752008-10-16 22:10:19 -040029
30/*
31 * Hardware version 2 custom PS/2 command value
32 */
33#define ETP_PS2_CUSTOM_COMMAND 0xf8
34
35/*
36 * Times to retry a ps2_command and millisecond delay between tries
37 */
38#define ETP_PS2_COMMAND_TRIES 3
39#define ETP_PS2_COMMAND_DELAY 500
40
41/*
42 * Times to try to read back a register and millisecond delay between tries
43 */
44#define ETP_READ_BACK_TRIES 5
45#define ETP_READ_BACK_DELAY 2000
46
47/*
48 * Register bitmasks for hardware version 1
49 */
50#define ETP_R10_ABSOLUTE_MODE 0x04
51#define ETP_R11_4_BYTE_MODE 0x02
52
53/*
54 * Capability bitmasks
55 */
56#define ETP_CAP_HAS_ROCKER 0x04
57
58/*
59 * One hard to find application note states that X axis range is 0 to 576
60 * and Y axis range is 0 to 384 for harware version 1.
61 * Edge fuzz might be necessary because of bezel around the touchpad
62 */
63#define ETP_EDGE_FUZZ_V1 32
64
65#define ETP_XMIN_V1 ( 0 + ETP_EDGE_FUZZ_V1)
66#define ETP_XMAX_V1 (576 - ETP_EDGE_FUZZ_V1)
67#define ETP_YMIN_V1 ( 0 + ETP_EDGE_FUZZ_V1)
68#define ETP_YMAX_V1 (384 - ETP_EDGE_FUZZ_V1)
69
70/*
JJ Ding8a360d02011-09-09 10:27:42 -070071 * The resolution for older v2 hardware doubled.
72 * (newer v2's firmware provides command so we can query)
Arjan Opmeer2a0bd752008-10-16 22:10:19 -040073 */
JJ Ding8a360d02011-09-09 10:27:42 -070074#define ETP_XMIN_V2 0
75#define ETP_XMAX_V2 1152
76#define ETP_YMIN_V2 0
77#define ETP_YMAX_V2 768
Arjan Opmeer2a0bd752008-10-16 22:10:19 -040078
Éric Pielf941c702011-05-16 22:45:54 -070079#define ETP_PMIN_V2 0
80#define ETP_PMAX_V2 255
81#define ETP_WMIN_V2 0
82#define ETP_WMAX_V2 15
83
JJ Ding28f49612011-09-09 10:30:31 -070084/*
85 * v3 hardware has 2 kinds of packet types.
86 */
87#define PACKET_UNKNOWN 0x01
88#define PACKET_DEBOUNCE 0x02
89#define PACKET_V3_HEAD 0x03
90#define PACKET_V3_TAIL 0x04
91
Arjan Opmeer2a0bd752008-10-16 22:10:19 -040092struct elantech_data {
93 unsigned char reg_10;
94 unsigned char reg_11;
95 unsigned char reg_20;
96 unsigned char reg_21;
97 unsigned char reg_22;
98 unsigned char reg_23;
99 unsigned char reg_24;
100 unsigned char reg_25;
101 unsigned char reg_26;
102 unsigned char debug;
JJ Ding230282a2011-09-09 10:26:16 -0700103 unsigned char capabilities[3];
Éric Piel7f29f172010-08-05 23:51:49 -0700104 bool paritycheck;
105 bool jumpy_cursor;
Éric Pielf941c702011-05-16 22:45:54 -0700106 bool reports_pressure;
Dmitry Torokhov504e8be2010-05-13 00:41:15 -0700107 unsigned char hw_version;
Éric Piel7f29f172010-08-05 23:51:49 -0700108 unsigned int fw_version;
109 unsigned int single_finger_reports;
JJ Ding230282a2011-09-09 10:26:16 -0700110 unsigned int y_max;
JJ Ding28f49612011-09-09 10:30:31 -0700111 unsigned int prev_x;
112 unsigned int prev_y;
Arjan Opmeer2a0bd752008-10-16 22:10:19 -0400113 unsigned char parity[256];
114};
115
116#ifdef CONFIG_MOUSE_PS2_ELANTECH
Dmitry Torokhovb7802c52009-09-09 19:13:20 -0700117int elantech_detect(struct psmouse *psmouse, bool set_properties);
Arjan Opmeer2a0bd752008-10-16 22:10:19 -0400118int elantech_init(struct psmouse *psmouse);
119#else
Dmitry Torokhovb7802c52009-09-09 19:13:20 -0700120static inline int elantech_detect(struct psmouse *psmouse, bool set_properties)
Arjan Opmeer2a0bd752008-10-16 22:10:19 -0400121{
122 return -ENOSYS;
123}
124static inline int elantech_init(struct psmouse *psmouse)
125{
126 return -ENOSYS;
127}
128#endif /* CONFIG_MOUSE_PS2_ELANTECH */
129
130#endif