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