Skip to content

Commit d91abc2

Browse files
palidtor
authored andcommitted
Input: alps - demystify trackstick initialization for v3 and v6 protocols
Remove cite "Not sure what this does, but it is absolutely essential". Extract initialization of trackstick part when touchpad is in passthrough mode for v3 and v6 protocols into own function. Initialization for v3 is: setscale11, setscale11, setscale11, nibble 0x9, nibble 0x4. Initialization for v6 is: setscale11, setscale11, setscale11, setrate 0xC8, setrate 0x14. Nibbles 0x9 and 0x4 for v3 protocol correspond to setrate 0xC8 and 0x14, therefore these sequences are same. When touchpad is in passthrough mode, then OS communicates with trackstick and this sequence is some magic vendor PS/2 command to put trackstick into "extended" mode. After that sequence trackstick starts reporting packets in some vendor 4 bytes format (first byte is always 0xE8). Next step after configuring trackstick to be in "extended" mode, is to configure touchpad for v3 protocol to expect that trackstick reports data in "extended" mode. For v3 protocol this is done by setting bit 1 in register 0xC2C8 (offset 0x08 from base address 0xC2C0). When both touchpad and trackstick are not configured for "extended" mode then touchpad reports trackstick packets in different format, which is not supported by psmouse/alps driver (yet). In Cirque documentation GP-AN- 130823 INTERFACING TO GEN4 OVER I2C (PDF) available at http://www.cirque.com/gen4-dev-resources is Logical Address 0xC2C8 named as PS2AuxControl and Bit Number 1 as ProcessAuxExtendedData with description: Auxiliary device data is assumed to be extended data when set. Signed-off-by: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 57eb13a commit d91abc2

1 file changed

Lines changed: 49 additions & 31 deletions

File tree

‎drivers/input/mouse/alps.c‎

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,24 +2049,37 @@ static int alps_hw_init_v1_v2(struct psmouse *psmouse)
20492049
return 0;
20502050
}
20512051

2052-
static int alps_hw_init_v6(struct psmouse *psmouse)
2052+
/* Must be in passthrough mode when calling this function */
2053+
static int alps_trackstick_enter_extended_mode_v3_v6(struct psmouse *psmouse)
20532054
{
20542055
unsigned char param[2] = {0xC8, 0x14};
20552056

2056-
/* Enter passthrough mode to let trackpoint enter 6byte raw mode */
2057-
if (alps_passthrough_mode_v2(psmouse, true))
2058-
return -1;
2059-
20602057
if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
20612058
ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
20622059
ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
20632060
ps2_command(&psmouse->ps2dev, &param[0], PSMOUSE_CMD_SETRATE) ||
20642061
ps2_command(&psmouse->ps2dev, &param[1], PSMOUSE_CMD_SETRATE))
20652062
return -1;
20662063

2064+
return 0;
2065+
}
2066+
2067+
static int alps_hw_init_v6(struct psmouse *psmouse)
2068+
{
2069+
int ret;
2070+
2071+
/* Enter passthrough mode to let trackpoint enter 6byte raw mode */
2072+
if (alps_passthrough_mode_v2(psmouse, true))
2073+
return -1;
2074+
2075+
ret = alps_trackstick_enter_extended_mode_v3_v6(psmouse);
2076+
20672077
if (alps_passthrough_mode_v2(psmouse, false))
20682078
return -1;
20692079

2080+
if (ret)
2081+
return ret;
2082+
20702083
if (alps_absolute_mode_v6(psmouse)) {
20712084
psmouse_err(psmouse, "Failed to enable absolute mode\n");
20722085
return -1;
@@ -2140,10 +2153,18 @@ static int alps_probe_trackstick_v3_v7(struct psmouse *psmouse, int reg_base)
21402153

21412154
static int alps_setup_trackstick_v3(struct psmouse *psmouse, int reg_base)
21422155
{
2143-
struct ps2dev *ps2dev = &psmouse->ps2dev;
21442156
int ret = 0;
2157+
int reg_val;
21452158
unsigned char param[4];
21462159

2160+
/*
2161+
* We need to configure trackstick to report data for touchpad in
2162+
* extended format. And also we need to tell touchpad to expect data
2163+
* from trackstick in extended format. Without this configuration
2164+
* trackstick packets sent from touchpad are in basic format which is
2165+
* different from what we expect.
2166+
*/
2167+
21472168
if (alps_passthrough_mode_v3(psmouse, reg_base, true))
21482169
return -EIO;
21492170

@@ -2161,39 +2182,36 @@ static int alps_setup_trackstick_v3(struct psmouse *psmouse, int reg_base)
21612182
ret = -ENODEV;
21622183
} else {
21632184
psmouse_dbg(psmouse, "trackstick E7 report: %3ph\n", param);
2164-
2165-
/*
2166-
* Not sure what this does, but it is absolutely
2167-
* essential. Without it, the touchpad does not
2168-
* work at all and the trackstick just emits normal
2169-
* PS/2 packets.
2170-
*/
2171-
if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
2172-
ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
2173-
ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
2174-
alps_command_mode_send_nibble(psmouse, 0x9) ||
2175-
alps_command_mode_send_nibble(psmouse, 0x4)) {
2176-
psmouse_err(psmouse,
2177-
"Error sending magic E6 sequence\n");
2185+
if (alps_trackstick_enter_extended_mode_v3_v6(psmouse)) {
2186+
psmouse_err(psmouse, "Failed to enter into trackstick extended mode\n");
21782187
ret = -EIO;
2179-
goto error;
21802188
}
2189+
}
2190+
2191+
if (alps_passthrough_mode_v3(psmouse, reg_base, false))
2192+
return -EIO;
2193+
2194+
if (ret)
2195+
return ret;
21812196

2197+
if (alps_enter_command_mode(psmouse))
2198+
return -EIO;
2199+
2200+
reg_val = alps_command_mode_read_reg(psmouse, reg_base + 0x08);
2201+
if (reg_val == -1) {
2202+
ret = -EIO;
2203+
} else {
21822204
/*
2183-
* This ensures the trackstick packets are in the format
2184-
* supported by this driver. If bit 1 isn't set the packet
2185-
* format is different.
2205+
* Tell touchpad that trackstick is now in extended mode.
2206+
* If bit 1 isn't set the packet format is different.
21862207
*/
2187-
if (alps_enter_command_mode(psmouse) ||
2188-
alps_command_mode_write_reg(psmouse,
2189-
reg_base + 0x08, 0x82) ||
2190-
alps_exit_command_mode(psmouse))
2208+
reg_val |= BIT(1);
2209+
if (__alps_command_mode_write_reg(psmouse, reg_val))
21912210
ret = -EIO;
21922211
}
21932212

2194-
error:
2195-
if (alps_passthrough_mode_v3(psmouse, reg_base, false))
2196-
ret = -EIO;
2213+
if (alps_exit_command_mode(psmouse))
2214+
return -EIO;
21972215

21982216
return ret;
21992217
}

0 commit comments

Comments
 (0)