]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
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 | ||
b5d6b851 KC |
15 | #define ALPS_PROTO_V1 1 |
16 | #define ALPS_PROTO_V2 2 | |
17 | #define ALPS_PROTO_V3 3 | |
18 | #define ALPS_PROTO_V4 4 | |
75af9e56 | 19 | #define ALPS_PROTO_V5 5 |
fa629ef5 | 20 | |
88a80348 KC |
21 | /** |
22 | * struct alps_model_info - touchpad ID table | |
23 | * @signature: E7 response string to match. | |
24 | * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response | |
25 | * (aka command mode response) identifies the firmware minor version. This | |
26 | * can be used to distinguish different hardware models which are not | |
27 | * uniquely identifiable through their E7 responses. | |
28 | * @proto_version: Indicates V1/V2/V3/... | |
29 | * @byte0: Helps figure out whether a position report packet matches the | |
30 | * known format for this model. The first byte of the report, ANDed with | |
31 | * mask0, should match byte0. | |
32 | * @mask0: The mask used to check the first byte of the report. | |
33 | * @flags: Additional device capabilities (passthrough port, trackstick, etc.). | |
34 | * | |
35 | * Many (but not all) ALPS touchpads can be identified by looking at the | |
36 | * values returned in the "E7 report" and/or the "EC report." This table | |
37 | * lists a number of such touchpads. | |
38 | */ | |
1da177e4 | 39 | struct alps_model_info { |
88a80348 KC |
40 | unsigned char signature[3]; |
41 | unsigned char command_mode_resp; | |
fa629ef5 | 42 | unsigned char proto_version; |
88a80348 KC |
43 | unsigned char byte0, mask0; |
44 | unsigned char flags; | |
1da177e4 LT |
45 | }; |
46 | ||
88a80348 KC |
47 | /** |
48 | * struct alps_nibble_commands - encodings for register accesses | |
49 | * @command: PS/2 command used for the nibble | |
50 | * @data: Data supplied as an argument to the PS/2 command, if applicable | |
51 | * | |
52 | * The ALPS protocol uses magic sequences to transmit binary data to the | |
53 | * touchpad, as it is generally not OK to send arbitrary bytes out the | |
54 | * PS/2 port. Each of the sequences in this table sends one nibble of the | |
55 | * register address or (write) data. Different versions of the ALPS protocol | |
56 | * use slightly different encodings. | |
57 | */ | |
25bded7c SF |
58 | struct alps_nibble_commands { |
59 | int command; | |
60 | unsigned char data; | |
61 | }; | |
62 | ||
f85e5001 KC |
63 | /** |
64 | * struct alps_fields - decoded version of the report packet | |
65 | * @x_map: Bitmap of active X positions for MT. | |
66 | * @y_map: Bitmap of active Y positions for MT. | |
67 | * @fingers: Number of fingers for MT. | |
68 | * @x: X position for ST. | |
69 | * @y: Y position for ST. | |
70 | * @z: Z position for ST. | |
71 | * @first_mp: Packet is the first of a multi-packet report. | |
72 | * @is_mp: Packet is part of a multi-packet report. | |
73 | * @left: Left touchpad button is active. | |
74 | * @right: Right touchpad button is active. | |
75 | * @middle: Middle touchpad button is active. | |
76 | * @ts_left: Left trackstick button is active. | |
77 | * @ts_right: Right trackstick button is active. | |
78 | * @ts_middle: Middle trackstick button is active. | |
79 | */ | |
80 | struct alps_fields { | |
81 | unsigned int x_map; | |
82 | unsigned int y_map; | |
83 | unsigned int fingers; | |
84 | unsigned int x; | |
85 | unsigned int y; | |
86 | unsigned int z; | |
87 | unsigned int first_mp:1; | |
88 | unsigned int is_mp:1; | |
89 | ||
90 | unsigned int left:1; | |
91 | unsigned int right:1; | |
92 | unsigned int middle:1; | |
93 | ||
94 | unsigned int ts_left:1; | |
95 | unsigned int ts_right:1; | |
96 | unsigned int ts_middle:1; | |
97 | }; | |
98 | ||
88a80348 KC |
99 | /** |
100 | * struct alps_data - private data structure for the ALPS driver | |
101 | * @dev2: "Relative" device used to report trackstick or mouse activity. | |
102 | * @phys: Physical path for the relative device. | |
88a80348 KC |
103 | * @nibble_commands: Command mapping used for touchpad register accesses. |
104 | * @addr_command: Command used to tell the touchpad that a register address | |
105 | * follows. | |
99df65e7 KC |
106 | * @proto_version: Indicates V1/V2/V3/... |
107 | * @byte0: Helps figure out whether a position report packet matches the | |
108 | * known format for this model. The first byte of the report, ANDed with | |
109 | * mask0, should match byte0. | |
110 | * @mask0: The mask used to check the first byte of the report. | |
111 | * @flags: Additional device capabilities (passthrough port, trackstick, etc.). | |
7a9f73e7 KC |
112 | * @x_max: Largest possible X position value. |
113 | * @y_max: Largest possible Y position value. | |
114 | * @x_bits: Number of X bits in the MT bitmap. | |
115 | * @y_bits: Number of Y bits in the MT bitmap. | |
24af5cb9 KC |
116 | * @hw_init: Protocol-specific hardware init function. |
117 | * @process_packet: Protocol-specific function to process a report packet. | |
f85e5001 | 118 | * @decode_fields: Protocol-specific function to read packet bitfields. |
24af5cb9 | 119 | * @set_abs_params: Protocol-specific function to configure the input_dev. |
88a80348 KC |
120 | * @prev_fin: Finger bit from previous packet. |
121 | * @multi_packet: Multi-packet data in progress. | |
122 | * @multi_data: Saved multi-packet data. | |
123 | * @x1: First X coordinate from last MT report. | |
124 | * @x2: Second X coordinate from last MT report. | |
125 | * @y1: First Y coordinate from last MT report. | |
126 | * @y2: Second Y coordinate from last MT report. | |
127 | * @fingers: Number of fingers from last MT report. | |
128 | * @quirks: Bitmap of ALPS_QUIRK_*. | |
129 | * @timer: Timer for flushing out the final report packet in the stream. | |
130 | */ | |
1da177e4 | 131 | struct alps_data { |
88a80348 KC |
132 | struct input_dev *dev2; |
133 | char phys[32]; | |
99df65e7 KC |
134 | |
135 | /* these are autodetected when the device is identified */ | |
25bded7c | 136 | const struct alps_nibble_commands *nibble_commands; |
88a80348 | 137 | int addr_command; |
99df65e7 KC |
138 | unsigned char proto_version; |
139 | unsigned char byte0, mask0; | |
140 | unsigned char flags; | |
7a9f73e7 KC |
141 | int x_max; |
142 | int y_max; | |
143 | int x_bits; | |
144 | int y_bits; | |
99df65e7 | 145 | |
24af5cb9 KC |
146 | int (*hw_init)(struct psmouse *psmouse); |
147 | void (*process_packet)(struct psmouse *psmouse); | |
f85e5001 | 148 | void (*decode_fields)(struct alps_fields *f, unsigned char *p); |
24af5cb9 KC |
149 | void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1); |
150 | ||
88a80348 KC |
151 | int prev_fin; |
152 | int multi_packet; | |
153 | unsigned char multi_data[6]; | |
154 | int x1, x2, y1, y2; | |
155 | int fingers; | |
25bded7c | 156 | u8 quirks; |
1d9f2626 | 157 | struct timer_list timer; |
1da177e4 LT |
158 | }; |
159 | ||
25bded7c SF |
160 | #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */ |
161 | ||
55e3d922 | 162 | #ifdef CONFIG_MOUSE_PS2_ALPS |
b7802c5c | 163 | int alps_detect(struct psmouse *psmouse, bool set_properties); |
55e3d922 AS |
164 | int alps_init(struct psmouse *psmouse); |
165 | #else | |
b7802c5c | 166 | inline int alps_detect(struct psmouse *psmouse, bool set_properties) |
55e3d922 AS |
167 | { |
168 | return -ENOSYS; | |
169 | } | |
170 | inline int alps_init(struct psmouse *psmouse) | |
171 | { | |
172 | return -ENOSYS; | |
173 | } | |
174 | #endif /* CONFIG_MOUSE_PS2_ALPS */ | |
175 | ||
1da177e4 | 176 | #endif |