NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/46868: usb - hid_is_collection matching problems.



>Number:         46868
>Category:       kern
>Synopsis:       usb - hid_is_collection matching problems.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 28 14:45:00 +0000 2012
>Originator:     Nat Sloss
>Release:        NetBSD Current 6.99.7
>Organization:
>Environment:
NetBSD beast 6.99.7 NetBSD 6.99.7 (LOCKDEBUG) #186: Wed Jul  4 05:47:37 EST 
2012  build@beast:/usr/src/sys/arch/i386/compile/obj/LOCKDEBUG i386

>Description:
There is a problem matching hid collections under certain conditions.

Consider the following usbhidctl output:

report ID=0
Report descriptor:
item: kind=3 repid=0 usage=0xd0002
Collection page=Digitizer usage=Pen (13:0x2)
item: kind=3 repid=0 usage=0xd0020
Collection page=Digitizer usage=Stylus (13:0x20)
item: kind=0 repid=0 usage=0xd0042
Input   size=1 count=1 page=Digitizer usage=Tip_Switch (13:0x42), logical range 
0..1
item: kind=0 repid=0 usage=0xd0044
Input   size=1 count=1 page=Digitizer usage=Barrel_Switch (13:0x44), logical 
range 0..1
item: kind=0 repid=0 usage=0xd003c
Input   size=1 count=1 page=Digitizer usage=Invert (13:0x3c), logical range 0..1
item: kind=0 repid=0 usage=0xd0045
Input   size=1 count=1 page=Digitizer usage=Eraser (13:0x45), logical range 0..1
item: kind=0 repid=0 usage=0x0
Input   size=1 count=1 Const page=0x0000 usage=0x0000 (0:0x0), logical range 
0..1
item: kind=0 repid=0 usage=0xd0032
Input   size=1 count=1 page=Digitizer usage=In_Range (13:0x32), logical range 
0..1
item: kind=0 repid=0 usage=0x0
Input   size=1 count=1 Const page=0x0000 usage=0x0000 (0:0x0), logical range 
0..1
item: kind=0 repid=0 usage=0x0
Input   size=1 count=1 Const page=0x0000 usage=0x0000 (0:0x0), logical range 
0..1
item: kind=0 repid=0 usage=0x10030
Input   size=16 count=1 page=Generic_Desktop usage=X (1:0x30), logical range 
0..4095, physical range 0..4095
item: kind=0 repid=0 usage=0x10031
Input   size=16 count=1 page=Generic_Desktop usage=Y (1:0x31), logical range 
0..4095, physical range 0..4095
item: kind=4 repid=0 usage=0x0
End collection
item: kind=4 repid=0 usage=0x0
End collection
Total   input size 5 bytes
Total  output size 0 bytes
Total feature size 0 bytes


There are two usages: Pen and stylus.
The Pen usage has collection type application and stylus physical.

Whilst experimenting with ums.c trying to match on the stylus usage it would 
always fail.  This was experienced by another user I believe this could be the 
reason for their problem.  Refer to kern/46391.

What ever the last usage of kind collection of collection application is 
considered and then it checks for input reports.

hid_is_collection should not check for any reports (input, output or feature) 
but just match on the collection usage and then it should be up to the 
corresponding driver to check for input reports or output reports.

It should check all collection types application, physical and logical and not 
check any input reports.  Just match if it is a valid collection.
>How-To-Repeat:
Attempt to use with certain types of touchscreen/digitizer.
>Fix:
To fix the problem I patched hid.c as follows:

Index: src/sys/dev/usb/hid.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/hid.c,v
retrieving revision 1.35
diff -u -r1.35 hid.c
--- src/sys/dev/usb/hid.c       24 Feb 2012 06:48:23 -0000      1.35
+++ src/sys/dev/usb/hid.c       28 Aug 2012 14:15:10 -0000
@@ -501,13 +501,15 @@
                            hi.kind, hi.report_ID, hi.usage, coll_usage));
 
                if (hi.kind == hid_collection &&
-                   hi.collection == HCOLL_APPLICATION)
+                   (hi.collection == HCOLL_APPLICATION ||
+                   hi.collection == HCOLL_PHYSICAL ||
+                   hi.collection == HCOLL_LOGICAL))
                        coll_usage = hi.usage;
 
                if (hi.kind == hid_endcollection)
                        coll_usage = ~0;
 
-               if (hi.kind == hid_input &&
+               if (hi.kind == hid_collection &&
                    coll_usage == usage &&
                    hi.report_ID == id) {
                        DPRINTFN(2,("hid_is_collection: found\n"));


Note:  This patch is my own work which I submit under the NetBSD licence.

After applying this patch, I was able to match on pen and stylus usages.

Regards,

Nat.



Home | Main Index | Thread Index | Old Index