From patchwork Mon Jan 5 22:28:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriele Mazzotta X-Patchwork-Id: 5570681 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D6F8CBF6C3 for ; Mon, 5 Jan 2015 22:29:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 10883202F8 for ; Mon, 5 Jan 2015 22:29:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34597202EB for ; Mon, 5 Jan 2015 22:29:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753750AbbAEW2y (ORCPT ); Mon, 5 Jan 2015 17:28:54 -0500 Received: from mail-we0-f171.google.com ([74.125.82.171]:54094 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753197AbbAEW2w (ORCPT ); Mon, 5 Jan 2015 17:28:52 -0500 Received: by mail-we0-f171.google.com with SMTP id u56so8736128wes.16; Mon, 05 Jan 2015 14:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=X9GqQRQyfseHgd/PKo0diy9IkBA0mNET042BqtVQu98=; b=MHjAX826pRTyBQ0/bigXVo2zKjzpc49BRP3RacY0uLKPS5azTpX8T/7DXV22PeaZBI 1cV640PL9+rKMmhW4D2ksomG6W/Dnn2JK0DMW6jLFBZ5VHZ7cgkWwNTlWWFTYfUaU2wX NLVDwu63WaYi3yn/ZCuxcFS6dOakD/cJNvumt/RXb1PyyGSIwufqhi+I7iO31Ydfm+9Y V0MxO39Jo4AhiNSWrG3idX00Mot8oMNRk+WJNUz5N+LdB2dX/3Dy6tS6jRStQ8uOJvu9 MkA5/7HEZic3mpaIrejGCYNbGIR6YUf5tgQtvdxBHoeBlEFBAZIVl6pHpevcAhFnmAjC PLAA== X-Received: by 10.194.86.135 with SMTP id p7mr184802041wjz.89.1420496931023; Mon, 05 Jan 2015 14:28:51 -0800 (PST) Received: from xps13.homenet (2-235-140-64.ip228.fastwebnet.it. [2.235.140.64]) by mx.google.com with ESMTPSA id h13sm11580679wiw.4.2015.01.05.14.28.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Jan 2015 14:28:50 -0800 (PST) From: Gabriele Mazzotta To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, rydberg@euromail.se, linux-kernel@vger.kernel.org, silverhammermba@gmail.com, peter.hutterer@who-t.net, hdegoede@redhat.com, benjamin.tissoires@gmail.com, Gabriele Mazzotta Subject: [PATCH v2 2/4] input: synaptics - fix width values calculation on image sensors Date: Mon, 5 Jan 2015 23:28:33 +0100 Message-Id: <1420496915-31560-3-git-send-email-gabriele.mzt@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1420496915-31560-1-git-send-email-gabriele.mzt@gmail.com> References: <1420496915-31560-1-git-send-email-gabriele.mzt@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When multiple fingers are on the touchpad, W reports the finger count rather than the width. Retrieve the correct value that is encoded in X, Y and Z of AGM and SGM packets. The minimum width reported is 8 rather than 4 in this case, while the maximum remains 15. Signed-off-by: Gabriele Mazzotta --- drivers/input/mouse/synaptics.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index 4d22ebd..918a727 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -585,10 +585,12 @@ static void synaptics_parse_agm(const unsigned char buf[], switch (agm_packet_type) { case 1: /* Gesture packet: (x, y, z) half resolution */ - agm->w = hw->w; - agm->x = (((buf[4] & 0x0f) << 8) | buf[1]) << 1; - agm->y = (((buf[4] & 0xf0) << 4) | buf[2]) << 1; - agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0f)) << 2; + agm->w = ((buf[1] & 0x01) | + ((buf[2] & 0x01) << 1) | + ((buf[5] & 0x01) << 2)) + 8; + agm->x = (((buf[4] & 0x0f) << 8) | (buf[1] & 0xfe)) << 1; + agm->y = (((buf[4] & 0xf0) << 4) | (buf[2] & 0xfe)) << 1; + agm->z = ((buf[3] & 0x30) | (buf[5] & 0x0e)) << 2; break; case 2: @@ -852,6 +854,17 @@ static void synaptics_image_sensor_process(struct psmouse *psmouse, else num_fingers = 4; + /* When multiple fingers are on the TouchPad, the width is encoded in + * X, Y and Z */ + if (sgm->w == 0 || sgm->w == 1) { + sgm->w = (((sgm->x & BIT(1)) >> 1) | + (sgm->y & BIT(1)) | + ((sgm->z & BIT(0)) << 2)) + 8; + sgm->x &= ~BIT(1); + sgm->y &= ~BIT(1); + sgm->z &= ~BIT(0); + } + /* Send resulting input events to user space */ synaptics_report_mt_data(psmouse, sgm, num_fingers); }