From patchwork Wed Jun 19 06:37:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 11003531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDCC813AF for ; Wed, 19 Jun 2019 06:38:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAFB028A99 for ; Wed, 19 Jun 2019 06:38:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B81628B4B; Wed, 19 Jun 2019 06:38:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2274328A99 for ; Wed, 19 Jun 2019 06:38:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726195AbfFSGiQ (ORCPT ); Wed, 19 Jun 2019 02:38:16 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:44126 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbfFSGiQ (ORCPT ); Wed, 19 Jun 2019 02:38:16 -0400 Received: from [125.35.49.90] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hdUEW-0001sD-N5; Wed, 19 Jun 2019 06:38:13 +0000 From: Hui Wang To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, pali.rohar@gmail.com, xiaoxiao.liu-1@cn.alps.com, sliuuxiaonxiao@gmail.com, xiaojian.cao@cn.alps.com, naoki.saito@alpsalpine.com, hideo.kawase@alpsalpine.com Subject: [PATCH v5] Input: alps - Don't handle ALPS cs19 trackpoint-only device Date: Wed, 19 Jun 2019 14:37:56 +0800 Message-Id: <20190619063756.9714-1-hui.wang@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On a latest Lenovo laptop, the trackpoint and 3 buttons below it don't work at all, when we move the trackpoint or press those 3 buttons, the kernel will print out: "Rejected trackstick packet from non DualPoint device" This device is identified as an alps touchpad but the packet has trackpoint format, so the alps.c drops the packet and prints out the message above. According to XiaoXiao's explanation, this device is named cs19 and is trackpoint-only device, its firmware is only for trackpoint, it is independent of touchpad and is a device completely different from DualPoint ones. To drive this device with mininal changes to the existing driver, we just let the alps driver not handle this device, then the trackpoint.c will be the driver of this device if the trackpoint driver is enabled. (if not, this device will fallback to a bare PS/2 device) With the trackpoint.c, this trackpoint and 3 buttons all work well, they have all features that the trackpoint should have, like scrolling-screen, drag-and-drop and frame-selection. Signed-off-by: XiaoXiao Liu Signed-off-by: Hui Wang Reviewed-by: Pali Rohár --- In the v5: change the commit header to add "fallback to a bare PS/2 device if trackpont driver is not enabled". add comment for checking param[0] and param[1] add psmouse_dbg and psmouse_warn respectively for PS2_TRACKPOINT is enabled or not enabled. drivers/input/mouse/alps.c | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 0a6f7ca883e7..536b8e531169 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -24,6 +24,7 @@ #include "psmouse.h" #include "alps.h" +#include "trackpoint.h" /* * Definitions for ALPS version 3 and 4 command mode protocol @@ -2864,6 +2865,34 @@ static const struct alps_protocol_info *alps_match_table(unsigned char *e7, return NULL; } +static bool alps_is_cs19_trackpoint(struct psmouse *psmouse) +{ + u8 param[2] = { 0 }; + + if (ps2_command(&psmouse->ps2dev, + param, MAKE_PS2_CMD(0, 2, TP_READ_ID))) + return false; + + /* + * param[0] contains the trackpoint device variant_id while param[1] + * contains the firmware_id, so far for all alps trackpoint-only + * devices, their variant_ids equal TP_VARIANT_ALPS and their + * firmware_ids are 0x20~0x2f, so here we check param[0] as well as + * param[1] to detect an ALPS trackpoint-only device. + */ + if ((param[0] == TP_VARIANT_ALPS) && (param[1] & 0x20)) { + if (IS_ENABLED(MOUSE_PS2_TRACKPOINT)) + psmouse_dbg(psmouse, + "ALPS CS19 trackpoint-only device detected, not using ALPS touchpad driver\n"); + else + psmouse_warn(psmouse, + "ALPS CS19 trackpoint-only device detected but MOUSE_PS2_TRACKPOINT not enabled, fallback to bare PS/2 mouse\n"); + return true; + } + + return false; +} + static int alps_identify(struct psmouse *psmouse, struct alps_data *priv) { const struct alps_protocol_info *protocol; @@ -3164,6 +3193,18 @@ int alps_detect(struct psmouse *psmouse, bool set_properties) if (error) return error; + /* + * ALPS cs19 is a trackpoint-only device, it is completely independent + * of touchpad. So it is a device different from DualPoint ones, if it + * is identified as a cs19 trackpoint device, we return -EINVAL here and + * let trackpoint.c to drive this device, if the trackpoint driver is + * not enabled, the device will fallback to a bare PS/2 mouse. + * If ps2_command() fails here, we depend on the immediate followed + * psmouse_reset() to reset the device to normal state. + */ + if (alps_is_cs19_trackpoint(psmouse)) + return -EINVAL; + /* * Reset the device to make sure it is fully operational: * on some laptops, like certain Dell Latitudes, we may