From patchwork Tue May 29 22:56:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Chan X-Patchwork-Id: 10437383 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 1AD3B602BF for ; Tue, 29 May 2018 22:57:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EB7E28801 for ; Tue, 29 May 2018 22:57:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 032AA2880D; Tue, 29 May 2018 22:57:14 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 606DA28801 for ; Tue, 29 May 2018 22:57:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966192AbeE2W5M (ORCPT ); Tue, 29 May 2018 18:57:12 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:46316 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935846AbeE2W5L (ORCPT ); Tue, 29 May 2018 18:57:11 -0400 Received: by mail-pl0-f67.google.com with SMTP id 30-v6so9808057pld.13 for ; Tue, 29 May 2018 15:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=JYT0T/Fcgw62BOG8cfqlnsTG3lsp/Qa4kfcfzP06/HE=; b=f+DWkv44BRH15W8oi2AEG9n9ooNUQqwEwi97kopbrYtguIqx0mnULEKhfzMCNHEtcs /Tw2PoX0dl2fvPZdz9LlQg2rEq/oClndMhD2DPAb3R9jZD7KYeLD6iayl95FP5EIxs/8 XoKQZz+v0IFAB9e+1DkojJ2qinjGJlkEbja4M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JYT0T/Fcgw62BOG8cfqlnsTG3lsp/Qa4kfcfzP06/HE=; b=n53nWm4lcPdMGNLmB/S8jUbkHZOlTawAUSVodYroHzV2ScE8oqjJNutVkd7SI+z7Cs 51Ut0kkMMNFpkAqrb7jJgHjq+q4h6pVy+Oqi9BO7tQ6jml9+3//b0OthI4QRNQMxw5ke XbGF1iZtmuSK4aAGmlY9h81bqVu9yI7YGus9zApfmywgDbJhRtCk27i5QA5TPPXH4kKU UpfrUlyN4txvlna3Tmw9+e/qNUdoqenzk38oWx+0E5Zand4azFkU58kuUiGo0KTbQ7/9 CmE8+SHRVKSCCgbxZNAXRORgPBJwIoqp42A8PjQSQRlpav4rpuRoig+JI81jP3eU8WN8 rB4g== X-Gm-Message-State: ALKqPwcW77tQgpKClA4q/LxVhM7NecsczVXIb9Xayd9F4nAWSCR/ES/i pfg23qOcBeYw24jASe07PXv3DBDy+kM= X-Google-Smtp-Source: ADUXVKIhj7oWmCeowd4sao/kPnf7llaKO7YKWeArWN2EhLbnufMJ3SDYi3JWlHyLtEcKv1Tw5DcgwQ== X-Received: by 2002:a17:902:4483:: with SMTP id l3-v6mr338006pld.282.1527634630468; Tue, 29 May 2018 15:57:10 -0700 (PDT) Received: from benchan.mtv.corp.google.com ([2620:0:1000:1501:c195:f7f9:990b:ad3d]) by smtp.gmail.com with ESMTPSA id b3-v6sm59867739pff.132.2018.05.29.15.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 15:57:09 -0700 (PDT) From: Ben Chan To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , dtor@chromium.org, drinkcat@chromium.org Subject: [PATCH] HID: multitouch: fix calculation of last slot field in multi-touch reports Date: Tue, 29 May 2018 15:56:55 -0700 Message-Id: <20180529225655.214380-1-benchan@chromium.org> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog 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 According to [1] and also seemingly agreed by [2], the Scan Time usage (0x0D 0x56) is a report level usage, not a contact level usage. However, the hid-multitouch driver currently includes HID_DG_SCANTIME when calculating `td->last_slot_field', which may lead to mt_complete_slot() being prematurely called in certain cases (e.g. when each touch input report includes more than one contact and the Scan Time usage appears before any contact logical collection). This patch fixes the issue by skipping mt_store_field() on HID_DG_SCANTIME, similar to how HID_DG_CONTACTCOUNT and HID_DG_CONTACTMAX are handled. [1] https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-precision-touchpad-required-hid-top-level-collections#windows-precision-touchpad-input-reports [2] https://patchwork.kernel.org/patch/1742181/ Fixes: 29cc309d8bf19 ("HID: hid-multitouch: forward MSC_TIMESTAMP") Signed-off-by: Ben Chan Reviewed-by: Dmitry Torokhov --- drivers/hid/hid-multitouch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index dad2fbb0e3f8..161551aab496 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -620,13 +620,16 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, hid_map_usage(hi, usage, bit, max, EV_MSC, MSC_TIMESTAMP); input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); - mt_store_field(usage, td, hi); /* Ignore if indexes are out of bounds. */ if (field->index >= field->report->maxfield || usage->usage_index >= field->report_count) return 1; td->scantime_index = field->index; td->scantime_val_index = usage->usage_index; + /* + * We don't set td->last_slot_field as scan time is + * global to the report. + */ return 1; case HID_DG_CONTACTCOUNT: /* Ignore if indexes are out of bounds. */