本來這個blog是記錄開發輸入法的點滴的,後來越來越雜,現在什麼都記錄了。

2010年11月2日 星期二

iPod HID Report Descriptor, what exactly is the content?

I am working on iPod HID interface recently.

As the first thing to do when working on HID interface, the lsusb -vv is used.

Here is the result:
Bus 002 Device 005: ID 05ac:1291 Apple, Inc. iPod Touch 1.Gen
...
Interface Descriptor:
  bLength                 9
  bDescriptorType         4
  bInterfaceNumber        2
  bAlternateSetting       0
  bNumEndpoints           1
  bInterfaceClass         3 Human Interface Device
  bInterfaceSubClass      0 No Subclass
  bInterfaceProtocol      0 None
  iInterface              0
    HID Device Descriptor:
      bLength                 9
      bDescriptorType        33
      bcdHID               1.11
      bCountryCode            0 Not supported
      bNumDescriptors         1
      bDescriptorType        34 Report
      wDescriptorLength     208
     Report Descriptors:
       ** UNAVAILABLE **

It seems to me that wDescriptorLength is 208. I am not sure why the Report Descriptors is UNAVAILABLE.

According to this link: which somehow make the Report Descriptors available, the 208 bytes are:
06 00 ff 09 01 a1 01 75 08 26 80 00 15 00 09 01 85 01 95 05 82 02 01 09 01 85 02
95 09 82 02 01 09 01 85 03 95 0d 82 02 01 09 01 85 04 95 11 82 02 01 09 01 85 05
95 19 82 02 01 09 01 85 06 95 31 82 02 01 09 01 85 07 95 5f 82 02 01 09 01 85 08
95 c1 82 02 01 09 01 85 09 96 01 01 82 02 01 09 01 85 0a 96 81 01 82 02 01 09 01
85 0b 96 01 02 82 02 01 09 01 85 0c 96 ff 02 82 02 01 09 01 85 0d 95 05 92 02 01
09 01 85 0e 95 09 92 02 01 09 01 85 0f 95 0d 92 02 01 09 01 85 10 95 11 92 02 01
09 01 85 11 95 19 92 02 01 09 01 85 12 95 31 92 02 01 09 01 85 13 95 5f 92 02 01
09 01 85 14 95 c1 92 02 01 09 01 85 15 95 ff 92 02 01 c0

With the hidrd-convert tool, the above is parsed as shown below:
Usage Page (FF00h), ; FF00h, vendor-defined
Usage (01h),
Collection (Application),
 Report Size (8),
 Logical Maximum (128),
 Logical Minimum (0),
 Usage (01h), ReportID( 0x1), ReportCount(  5),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0x2), ReportCount(  9),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0x3), ReportCount( 13),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0x4), ReportCount( 17),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0x5), ReportCount( 25),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0x6), ReportCount( 49),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0x7), ReportCount( 95),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0x8), ReportCount(193),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0x9), ReportCount(257),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0xa), ReportCount(385),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0xb), ReportCount(513),  Input(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0xc), ReportCount(767),  Input(Variable, Buffered Bytes),

 Usage (01h), ReportID( 0xd), ReportCount(  5), Output(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0xe), ReportCount(  9), Output(Variable, Buffered Bytes),
 Usage (01h), ReportID( 0xf), ReportCount( 13), Output(Variable, Buffered Bytes),
 Usage (01h), ReportID(0x10), ReportCount( 17), Output(Variable, Buffered Bytes),
 Usage (01h), ReportID(0x11), ReportCount( 25), Output(Variable, Buffered Bytes),
 Usage (01h), ReportID(0x12), ReportCount( 49), Output(Variable, Buffered Bytes),
 Usage (01h), ReportID(0x13), ReportCount( 95), Output(Variable, Buffered Bytes),
 Usage (01h), ReportID(0x14), ReportCount(193), Output(Variable, Buffered Bytes),
 Usage (01h), ReportID(0x15), ReportCount(255), Output(Variable, Buffered Bytes),
End Collection

However, with a 3rd party library that I used for the embedded system I am working on, I got a completely different result.

The size of descriptor is 96 bytes!!!!!!!!!!! (but not 208 bytes for lsusb -vv):
0600 ff09 01a1 0175 0826 8000 1500 0901
8501 950c 8202 0109 0185 0295 0e82 0201
0901 8503 9514 8202 0109 0185 0495 3f82
0201 0901 8505 9508 9202 0109 0185 0695
0a92 0201 0901 8507 950e 9202 0109 0185
0895 1492 0201 0901 8509 953f 9202 01c0

After parsing:
Usage Page (FF00h),                     ; FF00h, vendor-defined
Usage (01h),
Collection (Application),
  Report Size (8),
  Logical Maximum (128),
  Logical Minimum (0),

  Usage (01h), Report ID (1), Report Count (12), Input  (Variable, Buffered Bytes),
  Usage (01h), Report ID (2), Report Count (14), Input  (Variable, Buffered Bytes),
  Usage (01h), Report ID (3), Report Count (20), Input  (Variable, Buffered Bytes),
  Usage (01h), Report ID (4), Report Count (63), Input  (Variable, Buffered Bytes),

  Usage (01h), Report ID (5), Report Count (8),  Output (Variable, Buffered Bytes),
  Usage (01h), Report ID (6), Report Count (10), Output (Variable, Buffered Bytes),
  Usage (01h), Report ID (7), Report Count (14), Output (Variable, Buffered Bytes),
  Usage (01h), Report ID (8), Report Count (20), Output (Variable, Buffered Bytes),
  Usage (01h), Report ID (9), Report Count (63), Output (Variable, Buffered Bytes),
End Collection

Which one should I believe???????