* Added USB API Version 3. It's put into USB3.h while the v2 API resides in USB2.h. USB.h just includes USB2.h for now.
* Rewrote both headers on the way. * The usb module now exports both, the v2 and v3 module_info. * Changed the internals of the USB Stack to give out usb_ids instead of opaque handles to internal classes. * Cleaned up some more of the Stack by moving members into other classes and removing unused stuff. * Updated the usb_raw driver from v2 to v3 API. Since both usb_hid (which still uses the v2 API) and usb_raw (which now uses the v3 API) work, I'd call it a success ;-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18539 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+6
-187
@@ -1,189 +1,8 @@
|
||||
/*
|
||||
** USB.h - Version 2 USB Device Driver API
|
||||
**
|
||||
** Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||
**
|
||||
*/
|
||||
* This file is here for compatibility reasons.
|
||||
*
|
||||
* You should include USB2.h or USB3.h depending on which API version you
|
||||
* intend to use.
|
||||
*/
|
||||
|
||||
#ifndef _USB_H
|
||||
#define _USB_H
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <bus_manager.h>
|
||||
|
||||
#include <USB_spec.h>
|
||||
#include <USB_rle.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct usb_module_info usb_module_info;
|
||||
|
||||
/* these are opaque handles to internal stack objects */
|
||||
typedef struct usb_device usb_device;
|
||||
typedef struct usb_interface usb_interface;
|
||||
typedef struct usb_pipe usb_pipe;
|
||||
|
||||
typedef struct usb_endpoint_info usb_endpoint_info;
|
||||
typedef struct usb_interface_info usb_interface_info;
|
||||
typedef struct usb_interface_list usb_interface_list;
|
||||
typedef struct usb_configuration_info usb_configuration_info;
|
||||
|
||||
typedef struct usb_notify_hooks {
|
||||
status_t (*device_added)(const usb_device *device, void **cookie);
|
||||
status_t (*device_removed)(void *cookie);
|
||||
} usb_notify_hooks;
|
||||
|
||||
typedef struct usb_support_descriptor {
|
||||
uint8 dev_class;
|
||||
uint8 dev_subclass;
|
||||
uint8 dev_protocol;
|
||||
uint16 vendor;
|
||||
uint16 product;
|
||||
} usb_support_descriptor;
|
||||
|
||||
/* ie, I support any hub device:
|
||||
** usb_support_descriptor hub_devs = { 9, 0, 0, 0, 0 };
|
||||
*/
|
||||
|
||||
struct usb_endpoint_info {
|
||||
usb_endpoint_descriptor *descr; /* descriptor and handle */
|
||||
usb_pipe *handle; /* of this endpoint/pipe */
|
||||
};
|
||||
|
||||
struct usb_interface_info {
|
||||
usb_interface_descriptor *descr; /* descriptor and handle */
|
||||
usb_interface *handle; /* of this interface */
|
||||
|
||||
size_t endpoint_count; /* count and list of endpoints */
|
||||
usb_endpoint_info *endpoint; /* in this interface */
|
||||
|
||||
size_t generic_count; /* unparsed descriptors in this */
|
||||
usb_descriptor **generic; /* interface */
|
||||
};
|
||||
|
||||
struct usb_interface_list {
|
||||
size_t alt_count; /* count and list of alternate */
|
||||
usb_interface_info *alt; /* interfaces available */
|
||||
|
||||
usb_interface_info *active; /* currently active alternate */
|
||||
};
|
||||
|
||||
struct usb_configuration_info {
|
||||
usb_configuration_descriptor *descr; /* descriptor of this config */
|
||||
|
||||
size_t interface_count; /* interfaces in this config */
|
||||
usb_interface_list *interface;
|
||||
};
|
||||
|
||||
|
||||
typedef void (*usb_callback_func)(void *cookie, uint32 status,
|
||||
void *data, uint32 actual_len);
|
||||
|
||||
struct usb_module_info {
|
||||
bus_manager_info binfo;
|
||||
|
||||
/* inform the bus manager of our intent to support a set of devices */
|
||||
status_t (*register_driver)(const char *driver_name,
|
||||
const usb_support_descriptor *descriptors,
|
||||
size_t count,
|
||||
const char *optional_republish_driver_name);
|
||||
|
||||
/* request notification from the bus manager for add/remove of devices we
|
||||
support */
|
||||
status_t (*install_notify)(const char *driver_name,
|
||||
const usb_notify_hooks *hooks);
|
||||
status_t (*uninstall_notify)(const char *driver_name);
|
||||
|
||||
/* get the device descriptor */
|
||||
const usb_device_descriptor *(*get_device_descriptor)(const usb_device *dev);
|
||||
|
||||
/* get the nth supported configuration */
|
||||
const usb_configuration_info *(*get_nth_configuration)(const usb_device *dev, uint index);
|
||||
|
||||
/* get the active configuration */
|
||||
const usb_configuration_info *(*get_configuration)(const usb_device *dev);
|
||||
|
||||
/* set the active configuration */
|
||||
status_t (*set_configuration)(const usb_device *dev,
|
||||
const usb_configuration_info *configuration);
|
||||
|
||||
status_t (*set_alt_interface)(const usb_device *dev,
|
||||
const usb_interface_info *ifc);
|
||||
|
||||
/* standard device requests -- convenience functions */
|
||||
/* obj may be a usb_device*, usb_pipe*, or usb_interface* */
|
||||
status_t (*set_feature)(const void *object, uint16 selector);
|
||||
status_t (*clear_feature)(const void *object, uint16 selector);
|
||||
status_t (*get_status)(const void *object, uint16 *status);
|
||||
|
||||
status_t (*get_descriptor)(const usb_device *d,
|
||||
uint8 type, uint8 index, uint16 lang,
|
||||
void *data, size_t len, size_t *actual_len);
|
||||
|
||||
/* generic device request function */
|
||||
status_t (*send_request)(const usb_device *d,
|
||||
uint8 request_type, uint8 request,
|
||||
uint16 value, uint16 index, uint16 length,
|
||||
void *data, size_t data_len, size_t *actual_len);
|
||||
|
||||
/* async request queueing */
|
||||
status_t (*queue_interrupt)(const usb_pipe *handle,
|
||||
void *data, size_t len,
|
||||
usb_callback_func notify, void *cookie);
|
||||
|
||||
status_t (*queue_bulk)(const usb_pipe *handle,
|
||||
void *data, size_t len,
|
||||
usb_callback_func notify, void *cookie);
|
||||
|
||||
status_t (*queue_isochronous)(const usb_pipe *handle,
|
||||
void *data, size_t len,
|
||||
rlea* rle_array, uint16 buffer_duration_ms,
|
||||
usb_callback_func notify, void *cookie);
|
||||
|
||||
status_t (*queue_request)(const usb_device *d,
|
||||
uint8 request_type, uint8 request,
|
||||
uint16 value, uint16 index, uint16 length,
|
||||
void *data, size_t data_len,
|
||||
usb_callback_func notify, void *cookie);
|
||||
|
||||
status_t (*set_pipe_policy)(const usb_pipe *handle, uint8 max_num_queued_packets,
|
||||
uint16 max_buffer_duration_ms, uint16 sample_size);
|
||||
|
||||
/* cancel pending async requests to an endpoint */
|
||||
status_t (*cancel_queued_transfers)(const usb_pipe *handle);
|
||||
|
||||
/* tuning, timeouts, etc */
|
||||
status_t (*usb_ioctl)(uint32 opcode, void* buf, size_t buf_size);
|
||||
};
|
||||
|
||||
/* status code for usb callback functions */
|
||||
#define B_USB_STATUS_SUCCESS 0x0000
|
||||
#define B_USB_STATUS_DEVICE_CRC_ERROR 0x0002
|
||||
#define B_USB_STATUS_DEVICE_TIMEOUT 0x0004
|
||||
#define B_USB_STATUS_DEVICE_STALLED 0x0008
|
||||
#define B_USB_STATUS_IRP_CANCELLED_BY_REQUEST 0x0010
|
||||
#define B_USB_STATUS_DRIVER_INTERNAL_ERROR 0x0020
|
||||
#define B_USB_STATUS_ADAPTER_HARDWARE_ERROR 0x0040
|
||||
#define B_USB_STATUS_ISOCH_IRP_ABORTED 0x0080
|
||||
|
||||
/* result codes for usb bus manager functions */
|
||||
#define B_USBD_SUCCESS 0
|
||||
#define B_USBD_BAD_HANDLE 1
|
||||
#define B_USBD_BAD_ARGS 2
|
||||
#define B_USBD_NO_DATA 3
|
||||
#define B_USBD_DEVICE_FAILURE 4
|
||||
#define B_USBD_COMMAND_FAILED 5
|
||||
#define B_USBD_PIPE_NOT_CONFIGURED 6
|
||||
#define B_USBD_DEVICE_ERROR 7
|
||||
#define B_USBD_PIPE_ERROR 8
|
||||
#define B_USBD_NO_MEMORY 9
|
||||
|
||||
#define B_USB_MODULE_NAME "bus_managers/usb/v2"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#include <USB2.h>
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Version 2 USB Device Driver API
|
||||
*
|
||||
* Copyright 2006, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef _USB_V2_H_
|
||||
#define _USB_V2_H_
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <bus_manager.h>
|
||||
|
||||
#include <USB_spec.h>
|
||||
#include <USB_rle.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct usb_module_info usb_module_info;
|
||||
|
||||
/* these are opaque handles to internal stack objects */
|
||||
typedef struct usb_device usb_device;
|
||||
typedef struct usb_interface usb_interface;
|
||||
typedef struct usb_pipe usb_pipe;
|
||||
|
||||
typedef struct usb_endpoint_info usb_endpoint_info;
|
||||
typedef struct usb_interface_info usb_interface_info;
|
||||
typedef struct usb_interface_list usb_interface_list;
|
||||
typedef struct usb_configuration_info usb_configuration_info;
|
||||
|
||||
typedef struct usb_notify_hooks {
|
||||
status_t (*device_added)(const usb_device *device, void **cookie);
|
||||
status_t (*device_removed)(void *cookie);
|
||||
} usb_notify_hooks;
|
||||
|
||||
typedef struct usb_support_descriptor {
|
||||
uint8 dev_class;
|
||||
uint8 dev_subclass;
|
||||
uint8 dev_protocol;
|
||||
uint16 vendor;
|
||||
uint16 product;
|
||||
} usb_support_descriptor;
|
||||
|
||||
struct usb_endpoint_info {
|
||||
usb_endpoint_descriptor *descr; /* descriptor and handle */
|
||||
usb_pipe *handle; /* of this endpoint/pipe */
|
||||
};
|
||||
|
||||
struct usb_interface_info {
|
||||
usb_interface_descriptor *descr; /* descriptor and handle */
|
||||
usb_interface *handle; /* of this interface */
|
||||
|
||||
size_t endpoint_count; /* count and list of endpoints */
|
||||
usb_endpoint_info *endpoint; /* in this interface */
|
||||
|
||||
size_t generic_count; /* unparsed descriptors in */
|
||||
usb_descriptor **generic; /* this interface */
|
||||
};
|
||||
|
||||
struct usb_interface_list {
|
||||
size_t alt_count; /* count and list of alternate */
|
||||
usb_interface_info *alt; /* interfaces available */
|
||||
|
||||
usb_interface_info *active; /* currently active alternate */
|
||||
};
|
||||
|
||||
struct usb_configuration_info {
|
||||
usb_configuration_descriptor *descr; /* descriptor of this config */
|
||||
|
||||
size_t interface_count;/* interfaces in this config */
|
||||
usb_interface_list *interface;
|
||||
};
|
||||
|
||||
typedef void (*usb_callback_func)(void *cookie, uint32 status, void *data,
|
||||
uint32 actualLength);
|
||||
|
||||
|
||||
/* The usb_module_info represents the public API of the USB Stack. */
|
||||
struct usb_module_info {
|
||||
bus_manager_info binfo;
|
||||
|
||||
/*
|
||||
* Use register_driver() to inform the Stack of your interest to support
|
||||
* USB devices. Support descriptors are used to indicate support for a
|
||||
* specific device class/subclass/protocol or vendor/product.
|
||||
* A value of 0 can be used as a wildcard for all fields.
|
||||
*
|
||||
* Would you like to be notified about all added hubs (class 0x09) you
|
||||
* would a support descriptor like this to register_driver:
|
||||
* usb_support_descriptor hub_devs = { 9, 0, 0, 0, 0 };
|
||||
*
|
||||
* If you intend to support just any device, or you at least want to be
|
||||
* notified about any device, just pass NULL as the supportDescriptor and
|
||||
* 0 as the supportDescriptorCount to register_driver.
|
||||
*/
|
||||
status_t (*register_driver)(const char *driverName,
|
||||
const usb_support_descriptor *supportDescriptors,
|
||||
size_t supportDescriptorCount,
|
||||
const char *optionalRepublishDriverName);
|
||||
|
||||
/*
|
||||
* Install notification hooks using your registered driverName. The
|
||||
* device_added hook will be called for every device that matches the
|
||||
* support descriptors you provided in register_driver.
|
||||
* When first installing the hooks you will receive a notification about
|
||||
* any already present matching device. If you return B_OK in this hook,
|
||||
* you can use the id that is provided. If the hook indicates an error,
|
||||
* the resources will be deallocated and you may not use the usb_device
|
||||
* that is provided. In this case you will not receive a device_removed
|
||||
* notification for the device either.
|
||||
*/
|
||||
status_t (*install_notify)(const char *driverName,
|
||||
const usb_notify_hooks *hooks);
|
||||
status_t (*uninstall_notify)(const char *driverName);
|
||||
|
||||
/* Get the device descriptor of a device. */
|
||||
const usb_device_descriptor *(*get_device_descriptor)(const usb_device *device);
|
||||
|
||||
/* Get the nth supported configuration of a device*/
|
||||
const usb_configuration_info *(*get_nth_configuration)(const usb_device *device,
|
||||
uint index);
|
||||
|
||||
/* Get the current configuration */
|
||||
const usb_configuration_info *(*get_configuration)(const usb_device *device);
|
||||
|
||||
/* Set the current configuration */
|
||||
status_t (*set_configuration)(const usb_device *device,
|
||||
const usb_configuration_info *configuration);
|
||||
|
||||
status_t (*set_alt_interface)(const usb_device *device,
|
||||
const usb_interface_info *interface);
|
||||
|
||||
/*
|
||||
* Standard device requests - convenience functions
|
||||
* The provided object may be a usb_device, usb_pipe or usb_interface
|
||||
*/
|
||||
status_t (*set_feature)(const void *object, uint16 selector);
|
||||
status_t (*clear_feature)(const void *object, uint16 selector);
|
||||
status_t (*get_status)(const void *object, uint16 *status);
|
||||
|
||||
status_t (*get_descriptor)(const usb_device *device,
|
||||
uint8 descriptorType, uint8 index,
|
||||
uint16 languageID, void *data,
|
||||
size_t dataLength,
|
||||
size_t *actualLength);
|
||||
|
||||
/* Generic device request function - synchronous */
|
||||
status_t (*send_request)(const usb_device *device,
|
||||
uint8 requestType, uint8 request,
|
||||
uint16 value, uint16 index,
|
||||
uint16 length, void *data,
|
||||
size_t dataLength,
|
||||
size_t *actualLength);
|
||||
|
||||
/*
|
||||
* Asynchronous request queueing. These functions return immediately
|
||||
* and the return code only tells whether the _queuing_ of the request
|
||||
* was successful or not. It doesn't indicate transfer success or error.
|
||||
*
|
||||
* When the transfer is finished, the provided callback function is
|
||||
* called with the transfer status, a pointer to the data buffer and
|
||||
* the actually transfered length as well as with the callbackCookie
|
||||
* that was used when queuing the request.
|
||||
*/
|
||||
status_t (*queue_interrupt)(const usb_pipe *pipe,
|
||||
void *data, size_t dataLength,
|
||||
usb_callback_func callback,
|
||||
void *callbackCookie);
|
||||
|
||||
status_t (*queue_bulk)(const usb_pipe *pipe,
|
||||
void *data, size_t dataLength,
|
||||
usb_callback_func callback,
|
||||
void *callbackCookie);
|
||||
|
||||
status_t (*queue_isochronous)(const usb_pipe *pipe,
|
||||
void *data, size_t dataLength,
|
||||
rlea *rleArray,
|
||||
uint16 bufferDurationMS,
|
||||
usb_callback_func callback,
|
||||
void *callbackCookie);
|
||||
|
||||
status_t (*queue_request)(const usb_device *device,
|
||||
uint8 requestType, uint8 request,
|
||||
uint16 value, uint16 index,
|
||||
uint16 length, void *data,
|
||||
size_t dataLength,
|
||||
usb_callback_func callback,
|
||||
void *callbackCookie);
|
||||
|
||||
status_t (*set_pipe_policy)(const usb_pipe *pipe,
|
||||
uint8 maxNumQueuedPackets,
|
||||
uint16 maxBufferDurationMS,
|
||||
uint16 sampleSize);
|
||||
|
||||
/* Cancel all pending async requests in a pipe */
|
||||
status_t (*cancel_queued_transfers)(const usb_pipe *pipe);
|
||||
|
||||
/* tuning, timeouts, etc */
|
||||
status_t (*usb_ioctl)(uint32 opcode, void *buffer,
|
||||
size_t bufferSize);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* These status are passed to the usb_callback_func callbacks. They indicate
|
||||
* the status of a completed queued transfer. Multiple of these status codes
|
||||
* may be combined. For example it is possible to have:
|
||||
* B_USB_STATUS_DEVICE_TIMEOUT | B_USB_STATUS_DEVICE_STALLED
|
||||
* This indicates that a timeout happened and that the used pipe is now
|
||||
* stalled.
|
||||
*/
|
||||
#define B_USB_STATUS_SUCCESS 0x0000
|
||||
#define B_USB_STATUS_DEVICE_CRC_ERROR 0x0002
|
||||
#define B_USB_STATUS_DEVICE_TIMEOUT 0x0004
|
||||
#define B_USB_STATUS_DEVICE_STALLED 0x0008
|
||||
#define B_USB_STATUS_IRP_CANCELLED_BY_REQUEST 0x0010
|
||||
#define B_USB_STATUS_DRIVER_INTERNAL_ERROR 0x0020
|
||||
#define B_USB_STATUS_ADAPTER_HARDWARE_ERROR 0x0040
|
||||
#define B_USB_STATUS_ISOCH_IRP_ABORTED 0x0080
|
||||
|
||||
|
||||
#define B_USB_MODULE_NAME "bus_managers/usb/v2"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_USB_V2_H_ */
|
||||
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* Version 3 USB Device Driver API
|
||||
*
|
||||
* Copyright 2006, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef _USB_V3_H_
|
||||
#define _USB_V3_H_
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <bus_manager.h>
|
||||
#include <iovec.h>
|
||||
|
||||
#include <USB_spec.h>
|
||||
#include <USB_rle.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct usb_module_info usb_module_info;
|
||||
|
||||
typedef uint32 usb_id;
|
||||
typedef usb_id usb_device;
|
||||
typedef usb_id usb_interface;
|
||||
typedef usb_id usb_pipe;
|
||||
|
||||
typedef struct usb_endpoint_info usb_endpoint_info;
|
||||
typedef struct usb_interface_info usb_interface_info;
|
||||
typedef struct usb_interface_list usb_interface_list;
|
||||
typedef struct usb_configuration_info usb_configuration_info;
|
||||
|
||||
typedef struct usb_notify_hooks {
|
||||
status_t (*device_added)(usb_device device, void **cookie);
|
||||
status_t (*device_removed)(void *cookie);
|
||||
} usb_notify_hooks;
|
||||
|
||||
typedef struct usb_support_descriptor {
|
||||
uint8 dev_class;
|
||||
uint8 dev_subclass;
|
||||
uint8 dev_protocol;
|
||||
uint16 vendor;
|
||||
uint16 product;
|
||||
} usb_support_descriptor;
|
||||
|
||||
struct usb_endpoint_info {
|
||||
usb_endpoint_descriptor *descr; /* descriptor and handle */
|
||||
usb_pipe handle; /* of this endpoint/pipe */
|
||||
};
|
||||
|
||||
struct usb_interface_info {
|
||||
usb_interface_descriptor *descr; /* descriptor and handle */
|
||||
usb_interface handle; /* of this interface */
|
||||
|
||||
size_t endpoint_count; /* count and list of endpoints */
|
||||
usb_endpoint_info *endpoint; /* in this interface */
|
||||
|
||||
size_t generic_count; /* unparsed descriptors in */
|
||||
usb_descriptor **generic; /* this interface */
|
||||
};
|
||||
|
||||
struct usb_interface_list {
|
||||
size_t alt_count; /* count and list of alternate */
|
||||
usb_interface_info *alt; /* interfaces available */
|
||||
|
||||
usb_interface_info *active; /* currently active alternate */
|
||||
};
|
||||
|
||||
struct usb_configuration_info {
|
||||
usb_configuration_descriptor *descr; /* descriptor of this config */
|
||||
|
||||
size_t interface_count;/* interfaces in this config */
|
||||
usb_interface_list *interface;
|
||||
};
|
||||
|
||||
typedef void (*usb_callback_func)(void *cookie, uint32 status, void *data,
|
||||
uint32 actualLength);
|
||||
|
||||
|
||||
/* The usb_module_info represents the public API of the USB Stack. */
|
||||
struct usb_module_info {
|
||||
bus_manager_info binfo;
|
||||
|
||||
/*
|
||||
* Use register_driver() to inform the Stack of your interest to support
|
||||
* USB devices. Support descriptors are used to indicate support for a
|
||||
* specific device class/subclass/protocol or vendor/product.
|
||||
* A value of 0 can be used as a wildcard for all fields.
|
||||
*
|
||||
* Would you like to be notified about all added hubs (class 0x09) you
|
||||
* would a support descriptor like this to register_driver:
|
||||
* usb_support_descriptor hub_devs = { 9, 0, 0, 0, 0 };
|
||||
*
|
||||
* If you intend to support just any device, or you at least want to be
|
||||
* notified about any device, just pass NULL as the supportDescriptor and
|
||||
* 0 as the supportDescriptorCount to register_driver.
|
||||
*/
|
||||
status_t (*register_driver)(const char *driverName,
|
||||
const usb_support_descriptor *supportDescriptors,
|
||||
size_t supportDescriptorCount,
|
||||
const char *optionalRepublishDriverName);
|
||||
|
||||
/*
|
||||
* Install notification hooks using your registered driverName. The
|
||||
* device_added hook will be called for every device that matches the
|
||||
* support descriptors you provided in register_driver.
|
||||
* When first installing the hooks you will receive a notification about
|
||||
* any already present matching device. If you return B_OK in this hook,
|
||||
* you can use the id that is provided. If the hook indicates an error,
|
||||
* the resources will be deallocated and you may not use the usb_device
|
||||
* that is provided. In this case you will not receive a device_removed
|
||||
* notification for the device either.
|
||||
*/
|
||||
status_t (*install_notify)(const char *driverName,
|
||||
const usb_notify_hooks *hooks);
|
||||
status_t (*uninstall_notify)(const char *driverName);
|
||||
|
||||
/* Get the device descriptor of a device. */
|
||||
const usb_device_descriptor *(*get_device_descriptor)(usb_device device);
|
||||
|
||||
/* Get the nth supported configuration of a device*/
|
||||
const usb_configuration_info *(*get_nth_configuration)(usb_device device,
|
||||
uint index);
|
||||
|
||||
/* Get the current configuration */
|
||||
const usb_configuration_info *(*get_configuration)(usb_device device);
|
||||
|
||||
/* Set the current configuration */
|
||||
status_t (*set_configuration)(usb_device device,
|
||||
const usb_configuration_info *configuration);
|
||||
|
||||
status_t (*set_alt_interface)(usb_device device,
|
||||
const usb_interface_info *interface);
|
||||
|
||||
/*
|
||||
* Standard device requests - convenience functions
|
||||
* The provided handle may be a usb_device, usb_pipe or usb_interface
|
||||
*/
|
||||
status_t (*set_feature)(usb_id handle, uint16 selector);
|
||||
status_t (*clear_feature)(usb_id handle, uint16 selector);
|
||||
status_t (*get_status)(usb_id handle, uint16 *status);
|
||||
|
||||
status_t (*get_descriptor)(usb_device device,
|
||||
uint8 descriptorType, uint8 index,
|
||||
uint16 languageID, void *data,
|
||||
size_t dataLength,
|
||||
size_t *actualLength);
|
||||
|
||||
/* Generic device request function - synchronous */
|
||||
status_t (*send_request)(usb_device device,
|
||||
uint8 requestType, uint8 request,
|
||||
uint16 value, uint16 index,
|
||||
uint16 length, void *data,
|
||||
size_t *actualLength);
|
||||
|
||||
/*
|
||||
* Asynchronous request queueing. These functions return immediately
|
||||
* and the return code only tells whether the _queuing_ of the request
|
||||
* was successful or not. It doesn't indicate transfer success or error.
|
||||
*
|
||||
* When the transfer is finished, the provided callback function is
|
||||
* called with the transfer status, a pointer to the data buffer and
|
||||
* the actually transfered length as well as with the callbackCookie
|
||||
* that was used when queuing the request.
|
||||
*/
|
||||
status_t (*queue_interrupt)(usb_pipe pipe,
|
||||
void *data, size_t dataLength,
|
||||
usb_callback_func callback,
|
||||
void *callbackCookie);
|
||||
|
||||
status_t (*queue_bulk)(usb_pipe pipe,
|
||||
void *data, size_t dataLength,
|
||||
usb_callback_func callback,
|
||||
void *callbackCookie);
|
||||
|
||||
status_t (*queue_bulk_v)(usb_pipe pipe,
|
||||
iovec *vector, size_t vectorCount,
|
||||
usb_callback_func callback,
|
||||
void *callbackCookie);
|
||||
|
||||
status_t (*queue_isochronous)(usb_pipe pipe,
|
||||
void *data, size_t dataLength,
|
||||
rlea *rleArray,
|
||||
uint16 bufferDurationMS,
|
||||
usb_callback_func callback,
|
||||
void *callbackCookie);
|
||||
|
||||
status_t (*queue_request)(usb_device device,
|
||||
uint8 requestType, uint8 request,
|
||||
uint16 value, uint16 index,
|
||||
uint16 length, void *data,
|
||||
usb_callback_func callback,
|
||||
void *callbackCookie);
|
||||
|
||||
status_t (*set_pipe_policy)(usb_pipe pipe,
|
||||
uint8 maxNumQueuedPackets,
|
||||
uint16 maxBufferDurationMS,
|
||||
uint16 sampleSize);
|
||||
|
||||
/* Cancel all pending async requests in a pipe */
|
||||
status_t (*cancel_queued_transfers)(usb_pipe pipe);
|
||||
|
||||
/* tuning, timeouts, etc */
|
||||
status_t (*usb_ioctl)(uint32 opcode, void *buffer,
|
||||
size_t bufferSize);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* These status are passed to the usb_callback_func callbacks. They indicate
|
||||
* the status of a completed queued transfer. Multiple of these status codes
|
||||
* may be combined. For example it is possible to have:
|
||||
* B_USB_STATUS_DEVICE_TIMEOUT | B_USB_STATUS_DEVICE_STALLED
|
||||
* This indicates that a timeout happened and that the used pipe is now
|
||||
* stalled.
|
||||
*/
|
||||
#define B_USB_STATUS_SUCCESS 0x0000
|
||||
#define B_USB_STATUS_DEVICE_CRC_ERROR 0x0002
|
||||
#define B_USB_STATUS_DEVICE_TIMEOUT 0x0004
|
||||
#define B_USB_STATUS_DEVICE_STALLED 0x0008
|
||||
#define B_USB_STATUS_IRP_CANCELLED_BY_REQUEST 0x0010
|
||||
#define B_USB_STATUS_DRIVER_INTERNAL_ERROR 0x0020
|
||||
#define B_USB_STATUS_ADAPTER_HARDWARE_ERROR 0x0040
|
||||
#define B_USB_STATUS_ISOCH_IRP_ABORTED 0x0080
|
||||
|
||||
|
||||
#define B_USB_MODULE_NAME "bus_managers/usb/v3"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_USB_V3_H_ */
|
||||
Reference in New Issue
Block a user