diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index b7a10d12..a48dc067 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Nuand, LLC. +# Copyright 2013 Nuand, LLC. # # This file is part of the bladeRF project # diff --git a/host/cmake/modules/FindLibbladeRF.cmake b/host/cmake/modules/FindLibbladeRF.cmake deleted file mode 100644 index f2ce9f75..00000000 --- a/host/cmake/modules/FindLibbladeRF.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# This file has been borrowed from the gr-osmosdr project (GPLv3) -# Author: Dimitri Stolnikov -# -# http://openbsc.osmocom.org/trac/wiki/OsmocomOverview -# http://git.osmocom.org/gr-osmosdr/log/cmake/Modules/FindLibbladeRF.cmake -# -if(NOT LIBBLADERF_FOUND) - pkg_check_modules (LIBBLADERF_PKG libbladeRF) - find_path(LIBBLADERF_INCLUDE_DIR NAMES libbladeRF.h - PATHS - ${LIBBLADERF_PKG_INCLUDE_DIRS} - /usr/include - /usr/local/include - ) - - find_library(LIBBLADERF_LIBRARIES NAMES bladeRF - PATHS - ${LIBBLADERF_PKG_LIBRARY_DIRS} - /usr/lib - /usr/local/lib - ) - -if(LIBBLADERF_INCLUDE_DIR AND LIBBLADERF_LIBRARIES) - set(LIBBLADERF_FOUND TRUE CACHE INTERNAL "libbladeRF found") - message(STATUS "Found libbladeRF: ${LIBBLADERF_INCLUDE_DIR}, ${LIBBLADERF_LIBRARIES}") -else(LIBBLADERF_INCLUDE_DIR AND LIBBLADERF_LIBRARIES) - set(LIBBLADERF_FOUND FALSE CACHE INTERNAL "libbladeRF found") - message(STATUS "libbladeRF not found.") -endif(LIBBLADERF_INCLUDE_DIR AND LIBBLADERF_LIBRARIES) - -mark_as_advanced(LIBBLADERF_INCLUDE_DIR LIBBLADERF_LIBRARIES) - -endif(NOT LIBBLADERF_FOUND) - diff --git a/host/libraries/CMakeLists.txt b/host/libraries/CMakeLists.txt index ced7606a..f014470c 100644 --- a/host/libraries/CMakeLists.txt +++ b/host/libraries/CMakeLists.txt @@ -1,214 +1,2 @@ -# Copyright 2012 Nuand, LLC. -# -# This file is part of the bladeRF project -# -# TODO license text here (see top-level COPYING for time being) -# -# Portions of this file have been borrowed from and/or inspired by -# the CMakeLists.txt from the rtl-sdr project (GPLv2) -# http://sdr.osmocom.org/trac/wiki/rtl-sdr - cmake_minimum_required(VERSION 2.8) -project(libbladeRF C) - -################################################################################ -# Version information -################################################################################ - -set(VERSION_INFO_MAJOR 0) -set(VERSION_INFO_MINOR 3) -set(VERSION_INFO_PATCH 0) -set(VERSION_INFO_EXTRA "git") -include(Version) - -set(VERSION "${VERSION_INFO}") -set(LIBVER "${VERSION_INFO_BASE}") - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in - ${CMAKE_CURRENT_BINARY_DIR}/src/version.h - @ONLY -) - -################################################################################ -# Configuration options -################################################################################ - -############################## -# Backend Support -############################## - -option(BACKEND_LIBUSB - "Enable libusb backend support" - ON -) - -option(LIBUSB_DETACH_KERNEL_DRIVER - "Enable calls to libusb_detach_kernel_driver(). Not supported in Windows." - ON -) - -option(BACKEND_LINUX_DRIVER - "Enable Linux driver backend support." - OFF -) - -# Ensure we've got at least one backend enabled -if(NOT BACKEND_LIBUSB AND NOT BACKEND_LINUX_DRIVER) - message(FATAL_ERROR - "No libbladeRF backends are enabled. " - "Please enable one or more backends." ) -endif() - - -# Detach kernel not supported in Windows -if(CMAKE_HOST_WIN32) - set(LIBUSB_DETACH_KERNEL_DRIVER OFF) -endif() - -################################################################################ -# Additional compiler options -################################################################################ -if("${CMAKE_CC_COMPILER_ID}" STREQUAL "GNU" OR - "${CMAKE_CC_COMPILER_ID}" STREQUAL "Clang" ) -# ADD_DEFINITIONS(-fvisibility=hidden) -endif() - -################################################################################ -# Include paths -################################################################################ -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${BLADERF_COMMON_INCLUDE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/src - ${LIBUSB_INCLUDE_DIRS} -) - -################################################################################ -# Build dependencies -################################################################################ -find_package(PkgConfig) - -if(BACKEND_LIBUSB) - find_package(LibUSB) - if(NOT LIBUSB_FOUND) - message(FATAL_ERROR "libusb-1.0 required to use for libusb backend") - endif(NOT LIBUSB_FOUND) - - # TODO stricter LibUSB version check? IIRC we actually require >= 1.0.10? -endif(BACKEND_LIBUSB) - -if(BACKEND_LINUX_DRIVER) - # TODO find Linux Driver? -endif() - -################################################################################ -# Configure source files -################################################################################ -set(LIBBLADERF_SOURCE - src/backend.c - src/bladerf.c - src/bladerf_priv.c - src/conversions.c - src/device_identifier.c - src/file_ops.c - src/lms.c - src/si5338.c - src/version.h -) - -if(BACKEND_LIBUSB) - set(LIBBLADERF_SOURCE ${LIBBLADERF_SOURCE} src/backend/libusb.c) -endif() - -if(BACKEND_LINUX_DRIVER) - set(LIBBLADERF_SOURCE ${LIBBLADERF_SOURCE} src/linux.c) -endif() - -add_library(libbladerf_shared SHARED ${LIBBLADERF_SOURCE}) - -################################################################################ -# Build configuration -################################################################################ - -if(BACKEND_LIBUSB) - target_link_libraries(libbladerf_shared ${LIBUSB_LIBRARIES}) -endif() - -# Adjust our output name -set_target_properties(libbladerf_shared PROPERTIES OUTPUT_NAME bladeRF) - -# Set shared library version -set_target_properties(libbladerf_shared PROPERTIES SOVERSION ${VERSION_INFO_MAJOR}) - - -################################################################################ -# Misc. installation config -################################################################################ - -if(NOT DEFINED LIB_INSTALL_DIR) - set(LIB_INSTALL_DIR lib) -endif() - -################################################################################ -# Install udev rules -################################################################################ -# TODO - -################################################################################ -# Generate pkg-config file -################################################################################ -add_subdirectory(include) -foreach(inc ${LIBBLADERF_INCLUDE_DIR}) - list(APPEND LIBBLADERF_PC_CFLAGS "-I${inc}") -endforeach() - -foreach(lib ${LIBBLADERF_LIBRARY_DIRS}) - list(APPEND LIBBLADERF_PC_PRIV_LIBS "-L${lib}") -endforeach() - -if(BACKEND_LIBUSB) - # TODO set(LIBBLADERF_PC_REQUIRES ${LIBBLADERF_PC_REQUIRES} libusb-1.0 = ?) -endif() - -set(LIBBLADERF_PC_PREFIX ${CMAKE_INSTALL_PREFIX}) -set(LIBBLADERF_PC_EXEC_PREFIX \${prefix}) -set(LIBBLADERF_PC_LIBDIR \${exec_prefix}/${LIB_INSTALL_DIR}) -set(LIBBLADERF_PC_INCLUDEDIR \${prefix}/include) -set(LIBBLADERF_PC_VERSION ${VERSION}) - -# Use space-delimiter in the .pc file, rather than CMake's semicolon separator -string(REPLACE ";" " " LIBBLADERF_PC_CFLAGS "${LIBBLADERF_PC_CFLAGS}") -string(REPLACE ";" " " LIBBLADERF_PC_LIBS "${LIBBLADERF_PC_LIBS}") - -# Unset these to avoid hard-coded paths in a cross-environment -if(CMAKE_CROSSCOMPILING) - unset(LIBBLADERF_PC_CFLAGS) - unset(LIBBLADERF_PC_LIBS) -endif() - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/libbladeRF.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/libbladeRF.pc - @ONLY -) - -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/libbladeRF.pc - DESTINATION ${LIB_INSTALL_DIR}/pkgconfig/ -) - -################################################################################ -# Library installation information -################################################################################ -install(TARGETS libbladerf_shared - LIBRARY DESTINATION ${LIB_INSTALL_DIR} # .so/.dylib - ARCHIVE DESTINATION ${LIB_INSTALL_DIR} # .a/.lib - RUNTIME DESTINATION bin # .dll -) - - -################################################################################ -# Informational output -################################################################################ -message(STATUS "libbladeRF version: ${VERSION_INFO}") +add_subdirectory(libbladeRF) diff --git a/host/libraries/libbladeRF/CMakeLists.txt b/host/libraries/libbladeRF/CMakeLists.txt new file mode 100644 index 00000000..167553ed --- /dev/null +++ b/host/libraries/libbladeRF/CMakeLists.txt @@ -0,0 +1,220 @@ +# Copyright 2012 Nuand, LLC. +# +# This file is part of the bladeRF project +# +# TODO license text here (see top-level COPYING for time being) +# +# Portions of this file have been borrowed from and/or inspired by +# the CMakeLists.txt from the rtl-sdr project (GPLv2) +# http://sdr.osmocom.org/trac/wiki/rtl-sdr + +cmake_minimum_required(VERSION 2.8) +project(libbladeRF C) + +################################################################################ +# Version information +################################################################################ + +set(VERSION_INFO_MAJOR 0) +set(VERSION_INFO_MINOR 3) +set(VERSION_INFO_PATCH 0) +set(VERSION_INFO_EXTRA "git") +include(Version) + +set(VERSION "${VERSION_INFO}") +set(LIBVER "${VERSION_INFO_BASE}") + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in + ${CMAKE_CURRENT_BINARY_DIR}/src/version.h + @ONLY +) + +################################################################################ +# Configuration options +################################################################################ + +############################## +# Backend Support +############################## + +option(ENABLE_BACKEND_LIBUSB + "Enable libusb backend support" + ON +) + +option(LIBUSB_DETACH_KERNEL_DRIVER + "Enable calls to libusb_detach_kernel_driver(). Not supported in Windows." + ON +) + +option(ENABLE_BACKEND_LINUX_DRIVER + "Enable Linux driver backend support." + OFF +) + +# Ensure we've got at least one backend enabled +if(NOT ENABLE_BACKEND_LIBUSB AND NOT ENABLE_BACKEND_LINUX_DRIVER) + message(FATAL_ERROR + "No libbladeRF backends are enabled. " + "Please enable one or more backends." ) +endif() + + +# Detach kernel not supported in Windows +if(CMAKE_HOST_WIN32) + set(LIBUSB_DETACH_KERNEL_DRIVER OFF) +endif() + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/src/backend_config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/src/backend_config.h + @ONLY +) + +################################################################################ +# Additional compiler options +################################################################################ +if("${CMAKE_CC_COMPILER_ID}" STREQUAL "GNU" OR + "${CMAKE_CC_COMPILER_ID}" STREQUAL "Clang" ) +# add_definitions(-fvisibility=hidden) +endif() + +################################################################################ +# Include paths +################################################################################ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${BLADERF_COMMON_INCLUDE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/src + ${LIBUSB_INCLUDE_DIRS} +) + +################################################################################ +# Build dependencies +################################################################################ +find_package(PkgConfig) + +if(ENABLE_BACKEND_LIBUSB) + find_package(LibUSB) + if(NOT LIBUSB_FOUND) + message(FATAL_ERROR "libusb-1.0 required to use for libusb backend") + endif(NOT LIBUSB_FOUND) + + # TODO stricter LibUSB version check? IIRC we actually require >= 1.0.10? +endif(ENABLE_BACKEND_LIBUSB) + +if(ENABLE_BACKEND_LINUX_DRIVER) + # TODO find Linux Driver? +endif() + +################################################################################ +# Configure source files +################################################################################ +set(LIBBLADERF_SOURCE + src/backend.c + src/bladerf.c + src/bladerf_priv.c + src/conversions.c + src/device_identifier.c + src/file_ops.c + src/lms.c + src/si5338.c + src/version.h +) + +if(ENABLE_BACKEND_LIBUSB) + set(LIBBLADERF_SOURCE ${LIBBLADERF_SOURCE} src/backend/libusb.c) +endif() + +if(ENABLE_BACKEND_LINUX_DRIVER) + set(LIBBLADERF_SOURCE ${LIBBLADERF_SOURCE} src/linux.c) +endif() + +add_library(libbladerf_shared SHARED ${LIBBLADERF_SOURCE}) + +################################################################################ +# Build configuration +################################################################################ + +if(ENABLE_BACKEND_LIBUSB) + target_link_libraries(libbladerf_shared ${LIBUSB_LIBRARIES}) +endif() + +# Adjust our output name +set_target_properties(libbladerf_shared PROPERTIES OUTPUT_NAME bladeRF) + +# Set shared library version +set_target_properties(libbladerf_shared PROPERTIES SOVERSION ${VERSION_INFO_MAJOR}) + + +################################################################################ +# Misc. installation config +################################################################################ + +if(NOT DEFINED LIB_INSTALL_DIR) + set(LIB_INSTALL_DIR lib) +endif() + +################################################################################ +# Install udev rules +################################################################################ +# TODO + +################################################################################ +# Generate pkg-config file +################################################################################ +add_subdirectory(include) +foreach(inc ${LIBBLADERF_INCLUDE_DIR}) + list(APPEND LIBBLADERF_PC_CFLAGS "-I${inc}") +endforeach() + +foreach(lib ${LIBBLADERF_LIBRARY_DIRS}) + list(APPEND LIBBLADERF_PC_PRIV_LIBS "-L${lib}") +endforeach() + +if(ENABLE_BACKEND_LIBUSB) + # TODO set(LIBBLADERF_PC_REQUIRES ${LIBBLADERF_PC_REQUIRES} libusb-1.0 = ?) +endif() + +set(LIBBLADERF_PC_PREFIX ${CMAKE_INSTALL_PREFIX}) +set(LIBBLADERF_PC_EXEC_PREFIX \${prefix}) +set(LIBBLADERF_PC_LIBDIR \${exec_prefix}/${LIB_INSTALL_DIR}) +set(LIBBLADERF_PC_INCLUDEDIR \${prefix}/include) +set(LIBBLADERF_PC_VERSION ${VERSION}) + +# Use space-delimiter in the .pc file, rather than CMake's semicolon separator +string(REPLACE ";" " " LIBBLADERF_PC_CFLAGS "${LIBBLADERF_PC_CFLAGS}") +string(REPLACE ";" " " LIBBLADERF_PC_LIBS "${LIBBLADERF_PC_LIBS}") + +# Unset these to avoid hard-coded paths in a cross-environment +if(CMAKE_CROSSCOMPILING) + unset(LIBBLADERF_PC_CFLAGS) + unset(LIBBLADERF_PC_LIBS) +endif() + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/libbladeRF.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/libbladeRF.pc + @ONLY +) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/libbladeRF.pc + DESTINATION ${LIB_INSTALL_DIR}/pkgconfig/ +) + +################################################################################ +# Library installation information +################################################################################ +install(TARGETS libbladerf_shared + LIBRARY DESTINATION ${LIB_INSTALL_DIR} # .so/.dylib + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} # .a/.lib + RUNTIME DESTINATION bin # .dll +) + + +################################################################################ +# Informational output +################################################################################ +message(STATUS "libbladeRF version: ${VERSION_INFO}") diff --git a/host/libraries/README.md b/host/libraries/libbladeRF/README.md similarity index 100% rename from host/libraries/README.md rename to host/libraries/libbladeRF/README.md diff --git a/host/libraries/doc/doxygen/Doxyfile b/host/libraries/libbladeRF/doc/doxygen/Doxyfile similarity index 100% rename from host/libraries/doc/doxygen/Doxyfile rename to host/libraries/libbladeRF/doc/doxygen/Doxyfile diff --git a/host/libraries/doc/doxygen/Makefile b/host/libraries/libbladeRF/doc/doxygen/Makefile similarity index 100% rename from host/libraries/doc/doxygen/Makefile rename to host/libraries/libbladeRF/doc/doxygen/Makefile diff --git a/host/libraries/doc/doxygen/mainpage.dox b/host/libraries/libbladeRF/doc/doxygen/mainpage.dox similarity index 100% rename from host/libraries/doc/doxygen/mainpage.dox rename to host/libraries/libbladeRF/doc/doxygen/mainpage.dox diff --git a/host/libraries/include/CMakeLists.txt b/host/libraries/libbladeRF/include/CMakeLists.txt similarity index 100% rename from host/libraries/include/CMakeLists.txt rename to host/libraries/libbladeRF/include/CMakeLists.txt diff --git a/host/libraries/include/libbladeRF.h b/host/libraries/libbladeRF/include/libbladeRF.h similarity index 100% rename from host/libraries/include/libbladeRF.h rename to host/libraries/libbladeRF/include/libbladeRF.h diff --git a/host/libraries/libbladeRF.pc.in b/host/libraries/libbladeRF/libbladeRF.pc.in similarity index 100% rename from host/libraries/libbladeRF.pc.in rename to host/libraries/libbladeRF/libbladeRF.pc.in diff --git a/host/libraries/libbladeRF/src/backend.c b/host/libraries/libbladeRF/src/backend.c new file mode 100644 index 00000000..01060366 --- /dev/null +++ b/host/libraries/libbladeRF/src/backend.c @@ -0,0 +1,90 @@ +#include + +#include "backend.h" +#include "backend_config.h" +#include "debug.h" + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) + +struct backend_table_entry { + const bladerf_backend_t type; + const struct bladerf_fn *fns; +}; + +static const struct backend_table_entry backend_list[] = BLADERF_BACKEND_LIST; + +int open_with_any_backend(struct bladerf **device, + struct bladerf_devinfo *info) +{ + size_t i; + int status = BLADERF_ERR_NODEV; + const size_t n_backends = ARRAY_SIZE(backend_list); + + for (i = 0; i < n_backends && status != 0; i++) { + status = backend_list[i].fns->open(device, info); + } + + return status; +} + +int backend_open(struct bladerf **device, struct bladerf_devinfo *info) { + + size_t i; + int status = BLADERF_ERR_NODEV; + const size_t n_backends = ARRAY_SIZE(backend_list); + + if (info->backend == BACKEND_ANY) { + status = open_with_any_backend(device, info); + } else { + for (i = 0; i < n_backends; i++) { + if (backend_list[i].type == info->backend) { + status = backend_list[i].fns->open(device, info); + break; + } + } + } + + return status; +} + +int backend_probe(struct bladerf_devinfo **devinfo_items, size_t *num_items) +{ + int probe_status, backend_status; + struct bladerf_devinfo_list list; + size_t i; + const size_t n_backends = ARRAY_SIZE(backend_list); + + *devinfo_items = NULL; + *num_items = 0; + + probe_status = bladerf_devinfo_list_init(&list); + + if (probe_status == 0) { + for (i = 0; i < n_backends && probe_status == 0; i++) { + backend_status = backend_list[i].fns->probe(&list); + + /* Error out if a backend hit any concerning error */ + if (backend_status < 0 && backend_status != BLADERF_ERR_NODEV) { + probe_status = backend_status; + } + } + } + + if (probe_status == 0) { + *num_items = list.num_elt; + + if (*num_items != 0) { + *devinfo_items = list.elt; + } else { + /* For no items, we end up passing back a NULL list to the + * API caller, so we'll just free this up now */ + free(list.elt); + probe_status = BLADERF_ERR_NODEV; + } + + } else { + free(list.elt); + } + + return probe_status; +} diff --git a/host/libraries/src/backend.h b/host/libraries/libbladeRF/src/backend.h similarity index 100% rename from host/libraries/src/backend.h rename to host/libraries/libbladeRF/src/backend.h diff --git a/host/libraries/src/backend/libusb.c b/host/libraries/libbladeRF/src/backend/libusb.c similarity index 100% rename from host/libraries/src/backend/libusb.c rename to host/libraries/libbladeRF/src/backend/libusb.c diff --git a/host/libraries/src/backend/libusb.h b/host/libraries/libbladeRF/src/backend/libusb.h similarity index 100% rename from host/libraries/src/backend/libusb.h rename to host/libraries/libbladeRF/src/backend/libusb.h diff --git a/host/libraries/src/backend/linux.c b/host/libraries/libbladeRF/src/backend/linux.c similarity index 100% rename from host/libraries/src/backend/linux.c rename to host/libraries/libbladeRF/src/backend/linux.c diff --git a/host/libraries/src/backend/linux.h b/host/libraries/libbladeRF/src/backend/linux.h similarity index 100% rename from host/libraries/src/backend/linux.h rename to host/libraries/libbladeRF/src/backend/linux.h diff --git a/host/libraries/libbladeRF/src/backend_config.h.in b/host/libraries/libbladeRF/src/backend_config.h.in new file mode 100644 index 00000000..72108339 --- /dev/null +++ b/host/libraries/libbladeRF/src/backend_config.h.in @@ -0,0 +1,36 @@ +#ifndef BLADERF_BACKEND_CONFIG_H__ +#define BLADERF_BACKEND_CONFIG_H__ + +#cmakedefine ENABLE_BACKEND_LIBUSB +#cmakedefine ENABLE_BACKEND_LINUX_DRIVER + +#ifdef ENABLE_BACKEND_LIBUSB +# include "backend/libusb.h" +# define BACKEND_LIBUSB_FN_TBL_ENTRY \ + {BACKEND_LIBUSB, &bladerf_lusb_fn}, +#else +# define BACKEND_LIBUSB_FN_TBL_ENTRY +#endif + +#ifdef ENABLE_BACKEND_LINUX_DRIVER +# include "backend/linux.h" +# define BACKEND_LINUX_DRIVER_FN_TBL_ENTRY \ + { BACKEND_LINUX_DRIVER, &bladerf_linux_fn}, +#else +# define BACKEND_LINUX_DRIVER_FN_TBL_ENTRY +#endif + +/* TODO complain if native drivers for multiple OSs are enabled */ + +#if !defined(ENABLE_BACKEND_LIBUSB) && \ + !defined(ENABLE_BACKEND_LINUX_DRIVER) + #error "No backends are enabled - one more more must be enabled." +#endif + +/* This list should be ordered by preference (highest first) */ +#define BLADERF_BACKEND_LIST { \ + BACKEND_LIBUSB_FN_TBL_ENTRY \ + BACKEND_LINUX_DRIVER_FN_TBL_ENTRY \ +} + +#endif diff --git a/host/libraries/src/bladerf.c b/host/libraries/libbladeRF/src/bladerf.c similarity index 100% rename from host/libraries/src/bladerf.c rename to host/libraries/libbladeRF/src/bladerf.c diff --git a/host/libraries/src/bladerf_priv.c b/host/libraries/libbladeRF/src/bladerf_priv.c similarity index 100% rename from host/libraries/src/bladerf_priv.c rename to host/libraries/libbladeRF/src/bladerf_priv.c diff --git a/host/libraries/src/bladerf_priv.h b/host/libraries/libbladeRF/src/bladerf_priv.h similarity index 100% rename from host/libraries/src/bladerf_priv.h rename to host/libraries/libbladeRF/src/bladerf_priv.h diff --git a/host/libraries/src/conversions.c b/host/libraries/libbladeRF/src/conversions.c similarity index 100% rename from host/libraries/src/conversions.c rename to host/libraries/libbladeRF/src/conversions.c diff --git a/host/libraries/src/conversions.h b/host/libraries/libbladeRF/src/conversions.h similarity index 100% rename from host/libraries/src/conversions.h rename to host/libraries/libbladeRF/src/conversions.h diff --git a/host/libraries/src/debug.h b/host/libraries/libbladeRF/src/debug.h similarity index 100% rename from host/libraries/src/debug.h rename to host/libraries/libbladeRF/src/debug.h diff --git a/host/libraries/src/device_identifier.c b/host/libraries/libbladeRF/src/device_identifier.c similarity index 100% rename from host/libraries/src/device_identifier.c rename to host/libraries/libbladeRF/src/device_identifier.c diff --git a/host/libraries/src/device_identifier.h b/host/libraries/libbladeRF/src/device_identifier.h similarity index 100% rename from host/libraries/src/device_identifier.h rename to host/libraries/libbladeRF/src/device_identifier.h diff --git a/host/libraries/src/file_ops.c b/host/libraries/libbladeRF/src/file_ops.c similarity index 100% rename from host/libraries/src/file_ops.c rename to host/libraries/libbladeRF/src/file_ops.c diff --git a/host/libraries/src/file_ops.h b/host/libraries/libbladeRF/src/file_ops.h similarity index 100% rename from host/libraries/src/file_ops.h rename to host/libraries/libbladeRF/src/file_ops.h diff --git a/host/libraries/src/lms.c b/host/libraries/libbladeRF/src/lms.c similarity index 100% rename from host/libraries/src/lms.c rename to host/libraries/libbladeRF/src/lms.c diff --git a/host/libraries/src/lms.h b/host/libraries/libbladeRF/src/lms.h similarity index 100% rename from host/libraries/src/lms.h rename to host/libraries/libbladeRF/src/lms.h diff --git a/host/libraries/src/si5338.c b/host/libraries/libbladeRF/src/si5338.c similarity index 100% rename from host/libraries/src/si5338.c rename to host/libraries/libbladeRF/src/si5338.c diff --git a/host/libraries/src/si5338.h b/host/libraries/libbladeRF/src/si5338.h similarity index 100% rename from host/libraries/src/si5338.h rename to host/libraries/libbladeRF/src/si5338.h diff --git a/host/libraries/src/version.h.in b/host/libraries/libbladeRF/src/version.h.in similarity index 100% rename from host/libraries/src/version.h.in rename to host/libraries/libbladeRF/src/version.h.in diff --git a/host/libraries/src/backend.c b/host/libraries/src/backend.c deleted file mode 100644 index 551ce511..00000000 --- a/host/libraries/src/backend.c +++ /dev/null @@ -1,119 +0,0 @@ -#include - -#include "backend.h" -#include "debug.h" - -#ifdef ENABLE_BACKEND_LIBUSB -#include "backend/libusb.h" -#endif - -#ifdef ENABLE_BACKEND_LINUX_DRIVER -#include "backend/linux.h" -#endif - -/* TODO complain if native drivers for multiple OSs are enabled */ - -/* This table should be in order of preferred precedence (first = highest) */ -static const struct bladerf_fn * backend_fns[] = { - -#ifdef ENABLE_BACKEND_LIBUSB - &bladerf_lusb_fn, -#endif - -#ifdef ENABLE_BACKEND_LINUX_DRIVER - &bladerf_linux_fn, -#endif - - /* This table must be NULL terminated */ - NULL -}; - -int open_with_any_backend(struct bladerf **device, - struct bladerf_devinfo *info) -{ - int status = BLADERF_ERR_NODEV; - const struct bladerf_fn **fn_tbl; - - for (fn_tbl = &backend_fns[0]; *fn_tbl != NULL && status != 0; fn_tbl++) { - assert((*fn_tbl)->open); - status = (*fn_tbl)->open(device, info); - } - - return status; -} - -/* To keep this from getting messy, the fn table could be a tuple: - * and we could walk through it here... - * - * (Then again, how many backend will we ever have? 4?) */ -int backend_open(struct bladerf **device, struct bladerf_devinfo *info) { - int status = BLADERF_ERR_INVAL; - - switch (info->backend) { - -#ifdef ENABLE_BACKEND_LIBUSB - case BACKEND_LIBUSB: - status = bladerf_lusb_fn.open(device, info); - break; -#endif - -#ifdef ENABLE_BACKEND_LINUX_DRIVER - case BACKEND_LINUX: - status = bladerf_linux_fn.open(device, info); - break; -#endif - - case BACKEND_ANY: - status = open_with_any_backend(device, info); - break; - - default: - /* Bug - this shouldn't happend */ - dbg_printf("Invalid backend!\n"); - assert(0); - } - - return status; -} - -int backend_probe(struct bladerf_devinfo **devinfo_items, size_t *num_items) -{ - int probe_status, backend_status; - struct bladerf_devinfo_list list; - const struct bladerf_fn **fn_tbl; - - *devinfo_items = NULL; - *num_items = 0; - - probe_status = bladerf_devinfo_list_init(&list); - - if (probe_status == 0) { - for (fn_tbl = &backend_fns[0]; *fn_tbl != NULL && !probe_status; fn_tbl++) { - assert((*fn_tbl)->probe); - backend_status = (*fn_tbl)->probe(&list); - - /* Error out if a backend hit any concerning error */ - if (backend_status < 0 && backend_status != BLADERF_ERR_NODEV) { - probe_status = backend_status; - } - } - } - - if (probe_status == 0) { - *num_items = list.num_elt; - - if (*num_items != 0) { - *devinfo_items = list.elt; - } else { - /* For no items, we end up passing back a NULL list to the - * API caller, so we'll just free this up now */ - free(list.elt); - probe_status = BLADERF_ERR_NODEV; - } - - } else { - free(list.elt); - } - - return probe_status; -} diff --git a/host/misc/CMakeLists.txt b/host/misc/CMakeLists.txt index 3d540579..f6f3c7e2 100644 --- a/host/misc/CMakeLists.txt +++ b/host/misc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Nuand, LLC. +# Copyright 2013 Nuand, LLC. # # This file is part of the bladeRF project # diff --git a/host/misc/udev/CMakeLists.txt b/host/misc/udev/CMakeLists.txt index aef631be..fe6f5486 100644 --- a/host/misc/udev/CMakeLists.txt +++ b/host/misc/udev/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Nuand, LLC. +# Copyright 2013 Nuand, LLC. # # This file is part of the bladeRF project # diff --git a/host/utilities/CMakeLists.txt b/host/utilities/CMakeLists.txt index 4230adad..cd4db9c4 100644 --- a/host/utilities/CMakeLists.txt +++ b/host/utilities/CMakeLists.txt @@ -1,7 +1,2 @@ -# Copyright 2012 Nuand, LLC. -# -# This file is part of the bladeRF project -# -# TODO license text here (see top-level COPYING for time being) cmake_minimum_required(VERSION 2.8) add_subdirectory(cli) diff --git a/host/utilities/cli/CMakeLists.txt b/host/utilities/cli/CMakeLists.txt index 609caf99..a6209271 100644 --- a/host/utilities/cli/CMakeLists.txt +++ b/host/utilities/cli/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Nuand, LLC. +# Copyright 2013 Nuand, LLC. # # This file is part of the bladeRF project # @@ -40,7 +40,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/cmd ${CMAKE_CURRENT_SOURCE_DIR}/src/interactive ${CMAKE_CURRENT_BINARY_DIR}/src - ${LIBBLADERF_INCLUDE_DIR} + ${libbladeRF_SOURCE_DIR}/include ${LIBTECLA_INCLUDE_DIR} ) @@ -74,11 +74,7 @@ add_executable(bladeRF-cli ${BLADERF_CLI_SOURCE}) ################################################################################ find_package(PkgConfig) find_package(Threads) -find_package(LibbladeRF) - -if(NOT LIBBLADERF_FOUND) - message(FATAL_ERROR "Unable to find libbladeRF") -endif() +#find_package(LibbladeRF) if(ENABLE_INTERACTIVE_TECLA) find_package(LibTecla) @@ -92,7 +88,7 @@ endif(ENABLE_INTERACTIVE_TECLA) # Build configuration ################################################################################ target_link_libraries(bladeRF-cli - ${LIBBLADERF_LIBRARIES} + libbladerf_shared ${CMAKE_THREAD_LIBS_INIT} ${LIBTECLA_LIBRARIES} ) @@ -109,4 +105,4 @@ install(TARGETS bladeRF-cli DESTINATION ${BIN_INSTALL_DIR}) ################################################################################ # Informational output ################################################################################ -message(STATUS "bladeRF-cli version: ${VERSION_INFO}") +message(STATUS "Configured to build bladeRF-cli version: ${VERSION_INFO}")