2 * ALPS touchpad PS/2 mouse driver
4 * Copyright (c) 2003 Peter Osterlund <petero2@telia.com>
5 * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
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.
15 #define ALPS_PROTO_V1 1
16 #define ALPS_PROTO_V2 2
17 #define ALPS_PROTO_V3 3
18 #define ALPS_PROTO_V4 4
19 #define ALPS_PROTO_V5 5
20 #define ALPS_PROTO_V6 6
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 */
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.).
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.
44 struct alps_model_info {
45 unsigned char signature[3];
46 unsigned char command_mode_resp;
47 unsigned char proto_version;
48 unsigned char byte0, mask0;
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
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.
63 struct alps_nibble_commands {
68 struct alps_bitmap_point {
74 * struct alps_fields - decoded version of the report packet
75 * @x_map: Bitmap of active X positions for MT.
76 * @y_map: Bitmap of active Y positions for MT.
77 * @fingers: Number of fingers for MT.
78 * @x: X position for ST.
79 * @y: Y position for ST.
80 * @z: Z position for ST.
81 * @first_mp: Packet is the first of a multi-packet report.
82 * @is_mp: Packet is part of a multi-packet report.
83 * @left: Left touchpad button is active.
84 * @right: Right touchpad button is active.
85 * @middle: Middle touchpad button is active.
86 * @ts_left: Left trackstick button is active.
87 * @ts_right: Right trackstick button is active.
88 * @ts_middle: Middle trackstick button is active.
97 unsigned int first_mp:1;
101 unsigned int right:1;
102 unsigned int middle:1;
104 unsigned int ts_left:1;
105 unsigned int ts_right:1;
106 unsigned int ts_middle:1;
110 * struct alps_data - private data structure for the ALPS driver
111 * @dev2: "Relative" device used to report trackstick or mouse activity.
112 * @phys: Physical path for the relative device.
113 * @nibble_commands: Command mapping used for touchpad register accesses.
114 * @addr_command: Command used to tell the touchpad that a register address
116 * @proto_version: Indicates V1/V2/V3/...
117 * @byte0: Helps figure out whether a position report packet matches the
118 * known format for this model. The first byte of the report, ANDed with
119 * mask0, should match byte0.
120 * @mask0: The mask used to check the first byte of the report.
121 * @flags: Additional device capabilities (passthrough port, trackstick, etc.).
122 * @x_max: Largest possible X position value.
123 * @y_max: Largest possible Y position value.
124 * @x_bits: Number of X bits in the MT bitmap.
125 * @y_bits: Number of Y bits in the MT bitmap.
126 * @hw_init: Protocol-specific hardware init function.
127 * @process_packet: Protocol-specific function to process a report packet.
128 * @decode_fields: Protocol-specific function to read packet bitfields.
129 * @set_abs_params: Protocol-specific function to configure the input_dev.
130 * @prev_fin: Finger bit from previous packet.
131 * @multi_packet: Multi-packet data in progress.
132 * @multi_data: Saved multi-packet data.
133 * @x1: First X coordinate from last MT report.
134 * @x2: Second X coordinate from last MT report.
135 * @y1: First Y coordinate from last MT report.
136 * @y2: Second Y coordinate from last MT report.
137 * @fingers: Number of fingers from last MT report.
138 * @quirks: Bitmap of ALPS_QUIRK_*.
139 * @timer: Timer for flushing out the final report packet in the stream.
142 struct input_dev *dev2;
145 /* these are autodetected when the device is identified */
146 const struct alps_nibble_commands *nibble_commands;
148 unsigned char proto_version;
149 unsigned char byte0, mask0;
156 int (*hw_init)(struct psmouse *psmouse);
157 void (*process_packet)(struct psmouse *psmouse);
158 void (*decode_fields)(struct alps_fields *f, unsigned char *p,
159 struct psmouse *psmouse);
160 void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1);
164 unsigned char multi_data[6];
168 struct timer_list timer;
171 #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */
173 #ifdef CONFIG_MOUSE_PS2_ALPS
174 int alps_detect(struct psmouse *psmouse, bool set_properties);
175 int alps_init(struct psmouse *psmouse);
177 inline int alps_detect(struct psmouse *psmouse, bool set_properties)
181 inline int alps_init(struct psmouse *psmouse)
185 #endif /* CONFIG_MOUSE_PS2_ALPS */