summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-12-04 16:47:12 +0100
committerHans de Goede <hdegoede@redhat.com>2012-12-05 01:02:13 +0100
commit8c902c510b8e1c01d620064149c55185680b8679 (patch)
tree24ff8c98f2c4aa05330c81979a2e402afbc36150
parentd9d72deff1ed26324fa5a143f11a2040faf29993 (diff)
usbredirhost: Add a do-not-reset device blacklistbuffered-bulk-wip
And populate it with 1210:001c Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--ChangeLog1
-rw-r--r--usbredirhost/usbredirhost.c58
2 files changed, 48 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index f7af394..d60d3c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@ usbredir-0.6 28 November 2012
-queue multiple transfers for interrupt receiving
-add support for buffered bulk input
-only apply mult to max-packet-size for isoc high speed endpoints
+ -add a do-not-reset device blacklist, populate it with 1210:001c
usbredir-0.5.3 7 October 2012
------------------------------
diff --git a/usbredirhost/usbredirhost.c b/usbredirhost/usbredirhost.c
index b6b4ead..da3ef90 100644
--- a/usbredirhost/usbredirhost.c
+++ b/usbredirhost/usbredirhost.c
@@ -42,6 +42,9 @@
/* Special packet_idx value indicating a submitted transfer */
#define SUBMITTED_IDX -1
+/* quirk flags */
+#define QUIRK_DO_NOT_RESET 0x01
+
/* Macros to go from an endpoint address to an index for our ep array */
#define EP2I(ep_address) (((ep_address & 0x80) >> 3) | (ep_address & 0x0f))
#define I2EP(i) (((i & 0x10) << 3) | (i & 0x0f))
@@ -112,6 +115,7 @@ struct usbredirhost {
libusb_device_handle *handle;
struct libusb_device_descriptor desc;
struct libusb_config_descriptor *config;
+ int quirks;
int restore_config;
int claimed;
int reset;
@@ -127,6 +131,16 @@ struct usbredirhost {
int filter_rules_count;
};
+struct usbredirhost_dev_ids {
+ int vendor_id;
+ int product_id;
+};
+
+static const struct usbredirhost_dev_ids usbredirhost_reset_blacklist[] = {
+ { 0x1210, 0x001c },
+ { -1, -1 } /* Terminating Entry */
+};
+
static void
#if defined __GNUC__
__attribute__((format(printf, 3, 4)))
@@ -699,10 +713,29 @@ void usbredirhost_close(struct usbredirhost *host)
free(host);
}
+static int usbredirhost_reset_device(struct usbredirhost *host)
+{
+ int r;
+
+ if (host->quirks & QUIRK_DO_NOT_RESET) {
+ return 0;
+ }
+
+ r = libusb_reset_device(host->handle);
+ if (r != 0) {
+ ERROR("error resetting device: %s", libusb_error_name(r));
+ usbredirhost_clear_device(host);
+ return r;
+ }
+
+ host->reset = 1;
+ return 0;
+}
+
int usbredirhost_set_device(struct usbredirhost *host,
libusb_device_handle *usb_dev_handle)
{
- int r, status;
+ int i, r, status;
usbredirhost_clear_device(host);
@@ -718,15 +751,21 @@ int usbredirhost_set_device(struct usbredirhost *host,
return status;
}
+ for (i = 0; usbredirhost_reset_blacklist[i].vendor_id != -1; i++) {
+ if (host->desc.idVendor == usbredirhost_reset_blacklist[i].vendor_id &&
+ host->desc.idProduct ==
+ usbredirhost_reset_blacklist[i].product_id) {
+ host->quirks |= QUIRK_DO_NOT_RESET;
+ break;
+ }
+ }
+
/* The first thing almost any usb-guest does is a (slow) device-reset
so lets do that before hand */
- r = libusb_reset_device(host->handle);
+ r = usbredirhost_reset_device(host);
if (r != 0) {
- ERROR("error resetting device: %s", libusb_error_name(r));
- usbredirhost_clear_device(host);
return libusb_status_or_error_to_redir_status(host, r);
}
- host->reset = 1;
usbredirhost_send_device_connect(host);
@@ -763,6 +802,7 @@ static void usbredirhost_clear_device(struct usbredirhost *host)
}
host->connect_pending = 0;
+ host->quirks = 0;
host->dev = NULL;
usbredirhost_handle_disconnect(host);
@@ -1451,12 +1491,8 @@ static void usbredirhost_reset(void *priv)
return;
}
- r = libusb_reset_device(host->handle);
- if (r == 0) {
- host->reset = 1;
- } else {
- ERROR("error resetting device: %s", libusb_error_name(r));
- usbredirhost_clear_device(host);
+ r = usbredirhost_reset_device(host);
+ if (r != 0) {
host->read_status = usbredirhost_read_device_lost;
}
}