Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 1 | /* |
Arjan Opmeer | 3f8c0df | 2009-04-18 19:05:40 -0700 | [diff] [blame] | 2 | * Elantech Touchpad driver (v6) |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 3 | * |
Arjan Opmeer | 3f8c0df | 2009-04-18 19:05:40 -0700 | [diff] [blame] | 4 | * Copyright (C) 2007-2009 Arjan Opmeer <arjan@opmeer.net> |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 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 | */ |
JJ Ding | 28f4961 | 2011-09-09 10:30:31 -0700 | [diff] [blame] | 19 | #define ETP_FW_ID_QUERY 0x00 |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 20 | #define ETP_FW_VERSION_QUERY 0x01 |
| 21 | #define ETP_CAPABILITIES_QUERY 0x02 |
JJ Ding | 84a90b6 | 2011-09-20 22:42:51 -0700 | [diff] [blame] | 22 | #define ETP_SAMPLE_QUERY 0x03 |
JJ Ding | 3d95fd6 | 2011-11-20 22:26:56 -0800 | [diff] [blame] | 23 | #define ETP_RESOLUTION_QUERY 0x04 |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Command values for register reading or writing |
| 27 | */ |
| 28 | #define ETP_REGISTER_READ 0x10 |
| 29 | #define ETP_REGISTER_WRITE 0x11 |
JJ Ding | 28f4961 | 2011-09-09 10:30:31 -0700 | [diff] [blame] | 30 | #define ETP_REGISTER_READWRITE 0x00 |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 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 | /* |
JJ Ding | 8a360d0 | 2011-09-09 10:27:42 -0700 | [diff] [blame] | 73 | * The resolution for older v2 hardware doubled. |
| 74 | * (newer v2's firmware provides command so we can query) |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 75 | */ |
JJ Ding | 8a360d0 | 2011-09-09 10:27:42 -0700 | [diff] [blame] | 76 | #define ETP_XMIN_V2 0 |
| 77 | #define ETP_XMAX_V2 1152 |
| 78 | #define ETP_YMIN_V2 0 |
| 79 | #define ETP_YMAX_V2 768 |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 80 | |
Éric Piel | f941c70 | 2011-05-16 22:45:54 -0700 | [diff] [blame] | 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 | |
JJ Ding | 28f4961 | 2011-09-09 10:30:31 -0700 | [diff] [blame] | 86 | /* |
JJ Ding | 1dc6ede | 2011-09-09 10:31:58 -0700 | [diff] [blame] | 87 | * v3 hardware has 2 kinds of packet types, |
| 88 | * v4 hardware has 3. |
JJ Ding | 28f4961 | 2011-09-09 10:30:31 -0700 | [diff] [blame] | 89 | */ |
| 90 | #define PACKET_UNKNOWN 0x01 |
| 91 | #define PACKET_DEBOUNCE 0x02 |
| 92 | #define PACKET_V3_HEAD 0x03 |
| 93 | #define PACKET_V3_TAIL 0x04 |
JJ Ding | 1dc6ede | 2011-09-09 10:31:58 -0700 | [diff] [blame] | 94 | #define PACKET_V4_HEAD 0x05 |
| 95 | #define PACKET_V4_MOTION 0x06 |
| 96 | #define PACKET_V4_STATUS 0x07 |
| 97 | |
| 98 | /* |
| 99 | * track up to 5 fingers for v4 hardware |
| 100 | */ |
| 101 | #define ETP_MAX_FINGERS 5 |
| 102 | |
| 103 | /* |
| 104 | * weight value for v4 hardware |
| 105 | */ |
| 106 | #define ETP_WEIGHT_VALUE 5 |
| 107 | |
| 108 | /* |
| 109 | * The base position for one finger, v4 hardware |
| 110 | */ |
| 111 | struct finger_pos { |
| 112 | unsigned int x; |
| 113 | unsigned int y; |
| 114 | }; |
JJ Ding | 28f4961 | 2011-09-09 10:30:31 -0700 | [diff] [blame] | 115 | |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 116 | struct elantech_data { |
JJ Ding | 1dc6ede | 2011-09-09 10:31:58 -0700 | [diff] [blame] | 117 | unsigned char reg_07; |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 118 | unsigned char reg_10; |
| 119 | unsigned char reg_11; |
| 120 | unsigned char reg_20; |
| 121 | unsigned char reg_21; |
| 122 | unsigned char reg_22; |
| 123 | unsigned char reg_23; |
| 124 | unsigned char reg_24; |
| 125 | unsigned char reg_25; |
| 126 | unsigned char reg_26; |
| 127 | unsigned char debug; |
JJ Ding | 230282a | 2011-09-09 10:26:16 -0700 | [diff] [blame] | 128 | unsigned char capabilities[3]; |
Éric Piel | 7f29f17 | 2010-08-05 23:51:49 -0700 | [diff] [blame] | 129 | bool paritycheck; |
| 130 | bool jumpy_cursor; |
Éric Piel | f941c70 | 2011-05-16 22:45:54 -0700 | [diff] [blame] | 131 | bool reports_pressure; |
Matteo Delfino | acc0444 | 2013-08-15 00:09:41 -0700 | [diff] [blame] | 132 | bool crc_enabled; |
Hans de Goede | 36189cc | 2014-05-05 09:36:43 -0700 | [diff] [blame] | 133 | bool set_hw_resolution; |
Dmitry Torokhov | 504e8be | 2010-05-13 00:41:15 -0700 | [diff] [blame] | 134 | unsigned char hw_version; |
Éric Piel | 7f29f17 | 2010-08-05 23:51:49 -0700 | [diff] [blame] | 135 | unsigned int fw_version; |
| 136 | unsigned int single_finger_reports; |
JJ Ding | 230282a | 2011-09-09 10:26:16 -0700 | [diff] [blame] | 137 | unsigned int y_max; |
JJ Ding | 1dc6ede | 2011-09-09 10:31:58 -0700 | [diff] [blame] | 138 | unsigned int width; |
| 139 | struct finger_pos mt[ETP_MAX_FINGERS]; |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 140 | unsigned char parity[256]; |
JJ Ding | b56b92a | 2011-11-20 22:21:45 -0800 | [diff] [blame] | 141 | int (*send_cmd)(struct psmouse *psmouse, unsigned char c, unsigned char *param); |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | #ifdef CONFIG_MOUSE_PS2_ELANTECH |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 145 | int elantech_detect(struct psmouse *psmouse, bool set_properties); |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 146 | int elantech_init(struct psmouse *psmouse); |
| 147 | #else |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 148 | static inline int elantech_detect(struct psmouse *psmouse, bool set_properties) |
Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 149 | { |
| 150 | return -ENOSYS; |
| 151 | } |
| 152 | static inline int elantech_init(struct psmouse *psmouse) |
| 153 | { |
| 154 | return -ENOSYS; |
| 155 | } |
| 156 | #endif /* CONFIG_MOUSE_PS2_ELANTECH */ |
| 157 | |
| 158 | #endif |