dump_audiostreaming_interface(): fix ac-3 decoder

Signed-off-by: Daniel Mack <daniel@caiaq.de>
parse USB audio class 2 control interface types

Audio Class 2 devices have to be dealt with differently in many ways.
The descriptors have different layouts, there are some new types etc.

This patch adds support parsing for the audio control interfaces and
introduces a new helper function dump_audio_bmcontrols() to parse the
control bitmaps.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
parse USB audio class 2 streaming interfaces

Signed-off-by: Daniel Mack <daniel@caiaq.de>
parse USB audio class 2 endpoints

Signed-off-by: Daniel Mack <daniel@caiaq.de>
dump_audio_bmcontrols(): tell users about faulty bmControl bits

Signed-off-by: Daniel Mack <daniel@caiaq.de>
dump_audiostreaming_interface(): drop audio class 2 FORMAT_TYPE length check

This check is done for the individual subtypes anyway, so drop it for
the generic header.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
more gadget device ids reserved for the Linux Foundation vendor id

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Include config.h before everything else.

In a couple of cases, we fail to include config.h before all standard
header files. As configure.ac specifies AC_SYS_LARGEFILE, config.h can
define things like _FILE_OFFSET_BITS=64, which must be defined before
all standard headers are included. Changing this in the middle of
compilation confuses things like zlib, and can lead to compilation
failures:

In file included from names.c:42:
/usr/include/32/zlib.h:1583: error: conflicting types for 'gzseek64'
/usr/include/32/zlib.h:1567: note: previous declaration of 'gzseek64' was here
/usr/include/32/zlib.h:1584: error: conflicting types for 'gztell64'
/usr/include/32/zlib.h:1568: note: previous declaration of 'gztell64' was here
/usr/include/32/zlib.h:1585: error: conflicting types for 'gzoffset64'
/usr/include/32/zlib.h:1569: note: previous declaration of 'gzoffset64' was here
/usr/include/32/zlib.h:1586: error: conflicting types for 'adler32_combine64'
/usr/include/32/zlib.h:1570: note: previous declaration of 'adler32_combine64' was here
/usr/include/32/zlib.h:1587: error: conflicting types for 'crc32_combine64'
/usr/include/32/zlib.h:1571: note: previous declaration of 'crc32_combine64' was here
make[1]: *** [lsusb-names.o] Error 1

The fix is to include it first.

Signed-off-by: Nick Alcock <nix@esperi.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
lsusb: fix iFeature position calculation for UAC2 feature units

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Reported-by: Ken McGuire <kenm@paonia.com>
Update Gemplus id

The file /var/lib/usbutils/usb.ids I have (from Debian package 0.87-5)
contains the line:
	08e6	Gemplus

Gemplus and Axalto companies have been merged into Gemalto a few years ago.
08e6 is now the identification for Gemalto (and not Gemplus any more).

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Fix up a lot of memory leaks

Based on an original patch from Pedro Kiefer <pedro@kiefer.com.br>

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
usbutils 0.90 release
usbutils.pc: use datarootdir

If you want to configure paths so that the usb.ids is stored in a proper
subdir of the /usr/share tree, you currently then have to manually move
the .pc file back up to /usr/share.  If we based the pkgconfig dir on the
datarootdir variable however, we can easily decouple the install of the
usb.ids file file from the rest of the files (man/etc...).

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fix building on non-Linux systems (e.g. BSD)

Not all C libraries provide byteswap.h, so check for it before we include
it.  Further, we use functions from unistd.h (e.g. access()), but don't
include the header, so pull it in.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Integrate usbhid-dump

Add usbhid-dump as a submodule,
integrate into the build with AC_CONFIG_SUBDIRS.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
usbutils: Fix Wireless USB descriptor fetching.

