summaryrefslogtreecommitdiff
path: root/libusb/core.c
diff options
context:
space:
mode:
authorosy <50960678+osy@users.noreply.github.com>2021-05-11 20:56:27 -0700
committerNathan Hjelm <hjelmn@google.com>2021-05-16 15:14:49 -0600
commitabd788c203624930241f45f32b501c16936bd806 (patch)
tree2b37ea0501f4290ff66c3def72ce1c5d54767327 /libusb/core.c
parentbd097fe80255d4df55b673f45d96d39db0d47886 (diff)
downloadlibusb-abd788c203624930241f45f32b501c16936bd806.tar.gz
darwin: use detach kernel APIs for capture
When libusb_detach_kernel_driver() is called on the first interface, we use the capture re-enumerate APIs to force kernel drivers to detach. On subsequent calls, a counter is incremented to keep track of the number of detach calls. When libusb_attach_kernel_driver() is called for the same number of times, then we re-enumerate (reset) and let kernel drivers re-attach. darwin_kernel_driver_active() is changed to attempt to claim an interface and return 1 only if a kIOReturnExclusiveAccess status is returned. The old implementation which looks for a CFBundleID in the IORegistryEntry does not seem to work in all cases. darwin_reset_device() is aware of the capture status and will re-set twice if capture mode is enabled: once to do a USB reset and again to re-capture. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
Diffstat (limited to 'libusb/core.c')
-rw-r--r--libusb/core.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libusb/core.c b/libusb/core.c
index e04ec67..7a2f6c3 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -1994,7 +1994,7 @@ int API_EXPORTED libusb_kernel_driver_active(libusb_device_handle *dev_handle,
* Detach a kernel driver from an interface. If successful, you will then be
* able to claim the interface and perform I/O.
*
- * This functionality is not available on Darwin or Windows.
+ * This functionality is not available on Windows.
*
* Note that libusb itself also talks to the device through a special kernel
* driver, if this driver is already attached to the device, this call will
@@ -2030,10 +2030,9 @@ int API_EXPORTED libusb_detach_kernel_driver(libusb_device_handle *dev_handle,
/** \ingroup libusb_dev
* Re-attach an interface's kernel driver, which was previously detached
- * using libusb_detach_kernel_driver(). This call is only effective on
- * Linux and returns LIBUSB_ERROR_NOT_SUPPORTED on all other platforms.
+ * using libusb_detach_kernel_driver().
*
- * This functionality is not available on Darwin or Windows.
+ * This functionality is not available on Windows.
*
* \param dev_handle a device handle
* \param interface_number the interface to attach the driver from