Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ALPS touchpad PS/2 mouse driver |
| 3 | * |
| 4 | * Copyright (c) 2003 Peter Osterlund <petero2@telia.com> |
| 5 | * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License version 2 as published by |
| 9 | * the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | #ifndef _ALPS_H |
| 13 | #define _ALPS_H |
| 14 | |
Kevin Cernekee | b5d6b85 | 2013-02-13 22:19:59 -0800 | [diff] [blame] | 15 | #define ALPS_PROTO_V1 1 |
| 16 | #define ALPS_PROTO_V2 2 |
| 17 | #define ALPS_PROTO_V3 3 |
| 18 | #define ALPS_PROTO_V4 4 |
Dave Turvene | 75af9e5 | 2013-02-21 22:58:28 -0800 | [diff] [blame] | 19 | #define ALPS_PROTO_V5 5 |
Yunkang Tang | 95f75e9 | 2013-12-01 22:33:52 -0800 | [diff] [blame] | 20 | #define ALPS_PROTO_V6 6 |
Seth Forshee | fa629ef | 2011-11-07 19:53:24 -0800 | [diff] [blame] | 21 | |
Yunkang Tang | ee65d4b | 2013-12-26 14:54:19 -0800 | [diff] [blame] | 22 | #define DOLPHIN_COUNT_PER_ELECTRODE 64 |
| 23 | #define DOLPHIN_PROFILE_XOFFSET 8 /* x-electrode offset */ |
| 24 | #define DOLPHIN_PROFILE_YOFFSET 1 /* y-electrode offset */ |
| 25 | |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 26 | /** |
| 27 | * struct alps_model_info - touchpad ID table |
| 28 | * @signature: E7 response string to match. |
| 29 | * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response |
| 30 | * (aka command mode response) identifies the firmware minor version. This |
| 31 | * can be used to distinguish different hardware models which are not |
| 32 | * uniquely identifiable through their E7 responses. |
| 33 | * @proto_version: Indicates V1/V2/V3/... |
| 34 | * @byte0: Helps figure out whether a position report packet matches the |
| 35 | * known format for this model. The first byte of the report, ANDed with |
| 36 | * mask0, should match byte0. |
| 37 | * @mask0: The mask used to check the first byte of the report. |
| 38 | * @flags: Additional device capabilities (passthrough port, trackstick, etc.). |
| 39 | * |
| 40 | * Many (but not all) ALPS touchpads can be identified by looking at the |
| 41 | * values returned in the "E7 report" and/or the "EC report." This table |
| 42 | * lists a number of such touchpads. |
| 43 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | struct alps_model_info { |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 45 | unsigned char signature[3]; |
| 46 | unsigned char command_mode_resp; |
Seth Forshee | fa629ef | 2011-11-07 19:53:24 -0800 | [diff] [blame] | 47 | unsigned char proto_version; |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 48 | unsigned char byte0, mask0; |
| 49 | unsigned char flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 52 | /** |
| 53 | * struct alps_nibble_commands - encodings for register accesses |
| 54 | * @command: PS/2 command used for the nibble |
| 55 | * @data: Data supplied as an argument to the PS/2 command, if applicable |
| 56 | * |
| 57 | * The ALPS protocol uses magic sequences to transmit binary data to the |
| 58 | * touchpad, as it is generally not OK to send arbitrary bytes out the |
| 59 | * PS/2 port. Each of the sequences in this table sends one nibble of the |
| 60 | * register address or (write) data. Different versions of the ALPS protocol |
| 61 | * use slightly different encodings. |
| 62 | */ |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame] | 63 | struct alps_nibble_commands { |
| 64 | int command; |
| 65 | unsigned char data; |
| 66 | }; |
| 67 | |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 68 | /** |
Kevin Cernekee | f85e500 | 2013-02-13 22:26:11 -0800 | [diff] [blame] | 69 | * struct alps_fields - decoded version of the report packet |
| 70 | * @x_map: Bitmap of active X positions for MT. |
| 71 | * @y_map: Bitmap of active Y positions for MT. |
| 72 | * @fingers: Number of fingers for MT. |
| 73 | * @x: X position for ST. |
| 74 | * @y: Y position for ST. |
| 75 | * @z: Z position for ST. |
| 76 | * @first_mp: Packet is the first of a multi-packet report. |
| 77 | * @is_mp: Packet is part of a multi-packet report. |
| 78 | * @left: Left touchpad button is active. |
| 79 | * @right: Right touchpad button is active. |
| 80 | * @middle: Middle touchpad button is active. |
| 81 | * @ts_left: Left trackstick button is active. |
| 82 | * @ts_right: Right trackstick button is active. |
| 83 | * @ts_middle: Middle trackstick button is active. |
| 84 | */ |
| 85 | struct alps_fields { |
| 86 | unsigned int x_map; |
| 87 | unsigned int y_map; |
| 88 | unsigned int fingers; |
| 89 | unsigned int x; |
| 90 | unsigned int y; |
| 91 | unsigned int z; |
| 92 | unsigned int first_mp:1; |
| 93 | unsigned int is_mp:1; |
| 94 | |
| 95 | unsigned int left:1; |
| 96 | unsigned int right:1; |
| 97 | unsigned int middle:1; |
| 98 | |
| 99 | unsigned int ts_left:1; |
| 100 | unsigned int ts_right:1; |
| 101 | unsigned int ts_middle:1; |
| 102 | }; |
| 103 | |
| 104 | /** |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 105 | * struct alps_data - private data structure for the ALPS driver |
| 106 | * @dev2: "Relative" device used to report trackstick or mouse activity. |
| 107 | * @phys: Physical path for the relative device. |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 108 | * @nibble_commands: Command mapping used for touchpad register accesses. |
| 109 | * @addr_command: Command used to tell the touchpad that a register address |
| 110 | * follows. |
Kevin Cernekee | 99df65e | 2013-02-13 20:56:33 -0800 | [diff] [blame] | 111 | * @proto_version: Indicates V1/V2/V3/... |
| 112 | * @byte0: Helps figure out whether a position report packet matches the |
| 113 | * known format for this model. The first byte of the report, ANDed with |
| 114 | * mask0, should match byte0. |
| 115 | * @mask0: The mask used to check the first byte of the report. |
| 116 | * @flags: Additional device capabilities (passthrough port, trackstick, etc.). |
Kevin Cernekee | 7a9f73e | 2013-02-13 22:24:55 -0800 | [diff] [blame] | 117 | * @x_max: Largest possible X position value. |
| 118 | * @y_max: Largest possible Y position value. |
| 119 | * @x_bits: Number of X bits in the MT bitmap. |
| 120 | * @y_bits: Number of Y bits in the MT bitmap. |
Kevin Cernekee | 24af5cb | 2013-02-13 22:22:08 -0800 | [diff] [blame] | 121 | * @hw_init: Protocol-specific hardware init function. |
| 122 | * @process_packet: Protocol-specific function to process a report packet. |
Kevin Cernekee | f85e500 | 2013-02-13 22:26:11 -0800 | [diff] [blame] | 123 | * @decode_fields: Protocol-specific function to read packet bitfields. |
Kevin Cernekee | 24af5cb | 2013-02-13 22:22:08 -0800 | [diff] [blame] | 124 | * @set_abs_params: Protocol-specific function to configure the input_dev. |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 125 | * @prev_fin: Finger bit from previous packet. |
| 126 | * @multi_packet: Multi-packet data in progress. |
| 127 | * @multi_data: Saved multi-packet data. |
| 128 | * @x1: First X coordinate from last MT report. |
| 129 | * @x2: Second X coordinate from last MT report. |
| 130 | * @y1: First Y coordinate from last MT report. |
| 131 | * @y2: Second Y coordinate from last MT report. |
| 132 | * @fingers: Number of fingers from last MT report. |
| 133 | * @quirks: Bitmap of ALPS_QUIRK_*. |
| 134 | * @timer: Timer for flushing out the final report packet in the stream. |
| 135 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | struct alps_data { |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 137 | struct input_dev *dev2; |
| 138 | char phys[32]; |
Kevin Cernekee | 99df65e | 2013-02-13 20:56:33 -0800 | [diff] [blame] | 139 | |
| 140 | /* these are autodetected when the device is identified */ |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame] | 141 | const struct alps_nibble_commands *nibble_commands; |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 142 | int addr_command; |
Kevin Cernekee | 99df65e | 2013-02-13 20:56:33 -0800 | [diff] [blame] | 143 | unsigned char proto_version; |
| 144 | unsigned char byte0, mask0; |
| 145 | unsigned char flags; |
Kevin Cernekee | 7a9f73e | 2013-02-13 22:24:55 -0800 | [diff] [blame] | 146 | int x_max; |
| 147 | int y_max; |
| 148 | int x_bits; |
| 149 | int y_bits; |
Kevin Cernekee | 99df65e | 2013-02-13 20:56:33 -0800 | [diff] [blame] | 150 | |
Kevin Cernekee | 24af5cb | 2013-02-13 22:22:08 -0800 | [diff] [blame] | 151 | int (*hw_init)(struct psmouse *psmouse); |
| 152 | void (*process_packet)(struct psmouse *psmouse); |
Yunkang Tang | ee65d4b | 2013-12-26 14:54:19 -0800 | [diff] [blame] | 153 | void (*decode_fields)(struct alps_fields *f, unsigned char *p, |
| 154 | struct psmouse *psmouse); |
Kevin Cernekee | 24af5cb | 2013-02-13 22:22:08 -0800 | [diff] [blame] | 155 | void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1); |
| 156 | |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 157 | int prev_fin; |
| 158 | int multi_packet; |
| 159 | unsigned char multi_data[6]; |
| 160 | int x1, x2, y1, y2; |
| 161 | int fingers; |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame] | 162 | u8 quirks; |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 163 | struct timer_list timer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | }; |
| 165 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame] | 166 | #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */ |
| 167 | |
Andres Salomon | 55e3d92 | 2007-03-10 01:39:54 -0500 | [diff] [blame] | 168 | #ifdef CONFIG_MOUSE_PS2_ALPS |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 169 | int alps_detect(struct psmouse *psmouse, bool set_properties); |
Andres Salomon | 55e3d92 | 2007-03-10 01:39:54 -0500 | [diff] [blame] | 170 | int alps_init(struct psmouse *psmouse); |
| 171 | #else |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 172 | inline int alps_detect(struct psmouse *psmouse, bool set_properties) |
Andres Salomon | 55e3d92 | 2007-03-10 01:39:54 -0500 | [diff] [blame] | 173 | { |
| 174 | return -ENOSYS; |
| 175 | } |
| 176 | inline int alps_init(struct psmouse *psmouse) |
| 177 | { |
| 178 | return -ENOSYS; |
| 179 | } |
| 180 | #endif /* CONFIG_MOUSE_PS2_ALPS */ |
| 181 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | #endif |