From 1e340f4bad503a07dd30310aa3d10d5ec37f2b83 Mon Sep 17 00:00:00 2001 From: libdlo Date: Thu, 14 May 2009 11:00:28 -0700 Subject: Add functions to detach kernel drivers (but not yet working properly) --- src/dlo_usb.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/dlo_usb.c b/src/dlo_usb.c index 5c12ee3..e28f803 100644 --- a/src/dlo_usb.c +++ b/src/dlo_usb.c @@ -289,6 +289,7 @@ dlo_retcode_t dlo_usb_open(dlo_device_t * const dev) { dlo_retcode_t err; usb_dev_handle *uhand; + char* driver_name; int usb_configuration; int32_t db = usb_find_busses(); int32_t dd = usb_find_devices(); @@ -310,11 +311,26 @@ dlo_retcode_t dlo_usb_open(dlo_device_t * const dev) /* Establish the connection with the device */ //DPRINTF("usb: open: setting config...\n"); - /* set configuration fails on composite devices, - * such as 1st gen HP USB 2.0 docks. - * With libusb 1.0, we could at least only set - * configuration when necessary, but only partial - * mitigation. Need full solution. + /* + * Because some displaylink devices may report + * a class code (like HID or MSC) that gets + * matched by a kernel driver, must detach + * those drivers before libusb can successfully + * set configuration or talk to those devices + * unfortunately, this call returns error + * even if successful + / + driver_name = dlo_malloc(128); + if (!usb_get_driver_np(uhand, 0, driver_name, 128)) + { + DPRINTF("usb: driver (%s) already attached to device\n", driver_name); + usb_detach_kernel_driver_np(uhand,0); + } + + /* set configuration fails on composite devices. + * We could set configuration + * only when necessary, but that's just a partial + * mitigation. TODO: Need fuller solution. */ //usb_configuration = usb_get_configuration(uhand); //if (usb_configuration != 1) -- cgit v1.2.3