From patchwork Fri Jan 12 01:02:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Masaki Ota X-Patchwork-Id: 10159103 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 743CF601A1 for ; Fri, 12 Jan 2018 01:03:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60EC6288D1 for ; Fri, 12 Jan 2018 01:03:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5582A288E1; Fri, 12 Jan 2018 01:03:11 +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_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 CE92C288D1 for ; Fri, 12 Jan 2018 01:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933096AbeALBDB (ORCPT ); Thu, 11 Jan 2018 20:03:01 -0500 Received: from mail-ty1jpn01on0042.outbound.protection.outlook.com ([104.47.93.42]:48808 "EHLO JPN01-TY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932169AbeALBC6 (ORCPT ); Thu, 11 Jan 2018 20:02:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alpsgroup.onmicrosoft.com; s=selector1-jp-alps-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=X4ov+4OXU9m7f7GRdkxGE8Zer80tR9pCrhwg/SXlydU=; b=LssTd1m/9IHqnXL9G40SwnzP/xKdbkXuNHnddf7ML407wh+/BLdq6UCX6a+owUH5yEpkYx+OzJozmkzpMuKA576TOM4m1rCFRvoisNGecnGBRS5EDgSL8EOVCvSNB3XJPFfIawLuwozrGQD7+zWXp4O5GADGmE4WeSq+EnZNsWA= Received: from TYXPR01MB0719.jpnprd01.prod.outlook.com (10.168.44.10) by TYXPR01MB0718.jpnprd01.prod.outlook.com (10.168.44.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Fri, 12 Jan 2018 01:02:55 +0000 Received: from TYXPR01MB0719.jpnprd01.prod.outlook.com ([10.168.44.10]) by TYXPR01MB0719.jpnprd01.prod.outlook.com ([10.168.44.10]) with mapi id 15.20.0386.008; Fri, 12 Jan 2018 01:02:55 +0000 From: Masaki Ota To: Nir Perry , Dmitry Torokhov , =?utf-8?B?UGFsaSBSb2jDoXI=?= CC: "linux-kernel@vger.kernel.org" , "linux-input@vger.kernel.org" Subject: RE: [PATCH] input: multi-touch fix for ALPS touchpads ("SS4 plus" variant) Thread-Topic: [PATCH] input: multi-touch fix for ALPS touchpads ("SS4 plus" variant) Thread-Index: AQHThuUo+/g8rr7gj0Gn13k4a1N4aKNvcV9g Date: Fri, 12 Jan 2018 01:02:55 +0000 Message-ID: References: In-Reply-To: Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=masaki.ota@jp.alps.com; x-originating-ip: [106.184.109.136] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; TYXPR01MB0718; 7:3UIe1ueMfTCfH5j0jDwSqaUeviaQvJFXUm0zVidGBOwHAdJzEEQYYvavm3ppI1SrHJC6DRA+TapiJN+MO80+bkYza7YGoqZd/7o6UJEHmSrm9UQueQcHZQOfJchDw92vcWaSoEPBy3uxtiRvsgAbYg9kOPjghqKAqzyZ6L5JN4lOqpoCf5aAYDguhgS6P4zM1/R+hD0bKrhiyd3TMa/MDuZ4zDPLrNg59FrRIlnyrWrYRqYWhMZoyZMZyYg5a/qc; 20:tyuYHS+NWfZE75/bw1wjWaaQoywddaq2vDlErb76/Ija0Aayl29ja8ZfG6y6amGxcXM3CvFnxqfiu9BKkTftUDqlL41JSqr6VPq9PWjkIwyl4fsQAtEtViCRxLVMLdanBlkiui2pCWffXlFdBdVFz5en5OejZ2kn6JX7mKDwDd8= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 2fddeaaa-5a5b-445c-5c45-08d5595836c1 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020074)(4652020)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020); SRVR:TYXPR01MB0718; x-ms-traffictypediagnostic: TYXPR01MB0718: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(85827821059158)(9931346810618); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231023)(944501075)(6055026)(6041268)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:TYXPR01MB0718; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:TYXPR01MB0718; x-forefront-prvs: 0550778858 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(346002)(39380400002)(376002)(189003)(13464003)(199004)(53754006)(2950100002)(74316002)(99286004)(59450400001)(42882006)(6436002)(53936002)(85182001)(3660700001)(77096006)(55016002)(8936002)(66066001)(3280700002)(305945005)(7736002)(2900100001)(81156014)(2906002)(345774005)(68736007)(5660300001)(229853002)(8676002)(81166006)(9686003)(33656002)(53546011)(106356001)(102836004)(7696005)(478600001)(86362001)(6506007)(110136005)(54906003)(76176011)(3846002)(6116002)(316002)(4326008)(14454004)(6246003)(39060400002)(105586002)(25786009)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:TYXPR01MB0718; H:TYXPR01MB0719.jpnprd01.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:0; LANG:en; received-spf: None (protection.outlook.com: jp.alps.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 8N5WiOgEpGpkoriq4ePRUPHDIebpVu+MW1vMfMaU+P7H0d1i/Kk3D6Lb/o8khzPCg8V1IK/0/c3xXMXpRoKHkg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: jp.alps.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fddeaaa-5a5b-445c-5c45-08d5595836c1 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jan 2018 01:02:55.1710 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 57e76998-77bd-4b82-a424-198f46eb2254 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYXPR01MB0718 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, Nir, Wow, thank you for fixing the bug. Your code is correct! Best Regards, Masaki Ota -----Original Message----- From: Nir Perry [mailto:nirperry@gmail.com] Sent: Saturday, January 06, 2018 8:55 PM To: 太田 真喜 Masaki Ota ; Dmitry Torokhov ; Pali Rohár Cc: linux-kernel@vger.kernel.org; linux-input@vger.kernel.org Subject: [PATCH] input: multi-touch fix for ALPS touchpads ("SS4 plus" variant) 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 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