linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: Improve Windows Precision Touchpad detection.
@ 2019-11-06 11:02 Blaž Hrastnik
  2019-11-07  8:48 ` Benjamin Tissoires
  0 siblings, 1 reply; 4+ messages in thread
From: Blaž Hrastnik @ 2019-11-06 11:02 UTC (permalink / raw)
  Cc: Blaž Hrastnik, Jiri Kosina, Benjamin Tissoires, linux-input,
	linux-kernel

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ž Hrastnik <blaz@mxxn.io>
---
 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 == 0xff0000c5 && parser->global.report_count == 256 &&
 	    parser->global.report_size == 8)
 		parser->scan_flags |= HID_SCAN_FLAG_MT_WIN_8;
+
+	if (usage == 0xff0000c6 && parser->global.report_count == 1 &&
+	    parser->global.report_size == 8)
+		parser->scan_flags |= HID_SCAN_FLAG_MT_WIN_8;
 }
 
 static void hid_scan_collection(struct hid_parser *parser, unsigned type)
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: Improve Windows Precision Touchpad detection.
  2019-11-06 11:02 [PATCH] HID: Improve Windows Precision Touchpad detection Blaž Hrastnik
@ 2019-11-07  8:48 ` Benjamin Tissoires
  2019-11-07  9:06   ` Blaž Hrastnik
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Tissoires @ 2019-11-07  8:48 UTC (permalink / raw)
  To: Blaž Hrastnik; +Cc: Jiri Kosina, open list:HID CORE LAYER, lkml

Hi Blaž,

On Wed, Nov 6, 2019 at 12:03 PM Blaž Hrastnik <blaz@mxxn.io> 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ž Hrastnik <blaz@mxxn.io>
> ---

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/test_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 == 0xff0000c5 && parser->global.report_count == 256 &&
>             parser->global.report_size == 8)
>                 parser->scan_flags |= HID_SCAN_FLAG_MT_WIN_8;
> +
> +       if (usage == 0xff0000c6 && parser->global.report_count == 1 &&
> +           parser->global.report_size == 8)
> +               parser->scan_flags |= HID_SCAN_FLAG_MT_WIN_8;
>  }
>
>  static void hid_scan_collection(struct hid_parser *parser, unsigned type)
> --
> 2.23.0
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: Improve Windows Precision Touchpad detection.
  2019-11-07  8:48 ` Benjamin Tissoires
@ 2019-11-07  9:06   ` Blaž Hrastnik
  2019-11-18 10:04     ` Benjamin Tissoires
  0 siblings, 1 reply; 4+ messages in thread
From: Blaž Hrastnik @ 2019-11-07  9:06 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: Jiri Kosina, open list:HID CORE LAYER, lkml

I've submitted a test containing the Surface Book 2 descriptor.

https://gitlab.freedesktop.org/libevdev/hid-tools/merge_requests/59

Blaž

On Thu, 7 Nov 2019, at 17:48, Benjamin Tissoires wrote:
> Hi Blaž,
> 
> On Wed, Nov 6, 2019 at 12:03 PM Blaž Hrastnik <blaz@mxxn.io> 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ž Hrastnik <blaz@mxxn.io>
> > ---
> 
> 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/test_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 == 0xff0000c5 && parser->global.report_count == 256 &&
> >             parser->global.report_size == 8)
> >                 parser->scan_flags |= HID_SCAN_FLAG_MT_WIN_8;
> > +
> > +       if (usage == 0xff0000c6 && parser->global.report_count == 1 &&
> > +           parser->global.report_size == 8)
> > +               parser->scan_flags |= HID_SCAN_FLAG_MT_WIN_8;
> >  }
> >
> >  static void hid_scan_collection(struct hid_parser *parser, unsigned type)
> > --
> > 2.23.0
> >
> 
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: Improve Windows Precision Touchpad detection.
  2019-11-07  9:06   ` Blaž Hrastnik
@ 2019-11-18 10:04     ` Benjamin Tissoires
  0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Tissoires @ 2019-11-18 10:04 UTC (permalink / raw)
  To: Blaž Hrastnik; +Cc: Jiri Kosina, open list:HID CORE LAYER, lkml

On Thu, Nov 7, 2019 at 10:07 AM Blaž Hrastnik <blaz@mxxn.io> wrote:
>
> I've submitted a test containing the Surface Book 2 descriptor.
>
> https://gitlab.freedesktop.org/libevdev/hid-tools/merge_requests/59

Thanks.

Patch is now queued in branch for-5.5/core.

Cheers,
Benjamin

>
> Blaž
>
> On Thu, 7 Nov 2019, at 17:48, Benjamin Tissoires wrote:
> > Hi Blaž,
> >
> > On Wed, Nov 6, 2019 at 12:03 PM Blaž Hrastnik <blaz@mxxn.io> 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ž Hrastnik <blaz@mxxn.io>
> > > ---
> >
> > 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/test_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 == 0xff0000c5 && parser->global.report_count == 256 &&
> > >             parser->global.report_size == 8)
> > >                 parser->scan_flags |= HID_SCAN_FLAG_MT_WIN_8;
> > > +
> > > +       if (usage == 0xff0000c6 && parser->global.report_count == 1 &&
> > > +           parser->global.report_size == 8)
> > > +               parser->scan_flags |= HID_SCAN_FLAG_MT_WIN_8;
> > >  }
> > >
> > >  static void hid_scan_collection(struct hid_parser *parser, unsigned type)
> > > --
> > > 2.23.0
> > >
> >
> >


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-18 10:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 11:02 [PATCH] HID: Improve Windows Precision Touchpad detection Blaž Hrastnik
2019-11-07  8:48 ` Benjamin Tissoires
2019-11-07  9:06   ` Blaž Hrastnik
2019-11-18 10:04     ` Benjamin Tissoires

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).