blob: 4ebcdf802e9a2824b8824800c7573c502697531b [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * IBM TrackPoint PS/2 mouse driver
3 *
4 * Stephen Evanchik <evanchsa@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
9 */
10
11#ifndef _TRACKPOINT_H
12#define _TRACKPOINT_H
13
14/*
15 * These constants are from the TrackPoint System
16 * Engineering documentation Version 4 from IBM Watson
17 * research:
18 * http://wwwcssrv.almaden.ibm.com/trackpoint/download.html
19 */
20
21#define TP_COMMAND 0xE2 /* Commands start with this */
22
23#define TP_READ_ID 0xE1 /* Sent for device identification */
24
25/*
26 * Valid first byte responses to the "Read Secondary ID" (0xE1) command.
27 * 0x01 was the original IBM trackpoint, others implement very limited
28 * subset of trackpoint features.
29 */
30#define TP_VARIANT_IBM 0x01
31#define TP_VARIANT_ALPS 0x02
32#define TP_VARIANT_ELAN 0x03
33#define TP_VARIANT_NXP 0x04
34#define TP_VARIANT_JYT_SYNAPTICS 0x05
35#define TP_VARIANT_SYNAPTICS 0x06
36
37/*
38 * Commands
39 */
40#define TP_RECALIB 0x51 /* Recalibrate */
41#define TP_POWER_DOWN 0x44 /* Can only be undone through HW reset */
42#define TP_EXT_DEV 0x21 /* Determines if external device is connected (RO) */
43#define TP_EXT_BTN 0x4B /* Read extended button status */
44#define TP_POR 0x7F /* Execute Power on Reset */
45#define TP_POR_RESULTS 0x25 /* Read Power on Self test results */
46#define TP_DISABLE_EXT 0x40 /* Disable external pointing device */
47#define TP_ENABLE_EXT 0x41 /* Enable external pointing device */
48
49/*
50 * Mode manipulation
51 */
52#define TP_SET_SOFT_TRANS 0x4E /* Set mode */
53#define TP_CANCEL_SOFT_TRANS 0xB9 /* Cancel mode */
54#define TP_SET_HARD_TRANS 0x45 /* Mode can only be set */
55
56
57/*
58 * Register oriented commands/properties
59 */
60#define TP_WRITE_MEM 0x81
61#define TP_READ_MEM 0x80 /* Not used in this implementation */
62
63/*
64* RAM Locations for properties
65 */
66#define TP_SENS 0x4A /* Sensitivity */
67#define TP_MB 0x4C /* Read Middle Button Status (RO) */
68#define TP_INERTIA 0x4D /* Negative Inertia */
69#define TP_SPEED 0x60 /* Speed of TP Cursor */
70#define TP_REACH 0x57 /* Backup for Z-axis press */
71#define TP_DRAGHYS 0x58 /* Drag Hysteresis */
72 /* (how hard it is to drag */
73 /* with Z-axis pressed) */
74
75#define TP_MINDRAG 0x59 /* Minimum amount of force needed */
76 /* to trigger dragging */
77
78#define TP_THRESH 0x5C /* Minimum value for a Z-axis press */
79#define TP_UP_THRESH 0x5A /* Used to generate a 'click' on Z-axis */
80#define TP_Z_TIME 0x5E /* How sharp of a press */
81#define TP_JENKS_CURV 0x5D /* Minimum curvature for double click */
82#define TP_DRIFT_TIME 0x5F /* How long a 'hands off' condition */
83 /* must last (x*107ms) for drift */
84 /* correction to occur */
85
86/*
87 * Toggling Flag bits
88 */
89#define TP_TOGGLE 0x47 /* Toggle command */
90
91#define TP_TOGGLE_MB 0x23 /* Disable/Enable Middle Button */
92#define TP_MASK_MB 0x01
93#define TP_TOGGLE_EXT_DEV 0x23 /* Disable external device */
94#define TP_MASK_EXT_DEV 0x02
95#define TP_TOGGLE_DRIFT 0x23 /* Drift Correction */
96#define TP_MASK_DRIFT 0x80
97#define TP_TOGGLE_BURST 0x28 /* Burst Mode */
98#define TP_MASK_BURST 0x80
99#define TP_TOGGLE_PTSON 0x2C /* Press to Select */
100#define TP_MASK_PTSON 0x01
101#define TP_TOGGLE_HARD_TRANS 0x2C /* Alternate method to set Hard Transparency */
102#define TP_MASK_HARD_TRANS 0x80
103#define TP_TOGGLE_TWOHAND 0x2D /* Two handed */
104#define TP_MASK_TWOHAND 0x01
105#define TP_TOGGLE_STICKY_TWO 0x2D /* Sticky two handed */
106#define TP_MASK_STICKY_TWO 0x04
107#define TP_TOGGLE_SKIPBACK 0x2D /* Suppress movement after drag release */
108#define TP_MASK_SKIPBACK 0x08
109#define TP_TOGGLE_SOURCE_TAG 0x20 /* Bit 3 of the first packet will be set to
110 to the origin of the packet (external or TP) */
111#define TP_MASK_SOURCE_TAG 0x80
112#define TP_TOGGLE_EXT_TAG 0x22 /* Bit 3 of the first packet coming from the
113 external device will be forced to 1 */
114#define TP_MASK_EXT_TAG 0x04
115
116
117/* Power on Self Test Results */
118#define TP_POR_SUCCESS 0x3B
119
120/*
121 * Default power on values
122 */
123#define TP_DEF_SENS 0x80
124#define TP_DEF_INERTIA 0x06
125#define TP_DEF_SPEED 0x61
126#define TP_DEF_REACH 0x0A
127
128#define TP_DEF_DRAGHYS 0xFF
129#define TP_DEF_MINDRAG 0x14
130
131#define TP_DEF_THRESH 0x08
132#define TP_DEF_UP_THRESH 0xFF
133#define TP_DEF_Z_TIME 0x26
134#define TP_DEF_JENKS_CURV 0x87
135#define TP_DEF_DRIFT_TIME 0x05
136
137/* Toggles */
138#define TP_DEF_MB 0x00
139#define TP_DEF_PTSON 0x00
140#define TP_DEF_SKIPBACK 0x00
141#define TP_DEF_EXT_DEV 0x00 /* 0 means enabled */
142#define TP_DEF_TWOHAND 0x00
143#define TP_DEF_SOURCE_TAG 0x00
144
145#define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd))
146
147struct trackpoint_data {
148 u8 variant_id;
149 u8 firmware_id;
150
151 u8 sensitivity, speed, inertia, reach;
152 u8 draghys, mindrag;
153 u8 thresh, upthresh;
154 u8 ztime, jenks;
155 u8 drift_time;
156
157 /* toggles */
158 bool press_to_select;
159 bool skipback;
160 bool ext_dev;
161};
162
163#ifdef CONFIG_MOUSE_PS2_TRACKPOINT
164int trackpoint_detect(struct psmouse *psmouse, bool set_properties);
165#else
166static inline int trackpoint_detect(struct psmouse *psmouse,
167 bool set_properties)
168{
169 return -ENOSYS;
170}
171#endif /* CONFIG_MOUSE_PS2_TRACKPOINT */
172
173#endif /* _TRACKPOINT_H */