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