History log of /haiku/src/add-ons/kernel/drivers/bus/usb/usb_raw.h
Revision Date Author Comments
# b24d095e 12-Aug-2018 Adrien Destugues <pulkomandy@pulkomandy.tk>

usb: support for retrieving full configuration descriptors

In USB, the interface and endpoint descriptors, and possibly other
vendor-specific descriptors, are nested inside the configuration
descriptors. This makes it possible to retrieve the complete information
about a configuration in one single call.

Our drivers do this, and so does libusb (the Device Kit doesn't, it only
cares about individual descriptors and does not provide access to the
vendor-specific ones).

The driver did not expose the full descriptor, only the part that
belongs strictly to the configuration. libusb worked around this by
getting the descriptor from the device directly, using a control
transfer. This should be ok, but apparently some devices get confused
when you do this too often or at unexpected times.

These changes introduce a variation of the GET_CONFIGURATION_DESCRIPTOR
ioctl that allows the caller to specify a size. This way, one can get
the complete descriptor (after getting the configuration-only part to
figure out the size needed, most likely). The data is copied from
structures stored by the driver, so no further communication with the
device is necessary, making this safe to the problems mentioned above,
and faster.

Change-Id: Id97e40ea0d45b8c051ae8548486c4751fc6aad2a
Reviewed-on: https://review.haiku-os.org/453
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 1ce29039 24-Oct-2011 Philippe Houdoin <philippe.houdoin@gmail.com>

Revert r42812. As pointed by Michael, one can use
BUSBDevice::GetDescriptor() to retrieve whatever descriptor, including a
complete configuration descriptor.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42905 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d4155975 09-Oct-2011 Philippe Houdoin <philippe.houdoin@gmail.com>

Expand usb_raw ioctl to support retrieving full usb configuration descriptor from userland, not only the header part.
I try to keep UBSConfiguration binary compatibility, but proofreading is welcome.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42812 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 89dda280 10-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* Extend the usb_raw interface by alternate interface aware getters for
interfaces, endpoints and generic descriptors.
* Add getter for active interface index and simplify the count operation as
it isn't misused to also get interface descriptors anymore.
* Refactor out some common code into helper functions.
* Adapt the USBKit to the changed/new interface.
* Change how alternate interfaces are exposed by USBKit by providing normal
BUSBInterface objects for alternate interfaces that can easily be examined
and used.
* Make BUSBInterface class aware of its alternate index and use the alternate
aware usb_raw functionallity to build the endpoint and descriptor lists.
* Add ActiveAlternateIndex() to find out what alternate is currently active.
* Style cleanup of the USBKit classes, use std::nothrow everywhere and check
all allocations. Simplify some code by removing optimization where the benefit
is questionable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27409 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bfbbfedc 08-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Prepare usb_raw.h for eventually being made public. Prefixed enums values
with B_USB_* and the command union is now usb_raw_command.
* Changed usb_raw and the BUSB* classes accordingly.
* Moved the raw_device struct into usb_raw.cpp as suggested by Francois as it
was the only thing usb_raw_private.h defined.
* Removed usb_raw_private.h again because of the above.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24861 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d419b482 07-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Integrate the USBKit into libdevice and make it public. I left the USBKit.h
name, as it in fact is like a kit in the kit. It combines the different BUSB*
classes as compared to SerialPort.h where there really is a 1:1 relationship
between the header and the (one) class. If someone has a better fitting name
please shout.
Separated the usb_raw.h into usb_raw.h which defines the protocol and
usb_raw_private.h which holds the internal device structure for usb_raw. This
reduces the header dependencies.
Hopefully cought all occurencies of USBKit.a usage (in usb_dev_info and
the usb_webcam media add-on) but might have missed something that is not in
the image.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24858 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5aa70ae1 06-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Add a AlternateAt() method to the BUSBInterface class that can retrieve the
usb_interface_descriptor of an alternate interface without having to switch
to it.
* Add some reserve bytes to all classes and add some reserved virtual slots
where the objects are publically constructable.
* Remove the source compatibilty defines that were briding the old USB* with
the new BUSB* class names.
* Implement the usb_raw side of getting an alternate interface descriptor.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24842 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49df4099 06-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Implement a binary compatible way of setting an alternate interface through
usb_raw.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24835 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ca97e35 17-Jul-2007 Michael Lotz <mmlr@mlotz.ch>

Patches by Salvatore Benedetto to fix changes made by me and also the underlaying problem that caused high CPU usage in the isochronous finisher thread. Also includes patches to support isochronous support through USBKit / usb_raw. Thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21636 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2852a6db 25-Mar-2007 Michael Lotz <mmlr@mlotz.ch>

Removed transfer buffer in usb_raw driver. The user provided buffers are now used directly which saves two memcpy operations and removes the 4K transfer length restriction from the USBKit.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 42056120 23-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Made usb_raw more robust and correct when handling rescans and adding/removing devices
* Fixed warnings when debug output is on
* Disabled debug output

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18913 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cef51994 22-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

