From patchwork Sat Jan 6 11:54:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nir Perry X-Patchwork-Id: 10147811 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B20B7601BE for ; Sat, 6 Jan 2018 11:54:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93FB22899A for ; Sat, 6 Jan 2018 11:54:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 863AF289D0; Sat, 6 Jan 2018 11:54:51 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 6BEDC2899A for ; Sat, 6 Jan 2018 11:54:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752962AbeAFLyt (ORCPT ); Sat, 6 Jan 2018 06:54:49 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:38144 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753084AbeAFLys (ORCPT ); Sat, 6 Jan 2018 06:54:48 -0500 Received: by mail-io0-f194.google.com with SMTP id 87so8416087ior.5; Sat, 06 Jan 2018 03:54:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc :content-transfer-encoding; bh=sT6Ieirg/L8YBkUvaMg+DhLIv6J90PpVr/m6AU+dZqs=; b=oqQ9OBAfVjBvZ0RVzJnYfqfywQzonviDHbfzg3zgfIHCrupAqFxd9kJnJlYN8QxuPY ZWJGkYF7dW9hd8eWOpDqmXXFv5ThfHNgzZqf+pvM/PTEfXDH10ulzsTm3Nrisz7qBCYp I/LnO84JeglADY/aGYDJTvnTYI+ETm/FjEskDZYRK/ta8z4pEDH5VtuA19Clzk6noc2c oaeI0Bz6g45kPH8UVM+bkAjuUlm2woyUlO6OufLCKQCc6dugF/vvgmaTx23FxVXjZ/Ec CD/yrENnKsPxAYrjuQK4m09XKEGi5nCgpKeBsevKgDz6EnpBCjk/rY0oUl33oGX70k/B oRlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc :content-transfer-encoding; bh=sT6Ieirg/L8YBkUvaMg+DhLIv6J90PpVr/m6AU+dZqs=; b=O6blYEMYgQ+T7dR6JNf88eVkB+5HBIm1mHkbLGgOZnzfl3DJy8iGaH4/mNrMMoGanc zy4pt3KUB2y4t0UY3gkeX/UrdrRO34CxTf2Q5+lH/opUSofpSaBhvpwMgJHhTgHeEIZT zxrMgw4pZrBJ3LPZCkpBHfgGbaceTSRNtqbcQeXxaVPcjNl9teznxt1pxOdkG7yiVEBK +reSkKDk/QZGRrkRgwsky2dnw99FAw5+mLRSzBtH7LgCa010aMOecq/klWqWi+rs61dh hGEDLAdnc6D9mqdAWsSEwy2GpF+lHAgem94AbXZ5Jwuqc7i6bo9+59y8gf5Qm/ez0Uja 0Xcg== X-Gm-Message-State: AKwxytenrs/ITzq36vKrxUAeAIiEfH2AkFVy2ppeSWpJ8tzXeENcZJHm USW6MzoY7zo+gjhwxkb3YC3XbFbawda0WBywOFTdTcxo X-Google-Smtp-Source: ACJfBovX5xRE/feS/2Oo1Fykz0Hhn1AB9ObIkl4Mu+ga2KQ2cbIHduXgL/TIE3pgOFwkWQ9onT21St5YjzDV40mcLnI= X-Received: by 10.107.12.141 with SMTP id 13mr4654889iom.111.1515239687468; Sat, 06 Jan 2018 03:54:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.134.7 with HTTP; Sat, 6 Jan 2018 03:54:47 -0800 (PST) From: Nir Perry Date: Sat, 6 Jan 2018 13:54:47 +0200 Message-ID: Subject: [PATCH] input: multi-touch fix for ALPS touchpads ("SS4 plus" variant) To: Masaki Ota , Dmitry Torokhov , =?UTF-8?Q?Pali_Roh=C3=A1r?= Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org 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 Hi all, I think a minor "typo" bug was accidentally introduced to ALPS touchpad driver by a previous bug-fix (commit 4a646580f793d19717f7e034c8d473b509c27d49, "Input: ALPS - fix two-finger scroll breakage in right side on ALPS touchpad"). It breaks how multi-touch events are decoded on some ALPS touchpads, so for example tapping with three-fingers can no longer be used to emulate middle-mouse-button (the kernel doesn't recognize this as the proper event, and doesn't report it correctly to userspace). This affects touchpads that use SS4 "plus" protocol variant, like those found on Dell E7270 & E7470 laptops (tested on E7270). The cause of the problem ------------------------------------------ First, probably due to a typo, the code in alps_decode_ss4_v2() for case SS4_PACKET_ID_MULTI used inconsistent indices to "f->mt[]". You can see 0 & 1 are used for the "if" part but 2 & 3 are used for the "else" part, which I believe is a typo. Second, in the previous patch, new macros were introduced to decode X coordinates specific to the SS4 "plus" variant, but the macro to define the maximum X value wasn't changed accordingly. The macros to decode X values for "plus" variant are effectively shifted right by 1 bit, but the max wasn't shifted too. This causes the driver to incorrectly handle "no data" cases, which also interfered with how multi-touch was handled. To fix it - I created new SS4 "plus" macros for the max value - SS4_PLUS_MFPACKET_NO_AX & SS4_PLUS_MFPACKET_NO_AX_BL. To make the change a little more readable, I moved also the Y-max lines so they are closer to the X-max lines. To get three-finger tap to work both changes are required. The included patch was generated against the mainline tree today, but was also tested against the 4.14 kernel branch. I've included in this e-mail the people involved with the old patch from August, plus Pali Rohár who is listed as the ALPS PS/2 touchpad driver reviewer (in the maintainers file). Fixes: 4a646580f793d19717f7e034c8d473b509c27d49 ("Input: ALPS - fix two-finger scroll breakage in right side on ALPS touchpad") Regards, Nir Signed-off-by: Nir Perry --- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 579b899..dbe57da 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -1250,29 +1250,32 @@ static int alps_decode_ss4_v2(struct alps_fields *f, case SS4_PACKET_ID_MULTI: if (priv->flags & ALPS_BUTTONPAD) { if (IS_SS4PLUS_DEV(priv->dev_id)) { - f->mt[0].x = SS4_PLUS_BTL_MF_X_V2(p, 0); - f->mt[1].x = SS4_PLUS_BTL_MF_X_V2(p, 1); + f->mt[2].x = SS4_PLUS_BTL_MF_X_V2(p, 0); + f->mt[3].x = SS4_PLUS_BTL_MF_X_V2(p, 1); + no_data_x = SS4_PLUS_MFPACKET_NO_AX_BL; } else { f->mt[2].x = SS4_BTL_MF_X_V2(p, 0); f->mt[3].x = SS4_BTL_MF_X_V2(p, 1); + no_data_x = SS4_MFPACKET_NO_AX_BL; } + no_data_y = SS4_MFPACKET_NO_AY_BL; f->mt[2].y = SS4_BTL_MF_Y_V2(p, 0); f->mt[3].y = SS4_BTL_MF_Y_V2(p, 1); - no_data_x = SS4_MFPACKET_NO_AX_BL; - no_data_y = SS4_MFPACKET_NO_AY_BL; } else { if (IS_SS4PLUS_DEV(priv->dev_id)) { - f->mt[0].x = SS4_PLUS_STD_MF_X_V2(p, 0); - f->mt[1].x = SS4_PLUS_STD_MF_X_V2(p, 1); + f->mt[2].x = SS4_PLUS_STD_MF_X_V2(p, 0); + f->mt[3].x = SS4_PLUS_STD_MF_X_V2(p, 1); + no_data_x = SS4_PLUS_MFPACKET_NO_AX; } else { - f->mt[0].x = SS4_STD_MF_X_V2(p, 0); - f->mt[1].x = SS4_STD_MF_X_V2(p, 1); + f->mt[2].x = SS4_STD_MF_X_V2(p, 0); + f->mt[3].x = SS4_STD_MF_X_V2(p, 1); + no_data_x = SS4_MFPACKET_NO_AX; } + no_data_y = SS4_MFPACKET_NO_AY; + f->mt[2].y = SS4_STD_MF_Y_V2(p, 0); f->mt[3].y = SS4_STD_MF_Y_V2(p, 1); - no_data_x = SS4_MFPACKET_NO_AX; - no_data_y = SS4_MFPACKET_NO_AY; } f->first_mp = 0; diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h index c80a7c7..3dfae83 100644 --- a/drivers/input/mouse/alps.h +++ b/drivers/input/mouse/alps.h @@ -145,6 +145,8 @@ enum SS4_PACKET_ID { #define SS4_MFPACKET_NO_AY 4080 /* Y-Coordinate value */ #define SS4_MFPACKET_NO_AX_BL 8176 /* Buttonless X-Coordinate value */ #define SS4_MFPACKET_NO_AY_BL 4088 /* Buttonless Y-Coordinate value */ +#define SS4_PLUS_MFPACKET_NO_AX 4080 /* SS4 PLUS, x */ +#define SS4_PLUS_MFPACKET_NO_AX_BL 4088 /* Buttonless SS4 PLUS, x */ /* * enum V7_PACKET_ID - defines the packet type for V7