The Wireless USB standard says all devices must have a bcdUSB of 0x250.
USB 3.0 devices must have a bcdUSB of 0x300, so don't try to dump wireless
descriptors for USB 3.0 devices.  (Note that do_wireless() immediately
returns, so this patch doesn't have any behavior change right now.)

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
usbutils: Support USB 3.0 hub descriptor output.

USB 3.0 hubs have a different hub descriptor than USB 2.0 hubs, with a
different bDescriptorType.  USB 3.0 hubs don't have transaction
translators (TTs) since they only handle SuperSpeed devices.  The USB 3.0
hubs also have a different port status and change format.

Sample output from a USB 3.0 hub prototype:

Hub Descriptor:
  bLength              12
  bDescriptorType      42
  nNbrPorts             4
  wHubCharacteristic 0x0009
    Per-port power switching
    Per-port overcurrent protection
  bPwrOn2PwrGood        0 * 2 milli seconds
  bHubContrCurrent      8 milli Ampere
  bHubDecLat          0.0 micro seconds
  wHubDelay             0 nano seconds
  DeviceRemovable    0x00
 Hub Port Status:
   Port 1: 0000.02a0 5Gbps power Rx.Detect
   Port 2: 0000.02a0 5Gbps power Rx.Detect
   Port 3: 0000.02a0 5Gbps power Rx.Detect
   Port 4: 0000.02a0 5Gbps power Rx.Detect

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
usbutils: Print MaxStreams and Mult for USB 3.0 devices.

Add the ability to print the MaxStreams and Mult fields from the
SuperSpeed Endpoint Companion Descriptors.  Only print them for the
correct endpoint types (MaxStreams is only valid for bulk endpoints, and
Mult is only valid for isochronous endpoints).

TODO: Print wBytesPerInterval from the SuperSpeed Endpoint Companion
Descriptor.

Sample output for a USB Attached SCSI device prototype with an alt setting
that supports bulk streams looks like:

    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       1
      bNumEndpoints           4
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     98
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0400  1x 1024 bytes
        bInterval               0
        bMaxBurst               1
        INTERFACE CLASS:  04 24 01 00
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0400  1x 1024 bytes
        bInterval               0
        bMaxBurst              16
        MaxStreams          65536
        INTERFACE CLASS:  04 24 03 00
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0400  1x 1024 bytes
        bInterval               0
        bMaxBurst               6
        MaxStreams          65536
        INTERFACE CLASS:  04 24 04 00
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0400  1x 1024 bytes
        bInterval               0
        bMaxBurst               1
        MaxStreams          65536
        INTERFACE CLASS:  04 24 02 00

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
usbutils: Print Binary Object Store descriptor.

Wireless USB devices and USB 3.0 devices both have Binary Object Store
(BOS) descriptors.  Some USB 2.0 devices also may also have a BOS
descriptor.

Add printing for 3 of the 4 Device Capability descriptors within the BOS
descriptor: USB 2.0 Extension, SuperSpeed USB, and Container ID device
capability descriptors.  I didn't add the Wireless USB case, because I
have no devices to test with.

Here's sample output of the BOS descriptor from lsusb -v:

Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength           42
  bNumDeviceCaps          3
  USB 2.0 Extension Device Capability:
    bLength                 7
    bDescriptorType        16
    bDevCapabilityType      2
    bmAttributes   0x00000002
      Link Power Management (LPM) Supported
  SuperSpeed USB Device Capability:
    bLength                10
    bDescriptorType        16
    bDevCapabilityType      3
    bmAttributes         0x00
      Latency Tolerance Messages (LTM) Supported
    wSpeedsSupported   0x000f
      Device can operate at Low Speed (1Mbps)
      Device can operate at Full Speed (12Mbps)
      Device can operate at High Speed (480Mbps)
      Device can operate at SuperSpeed (5Gbps)
    bFunctionalitySupport   0
      Lowest fully-functional device speed is Low Speed (1Mbps)
    bU1DevExitLat           0 micro seconds
    bU2DevExitLat        1255 micro seconds
  Container ID Device Capability:
    bLength                20
    bDescriptorType        16
    bDevCapabilityType      4
    bReserved               0
    ContainerID             {00000000-0000-0000-0000-000000000000}

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
add usbhid-dump to the autogen.sh script

as recommended by Nikolai Kondrashov

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>