Hi,

on the Pinebook Pro the trackpad isn't working.  The reason is that the
Y-coordinate is extracted twice.  The first location has thevalue
correctly, the second location has it zeroed or garbage.  This is
because when we iterate over the report, the Y-coordinate usage
appears twice.  This shouldn't happen, so why does it?

Here's an excerpt of the report descriptor:

Item(Global): Logical Maximum, data= [ 0x92 0x03 ] 914
Item(Global): Physical Maximum, data= [ 0x40 0x01 ] 320
Item(Local ): Usage, data= [ 0x31 ] 49
                Direction-Y
Item(Main  ): Input, data= [ 0x02 ] 2
                Data Variable Absolute No_Wrap Linear
                Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Main  ): End Collection, data=none
Item(Main  ): Collection, data= [ 0x02 ] 2
                Logical

Directly after the Y-coordinate a collection ends and another starts.
The end of the collection will make hid_get_item() return with an item
where h.kind is hid_endcollection and h.usage is zero.  The start of the
new collection will make hid_get_item() return, and it will return with
h.kind set to hid_collection and h.usage set to the last usage, which
in this case is "Direction-Y".

Since we don't filter out hid_(end)collection, we add this item to the
list.  So, by making sure we only add hid_input items, the Pinebook
Pro's trackpad works.

Now I'm not sure if the hid code is supposed to re-use the Y-coordi-
nates usage on the next collection.  If someone knows how that should
work, please let me down.

ok?

Patrick

diff --git a/sys/dev/hid/hidmt.c b/sys/dev/hid/hidmt.c
index ee8dcadcc31..67eea46f0c0 100644
--- a/sys/dev/hid/hidmt.c
+++ b/sys/dev/hid/hidmt.c
@@ -176,6 +176,8 @@ hidmt_setup(struct device *self, struct hidmt *mt, void 
*desc, int dlen)
 
                if (h.report_ID != mt->sc_rep_input)
                        continue;
+               if (h.kind != hid_input)
+                       continue;
 
                switch (h.usage) {
                /* contact level usages */

Reply via email to