Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3878915imm; Tue, 29 May 2018 15:58:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJQmpFnQ/2UpKXOE+BpYdmmkDDkJh01NWfEDFskA/cQW/WNtZmin3uR5u0Nqr1L+8a5iUpV X-Received: by 2002:a63:84c6:: with SMTP id k189-v6mr258245pgd.49.1527634701420; Tue, 29 May 2018 15:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527634701; cv=none; d=google.com; s=arc-20160816; b=Y1JE8IOY49YbPtJLzZcNNKN6wlADZe5AMZ2bKAWlx6IIrChIZQZJJAwhhppr0XXWXX K2kNIPMnxl7xT7jYI8j8sw39ZXcgEcDT9b2UxaPk9euuT/gsbYN6iRXfjJFME/ae3woc Juop+iImS+L7RNvdROtr+oKt3laumdaI8KQwJxEnB8/MmOjn+VWE6pw9rWBt6dxzVfqE nFLyxqc9kQj6hdOe5qmoZGUfdPXsGU8vMaCUk8uAxWivaDDJj7wR5AHkTB6+QM7quxOM CSyfffFMk/cTJmrxlGiV0NRLxDkzWic+7cAle5uQzySAzYFNv3TuOPQSUKNgX8YSDbAn 9lXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=JYT0T/Fcgw62BOG8cfqlnsTG3lsp/Qa4kfcfzP06/HE=; b=WD9DsuJIxJAIhzmHPaHLlCyxBiK4QpMu4iGIwOVSfD5H5To0tU46+GKAl2iFweN1Ws E3l2Vzy5O+P4jy7hsA3AXkH0E2XiNOxh0vtVFSyoPfuG8vykk8wOM3R5a7z5tl22dNq2 ZQx6ZRRpEHTLZMUePvcxHld6jUIy6p1SBfFRZw0F4Gz2abUicTY7BZfOeZwomTjFBzXG ZRK2rTL1pFyD4y5lS0d0jfgaLM5jrRMOGEYSDoFnpqa99WXu9wwRQBv2TgsmKyss5Q8v E2HNpKfSPOG76RC8qr41/sHrSAllRx5LTOLP74CxGj9RGyHR12AZw9iXr1D8fJ/7He5S CtfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f+DWkv44; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x61-v6si32691288plb.560.2018.05.29.15.58.07; Tue, 29 May 2018 15:58:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f+DWkv44; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967731AbeE2W5O (ORCPT + 99 others); Tue, 29 May 2018 18:57:14 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:38978 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935806AbeE2W5K (ORCPT ); Tue, 29 May 2018 18:57:10 -0400 Received: by mail-pl0-f68.google.com with SMTP id f1-v6so9378782plt.6 for ; Tue, 29 May 2018 15:57:10 -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=ANpadqd2NDVHPDleS7MTL1bvng6Fi6ze6JRoKNnUZp5RQOLVTAt+Nh6xZ1j1zT6UZ7 Dv3APAV4aRChtamCnqh936QG8CfCPDkR9wV9wrbrcpcvPvTVJ/dawhjKU9Zu+Sra//g2 2Dop5iY7KYkAot1vc0oTfSfel0qJsg/apJ+tH5Z8q45/Q6gnRMr6aBsB/fBppuy4cr/D n1XvZb6RgICUJqmLnTcHOKnrLv+btt3sNOBby8iBXU1CrwOL+36Zc1GnTCKVzMRjCHQT Nj3xTGnoCmqEGnqiQgRvchzu0ptZrw7U2TcIgQ/Ur+vQEb7swqIYEjz+3aFPlKi5KQsz 7vWg== X-Gm-Message-State: ALKqPweiyA/UYsOmFh12xbkuQaSoiHAm0lhiziG+PF6WzO4skwcmumiT FhtkzH+gmuLAxRIG7uOsiZesFA== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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. */ -- 2.17.0.921.gf22659ad46-goog