1*2326dee4SMarco Morandini.. SPDX-License-Identifier: GPL-2.0 2*2326dee4SMarco Morandini 3*2326dee4SMarco Morandini======================================== 4*2326dee4SMarco MorandiniManual parsing of HID report descriptors 5*2326dee4SMarco Morandini======================================== 6*2326dee4SMarco Morandini 7*2326dee4SMarco MorandiniConsider again the mouse HID report descriptor 8*2326dee4SMarco Morandiniintroduced in Documentation/hid/hidintro.rst:: 9*2326dee4SMarco Morandini 10*2326dee4SMarco Morandini $ hexdump -C /sys/bus/hid/devices/0003\:093A\:2510.0002/report_descriptor 11*2326dee4SMarco Morandini 00000000 05 01 09 02 a1 01 09 01 a1 00 05 09 19 01 29 03 |..............).| 12*2326dee4SMarco Morandini 00000010 15 00 25 01 75 01 95 03 81 02 75 05 95 01 81 01 |..%.u.....u.....| 13*2326dee4SMarco Morandini 00000020 05 01 09 30 09 31 09 38 15 81 25 7f 75 08 95 03 |...0.1.8..%.u...| 14*2326dee4SMarco Morandini 00000030 81 06 c0 c0 |....| 15*2326dee4SMarco Morandini 00000034 16*2326dee4SMarco Morandini 17*2326dee4SMarco Morandiniand try to parse it by hand. 18*2326dee4SMarco Morandini 19*2326dee4SMarco MorandiniStart with the first number, 0x05: it carries 2 bits for the 20*2326dee4SMarco Morandinilength of the item, 2 bits for the type of the item and 4 bits for the 21*2326dee4SMarco Morandinifunction:: 22*2326dee4SMarco Morandini 23*2326dee4SMarco Morandini +----------+ 24*2326dee4SMarco Morandini | 00000101 | 25*2326dee4SMarco Morandini +----------+ 26*2326dee4SMarco Morandini ^^ 27*2326dee4SMarco Morandini ---- Length of data (see HID spec 6.2.2.2) 28*2326dee4SMarco Morandini ^^ 29*2326dee4SMarco Morandini ------ Type of the item (see HID spec 6.2.2.2, then jump to 6.2.2.7) 30*2326dee4SMarco Morandini ^^^^ 31*2326dee4SMarco Morandini --------- Function of the item (see HID spec 6.2.2.7, then HUT Sec 3) 32*2326dee4SMarco Morandini 33*2326dee4SMarco MorandiniIn our case, the length is 1 byte, the type is ``Global`` and the 34*2326dee4SMarco Morandinifunction is ``Usage Page``, thus for parsing the value 0x01 in the second byte 35*2326dee4SMarco Morandiniwe need to refer to HUT Sec 3. 36*2326dee4SMarco Morandini 37*2326dee4SMarco MorandiniThe second number is the actual data, and its meaning can be found in 38*2326dee4SMarco Morandinithe HUT. We have a ``Usage Page``, thus we need to refer to HUT 39*2326dee4SMarco MorandiniSec. 3, "Usage Pages"; from there, one sees that ``0x01`` stands for 40*2326dee4SMarco Morandini``Generic Desktop Page``. 41*2326dee4SMarco Morandini 42*2326dee4SMarco MorandiniMoving now to the second two bytes, and following the same scheme, 43*2326dee4SMarco Morandini``0x09`` (i.e. ``00001001``) will be followed by one byte (``01``) 44*2326dee4SMarco Morandiniand is a ``Local`` item (``10``). Thus, the meaning of the remaining four bits 45*2326dee4SMarco Morandini(``0000``) is given in the HID spec Sec. 6.2.2.8 "Local Items", so that 46*2326dee4SMarco Morandiniwe have a ``Usage``. From HUT, Sec. 4, "Generic Desktop Page", we see that 47*2326dee4SMarco Morandini0x02 stands for ``Mouse``. 48*2326dee4SMarco Morandini 49*2326dee4SMarco MorandiniThe following numbers can be parsed in the same way. 50