1b85037dbSmrg/* 2b85037dbSmrg * Permission to use, copy, modify, distribute, and sell this software 3b85037dbSmrg * and its documentation for any purpose is hereby granted without 4b85037dbSmrg * fee, provided that the above copyright notice appear in all copies 5b85037dbSmrg * and that both that copyright notice and this permission notice 6b85037dbSmrg * appear in supporting documentation, and that the name of Red Hat 7b85037dbSmrg * not be used in advertising or publicity pertaining to distribution 8b85037dbSmrg * of the software without specific, written prior permission. Red 9b85037dbSmrg * Hat makes no representations about the suitability of this software 10b85037dbSmrg * for any purpose. It is provided "as is" without express or implied 11b85037dbSmrg * warranty. 12b85037dbSmrg * 13b85037dbSmrg * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 14b85037dbSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 15b85037dbSmrg * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 16b85037dbSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 17b85037dbSmrg * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 18b85037dbSmrg * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 19b85037dbSmrg * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20b85037dbSmrg */ 21b85037dbSmrg 22b85037dbSmrg#ifndef _PS2COMM_H_ 23b85037dbSmrg#define _PS2COMM_H_ 24b85037dbSmrg 25b85037dbSmrg#include <unistd.h> 26b85037dbSmrg#include <sys/ioctl.h> 27b85037dbSmrg#include "xf86_OSproc.h" 28b85037dbSmrg 29b85037dbSmrg/* acknowledge for commands and parameter */ 3028515619Smrg#define PS2_ACK 0xFA 31b85037dbSmrg#define PS2_ERROR 0xFC 32b85037dbSmrg 33b85037dbSmrg/* standard PS/2 commands */ 34b85037dbSmrg#define PS2_CMD_RESET 0xFF 35b85037dbSmrg#define PS2_CMD_RESEND 0xFE 36b85037dbSmrg#define PS2_CMD_SET_DEFAULT 0xF6 37b85037dbSmrg#define PS2_CMD_DISABLE 0xF5 38b85037dbSmrg#define PS2_CMD_ENABLE 0xF4 39b85037dbSmrg#define PS2_CMD_SET_SAMPLE_RATE 0xF3 40b85037dbSmrg#define PS2_CMD_READ_DEVICE_TYPE 0xF2 41b85037dbSmrg#define PS2_CMD_SET_REMOTE_MODE 0xF0 42b85037dbSmrg#define PS2_CMD_SET_WRAP_MODE 0xEE 43b85037dbSmrg#define PS2_CMD_RESET_WRAP_MODE 0xEC 44b85037dbSmrg#define PS2_CMD_READ_DATA 0xEB 45b85037dbSmrg#define PS2_CMD_SET_STREAM_MODE 0xEA 46b85037dbSmrg#define PS2_CMD_STATUS_REQUEST 0xE9 47b85037dbSmrg#define PS2_CMD_SET_RESOLUTION 0xE8 48b85037dbSmrg#define PS2_CMD_SET_SCALING_2_1 0xE7 49b85037dbSmrg#define PS2_CMD_SET_SCALING_1_1 0xE6 50b85037dbSmrg 51b85037dbSmrg/* synaptics modes */ 52b85037dbSmrg#define SYN_BIT_ABSOLUTE_MODE (1 << 7) 53b85037dbSmrg#define SYN_BIT_HIGH_RATE (1 << 6) 54b85037dbSmrg#define SYN_BIT_SLEEP_MODE (1 << 3) 55b85037dbSmrg#define SYN_BIT_DISABLE_GESTURE (1 << 2) 56b85037dbSmrg#define SYN_BIT_W_MODE (1 << 0) 57b85037dbSmrg 58b85037dbSmrg/* synaptics model ID bits */ 5928515619Smrg#define SYN_MODEL_ROT180(synhw) ((synhw)->model_id & (1 << 23)) 60b85037dbSmrg#define SYN_MODEL_PORTRAIT(synhw) ((synhw)->model_id & (1 << 22)) 61b85037dbSmrg#define SYN_MODEL_SENSOR(synhw) (((synhw)->model_id >> 16) & 0x3f) 62b85037dbSmrg#define SYN_MODEL_HARDWARE(synhw) (((synhw)->model_id >> 9) & 0x7f) 63b85037dbSmrg#define SYN_MODEL_NEWABS(synhw) ((synhw)->model_id & (1 << 7)) 64b85037dbSmrg#define SYN_MODEL_PEN(synhw) ((synhw)->model_id & (1 << 6)) 65b85037dbSmrg#define SYN_MODEL_SIMPLIC(synhw) ((synhw)->model_id & (1 << 5)) 66b85037dbSmrg#define SYN_MODEL_GEOMETRY(synhw) ((synhw)->model_id & 0x0f) 67b85037dbSmrg 68b85037dbSmrg/* synaptics capability bits */ 69b85037dbSmrg#define SYN_CAP_EXTENDED(synhw) ((synhw)->capabilities & (1 << 23)) 70b85037dbSmrg#define SYN_CAP_MIDDLE_BUTTON(synhw) ((synhw)->capabilities & (1 << 18)) 71b85037dbSmrg#define SYN_CAP_PASSTHROUGH(synhw) ((synhw)->capabilities & (1 << 7)) 72b85037dbSmrg#define SYN_CAP_SLEEP(synhw) ((synhw)->capabilities & (1 << 4)) 73b85037dbSmrg#define SYN_CAP_FOUR_BUTTON(synhw) ((synhw)->capabilities & (1 << 3)) 74b85037dbSmrg#define SYN_CAP_MULTIFINGER(synhw) ((synhw)->capabilities & (1 << 1)) 75b85037dbSmrg#define SYN_CAP_PALMDETECT(synhw) ((synhw)->capabilities & (1 << 0)) 76b85037dbSmrg#define SYN_CAP_VALID(synhw) ((((synhw)->capabilities & 0x00ff00) >> 8) == 0x47) 7728515619Smrg#define SYN_EXT_CAP_REQUESTS(synhw) (((synhw)->capabilities & 0x700000) != 0) 78b85037dbSmrg#define SYN_CAP_MULTI_BUTTON_NO(synhw) (((synhw)->ext_cap & 0x00f000) >> 12) 79b85037dbSmrg 80b85037dbSmrg/* synaptics modes query bits */ 81b85037dbSmrg#define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7)) 82b85037dbSmrg#define SYN_MODE_RATE(m) ((m) & (1 << 6)) 83b85037dbSmrg#define SYN_MODE_BAUD_SLEEP(m) ((m) & (1 << 3)) 84b85037dbSmrg#define SYN_MODE_DISABLE_GESTURE(m) ((m) & (1 << 2)) 85b85037dbSmrg#define SYN_MODE_PACKSIZE(m) ((m) & (1 << 1)) 86b85037dbSmrg#define SYN_MODE_WMODE(m) ((m) & (1 << 0)) 87b85037dbSmrg#define SYN_MODE_VALID(m) (((m) & 0xffff00) == 0x3B47) 88b85037dbSmrg 89b85037dbSmrg/* synaptics identify query bits */ 90b85037dbSmrg#define SYN_ID_MODEL(synhw) (((synhw)->identity >> 4) & 0x0f) 91b85037dbSmrg#define SYN_ID_MAJOR(synhw) ((synhw)->identity & 0x0f) 92b85037dbSmrg#define SYN_ID_MINOR(synhw) (((synhw)->identity >> 16) & 0xff) 93b85037dbSmrg#define SYN_ID_IS_SYNAPTICS(synhw) ((((synhw)->identity >> 8) & 0xff) == 0x47) 94b85037dbSmrg 95b85037dbSmrgtypedef unsigned char byte; 96b85037dbSmrg 9728515619Smrgstruct PS2SynapticsHwInfo { 9828515619Smrg unsigned int model_id; /* Model-ID */ 9928515619Smrg unsigned int capabilities; /* Capabilities */ 10028515619Smrg unsigned int ext_cap; /* Extended Capabilities */ 10128515619Smrg unsigned int identity; /* Identification */ 10228515619Smrg}; 103b85037dbSmrg 104b85037dbSmrgBool ps2_putbyte(int fd, byte b); 10528515619Smrgvoid ps2_print_ident(InputInfoPtr pInfo, 10628515619Smrg const struct PS2SynapticsHwInfo *synhw); 10728515619SmrgBool PS2ReadHwStateProto(InputInfoPtr pInfo, 10828515619Smrg struct SynapticsProtocolOperations *proto_ops, 10928515619Smrg struct CommData *comm, struct SynapticsHwState *hwRet); 110b85037dbSmrg 11128515619Smrg#endif /* _PS2COMM_H_ */ 112