]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/input/mouse/alps.h
Input: alps - change decode function prototype to return an int
[mirror_ubuntu-artful-kernel.git] / drivers / input / mouse / alps.h
CommitLineData
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
02d04254
HG
15#include <linux/input/mt.h>
16
b5d6b851
KC
17#define ALPS_PROTO_V1 1
18#define ALPS_PROTO_V2 2
19#define ALPS_PROTO_V3 3
20#define ALPS_PROTO_V4 4
75af9e56 21#define ALPS_PROTO_V5 5
95f75e91 22#define ALPS_PROTO_V6 6
fa629ef5 23
02d04254
HG
24#define MAX_TOUCHES 2
25
ee65d4b3
YT
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
88a80348
KC
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 */
1da177e4 48struct alps_model_info {
88a80348
KC
49 unsigned char signature[3];
50 unsigned char command_mode_resp;
fa629ef5 51 unsigned char proto_version;
88a80348 52 unsigned char byte0, mask0;
40e8f53b 53 int flags;
1da177e4
LT
54};
55
88a80348
KC
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 */
25bded7c
SF
67struct alps_nibble_commands {
68 int command;
69 unsigned char data;
70};
71
036e6c7b
HG
72struct alps_bitmap_point {
73 int start_bit;
74 int num_bits;
75};
76
f85e5001
KC
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.
02d04254
HG
82 * @pressure: Pressure.
83 * @st: position for ST.
84 * @mt: position for MT.
f85e5001
KC
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 */
94struct alps_fields {
95 unsigned int x_map;
96 unsigned int y_map;
97 unsigned int fingers;
02d04254
HG
98
99 int pressure;
100 struct input_mt_pos st;
101 struct input_mt_pos mt[MAX_TOUCHES];
102
f85e5001
KC
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
88a80348
KC
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.
88a80348
KC
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.
99df65e7
KC
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 * @flags: Additional device capabilities (passthrough port, trackstick, etc.).
7a9f73e7
KC
128 * @x_max: Largest possible X position value.
129 * @y_max: Largest possible Y position value.
130 * @x_bits: Number of X bits in the MT bitmap.
131 * @y_bits: Number of Y bits in the MT bitmap.
24af5cb9
KC
132 * @hw_init: Protocol-specific hardware init function.
133 * @process_packet: Protocol-specific function to process a report packet.
f85e5001 134 * @decode_fields: Protocol-specific function to read packet bitfields.
24af5cb9 135 * @set_abs_params: Protocol-specific function to configure the input_dev.
88a80348
KC
136 * @prev_fin: Finger bit from previous packet.
137 * @multi_packet: Multi-packet data in progress.
138 * @multi_data: Saved multi-packet data.
02d04254 139 * @f: Decoded packet data fields.
88a80348
KC
140 * @quirks: Bitmap of ALPS_QUIRK_*.
141 * @timer: Timer for flushing out the final report packet in the stream.
142 */
1da177e4 143struct alps_data {
88a80348
KC
144 struct input_dev *dev2;
145 char phys[32];
99df65e7
KC
146
147 /* these are autodetected when the device is identified */
25bded7c 148 const struct alps_nibble_commands *nibble_commands;
88a80348 149 int addr_command;
99df65e7
KC
150 unsigned char proto_version;
151 unsigned char byte0, mask0;
40e8f53b 152 int flags;
7a9f73e7
KC
153 int x_max;
154 int y_max;
155 int x_bits;
156 int y_bits;
99df65e7 157
24af5cb9
KC
158 int (*hw_init)(struct psmouse *psmouse);
159 void (*process_packet)(struct psmouse *psmouse);
38c11eaa 160 int (*decode_fields)(struct alps_fields *f, unsigned char *p,
ee65d4b3 161 struct psmouse *psmouse);
24af5cb9
KC
162 void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1);
163
88a80348
KC
164 int prev_fin;
165 int multi_packet;
166 unsigned char multi_data[6];
02d04254 167 struct alps_fields f;
25bded7c 168 u8 quirks;
1d9f2626 169 struct timer_list timer;
1da177e4
LT
170};
171
25bded7c
SF
172#define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */
173
55e3d922 174#ifdef CONFIG_MOUSE_PS2_ALPS
b7802c5c 175int alps_detect(struct psmouse *psmouse, bool set_properties);
55e3d922
AS
176int alps_init(struct psmouse *psmouse);
177#else
b7802c5c 178inline int alps_detect(struct psmouse *psmouse, bool set_properties)
55e3d922
AS
179{
180 return -ENOSYS;
181}
182inline int alps_init(struct psmouse *psmouse)
183{
184 return -ENOSYS;
185}
186#endif /* CONFIG_MOUSE_PS2_ALPS */
187
1da177e4 188#endif