Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * IBM TrackPoint PS/2 mouse driver
0004  *
0005  * Stephen Evanchik <evanchsa@gmail.com>
0006  */
0007 
0008 #ifndef _TRACKPOINT_H
0009 #define _TRACKPOINT_H
0010 
0011 /*
0012  * These constants are from the TrackPoint System
0013  * Engineering documentation Version 4 from IBM Watson
0014  * research:
0015  *  http://wwwcssrv.almaden.ibm.com/trackpoint/download.html
0016  */
0017 
0018 #define TP_COMMAND      0xE2    /* Commands start with this */
0019 
0020 #define TP_READ_ID      0xE1    /* Sent for device identification */
0021 
0022 /*
0023  * Valid first byte responses to the "Read Secondary ID" (0xE1) command.
0024  * 0x01 was the original IBM trackpoint, others implement very limited
0025  * subset of trackpoint features.
0026  */
0027 #define TP_VARIANT_IBM          0x01
0028 #define TP_VARIANT_ALPS         0x02
0029 #define TP_VARIANT_ELAN         0x03
0030 #define TP_VARIANT_NXP          0x04
0031 #define TP_VARIANT_JYT_SYNAPTICS    0x05
0032 #define TP_VARIANT_SYNAPTICS        0x06
0033 
0034 /*
0035  * Commands
0036  */
0037 #define TP_RECALIB      0x51    /* Recalibrate */
0038 #define TP_POWER_DOWN       0x44    /* Can only be undone through HW reset */
0039 #define TP_EXT_DEV      0x21    /* Determines if external device is connected (RO) */
0040 #define TP_EXT_BTN      0x4B    /* Read extended button status */
0041 #define TP_POR          0x7F    /* Execute Power on Reset */
0042 #define TP_POR_RESULTS      0x25    /* Read Power on Self test results */
0043 #define TP_DISABLE_EXT      0x40    /* Disable external pointing device */
0044 #define TP_ENABLE_EXT       0x41    /* Enable external pointing device */
0045 
0046 /*
0047  * Mode manipulation
0048  */
0049 #define TP_SET_SOFT_TRANS   0x4E    /* Set mode */
0050 #define TP_CANCEL_SOFT_TRANS    0xB9    /* Cancel mode */
0051 #define TP_SET_HARD_TRANS   0x45    /* Mode can only be set */
0052 
0053 
0054 /*
0055  * Register oriented commands/properties
0056  */
0057 #define TP_WRITE_MEM        0x81
0058 #define TP_READ_MEM     0x80    /* Not used in this implementation */
0059 
0060 /*
0061 * RAM Locations for properties
0062  */
0063 #define TP_SENS         0x4A    /* Sensitivity */
0064 #define TP_MB           0x4C    /* Read Middle Button Status (RO) */
0065 #define TP_INERTIA      0x4D    /* Negative Inertia */
0066 #define TP_SPEED        0x60    /* Speed of TP Cursor */
0067 #define TP_REACH        0x57    /* Backup for Z-axis press */
0068 #define TP_DRAGHYS      0x58    /* Drag Hysteresis */
0069                     /* (how hard it is to drag */
0070                     /* with Z-axis pressed) */
0071 
0072 #define TP_MINDRAG      0x59    /* Minimum amount of force needed */
0073                     /* to trigger dragging */
0074 
0075 #define TP_THRESH       0x5C    /* Minimum value for a Z-axis press */
0076 #define TP_UP_THRESH        0x5A    /* Used to generate a 'click' on Z-axis */
0077 #define TP_Z_TIME       0x5E    /* How sharp of a press */
0078 #define TP_JENKS_CURV       0x5D    /* Minimum curvature for double click */
0079 #define TP_DRIFT_TIME       0x5F    /* How long a 'hands off' condition */
0080                     /* must last (x*107ms) for drift */
0081                     /* correction to occur */
0082 
0083 /*
0084  * Toggling Flag bits
0085  */
0086 #define TP_TOGGLE       0x47    /* Toggle command */
0087 
0088 #define TP_TOGGLE_MB        0x23    /* Disable/Enable Middle Button */
0089 #define TP_MASK_MB          0x01
0090 #define TP_TOGGLE_EXT_DEV   0x23    /* Disable external device */
0091 #define TP_MASK_EXT_DEV         0x02
0092 #define TP_TOGGLE_DRIFT     0x23    /* Drift Correction */
0093 #define TP_MASK_DRIFT           0x80
0094 #define TP_TOGGLE_BURST     0x28    /* Burst Mode */
0095 #define TP_MASK_BURST           0x80
0096 #define TP_TOGGLE_PTSON     0x2C    /* Press to Select */
0097 #define TP_MASK_PTSON           0x01
0098 #define TP_TOGGLE_HARD_TRANS    0x2C    /* Alternate method to set Hard Transparency */
0099 #define TP_MASK_HARD_TRANS      0x80
0100 #define TP_TOGGLE_TWOHAND   0x2D    /* Two handed */
0101 #define TP_MASK_TWOHAND         0x01
0102 #define TP_TOGGLE_STICKY_TWO    0x2D    /* Sticky two handed */
0103 #define TP_MASK_STICKY_TWO      0x04
0104 #define TP_TOGGLE_SKIPBACK  0x2D    /* Suppress movement after drag release */
0105 #define TP_MASK_SKIPBACK        0x08
0106 #define TP_TOGGLE_SOURCE_TAG    0x20    /* Bit 3 of the first packet will be set to
0107                        to the origin of the packet (external or TP) */
0108 #define TP_MASK_SOURCE_TAG      0x80
0109 #define TP_TOGGLE_EXT_TAG   0x22    /* Bit 3 of the first packet coming from the
0110                        external device will be forced to 1 */
0111 #define TP_MASK_EXT_TAG         0x04
0112 
0113 
0114 /* Power on Self Test Results */
0115 #define TP_POR_SUCCESS      0x3B
0116 
0117 /*
0118  * Default power on values
0119  */
0120 #define TP_DEF_SENS     0x80
0121 #define TP_DEF_INERTIA      0x06
0122 #define TP_DEF_SPEED        0x61
0123 #define TP_DEF_REACH        0x0A
0124 
0125 #define TP_DEF_DRAGHYS      0xFF
0126 #define TP_DEF_MINDRAG      0x14
0127 
0128 #define TP_DEF_THRESH       0x08
0129 #define TP_DEF_UP_THRESH    0xFF
0130 #define TP_DEF_Z_TIME       0x26
0131 #define TP_DEF_JENKS_CURV   0x87
0132 #define TP_DEF_DRIFT_TIME   0x05
0133 
0134 /* Toggles */
0135 #define TP_DEF_MB       0x00
0136 #define TP_DEF_PTSON        0x00
0137 #define TP_DEF_SKIPBACK     0x00
0138 #define TP_DEF_EXT_DEV      0x00    /* 0 means enabled */
0139 #define TP_DEF_TWOHAND      0x00
0140 #define TP_DEF_SOURCE_TAG   0x00
0141 
0142 #define MAKE_PS2_CMD(params, results, cmd) ((params<<12) | (results<<8) | (cmd))
0143 
0144 struct trackpoint_data {
0145     u8 variant_id;
0146     u8 firmware_id;
0147 
0148     u8 sensitivity, speed, inertia, reach;
0149     u8 draghys, mindrag;
0150     u8 thresh, upthresh;
0151     u8 ztime, jenks;
0152     u8 drift_time;
0153 
0154     /* toggles */
0155     bool press_to_select;
0156     bool skipback;
0157     bool ext_dev;
0158 };
0159 
0160 int trackpoint_detect(struct psmouse *psmouse, bool set_properties);
0161 
0162 #endif /* _TRACKPOINT_H */