Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp521169pja; Thu, 7 Nov 2019 00:51:32 -0800 (PST) X-Google-Smtp-Source: APXvYqwqdJVkjL+cOOaL0U78X+2TzKVCMhjsg4v04lH0wtdxcev6ZhE2iqS0ToNiBANwILtuSs+T X-Received: by 2002:a05:6402:70e:: with SMTP id w14mr2214654edx.95.1573116691907; Thu, 07 Nov 2019 00:51:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573116691; cv=none; d=google.com; s=arc-20160816; b=zcfWnzmW8kt3H2eqOttWIGUywYrTLN0OIuD8hGisU3HzQ3gqMdwR5JJUzLj96hQRMf Msv/VbRaZw/w/5l2vlCsvMtHJZmivkWT0d2FJm94W98W5+3m58fkqV9LQ8At99WEk1A+ EsbfYwVTXQ68RMsxWr9PaQk4EWUQl0jWGvPljgNI10pE/GU8v+i2n0PoihxdbPu+M+vF 5z4uyBMM/ADsevkZQ5DIoKLLKtpn9gFmrM6oztc8w9otA7qJD9iK+IJwn3fWbUBgG97C 2G31Lfheq1876QQ2MAd7A1uKgJeJKmh77ckKv3zf/S0n4WD2AEEeagzQpxZvmDZRQ63f GtBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5GkaaySWUIuikkrk8Qp2LFGG/L7X0kNfIu5fvLKbIgk=; b=aDufmOb17+E6U/95DBl+7wpKN6cz5nMosRTA6h8XNItlhPJwjUq4THU/qbToYsdNmZ OQSWe4zzT0LBrpqhosQOpsnS+R5IODjBOS+5iUIg9KgW/BVvu9OhAbUdsbkrLUViQBKI e7F74lw7SZJNaVC6f+q+O/t0oD68k5IbaAL8SdcYoLLXw2qSJ4B3bWm8zb8tvmDIAbv1 GoqsKN2YabqNhJuQO231MVvluJwG2A8tAu38YXRkPOA/LoboEJ4Lt+7Ys83rNQ+EdyhS mpxsIZus8ewS9AYfBX4RT0Vr18fFmLn7J4Qqkwxn0O6QWciPAQTfcNl2EwDAX14sMrZS NpMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NzyNDpSK; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si1174162edi.272.2019.11.07.00.51.08; Thu, 07 Nov 2019 00:51:31 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=NzyNDpSK; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733139AbfKGIs2 (ORCPT + 99 others); Thu, 7 Nov 2019 03:48:28 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:41374 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727408AbfKGIs1 (ORCPT ); Thu, 7 Nov 2019 03:48:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573116506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5GkaaySWUIuikkrk8Qp2LFGG/L7X0kNfIu5fvLKbIgk=; b=NzyNDpSKr7sNZciskMSmKQw5zFGKJALA7piHiImrI5gL0rUF56EjkfzZWC1YFpV/EY5mpM v8iKdZqhrJHIfuj7SDsxufc4mvxOzBB7tWmP3mHOKKe0E4ZaKxc6fw0IUySgUzRiFU15kq 1cA7gZXS8BjbGg4O7a6DKjZfc9fSv6s= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-217-aF4NKaqTOa2FBXqgmi5b2Q-1; Thu, 07 Nov 2019 03:48:25 -0500 Received: by mail-qt1-f197.google.com with SMTP id b26so1687004qtr.23 for ; Thu, 07 Nov 2019 00:48:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=5GkaaySWUIuikkrk8Qp2LFGG/L7X0kNfIu5fvLKbIgk=; b=QYTyEBKAKoYJdHwOp2mQHCdlI+df3eK/TnUyvglZG6+ISkhM23wPe87uv0UunkIQ6g Qvjq+DnJnT/kB4+OObzTRGxuM1/Bzr0N32EMrec/XGPVwYbDwjPS0vIj8XFAKyuzHwJO Fi77b12rWwIBxz5dW4xZ+UybsM7dMaFsp95emgtGIc9a2+pRh9v7nAZoP3W/1V6b0lN/ mv6Sb46WMZtaRhydOpUg4LXSpVE0JBc6ZUNt6wE9PvMp13Eh6ub7C9nlpFzmhvJ0F8hR pMc7wajxHA5f9HrmJFdYf2QBM/+CXb7GvuN5jUpNzsXlLbbpOAcBk7sC1ctCtXKqVG6u FCCQ== X-Gm-Message-State: APjAAAUs+DustxpLcxNhx/OetMuL/rjXIr5yHRAuZOGQFrYN5XzroftM 33X2iXjuqaIxozdCuW+OhWd8Ll2I5uBGsD7Y+25ZcFmGUkwTRemyYLlb6yhKyvEzf6kjWP+sl1h ePAD+G+QuQt61k85Q3r48jB4tGWhr7HNtrfrwYopl X-Received: by 2002:a37:4b97:: with SMTP id y145mr1636940qka.133.1573116503887; Thu, 07 Nov 2019 00:48:23 -0800 (PST) X-Received: by 2002:a37:98c6:: with SMTP id a189mr1714662qke.230.1573116500554; Thu, 07 Nov 2019 00:48:20 -0800 (PST) MIME-Version: 1.0 References: <20191106110246.70937-1-blaz@mxxn.io> In-Reply-To: <20191106110246.70937-1-blaz@mxxn.io> From: Benjamin Tissoires Date: Thu, 7 Nov 2019 09:48:09 +0100 Message-ID: Subject: Re: [PATCH] HID: Improve Windows Precision Touchpad detection. To: =?UTF-8?Q?Bla=C5=BE_Hrastnik?= Cc: Jiri Kosina , "open list:HID CORE LAYER" , lkml X-MC-Unique: aF4NKaqTOa2FBXqgmi5b2Q-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bla=C5=BE, On Wed, Nov 6, 2019 at 12:03 PM Bla=C5=BE Hrastnik wrote: > > Per Microsoft spec, usage 0xC5 (page 0xFF) returns a blob containing > data used to verify the touchpad as a Windows Precision Touchpad. > > 0x85, REPORTID_PTPHQA, // REPORT_ID (PTPHQA) > 0x09, 0xC5, // USAGE (Vendor Usage 0xC5) > 0x15, 0x00, // LOGICAL_MINIMUM (0) > 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (0xff) > 0x75, 0x08, // REPORT_SIZE (8) > 0x96, 0x00, 0x01, // REPORT_COUNT (0x100 (256)) > 0xb1, 0x02, // FEATURE (Data,Var,Abs) > > However, some devices, namely Microsoft's Surface line of products > instead implement a "segmented device certification report" (usage 0xC6) > which returns the same report, but in smaller chunks. > > 0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined) > 0x85, REPORTID_PTPHQA, // REPORT_ID (PTPHQA) > 0x09, 0xC6, // USAGE (Vendor usage for segment #) > 0x25, 0x08, // LOGICAL_MAXIMUM (8) > 0x75, 0x08, // REPORT_SIZE (8) > 0x95, 0x01, // REPORT_COUNT (1) > 0xb1, 0x02, // FEATURE (Data,Var,Abs) > 0x09, 0xC7, // USAGE (Vendor Usage) > 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (0xff) > 0x95, 0x20, // REPORT_COUNT (32) > 0xb1, 0x02, // FEATURE (Data,Var,Abs) > > By expanding Win8 touchpad detection to also look for the segmented > report, all Surface touchpads are now properly recognized by > hid-multitouch. > > Signed-off-by: Bla=C5=BE Hrastnik > --- This looks good to me. We *could* shorten the ifs and make only one conditional, but I find it this way more readable and future proof. There is just one last step required before we merge this: add a regression test so we ensure we do not break it in the future. It should be merely a matter of sending a MR to https://gitlab.freedesktop.org/libevdev/hid-tools. It should consist in adding the report descriptor in the same way we have https://gitlab.freedesktop.org/libevdev/hid-tools/blob/master/tests/te= st_multitouch.py#L1656-1658. Then, make sure an unpatched kernel breaks the multitouch test (sudo pytest-3 -k 'multitouch and TestPTP') and that a patched kernel is fixed. Cheers, Benjamin > drivers/hid/hid-core.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c > index 63fdbf09b044..2af597cd5d65 100644 > --- a/drivers/hid/hid-core.c > +++ b/drivers/hid/hid-core.c > @@ -742,6 +742,10 @@ static void hid_scan_feature_usage(struct hid_parser= *parser, u32 usage) > if (usage =3D=3D 0xff0000c5 && parser->global.report_count =3D=3D= 256 && > parser->global.report_size =3D=3D 8) > parser->scan_flags |=3D HID_SCAN_FLAG_MT_WIN_8; > + > + if (usage =3D=3D 0xff0000c6 && parser->global.report_count =3D=3D= 1 && > + parser->global.report_size =3D=3D 8) > + parser->scan_flags |=3D HID_SCAN_FLAG_MT_WIN_8; > } > > static void hid_scan_collection(struct hid_parser *parser, unsigned type= ) > -- > 2.23.0 >