1 /* $OpenBSD: pmsreg.h,v 1.18 2020/03/18 22:38:10 bru Exp $ */ 2 /* $NetBSD: psmreg.h,v 1.1 1998/03/22 15:41:28 drochner Exp $ */ 3 4 #ifndef SYS_DEV_PCKBC_PMSREG_H 5 #define SYS_DEV_PCKBC_PMSREG_H 6 7 /* mouse commands */ 8 #define PMS_SET_SCALE11 0xe6 /* set scaling 1:1 */ 9 #define PMS_SET_SCALE21 0xe7 /* set scaling 2:1 */ 10 #define PMS_SET_RES 0xe8 /* set resolution (0..3) */ 11 #define PMS_SEND_DEV_STATUS 0xe9 /* status request */ 12 #define PMS_SET_STREAM_MODE 0xea 13 #define PMS_SEND_DEV_DATA 0xeb /* read data */ 14 #define PMS_RESET_WRAP_MODE 0xec 15 #define PMS_SET_WRAP_MODE 0xed 16 #define PMS_SET_REMOTE_MODE 0xf0 17 #define PMS_SEND_DEV_ID 0xf2 /* read device type */ 18 #define PMS_SET_SAMPLE 0xf3 /* set sampling rate */ 19 #define PMS_DEV_ENABLE 0xf4 /* mouse on */ 20 #define PMS_DEV_DISABLE 0xf5 /* mouse off */ 21 #define PMS_SET_DEFAULTS 0xf6 22 #define PMS_RESEND 0xfe 23 #define PMS_RESET 0xff /* reset */ 24 25 #define PMS_RSTDONE 0xaa 26 27 /* PS/2 mouse data packet */ 28 #define PMS_PS2_BUTTONSMASK 0x07 29 #define PMS_PS2_BUTTON1 0x01 /* left */ 30 #define PMS_PS2_BUTTON2 0x04 /* middle */ 31 #define PMS_PS2_BUTTON3 0x02 /* right */ 32 #define PMS_PS2_XNEG 0x10 33 #define PMS_PS2_YNEG 0x20 34 35 #define PMS_INTELLI_MAGIC1 200 36 #define PMS_INTELLI_MAGIC2 100 37 #define PMS_INTELLI_MAGIC3 80 38 #define PMS_INTELLI_ID 0x03 39 40 #define PMS_ALPS_MAGIC1 0 41 #define PMS_ALPS_MAGIC2 0 42 #define PMS_ALPS_MAGIC3_1 10 43 #define PMS_ALPS_MAGIC3_2 80 44 #define PMS_ALPS_MAGIC3_3 100 45 46 #define PMS_ELANTECH_MAGIC1 0x3c 47 #define PMS_ELANTECH_MAGIC2 0x03 48 #define PMS_ELANTECH_MAGIC3_1 0xc8 49 #define PMS_ELANTECH_MAGIC3_2 0x00 50 51 /* 52 * Checking for almost-standard PS/2 packet 53 * Note: ALPS devices never signal overflow condition 54 */ 55 #define PMS_ALPS_PS2_MASK 0xc8 56 #define PMS_ALPS_PS2_VALID 0x08 57 58 /* Checking for interleaved packet */ 59 #define PMS_ALPS_INTERLEAVED_MASK 0xcf 60 #define PMS_ALPS_INTERLEAVED_VALID 0x0f 61 62 /* Checking for non first byte */ 63 #define PMS_ALPS_MASK 0x80 64 #define PMS_ALPS_VALID 0x00 65 66 /* Synaptics queries */ 67 #define SYNAPTICS_QUE_IDENTIFY 0x00 68 #define SYNAPTICS_QUE_MODES 0x01 69 #define SYNAPTICS_QUE_CAPABILITIES 0x02 70 #define SYNAPTICS_QUE_MODEL 0x03 71 #define SYNAPTICS_QUE_SERIAL_NUMBER_PREFIX 0x06 72 #define SYNAPTICS_QUE_SERIAL_NUMBER_SUFFIX 0x07 73 #define SYNAPTICS_QUE_RESOLUTION 0x08 74 #define SYNAPTICS_QUE_EXT_MODEL 0x09 75 #define SYNAPTICS_QUE_EXT_CAPABILITIES 0x0c 76 #define SYNAPTICS_QUE_EXT_MAX_COORDS 0x0d 77 #define SYNAPTICS_QUE_EXT_MIN_COORDS 0x0f 78 #define SYNAPTICS_QUE_EXT2_CAPABILITIES 0x10 79 80 #define SYNAPTICS_CMD_SET_MODE 0x14 81 #define SYNAPTICS_CMD_SEND_CLIENT 0x28 82 #define SYNAPTICS_CMD_SET_ADV_GESTURE_MODE 0xc8 83 84 /* Identify */ 85 #define SYNAPTICS_ID_MODEL(id) (((id) >> 4) & 0x0f) 86 #define SYNAPTICS_ID_MINOR(id) (((id) >> 16) & 0xff) 87 #define SYNAPTICS_ID_MAJOR(id) ((id) & 0x0f) 88 #define SYNAPTICS_ID_FULL(id) \ 89 (SYNAPTICS_ID_MAJOR(id) << 8 | SYNAPTICS_ID_MINOR(id)) 90 #define SYNAPTICS_ID_MAGIC 0x47 91 92 /* Modes bits */ 93 #define SYNAPTICS_EXT2_CAP (1 << 17) 94 #define SYNAPTICS_ABSOLUTE_MODE (1 << 7) 95 #define SYNAPTICS_HIGH_RATE (1 << 6) 96 #define SYNAPTICS_SLEEP_MODE (1 << 3) 97 #define SYNAPTICS_DISABLE_GESTURE (1 << 2) 98 #define SYNAPTICS_FOUR_BYTE_CLIENT (1 << 1) 99 #define SYNAPTICS_W_MODE (1 << 0) 100 101 /* Capability bits */ 102 #define SYNAPTICS_CAP_EXTENDED (1 << 23) 103 #define SYNAPTICS_CAP_EXTENDED_QUERIES(c) (((c) >> 20) & 0x07) 104 #define SYNAPTICS_CAP_MIDDLE_BUTTON (1 << 18) 105 #define SYNAPTICS_CAP_PASSTHROUGH (1 << 7) 106 #define SYNAPTICS_CAP_SLEEP (1 << 4) 107 #define SYNAPTICS_CAP_FOUR_BUTTON (1 << 3) 108 #define SYNAPTICS_CAP_BALLISTICS (1 << 2) 109 #define SYNAPTICS_CAP_MULTIFINGER (1 << 1) 110 #define SYNAPTICS_CAP_PALMDETECT (1 << 0) 111 112 /* Model ID bits */ 113 #define SYNAPTICS_MODEL_ROT180 (1 << 23) 114 #define SYNAPTICS_MODEL_PORTRAIT (1 << 22) 115 #define SYNAPTICS_MODEL_SENSOR(m) (((m) >> 16) & 0x3f) 116 #define SYNAPTICS_MODEL_HARDWARE(m) (((m) >> 9) & 0x7f) 117 #define SYNAPTICS_MODEL_NEWABS (1 << 7) 118 #define SYNAPTICS_MODEL_PEN (1 << 6) 119 #define SYNAPTICS_MODEL_SIMPLC (1 << 5) 120 #define SYNAPTICS_MODEL_GEOMETRY(m) ((m) & 0x0f) 121 122 /* Resolutions */ 123 #define SYNAPTICS_RESOLUTION_VALID (1 << 15) 124 #define SYNAPTICS_RESOLUTION_X(r) (((r) >> 16) & 0xff) 125 #define SYNAPTICS_RESOLUTION_Y(r) ((r) & 0xff) 126 127 /* Extended Model ID bits */ 128 #define SYNAPTICS_EXT_MODEL_LIGHTCONTROL (1 << 22) 129 #define SYNAPTICS_EXT_MODEL_PEAKDETECT (1 << 21) 130 #define SYNAPTICS_EXT_MODEL_VWHEEL (1 << 19) 131 #define SYNAPTICS_EXT_MODEL_EW_MODE (1 << 18) 132 #define SYNAPTICS_EXT_MODEL_HSCROLL (1 << 17) 133 #define SYNAPTICS_EXT_MODEL_VSCROLL (1 << 16) 134 #define SYNAPTICS_EXT_MODEL_BUTTONS(em) ((em >> 12) & 0x0f) 135 #define SYNAPTICS_EXT_MODEL_SENSOR(em) ((em >> 10) & 0x03) 136 #define SYNAPTICS_EXT_MODEL_PRODUCT(em) ((em) & 0xff) 137 138 /* Extended Capability bits */ 139 #define SYNAPTICS_EXT_CAP_CLICKPAD (1 << 20) 140 #define SYNAPTICS_EXT_CAP_ADV_GESTURE (1 << 19) 141 #define SYNAPTICS_EXT_CAP_MAX_COORDS (1 << 17) 142 #define SYNAPTICS_EXT_CAP_MIN_COORDS (1 << 13) 143 #define SYNAPTICS_EXT_CAP_REPORTS_V (1 << 11) 144 #define SYNAPTICS_EXT_CAP_CLICKPAD_2BTN (1 << 8) 145 146 #define SYNAPTICS_SUPPORTS_AGM(extcaps) ((extcaps) & \ 147 (SYNAPTICS_EXT_CAP_ADV_GESTURE | SYNAPTICS_EXT_CAP_REPORTS_V)) 148 149 /* Coordinate Limits */ 150 #define SYNAPTICS_X_LIMIT(d) ((((d) & 0xff0000) >> 11) | \ 151 (((d) & 0xf00) >> 7)) 152 #define SYNAPTICS_Y_LIMIT(d) ((((d) & 0xff) << 5) | \ 153 (((d) & 0xf000) >> 11)) 154 155 /* Extended Capability 2 */ 156 #define SYNAPTICS_EXT2_CAP_BUTTONS_STICK (1 << 16) 157 158 /* Typical bezel limit */ 159 #define SYNAPTICS_XMIN_BEZEL 1472 160 #define SYNAPTICS_XMAX_BEZEL 5472 161 #define SYNAPTICS_YMIN_BEZEL 1408 162 #define SYNAPTICS_YMAX_BEZEL 4448 163 164 #define ALPS_XMIN_BEZEL 0 165 #define ALPS_XMAX_BEZEL 1023 166 #define ALPS_YMIN_BEZEL 0 167 #define ALPS_YMAX_BEZEL 767 168 169 #define ALPS_XSEC_BEZEL 768 170 #define ALPS_YSEC_BEZEL 512 171 172 #define ALPS_Z_MAGIC 127 173 174 /* ALPS "gesture" and "finger" bits */ 175 #define ALPS_TAP 0x01 176 #define ALPS_DRAG 0x03 177 178 /* Elantech queries */ 179 #define ELANTECH_QUE_FW_ID 0 180 #define ELANTECH_QUE_FW_VER 1 181 #define ELANTECH_QUE_CAPABILITIES 2 182 #define ELANTECH_QUE_SAMPLE 3 183 #define ELANTECH_QUE_RESOLUTION 4 184 185 /* Elantech capabilities */ 186 #define ELANTECH_CAP_HAS_ROCKER 4 187 #define ELANTECH_CAP_TRACKPOINT 0x80 188 189 #define ELANTECH_PS2_CUSTOM_COMMAND 0xf8 190 191 #define ELANTECH_CMD_READ_REG 0x10 192 #define ELANTECH_CMD_WRITE_REG 0x11 193 #define ELANTECH_CMD_READ_WRITE_REG 0x00 194 195 #define ELANTECH_ABSOLUTE_MODE 0x04 196 197 /* Hardware version 1 has hard-coded axis range values. 198 * X axis range is 0 to 576, Y axis range is 0 to 384. 199 * Edge offset accounts for bezel around the touchpad. */ 200 #define ELANTECH_V1_EDGE_OFFSET 32 201 #define ELANTECH_V1_X_MIN (0 + ELANTECH_V1_EDGE_OFFSET) 202 #define ELANTECH_V1_X_MAX (576 - ELANTECH_V1_EDGE_OFFSET) 203 #define ELANTECH_V1_Y_MIN (0 + ELANTECH_V1_EDGE_OFFSET) 204 #define ELANTECH_V1_Y_MAX (384 - ELANTECH_V1_EDGE_OFFSET) 205 206 /* Older hardware version 2 variants lack ID query capability. */ 207 #define ELANTECH_V2_X_MAX 1152 208 #define ELANTECH_V2_Y_MAX 768 209 210 /* V4 */ 211 #define ELANTECH_MAX_FINGERS 5 212 #define ELANTECH_V4_WEIGHT_VALUE 5 213 214 #define ELANTECH_V4_PKT_STATUS 0 215 #define ELANTECH_V4_PKT_HEAD 0x01 216 #define ELANTECH_V4_PKT_MOTION 0x02 217 218 /* V3 and V4 may be coupled with trackpoints, pms supports them for V4. */ 219 #define ELANTECH_PKT_TRACKPOINT 0x06 220 221 #endif /* SYS_DEV_PCKBC_PMSREG_H */ 222