Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Synaptics TouchPad PS/2 mouse driver
0004  */
0005 
0006 #ifndef _SYNAPTICS_H
0007 #define _SYNAPTICS_H
0008 
0009 /* synaptics queries */
0010 #define SYN_QUE_IDENTIFY        0x00
0011 #define SYN_QUE_MODES           0x01
0012 #define SYN_QUE_CAPABILITIES        0x02
0013 #define SYN_QUE_MODEL           0x03
0014 #define SYN_QUE_SERIAL_NUMBER_PREFIX    0x06
0015 #define SYN_QUE_SERIAL_NUMBER_SUFFIX    0x07
0016 #define SYN_QUE_RESOLUTION      0x08
0017 #define SYN_QUE_EXT_CAPAB       0x09
0018 #define SYN_QUE_FIRMWARE_ID     0x0a
0019 #define SYN_QUE_EXT_CAPAB_0C        0x0c
0020 #define SYN_QUE_EXT_MAX_COORDS      0x0d
0021 #define SYN_QUE_EXT_MIN_COORDS      0x0f
0022 #define SYN_QUE_MEXT_CAPAB_10       0x10
0023 
0024 /* synatics modes */
0025 #define SYN_BIT_ABSOLUTE_MODE       BIT(7)
0026 #define SYN_BIT_HIGH_RATE       BIT(6)
0027 #define SYN_BIT_SLEEP_MODE      BIT(3)
0028 #define SYN_BIT_DISABLE_GESTURE     BIT(2)
0029 #define SYN_BIT_FOUR_BYTE_CLIENT    BIT(1)
0030 #define SYN_BIT_W_MODE          BIT(0)
0031 
0032 /* synaptics model ID bits */
0033 #define SYN_MODEL_ROT180(m)     ((m) & BIT(23))
0034 #define SYN_MODEL_PORTRAIT(m)       ((m) & BIT(22))
0035 #define SYN_MODEL_SENSOR(m)     (((m) & GENMASK(21, 16)) >> 16)
0036 #define SYN_MODEL_HARDWARE(m)       (((m) & GENMASK(15, 9)) >> 9)
0037 #define SYN_MODEL_NEWABS(m)     ((m) & BIT(7))
0038 #define SYN_MODEL_PEN(m)        ((m) & BIT(6))
0039 #define SYN_MODEL_SIMPLIC(m)        ((m) & BIT(5))
0040 #define SYN_MODEL_GEOMETRY(m)       ((m) & GENMASK(3, 0))
0041 
0042 /* synaptics capability bits */
0043 #define SYN_CAP_EXTENDED(c)     ((c) & BIT(23))
0044 #define SYN_CAP_MIDDLE_BUTTON(c)    ((c) & BIT(18))
0045 #define SYN_CAP_PASS_THROUGH(c)     ((c) & BIT(7))
0046 #define SYN_CAP_SLEEP(c)        ((c) & BIT(4))
0047 #define SYN_CAP_FOUR_BUTTON(c)      ((c) & BIT(3))
0048 #define SYN_CAP_MULTIFINGER(c)      ((c) & BIT(1))
0049 #define SYN_CAP_PALMDETECT(c)       ((c) & BIT(0))
0050 #define SYN_CAP_SUBMODEL_ID(c)      (((c) & GENMASK(15, 8)) >> 8)
0051 #define SYN_EXT_CAP_REQUESTS(c)     (((c) & GENMASK(22, 20)) >> 20)
0052 #define SYN_CAP_MB_MASK         GENMASK(15, 12)
0053 #define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & SYN_CAP_MB_MASK) >> 12)
0054 #define SYN_CAP_PRODUCT_ID(ec)      (((ec) & GENMASK(23, 16)) >> 16)
0055 #define SYN_MEXT_CAP_BIT(m)     ((m) & BIT(1))
0056 
0057 /*
0058  * The following describes response for the 0x0c query.
0059  *
0060  * byte mask    name            meaning
0061  * ---- ----    -------         ------------
0062  * 1    0x01    adjustable threshold    capacitive button sensitivity
0063  *                  can be adjusted
0064  * 1    0x02    report max      query 0x0d gives max coord reported
0065  * 1    0x04    clearpad        sensor is ClearPad product
0066  * 1    0x08    advanced gesture    not particularly meaningful
0067  * 1    0x10    clickpad bit 0      1-button ClickPad
0068  * 1    0x60    multifinger mode    identifies firmware finger counting
0069  *                  (not reporting!) algorithm.
0070  *                  Not particularly meaningful
0071  * 1    0x80    covered pad     W clipped to 14, 15 == pad mostly covered
0072  * 2    0x01    clickpad bit 1      2-button ClickPad
0073  * 2    0x02    deluxe LED controls touchpad support LED commands
0074  *                  ala multimedia control bar
0075  * 2    0x04    reduced filtering   firmware does less filtering on
0076  *                  position data, driver should watch
0077  *                  for noise.
0078  * 2    0x08    image sensor        image sensor tracks 5 fingers, but only
0079  *                  reports 2.
0080  * 2    0x01    uniform clickpad    whole clickpad moves instead of being
0081  *                  hinged at the top.
0082  * 2    0x20    report min      query 0x0f gives min coord reported
0083  */
0084 #define SYN_CAP_CLICKPAD(ex0c)      ((ex0c) & BIT(20)) /* 1-button ClickPad */
0085 #define SYN_CAP_CLICKPAD2BTN(ex0c)  ((ex0c) & BIT(8))  /* 2-button ClickPad */
0086 #define SYN_CAP_MAX_DIMENSIONS(ex0c)    ((ex0c) & BIT(17))
0087 #define SYN_CAP_MIN_DIMENSIONS(ex0c)    ((ex0c) & BIT(13))
0088 #define SYN_CAP_ADV_GESTURE(ex0c)   ((ex0c) & BIT(19))
0089 #define SYN_CAP_REDUCED_FILTERING(ex0c) ((ex0c) & BIT(10))
0090 #define SYN_CAP_IMAGE_SENSOR(ex0c)  ((ex0c) & BIT(11))
0091 #define SYN_CAP_INTERTOUCH(ex0c)    ((ex0c) & BIT(14))
0092 
0093 /*
0094  * The following descibes response for the 0x10 query.
0095  *
0096  * byte mask    name            meaning
0097  * ---- ----    -------         ------------
0098  * 1    0x01    ext buttons are stick   buttons exported in the extended
0099  *                  capability are actually meant to be used
0100  *                  by the tracktick (pass-through).
0101  * 1    0x02    SecurePad       the touchpad is a SecurePad, so it
0102  *                  contains a built-in fingerprint reader.
0103  * 1    0xe0    more ext count      how many more extented queries are
0104  *                  available after this one.
0105  * 2    0xff    SecurePad width     the width of the SecurePad fingerprint
0106  *                  reader.
0107  * 3    0xff    SecurePad height    the height of the SecurePad fingerprint
0108  *                  reader.
0109  */
0110 #define SYN_CAP_EXT_BUTTONS_STICK(ex10) ((ex10) & BIT(16))
0111 #define SYN_CAP_SECUREPAD(ex10)     ((ex10) & BIT(17))
0112 
0113 #define SYN_EXT_BUTTON_STICK_L(eb)  (((eb) & BIT(0)) >> 0)
0114 #define SYN_EXT_BUTTON_STICK_M(eb)  (((eb) & BIT(1)) >> 1)
0115 #define SYN_EXT_BUTTON_STICK_R(eb)  (((eb) & BIT(2)) >> 2)
0116 
0117 /* synaptics modes query bits */
0118 #define SYN_MODE_ABSOLUTE(m)        ((m) & BIT(7))
0119 #define SYN_MODE_RATE(m)        ((m) & BIT(6))
0120 #define SYN_MODE_BAUD_SLEEP(m)      ((m) & BIT(3))
0121 #define SYN_MODE_DISABLE_GESTURE(m) ((m) & BIT(2))
0122 #define SYN_MODE_PACKSIZE(m)        ((m) & BIT(1))
0123 #define SYN_MODE_WMODE(m)       ((m) & BIT(0))
0124 
0125 /* synaptics identify query bits */
0126 #define SYN_ID_MODEL(i)         (((i) & GENMASK(7, 4)) >> 4)
0127 #define SYN_ID_MAJOR(i)         (((i) & GENMASK(3, 0)) >> 0)
0128 #define SYN_ID_MINOR(i)         (((i) & GENMASK(23, 16)) >> 16)
0129 #define SYN_ID_FULL(i)          ((SYN_ID_MAJOR(i) << 8) | SYN_ID_MINOR(i))
0130 #define SYN_ID_IS_SYNAPTICS(i)      (((i) & GENMASK(15, 8)) == 0x004700U)
0131 #define SYN_ID_DISGEST_SUPPORTED(i) (SYN_ID_MAJOR(i) >= 4)
0132 
0133 /* synaptics special commands */
0134 #define SYN_PS_SET_MODE2        0x14
0135 #define SYN_PS_CLIENT_CMD       0x28
0136 
0137 /* amount to fuzz position data when touchpad reports reduced filtering */
0138 #define SYN_REDUCED_FILTER_FUZZ     8
0139 
0140 /* synaptics packet types */
0141 enum synaptics_pkt_type {
0142     SYN_NEWABS,
0143     SYN_NEWABS_STRICT,
0144     SYN_NEWABS_RELAXED,
0145     SYN_OLDABS,
0146 };
0147 
0148 /*
0149  * A structure to describe the state of the touchpad hardware (buttons and pad)
0150  */
0151 struct synaptics_hw_state {
0152     int x;
0153     int y;
0154     int z;
0155     int w;
0156     unsigned int left:1;
0157     unsigned int right:1;
0158     unsigned int middle:1;
0159     unsigned int up:1;
0160     unsigned int down:1;
0161     u8 ext_buttons;
0162     s8 scroll;
0163 };
0164 
0165 /* Data read from the touchpad */
0166 struct synaptics_device_info {
0167     u32 model_id;       /* Model-ID */
0168     u32 firmware_id;    /* Firmware-ID */
0169     u32 board_id;       /* Board-ID */
0170     u32 capabilities;   /* Capabilities */
0171     u32 ext_cap;        /* Extended Capabilities */
0172     u32 ext_cap_0c;     /* Ext Caps from 0x0c query */
0173     u32 ext_cap_10;     /* Ext Caps from 0x10 query */
0174     u32 identity;       /* Identification */
0175     u32 x_res, y_res;   /* X/Y resolution in units/mm */
0176     u32 x_max, y_max;   /* Max coordinates (from FW) */
0177     u32 x_min, y_min;   /* Min coordinates (from FW) */
0178 };
0179 
0180 struct synaptics_data {
0181     struct synaptics_device_info info;
0182 
0183     enum synaptics_pkt_type pkt_type;   /* packet type - old, new, etc */
0184     u8 mode;                /* current mode byte */
0185     int scroll;
0186 
0187     bool absolute_mode;         /* run in Absolute mode */
0188     bool disable_gesture;           /* disable gestures */
0189 
0190     struct serio *pt_port;          /* Pass-through serio port */
0191 
0192     /*
0193      * Last received Advanced Gesture Mode (AGM) packet. An AGM packet
0194      * contains position data for a second contact, at half resolution.
0195      */
0196     struct synaptics_hw_state agm;
0197     unsigned int agm_count;         /* finger count reported by agm */
0198 
0199     /* ForcePad handling */
0200     unsigned long               press_start;
0201     bool                    press;
0202     bool                    report_press;
0203     bool                    is_forcepad;
0204 };
0205 
0206 void synaptics_module_init(void);
0207 int synaptics_detect(struct psmouse *psmouse, bool set_properties);
0208 int synaptics_init_absolute(struct psmouse *psmouse);
0209 int synaptics_init_relative(struct psmouse *psmouse);
0210 int synaptics_init_smbus(struct psmouse *psmouse);
0211 int synaptics_init(struct psmouse *psmouse);
0212 void synaptics_reset(struct psmouse *psmouse);
0213 
0214 #endif /* _SYNAPTICS_H */