summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-10-05 11:21:55 +0100
committerPete Batard <pbatard@gmail.com>2010-10-05 11:21:55 +0100
commit95ff145cbd1d972baaab29b2782c6aae47829a6e (patch)
tree081b0d7719c1b5baa983b89fd424c4fd33e9182c
parent96c4dd4e7fda606ad9f5473db8ff3f91a5392b63 (diff)
downloadlibusb-95ff145cbd1d972baaab29b2782c6aae47829a6e.tar.gz
added hub API and removed is_hub dev private property
-rw-r--r--libusb/os/windows_usb.c33
-rw-r--r--libusb/os/windows_usb.h19
2 files changed, 36 insertions, 16 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index c44fa0a..bf94603 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -912,7 +912,7 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d
}
priv = __device_priv(dev);
parent_priv = __device_priv(parent_dev);
- if (!parent_priv->is_hub) {
+ if (parent_priv->apib != &usb_api_backend[USB_API_HUB]) {
usbi_warn(ctx, "parent device is not a hub");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -1320,11 +1320,11 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
usbi_err(ctx, "program assertion failed: unlisted parent for '%s'", dev_id_path);
LOOP_BREAK(LIBUSB_ERROR_NO_DEVICE);
}
+ parent_priv = __device_priv(parent_dev);
// virtual USB devices are also listed during GEN - don't process these yet
- if ( (pass == GEN_PASS) && (!(__device_priv(parent_dev)->is_hub)) ) {
+ if ( (pass == GEN_PASS) && (parent_priv->apib != &usb_api_backend[USB_API_HUB]) ) {
continue;
}
- parent_priv = __device_priv(parent_dev);
break;
}
@@ -1335,7 +1335,7 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
dev = usbi_get_device_by_session_id(ctx, session_id);
if (dev != NULL) {
// No need to re-process hubs
- if (__device_priv(dev)->is_hub) {
+ if (__device_priv(dev)->apib == &usb_api_backend[USB_API_HUB]) {
continue;
}
usbi_dbg("found existing device for session [%lX]", session_id);
@@ -1381,7 +1381,7 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
dev->bus_number = (uint8_t)(i + 1); // bus 0 is reserved for disconnected
dev->device_address = 0; //UINT8_MAX;
dev->num_configurations = 0;
- priv->is_hub = true;
+ priv->apib = &usb_api_backend[USB_API_HUB];
priv->depth = UINT8_MAX; // Overflow to 0 for HCD Hubs
priv->path = dev_interface_path; dev_interface_path = NULL;
break;
@@ -1415,7 +1415,7 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
}
break;
case HUB_PASS:
- priv->is_hub = true;
+ priv->apib = &usb_api_backend[USB_API_HUB];
priv->path = dev_interface_path; dev_interface_path = NULL;
// fall through, as we must initialize hubs before generic devices
case GEN_PASS:
@@ -2178,6 +2178,27 @@ const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
unsupported_abort_transfers,
unsupported_copy_transfer_data,
}, {
+ USB_API_HUB,
+ "HUB API (Unsupported)",
+ &CLASS_GUID_UNSUPPORTED,
+ NULL,
+ 0,
+ unsupported_init,
+ unsupported_exit,
+ unsupported_open,
+ unsupported_close,
+ unsupported_claim_interface,
+ unsupported_set_interface_altsetting,
+ unsupported_release_interface,
+ unsupported_clear_halt,
+ unsupported_reset_device,
+ unsupported_submit_bulk_transfer,
+ unsupported_submit_iso_transfer,
+ unsupported_submit_control_transfer,
+ unsupported_abort_control,
+ unsupported_abort_transfers,
+ unsupported_copy_transfer_data,
+ }, {
USB_API_COMPOSITE,
"Composite API",
&CLASS_GUID_COMPOSITE,
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h
index b2cb160..4b708cc 100644
--- a/libusb/os/windows_usb.h
+++ b/libusb/os/windows_usb.h
@@ -114,10 +114,11 @@ const GUID GUID_NULL = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x
* Multiple USB API backend support
*/
#define USB_API_UNSUPPORTED 0
-#define USB_API_COMPOSITE 1
-#define USB_API_WINUSB 2
-#define USB_API_HID 3
-#define USB_API_MAX 4
+#define USB_API_HUB 1
+#define USB_API_COMPOSITE 2
+#define USB_API_WINUSB 3
+#define USB_API_HID 4
+#define USB_API_MAX 5
#define CLASS_GUID_UNSUPPORTED GUID_NULL
const GUID CLASS_GUID_HID = { 0x745A17A0, 0x74D3, 0x11D0, {0xB6, 0xFE, 0x00, 0xA0, 0xC9, 0x0F, 0x57, 0xDA} };
@@ -225,14 +226,13 @@ struct hid_device_priv {
typedef struct libusb_device_descriptor USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
struct windows_device_priv {
- bool is_hub; // NEW: is the device a hub?
- uint8_t depth; // NEW: distance to HCD
- uint8_t port; // NEW: port number on the hub
+ uint8_t depth; // distance to HCD
+ uint8_t port; // port number on the hub
struct libusb_device *parent_dev; // access to parent is required for usermode ops
- char *path; // Device Interface Path
+ char *path; // device interface path
struct windows_usb_api_backend const *apib;
struct {
- char *path; // Each interface needs a Device Interface Path,
+ char *path; // each interface needs a device interface path,
struct windows_usb_api_backend const *apib; // an API backend (multiple drivers support),
int8_t nb_endpoints; // and a set of endpoint addresses (USB_MAXENDPOINTS)
uint8_t *endpoint;
@@ -253,7 +253,6 @@ static inline struct windows_device_priv *__device_priv(struct libusb_device *de
static inline void windows_device_priv_init(libusb_device* dev) {
struct windows_device_priv* p = __device_priv(dev);
int i;
- p->is_hub = false;
p->depth = 0;
p->port = 0;
p->parent_dev = NULL;