diff options
author | Josh Blum <josh@joshknows.com> | 2013-03-11 11:30:37 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2013-03-11 11:30:37 -0700 |
commit | d39020b2364ef9fd17d51208fd94f025ed769e04 (patch) | |
tree | bc0615238875f3baa90f621949ae523ea9f5a5d7 | |
parent | 83063ea8b149281717677b1e20ab5e014996778d (diff) | |
download | uhd-d39020b2364ef9fd17d51208fd94f025ed769e04.tar.gz uhd-d39020b2364ef9fd17d51208fd94f025ed769e04.tar.bz2 uhd-d39020b2364ef9fd17d51208fd94f025ed769e04.zip |
usb: check for and use libusb_handle_events_timeout_completed
-rw-r--r-- | host/cmake/Modules/FindUSB1.cmake | 14 | ||||
-rw-r--r-- | host/lib/transport/CMakeLists.txt | 4 | ||||
-rw-r--r-- | host/lib/transport/libusb1_zero_copy.cpp | 10 |
3 files changed, 25 insertions, 3 deletions
diff --git a/host/cmake/Modules/FindUSB1.cmake b/host/cmake/Modules/FindUSB1.cmake index 8bfc2f975..33ac891bc 100644 --- a/host/cmake/Modules/FindUSB1.cmake +++ b/host/cmake/Modules/FindUSB1.cmake @@ -32,7 +32,19 @@ FIND_LIBRARY(LIBUSB_LIBRARIES PATHS /usr/local/lib /usr/lib /opt/local/lib ) +include(CheckFunctionExists) +if(LIBUSB_INCLUDE_DIRS) + set(CMAKE_REQUIRED_INCLUDES ${LIBUSB_INCLUDE_DIRS}) +endif() +if(LIBUSB_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES ${LIBUSB_LIBRARIES}) +endif() +CHECK_FUNCTION_EXISTS("libusb_handle_events_timeout_completed" HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED) + +if(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED) + list(APPEND LIBUSB_DEFINITIONS "HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED=1") +endif(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED) + include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIRS) MARK_AS_ADVANCED(LIBUSB_INCLUDE_DIRS LIBUSB_LIBRARIES) - diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index 6524a8412..4eb7c8c92 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -37,6 +37,10 @@ IF(ENABLE_USB) ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_base.cpp ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_base.hpp ) + SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_zero_copy.cpp + PROPERTIES COMPILE_DEFINITIONS "${LIBUSB_DEFINITIONS}" + ) ELSE(ENABLE_USB) LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/usb_dummy_impl.cpp diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 0e6cf94f5..3532dc4aa 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -36,6 +36,12 @@ static const size_t DEFAULT_XFER_SIZE = 32*512; //bytes #define LIBUSB_CALL #endif /*LIBUSB_CALL*/ +//! libusb_handle_events_timeout_completed is only in newer API +#ifndef HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED + #define libusb_handle_events_timeout_completed(ctx, tx, completed)\ + libusb_handle_events_timeout(ctx, tx) +#endif + /*! * All libusb callback functions should be marked with the LIBUSB_CALL macro * to ensure that they are compiled with the same calling convention as libusb. @@ -70,7 +76,7 @@ UHD_INLINE bool wait_for_completion(libusb_context *ctx, const double timeout, i timeval tv; tv.tv_sec = 0; tv.tv_usec = 0; - libusb_handle_events_timeout(ctx, &tv); + libusb_handle_events_timeout_completed(ctx, &tv, &completed); if (completed) return true; //finish the rest with a timeout loop @@ -79,7 +85,7 @@ UHD_INLINE bool wait_for_completion(libusb_context *ctx, const double timeout, i timeval tv; tv.tv_sec = 0; tv.tv_usec = 10000; /*10ms*/ - libusb_handle_events_timeout(ctx, &tv); + libusb_handle_events_timeout_completed(ctx, &tv, &completed); } return completed; |