As Jerome put out correctly, I have forgotten to commit the v3 changes to usb_raw.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18577 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c768687 15-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

Adding usb_raw driver. Written from scratch, but kept the data structures and status codes to be compatible with existing apps. Tested OK with the PTP plugin for Exposure.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18512 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1ce29039cdb74fff21e73ab6cd8b5c8bf51caba8 24-Oct-2011 Philippe Houdoin <philippe.houdoin@gmail.com>

Revert r42812. As pointed by Michael, one can use
BUSBDevice::GetDescriptor() to retrieve whatever descriptor, including a
complete configuration descriptor.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42905 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d41559757e228cf311731050388e2534c660a55a 09-Oct-2011 Philippe Houdoin <philippe.houdoin@gmail.com>

Expand usb_raw ioctl to support retrieving full usb configuration descriptor from userland, not only the header part.
I try to keep UBSConfiguration binary compatibility, but proofreading is welcome.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42812 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 89dda2805209631fb64bd73e4f30df28405ca985 10-Sep-2008 Michael Lotz <mmlr@mlotz.ch>

* Extend the usb_raw interface by alternate interface aware getters for
interfaces, endpoints and generic descriptors.
* Add getter for active interface index and simplify the count operation as
it isn't misused to also get interface descriptors anymore.
* Refactor out some common code into helper functions.
* Adapt the USBKit to the changed/new interface.
* Change how alternate interfaces are exposed by USBKit by providing normal
BUSBInterface objects for alternate interfaces that can easily be examined
and used.
* Make BUSBInterface class aware of its alternate index and use the alternate
aware usb_raw functionallity to build the endpoint and descriptor lists.
* Add ActiveAlternateIndex() to find out what alternate is currently active.
* Style cleanup of the USBKit classes, use std::nothrow everywhere and check
all allocations. Simplify some code by removing optimization where the benefit
is questionable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27409 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bfbbfedc5f5a1e9ebb261dcf9095f647eb87f84c 08-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Prepare usb_raw.h for eventually being made public. Prefixed enums values
with B_USB_* and the command union is now usb_raw_command.
* Changed usb_raw and the BUSB* classes accordingly.
* Moved the raw_device struct into usb_raw.cpp as suggested by Francois as it
was the only thing usb_raw_private.h defined.
* Removed usb_raw_private.h again because of the above.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24861 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d419b482adf7aad578bc94e3d8142683356d5f99 07-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Integrate the USBKit into libdevice and make it public. I left the USBKit.h
name, as it in fact is like a kit in the kit. It combines the different BUSB*
classes as compared to SerialPort.h where there really is a 1:1 relationship
between the header and the (one) class. If someone has a better fitting name
please shout.
Separated the usb_raw.h into usb_raw.h which defines the protocol and
usb_raw_private.h which holds the internal device structure for usb_raw. This
reduces the header dependencies.
Hopefully cought all occurencies of USBKit.a usage (in usb_dev_info and
the usb_webcam media add-on) but might have missed something that is not in
the image.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24858 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5aa70ae1108840c0fbdb3413654ff4536792ef5e 06-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Add a AlternateAt() method to the BUSBInterface class that can retrieve the
usb_interface_descriptor of an alternate interface without having to switch
to it.
* Add some reserve bytes to all classes and add some reserved virtual slots
where the objects are publically constructable.
* Remove the source compatibilty defines that were briding the old USB* with
the new BUSB* class names.
* Implement the usb_raw side of getting an alternate interface descriptor.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24842 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 49df4099d1da0432db60774252d0c0413210d30a 06-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Implement a binary compatible way of setting an alternate interface through
usb_raw.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24835 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7ca97e354826f2569efddb8100b32d8f61db9c59 17-Jul-2007 Michael Lotz <mmlr@mlotz.ch>

Patches by Salvatore Benedetto to fix changes made by me and also the underlaying problem that caused high CPU usage in the isochronous finisher thread. Also includes patches to support isochronous support through USBKit / usb_raw. Thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21636 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2852a6db8fba6ba900ccbc9f007f970562698db1 25-Mar-2007 Michael Lotz <mmlr@mlotz.ch>

Removed transfer buffer in usb_raw driver. The user provided buffers are now used directly which saves two memcpy operations and removes the 4K transfer length restriction from the USBKit.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 42056120126fd66024a1b921340cdb9d82757611 23-Sep-2006 Michael Lotz <mmlr@mlotz.ch>

* Made usb_raw more robust and correct when handling rescans and adding/removing devices
* Fixed warnings when debug output is on
* Disabled debug output

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18913 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cef5199427b07343618f676d5086c53583ad656a 22-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

As Jerome put out correctly, I have forgotten to commit the v3 changes to usb_raw.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18577 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c7686879453826db4e5bbfca60fc793a7208af5 15-Aug-2006 Michael Lotz <mmlr@mlotz.ch>

Adding usb_raw driver. Written from scratch, but kept the data structures and status codes to be compatible with existing apps. Tested OK with the PTP plugin for Exposure.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18512 a95241bf-73f2-0310-859d-f6bbb57e9c96