| 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 | */ | 
|  | 19 | #define ETP_FW_VERSION_QUERY		0x01 | 
|  | 20 | #define ETP_CAPABILITIES_QUERY		0x02 | 
|  | 21 |  | 
|  | 22 | /* | 
|  | 23 | * Command values for register reading or writing | 
|  | 24 | */ | 
|  | 25 | #define ETP_REGISTER_READ		0x10 | 
|  | 26 | #define ETP_REGISTER_WRITE		0x11 | 
|  | 27 |  | 
|  | 28 | /* | 
|  | 29 | * Hardware version 2 custom PS/2 command value | 
|  | 30 | */ | 
|  | 31 | #define ETP_PS2_CUSTOM_COMMAND		0xf8 | 
|  | 32 |  | 
|  | 33 | /* | 
|  | 34 | * Times to retry a ps2_command and millisecond delay between tries | 
|  | 35 | */ | 
|  | 36 | #define ETP_PS2_COMMAND_TRIES		3 | 
|  | 37 | #define ETP_PS2_COMMAND_DELAY		500 | 
|  | 38 |  | 
|  | 39 | /* | 
|  | 40 | * Times to try to read back a register and millisecond delay between tries | 
|  | 41 | */ | 
|  | 42 | #define ETP_READ_BACK_TRIES		5 | 
|  | 43 | #define ETP_READ_BACK_DELAY		2000 | 
|  | 44 |  | 
|  | 45 | /* | 
|  | 46 | * Register bitmasks for hardware version 1 | 
|  | 47 | */ | 
|  | 48 | #define ETP_R10_ABSOLUTE_MODE		0x04 | 
|  | 49 | #define ETP_R11_4_BYTE_MODE		0x02 | 
|  | 50 |  | 
|  | 51 | /* | 
|  | 52 | * Capability bitmasks | 
|  | 53 | */ | 
|  | 54 | #define ETP_CAP_HAS_ROCKER		0x04 | 
|  | 55 |  | 
|  | 56 | /* | 
|  | 57 | * One hard to find application note states that X axis range is 0 to 576 | 
|  | 58 | * and Y axis range is 0 to 384 for harware version 1. | 
|  | 59 | * Edge fuzz might be necessary because of bezel around the touchpad | 
|  | 60 | */ | 
|  | 61 | #define ETP_EDGE_FUZZ_V1		32 | 
|  | 62 |  | 
|  | 63 | #define ETP_XMIN_V1			(  0 + ETP_EDGE_FUZZ_V1) | 
|  | 64 | #define ETP_XMAX_V1			(576 - ETP_EDGE_FUZZ_V1) | 
|  | 65 | #define ETP_YMIN_V1			(  0 + ETP_EDGE_FUZZ_V1) | 
|  | 66 | #define ETP_YMAX_V1			(384 - ETP_EDGE_FUZZ_V1) | 
|  | 67 |  | 
|  | 68 | /* | 
|  | 69 | * It seems the resolution for hardware version 2 doubled. | 
|  | 70 | * Hence the X and Y ranges are doubled too. | 
|  | 71 | * The bezel around the pad also appears to be smaller | 
|  | 72 | */ | 
|  | 73 | #define ETP_EDGE_FUZZ_V2		8 | 
|  | 74 |  | 
|  | 75 | #define ETP_XMIN_V2			(   0 + ETP_EDGE_FUZZ_V2) | 
|  | 76 | #define ETP_XMAX_V2			(1152 - ETP_EDGE_FUZZ_V2) | 
|  | 77 | #define ETP_YMIN_V2			(   0 + ETP_EDGE_FUZZ_V2) | 
|  | 78 | #define ETP_YMAX_V2			( 768 - ETP_EDGE_FUZZ_V2) | 
|  | 79 |  | 
|  | 80 | /* | 
|  | 81 | * For two finger touches the coordinate of each finger gets reported | 
|  | 82 | * separately but with reduced resolution. | 
|  | 83 | */ | 
|  | 84 | #define ETP_2FT_FUZZ			4 | 
|  | 85 |  | 
|  | 86 | #define ETP_2FT_XMIN			(  0 + ETP_2FT_FUZZ) | 
|  | 87 | #define ETP_2FT_XMAX			(288 - ETP_2FT_FUZZ) | 
|  | 88 | #define ETP_2FT_YMIN			(  0 + ETP_2FT_FUZZ) | 
|  | 89 | #define ETP_2FT_YMAX			(192 - ETP_2FT_FUZZ) | 
|  | 90 |  | 
|  | 91 | struct elantech_data { | 
|  | 92 | unsigned char reg_10; | 
|  | 93 | unsigned char reg_11; | 
|  | 94 | unsigned char reg_20; | 
|  | 95 | unsigned char reg_21; | 
|  | 96 | unsigned char reg_22; | 
|  | 97 | unsigned char reg_23; | 
|  | 98 | unsigned char reg_24; | 
|  | 99 | unsigned char reg_25; | 
|  | 100 | unsigned char reg_26; | 
|  | 101 | unsigned char debug; | 
|  | 102 | unsigned char capabilities; | 
|  | 103 | unsigned char fw_version_maj; | 
|  | 104 | unsigned char fw_version_min; | 
|  | 105 | unsigned char hw_version; | 
|  | 106 | unsigned char paritycheck; | 
| Arjan Opmeer | 3f8c0df | 2009-04-18 19:05:40 -0700 | [diff] [blame] | 107 | unsigned char jumpy_cursor; | 
| Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 108 | unsigned char parity[256]; | 
|  | 109 | }; | 
|  | 110 |  | 
|  | 111 | #ifdef CONFIG_MOUSE_PS2_ELANTECH | 
| Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 112 | int elantech_detect(struct psmouse *psmouse, bool set_properties); | 
| Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 113 | int elantech_init(struct psmouse *psmouse); | 
|  | 114 | #else | 
| Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 115 | static inline int elantech_detect(struct psmouse *psmouse, bool set_properties) | 
| Arjan Opmeer | 2a0bd75 | 2008-10-16 22:10:19 -0400 | [diff] [blame] | 116 | { | 
|  | 117 | return -ENOSYS; | 
|  | 118 | } | 
|  | 119 | static inline int elantech_init(struct psmouse *psmouse) | 
|  | 120 | { | 
|  | 121 | return -ENOSYS; | 
|  | 122 | } | 
|  | 123 | #endif /* CONFIG_MOUSE_PS2_ELANTECH */ | 
|  | 124 |  | 
|  | 125 | #endif |