Received: by 10.213.65.68 with SMTP id h4csp29949imn; Mon, 12 Mar 2018 16:16:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELs/QoC/TN1QM52lLIyLOlwAUqLr7L4NVzHRQcJhLfonIanbj3nXCzTQCCQxvFjkmJlFNbXX X-Received: by 2002:a17:902:7c84:: with SMTP id y4-v6mr9821754pll.305.1520896560394; Mon, 12 Mar 2018 16:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520896560; cv=none; d=google.com; s=arc-20160816; b=h8cQHJV4bH1SEMaLp+CEYT7yb46DbvlBL04v0Wc3l2yPzO80pntn/RWaRcD2cNsZMa sihUxuTqKv0vQ9iO6ww5NTVy9tYjp4cpua4B9Tq5iEw3o/s16zSXyI+2AHTh2mji/el6 4dGSM9ue3avIVah3afg++9gIIOgwZhQ6MFRJkZsdAcGLMD2dONGx8NW2ptSmMKdwuy21 7M92w9TgCcsREtUR8g49nSLPH1g1Ppl91nNXIWH/dMCemLAN4AecGwVZq4HQyIkg4rds o0Uca5kVFwmr1Ry7qDR0bbRtLZzKmQ5zoValBd3Wmk0nvgLEXZuB8brKDy1abiC8P4D8 zV/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=j5zi0efyU2wM+QMh1Ie+xU2DoQi8KTTgF/9ktn95zdI=; b=HTHUSIXvYs+sno2il6MOAeQgXCFiuDzQrXHW8Y4hnRyvQka3MreGO8K/NyF88cYrYN jXr1xwYNmsBRw+d5vhWKGZ5FSKymOL6I4i8DPW7Kjtg+hMTcxmrJRLlcFviWdOb7FZRk IS2kT+ZU1djw4BL/2nQZjWO5KyrG7iHmZUvATHMGWQDOlJaCcMBBIOQ8BfKzaQJ05RoF lQJYNTbtDHL/16y6+Wu43q9FN8ZE9KOKQohYkMQFyf7OqqcutyDrdnCu40o0ZozXnmFu sVVLr3/IECKidyXPjRq9dYE06OTsLEdJqE+9uU9hiNP4huetuiNWZKwDhWfAsxIDxRkt NVNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sAfrGLqk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3-v6si6640791plb.4.2018.03.12.16.15.45; Mon, 12 Mar 2018 16:16:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sAfrGLqk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751616AbeCLXNk (ORCPT + 99 others); Mon, 12 Mar 2018 19:13:40 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:43257 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751327AbeCLXNi (ORCPT ); Mon, 12 Mar 2018 19:13:38 -0400 Received: by mail-wr0-f195.google.com with SMTP id o1so5688284wro.10; Mon, 12 Mar 2018 16:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=j5zi0efyU2wM+QMh1Ie+xU2DoQi8KTTgF/9ktn95zdI=; b=sAfrGLqkPYi2kdw7R8WkGgA5RX/zfP1/z71xaF22UkoqwrBRY7lcrrepjAeUWIDw7x sDPio3kjec+D372SYDipyEGqF4FyXmrEDO0o9wRh7uHMaTFk2VjdYRY0K9y3c8i5bfL0 trm48L1OUVQM2D0V5rm32aKD9cDuIL1pS7nrvAX0anUCrbNeufuZNj2WCp+aqQHdnTIS 2B9KZ4Z4/w7dwbQHgKWdhcokhNX/h1G+Vrd4tchHPzSUwzVUkrRmNbBm0DcGYR/J9fAJ jb1gpWw9G7snuOHTxEnuWnYJjv5r4gekgjW5XlkjZTJmdflcgQ8qfs2xmbvKJkozDKBB PdTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=j5zi0efyU2wM+QMh1Ie+xU2DoQi8KTTgF/9ktn95zdI=; b=YTOKccHX8HYpXHuzNKQNNvz1VmvFMWkyffRZTBBmW32eUgkj3KLUNa1664TKDydbgL 6VVdF0OKS8uLx42HDH5fSqkhsgOU3Av5YFSb2KMqENxyKvyPqp8iY0LLu5ivKkk/oMAh Bftw9tpCR4wMXD4KfJDOUY2QFaccbozTdW1D3EFfqHxYKGWApGnWt1c93gzq0tIdXkzE PjKeGM6T9IZwvkBFyh7uJlrtZDUkm+LgOzq4WH3FoEw1hbhm6Hqf5t4t426EedNm6COc 2XTOqrZJ4Gb+3+EzN+PhtUe3Za570pGvmhSmEVyK3Ic1LOlc9qqOF0M9kNY8LhgBBQSB YWqg== X-Gm-Message-State: AElRT7G+7imZOVR7Kl9LEQfVO2G8eNAw/RCugBaI0y+XCT7OXR3oejTm abeFlEKG2PzHDAetuRzKTBA= X-Received: by 10.28.55.129 with SMTP id e123mr6902094wma.78.1520896416680; Mon, 12 Mar 2018 16:13:36 -0700 (PDT) Received: from pali ([2a02:2b88:2:1::5cc6:2f]) by smtp.gmail.com with ESMTPSA id p12sm7350786wre.89.2018.03.12.16.13.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Mar 2018 16:13:35 -0700 (PDT) Date: Tue, 13 Mar 2018 00:13:35 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Masaki Ota , Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Input: alps - Demystify trackstick initialization for v3 and v6 protocols Message-ID: <20180312231335.fnfxgenu22utr3z6@pali> References: <20180312230915.26050-1-pali.rohar@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wapmdgzw56g4lcxp" Content-Disposition: inline In-Reply-To: <20180312230915.26050-1-pali.rohar@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --wapmdgzw56g4lcxp Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Masaki, if you have access to the internal ALPS v3 / Rushmore documentation, I would like to have a review of this patch or confirmation of those information :-) On Tuesday 13 March 2018 00:09:15 Pali Roh=C3=A1r wrote: > Remove cite "Not sure what this does, but it is absolutely essential". >=20 > Extract initialization of trackstick part when touchpad is in passthrought > 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 correspondent to setrate 0xC8 and 0x1= 4, > therefore these sequences are same. >=20 > When touchpad is in passthrought mode, then OS communicates with tracksti= ck > 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). >=20 > 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). >=20 > 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). >=20 > 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 wh= en > set. >=20 > Signed-off-by: Pali Roh=C3=A1r > --- > drivers/input/mouse/alps.c | 80 ++++++++++++++++++++++++++++------------= ------ > 1 file changed, 49 insertions(+), 31 deletions(-) >=20 > diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c > index dbe57da8c1a1..010c1bcdb06d 100644 > --- a/drivers/input/mouse/alps.c > +++ b/drivers/input/mouse/alps.c > @@ -2063,14 +2063,11 @@ static int alps_hw_init_v1_v2(struct psmouse *psm= ouse) > return 0; > } > =20 > -static int alps_hw_init_v6(struct psmouse *psmouse) > +/* Must be in passthrough mode when calling this function */ > +static int alps_trackstick_enter_extended_mode_v3_v6(struct psmouse *psm= ouse) > { > unsigned char param[2] =3D {0xC8, 0x14}; > =20 > - /* Enter passthrough mode to let trackpoint enter 6byte raw mode */ > - if (alps_passthrough_mode_v2(psmouse, true)) > - return -1; > - > if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || > ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || > ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || > @@ -2078,9 +2075,25 @@ static int alps_hw_init_v6(struct psmouse *psmouse) > ps2_command(&psmouse->ps2dev, ¶m[1], PSMOUSE_CMD_SETRATE)) > return -1; > =20 > + return 0; > +} > + > +static int alps_hw_init_v6(struct psmouse *psmouse) > +{ > + int ret; > + > + /* Enter passthrough mode to let trackpoint enter 6byte raw mode */ > + if (alps_passthrough_mode_v2(psmouse, true)) > + return -1; > + > + ret =3D alps_trackstick_enter_extended_mode_v3_v6(psmouse); > + > if (alps_passthrough_mode_v2(psmouse, false)) > return -1; > =20 > + if (ret) > + return ret; > + > if (alps_absolute_mode_v6(psmouse)) { > psmouse_err(psmouse, "Failed to enable absolute mode\n"); > return -1; > @@ -2154,10 +2167,18 @@ static int alps_probe_trackstick_v3_v7(struct psm= ouse *psmouse, int reg_base) > =20 > static int alps_setup_trackstick_v3(struct psmouse *psmouse, int reg_bas= e) > { > - struct ps2dev *ps2dev =3D &psmouse->ps2dev; > int ret =3D 0; > + int reg_val; > unsigned char param[4]; > =20 > + /* > + * We need to configure trackstick to report data for touchpad in > + * extended format. And also we need to tell touchpad to expect data > + * from trackstick in extended format. Without this configuration > + * trackstick packets sent from touchpad are in basic format which is > + * different from what we expect. > + */ > + > if (alps_passthrough_mode_v3(psmouse, reg_base, true)) > return -EIO; > =20 > @@ -2175,39 +2196,36 @@ static int alps_setup_trackstick_v3(struct psmous= e *psmouse, int reg_base) > ret =3D -ENODEV; > } else { > psmouse_dbg(psmouse, "trackstick E7 report: %3ph\n", param); > - > - /* > - * Not sure what this does, but it is absolutely > - * essential. Without it, the touchpad does not > - * work at all and the trackstick just emits normal > - * PS/2 packets. > - */ > - if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || > - ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || > - ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || > - alps_command_mode_send_nibble(psmouse, 0x9) || > - alps_command_mode_send_nibble(psmouse, 0x4)) { > - psmouse_err(psmouse, > - "Error sending magic E6 sequence\n"); > + if (alps_trackstick_enter_extended_mode_v3_v6(psmouse)) { > + psmouse_err(psmouse, "Failed to enter into trackstick extended mode\n= "); > ret =3D -EIO; > - goto error; > } > + } > + > + if (alps_passthrough_mode_v3(psmouse, reg_base, false)) > + return -EIO; > + > + if (ret) > + return ret; > =20 > + if (alps_enter_command_mode(psmouse)) > + return -EIO; > + > + reg_val =3D alps_command_mode_read_reg(psmouse, reg_base + 0x08); > + if (reg_val =3D=3D -1) { > + ret =3D -EIO; > + } else { > /* > - * This ensures the trackstick packets are in the format > - * supported by this driver. If bit 1 isn't set the packet > - * format is different. > + * Tell touchpad that trackstick is now in extended mode. > + * If bit 1 isn't set the packet format is different. > */ > - if (alps_enter_command_mode(psmouse) || > - alps_command_mode_write_reg(psmouse, > - reg_base + 0x08, 0x82) || > - alps_exit_command_mode(psmouse)) > + reg_val |=3D BIT(1); > + if (__alps_command_mode_write_reg(psmouse, reg_val)) > ret =3D -EIO; > } > =20 > -error: > - if (alps_passthrough_mode_v3(psmouse, reg_base, false)) > - ret =3D -EIO; > + if (alps_exit_command_mode(psmouse)) > + return -EIO; > =20 > return ret; > } --=20 Pali Roh=C3=A1r pali.rohar@gmail.com --wapmdgzw56g4lcxp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQS4VrIQdKium2krgIWL8Mk9A+RDUgUCWqcJmwAKCRCL8Mk9A+RD UvtrAJ0bHthOAthzxKY1ko/WTUK2RNBzPwCcCl/+bSes4qWJ5jyrfMHC6CxwgVk= =agNz -----END PGP SIGNATURE----- --wapmdgzw56g4lcxp--