From 2373dcf19760c2ca966e5f2d54657cf4951fd0fb Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 26 Sep 2018 18:59:52 +0200 Subject: [PATCH] libbladerRF2: Windows support with OOT build of libbladeRF --- devices/devices.pro | 13 + libbladerf/libbladerf.pro | 192 ++++++---- libbladerf/mingw/common/include/host_config.h | 333 ++++++++++++++++++ .../libbladeRF/src/backend/backend_config.h | 88 +++++ .../mingw/libraries/libbladeRF/src/version.h | 12 + .../{bladerfinput.pro => bladerf1input.pro} | 10 +- sdrangel.windows.pro | 6 +- 7 files changed, 576 insertions(+), 78 deletions(-) create mode 100644 libbladerf/mingw/common/include/host_config.h create mode 100644 libbladerf/mingw/libraries/libbladeRF/src/backend/backend_config.h create mode 100644 libbladerf/mingw/libraries/libbladeRF/src/version.h rename plugins/samplesource/bladerf1input/{bladerfinput.pro => bladerf1input.pro} (80%) diff --git a/devices/devices.pro b/devices/devices.pro index 1dd90d844..35aa88312 100644 --- a/devices/devices.pro +++ b/devices/devices.pro @@ -18,6 +18,8 @@ QMAKE_CXXFLAGS += -msse4.1 QMAKE_CXXFLAGS += -std=c++11 macx:QMAKE_LFLAGS += -F/Library/Frameworks +CONFIG(MINGW32):LIBBLADERF = "C:\Programs\bladeRF" +CONFIG(MINGW64):LIBBLADERF = "C:\Programs\bladeRF" CONFIG(macx):LIBHACKRFSRC = "/opt/local/include" CONFIG(MINGW32):LIBHACKRFSRC = "C:\softs\hackrf\host" CONFIG(MINGW64):LIBHACKRFSRC = "C:\softs\hackrf\host" @@ -32,6 +34,7 @@ CONFIG(MINGW64):LIBIIOSRC = "C:\softs\libiio" INCLUDEPATH += $$PWD INCLUDEPATH += ../exports INCLUDEPATH += ../sdrbase +INCLUDEPATH += $$LIBBLADERF/include INCLUDEPATH += $$LIBHACKRFSRC INCLUDEPATH += "C:\softs\boost_1_66_0" INCLUDEPATH += "C:\softs\libusb-1.0.20\include" @@ -52,6 +55,10 @@ INCLUDEPATH += $$LIBPERSEUSSRC CONFIG(Release):build_subdir = release CONFIG(Debug):build_subdir = debug +!macx:SOURCES += bladerf1/devicebladerf1.cpp\ + bladerf1/devicebladerf1values.cpp\ + bladerf1/devicebladerf1shared.cpp + SOURCES += hackrf/devicehackrf.cpp\ hackrf/devicehackrfvalues.cpp\ hackrf/devicehackrfshared.cpp @@ -66,6 +73,11 @@ SOURCES += limesdr/devicelimesdr.cpp\ plutosdr/deviceplutosdrscan.cpp\ plutosdr/deviceplutosdrshared.cpp +!macx:HEADERS += bladerf1/devicebladerf1.h\ + bladerf1/devicebladerf1param.h\ + bladerf1/devicebladerf1values.h\ + bladerf1/devicebladerf1shared.h + HEADERS += hackrf/devicehackrf.h\ hackrf/devicehackrfparam.h\ hackrf/devicehackrfvalues.h\ @@ -83,6 +95,7 @@ HEADERS += plutosdr/deviceplutosdr.h\ LIBS += -L../sdrbase/$${build_subdir} -lsdrbase !macx { + LIBS += -L$$LIBBLADERF/lib -lbladeRF LIBS += -L../libhackrf/$${build_subdir} -llibhackrf LIBS += -L../liblimesuite/$${build_subdir} -lliblimesuite LIBS += -L../libiio/$${build_subdir} -llibiio diff --git a/libbladerf/libbladerf.pro b/libbladerf/libbladerf.pro index 4919c084f..9a86b9559 100644 --- a/libbladerf/libbladerf.pro +++ b/libbladerf/libbladerf.pro @@ -9,7 +9,7 @@ QT += core TEMPLATE = lib TARGET = libbladerf -DEFINES += BLADERF_OS_WINDOWS=1 +#DEFINES += BLADERF_OS_WINDOWS=1 CONFIG(MINGW32):LIBBLADERFSRC = "C:\softs\bladeRF" CONFIG(MINGW32):LIBBLADERFCOMMONSRC = "C:\softs\bladeRF\host\common" @@ -17,90 +17,142 @@ CONFIG(MINGW32):LIBBLADERFLIBSRC = "C:\softs\bladeRF\host\libraries\libbladeRF" CONFIG(MINGW64):LIBBLADERFSRC = "C:\softs\bladeRF" CONFIG(MINGW64):LIBBLADERFCOMMONSRC = "C:\softs\bladeRF\host\common" CONFIG(MINGW64):LIBBLADERFLIBSRC = "C:\softs\bladeRF\host\libraries\libbladeRF" +INCLUDEPATH += $$PWD/mingw/include +INCLUDEPATH += $$PWD/mingw/common/include +INCLUDEPATH += $$PWD/mingw/libraries/libbladeRF/src +INCLUDEPATH += $$PWD/mingw/libraries/libbladeRF/src/backend INCLUDEPATH += $$LIBBLADERFLIBSRC/include INCLUDEPATH += $$LIBBLADERFLIBSRC/src INCLUDEPATH += $$LIBBLADERFSRC/firmware_common INCLUDEPATH += $$LIBBLADERFSRC/fpga_common/include INCLUDEPATH += $$LIBBLADERFCOMMONSRC/include INCLUDEPATH += $$LIBBLADERFCOMMONSRC/include/windows -INCLUDEPATH += $$PWD/include -CONFIG(MINGW32):INCLUDEPATH += "C:\softs\libusb-1.0.20\include\libusb-1.0" -CONFIG(MINGW64):INCLUDEPATH += "C:\softs\libusb-1.0.20\include\libusb-1.0" +CONFIG(MINGW32):INCLUDEPATH += "C:\softs\libusb-1.0.19\include\libusb-1.0" +CONFIG(MINGW64):INCLUDEPATH += "C:\softs\libusb-1.0.19\include\libusb-1.0" -SOURCES = $$LIBBLADERFLIBSRC/src/async.c\ - $$LIBBLADERFLIBSRC/src/bladerf_priv.c\ - $$LIBBLADERFLIBSRC/src/config.c\ - $$LIBBLADERFLIBSRC/src/device_identifier.c\ - $$PWD/src/file_ops.c\ - $$LIBBLADERFLIBSRC/src/flash_fields.c\ - $$LIBBLADERFLIBSRC/src/fx3_fw.c\ - $$LIBBLADERFLIBSRC/src/gain.c\ - $$LIBBLADERFLIBSRC/src/init_fini.c\ - $$LIBBLADERFLIBSRC/src/sync.c\ - $$LIBBLADERFLIBSRC/src/smb_clock.c\ - $$LIBBLADERFLIBSRC/src/tuning.c\ - $$LIBBLADERFLIBSRC/src/xb.c\ +SOURCES = $$LIBBLADERFCOMMONSRC/src/sha256.c\ + $$LIBBLADERFCOMMONSRC/src/dc_calibration.c\ + $$LIBBLADERFCOMMONSRC/src/parse.c\ + $$LIBBLADERFCOMMONSRC/src/devcfg.c\ + $$LIBBLADERFCOMMONSRC/src/conversions.c\ + $$LIBBLADERFCOMMONSRC/src/log.c\ + $$LIBBLADERFCOMMONSRC/src/str_queue.c\ +# $$LIBBLADERFCOMMONSRC/src/windows/clock_gettime.c\ +# $$LIBBLADERFCOMMONSRC/src/windows/getopt_long.c\ +# $$LIBBLADERFCOMMONSRC/src/windows/mkdtemp.c\ +# $$LIBBLADERFCOMMONSRC/src/windows/nanosleep.c\ +# $$LIBBLADERFCOMMONSRC/src/windows/setenv.c\ + $$LIBBLADERFSRC/host/misc/dev/lms_freqsel/freqsel.c\ + $$LIBBLADERFSRC/fpga_common/src/lms.c\ + $$LIBBLADERFSRC/fpga_common/src/band_select.c\ + $$LIBBLADERFLIBSRC/src/helpers/interleave.c\ + $$LIBBLADERFLIBSRC/src/helpers/timeout.c\ + $$LIBBLADERFLIBSRC/src/helpers/wallclock.c\ + $$LIBBLADERFLIBSRC/src/helpers/configfile.c\ + $$LIBBLADERFLIBSRC/src/helpers/file.c\ + $$LIBBLADERFLIBSRC/src/helpers/version.c\ + $$LIBBLADERFLIBSRC/src/driver/fpga_trigger.c\ + $$LIBBLADERFLIBSRC/src/driver/si5338.c\ + $$LIBBLADERFLIBSRC/src/driver/dac161s055.c\ + $$LIBBLADERFLIBSRC/src/driver/fx3_fw.c\ + $$LIBBLADERFLIBSRC/src/driver/smb_clock.c\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/dac_core.c\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/ad9361.c\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/util.c\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/platform.c\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/ad9361_api.c\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/adc_core.c\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/ad9361_conv.c\ + $$LIBBLADERFLIBSRC/src/driver/spi_flash.c\ + $$LIBBLADERFLIBSRC/src/driver/ina219.c\ + $$LIBBLADERFLIBSRC/src/board/bladerf2/compatibility.c\ + $$LIBBLADERFLIBSRC/src/board/bladerf2/capabilities.c\ + $$LIBBLADERFLIBSRC/src/board/bladerf2/params.c\ + $$LIBBLADERFLIBSRC/src/board/bladerf2/bladerf2.c\ + $$LIBBLADERFLIBSRC/src/board/board.c\ + $$LIBBLADERFLIBSRC/src/board/bladerf1/flash.c\ + $$LIBBLADERFLIBSRC/src/board/bladerf1/bladerf1.c\ + $$LIBBLADERFLIBSRC/src/board/bladerf1/image.c\ + $$LIBBLADERFLIBSRC/src/board/bladerf1/compatibility.c\ + $$LIBBLADERFLIBSRC/src/board/bladerf1/calibration.c\ + $$LIBBLADERFLIBSRC/src/board/bladerf1/capabilities.c\ + $$LIBBLADERFLIBSRC/src/expansion/xb100.c\ + $$LIBBLADERFLIBSRC/src/expansion/xb200.c\ + $$LIBBLADERFLIBSRC/src/expansion/xb300.c\ + $$LIBBLADERFLIBSRC/src/streaming/async.c\ + $$LIBBLADERFLIBSRC/src/streaming/sync_worker.c\ + $$LIBBLADERFLIBSRC/src/streaming/sync.c\ $$LIBBLADERFLIBSRC/src/bladerf.c\ - $$LIBBLADERFLIBSRC/src/capabilities.c\ - $$LIBBLADERFLIBSRC/src/dc_cal_table.c\ - $$LIBBLADERFLIBSRC/src/devinfo.c\ - $$LIBBLADERFLIBSRC/src/flash.c\ - $$LIBBLADERFLIBSRC/src/fpga.c\ - $$LIBBLADERFLIBSRC/src/fx3_fw_log.c\ - $$LIBBLADERFLIBSRC/src/image.c\ - $$LIBBLADERFLIBSRC/src/si5338.c\ - $$LIBBLADERFLIBSRC/src/sync_worker.c\ - $$LIBBLADERFLIBSRC/src/trigger.c\ - $$LIBBLADERFLIBSRC/src/version_compat.c\ + $$LIBBLADERFLIBSRC/src/init_fini.c\ + $$LIBBLADERFLIBSRC/src/backend/dummy/dummy.c\ $$LIBBLADERFLIBSRC/src/backend/backend.c\ - $$LIBBLADERFLIBSRC/src/backend/dummy.c\ - $$LIBBLADERFLIBSRC/src/backend/usb/libusb.c\ $$LIBBLADERFLIBSRC/src/backend/usb/usb.c\ + $$LIBBLADERFLIBSRC/src/backend/usb/libusb.c\ $$LIBBLADERFLIBSRC/src/backend/usb/nios_access.c\ $$LIBBLADERFLIBSRC/src/backend/usb/nios_legacy_access.c\ - $$LIBBLADERFSRC/fpga_common/src/band_select.c\ - $$LIBBLADERFSRC/fpga_common/src/lms.c\ - $$LIBBLADERFCOMMONSRC/src/conversions.c\ - $$LIBBLADERFCOMMONSRC/src/devcfg.c\ - $$LIBBLADERFCOMMONSRC/src/sha256.c\ - $$LIBBLADERFCOMMONSRC/src/parse.c + $$LIBBLADERFLIBSRC/src/devinfo.c -HEADERS = $$LIBBLADERFLIBSRC/src/async.h\ - $$LIBBLADERFLIBSRC/src/capabilities.h\ - $$LIBBLADERFLIBSRC/src/dc_cal_table.h\ - $$LIBBLADERFLIBSRC/src/devinfo.h\ - $$LIBBLADERFLIBSRC/src/flash.h\ - $$LIBBLADERFLIBSRC/src/fpga.h\ - $$LIBBLADERFLIBSRC/src/fx3_fw_log.h\ - $$LIBBLADERFLIBSRC/src/metadata.h\ - $$LIBBLADERFLIBSRC/src/sync.h\ - $$LIBBLADERFLIBSRC/src/smb_clock.h\ - $$LIBBLADERFLIBSRC/src/tuning.h\ - $$LIBBLADERFLIBSRC/src/xb.h\ - $$LIBBLADERFLIBSRC/src/bladerf_priv.h\ - $$LIBBLADERFLIBSRC/src/config.h\ - $$LIBBLADERFLIBSRC/src/device_identifier.h\ - $$LIBBLADERFLIBSRC/src/file_ops.h\ - $$LIBBLADERFLIBSRC/src/flash_fields.h\ - $$LIBBLADERFLIBSRC/src/fx3_fw.h\ - $$LIBBLADERFLIBSRC/src/gain.h\ - $$LIBBLADERFLIBSRC/src/si5338.h\ - $$LIBBLADERFLIBSRC/src/sync_worker.h\ - $$LIBBLADERFLIBSRC/src/trigger.h\ - $$LIBBLADERFLIBSRC/src/version_compat.h\ - $$LIBBLADERFLIBSRC/src/backend/backend.h\ - $$LIBBLADERFLIBSRC/src/backend/dummy.h\ - $$LIBBLADERFLIBSRC/src/backend/usb/usb.h\ - $$LIBBLADERFLIBSRC/src/backend/usb/nios_access.h\ - $$LIBBLADERFLIBSRC/src/backend/usb/nios_legacy_access.h\ - $$LIBBLADERFSRC/fpga_common/include/band_select.h\ - $$LIBBLADERFSRC/fpga_common/include/lms.h\ - $$LIBBLADERFCOMMONSRC/include/sha256.h\ +HEADERS = $$PWD/mingw/common/include/host_config.h\ + $$PWD/mingw/libraries/libbladeRF/src/version.h\ + $$PWD/mingw/libraries/libbladeRF/src/backend/backend_config.h\ + $$LIBBLADERFCOMMONSRC/include/thread.h\ $$LIBBLADERFCOMMONSRC/include/parse.h\ - $$PWD/include/host_config.h\ - $$PWD/include/backend/backend_config.h\ - $$PWD/include/version.h + $$LIBBLADERFCOMMONSRC/include/minmax.h\ + $$LIBBLADERFCOMMONSRC/include/rel_assert.h\ + $$LIBBLADERFCOMMONSRC/include/devcfg.h\ + $$LIBBLADERFCOMMONSRC/include/str_queue.h\ + $$LIBBLADERFCOMMONSRC/include/log.h\ + $$LIBBLADERFCOMMONSRC/include/dc_calibration.h\ + $$LIBBLADERFCOMMONSRC/include/sha256.h\ + $$LIBBLADERFCOMMONSRC/include/conversions.h\ + $$LIBBLADERFSRC/fpga_common/include/lms.h\ + $$LIBBLADERFSRC/fpga_common/include/band_select.h\ + $$LIBBLADERFLIBSRC/src/helpers/interleave.h\ + $$LIBBLADERFLIBSRC/src/helpers/wallclock.h\ + $$LIBBLADERFLIBSRC/src/helpers/timeout.h\ + $$LIBBLADERFLIBSRC/src/helpers/version.h\ + $$LIBBLADERFLIBSRC/src/helpers/configfile.h\ + $$LIBBLADERFLIBSRC/src/helpers/file.h\ + $$LIBBLADERFLIBSRC/src/driver/dac161s055.h\ + $$LIBBLADERFLIBSRC/src/driver/fpga_trigger.h\ + $$LIBBLADERFLIBSRC/src/driver/si5338.h\ + $$LIBBLADERFLIBSRC/src/driver/ina219.h\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/platform.h\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/util.h\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/dac_core.h\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/config.h\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/adc_core.h\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/common.h\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/ad9361.h\ + $$LIBBLADERFLIBSRC/src/driver/thirdparty/adi/ad9361_api.h\ + $$LIBBLADERFLIBSRC/src/driver/spi_flash.h\ + $$LIBBLADERFLIBSRC/src/driver/fx3_fw.h\ + $$LIBBLADERFLIBSRC/src/driver/smb_clock.h\ + $$LIBBLADERFLIBSRC/src/board/bladerf2/capabilities.h\ + $$LIBBLADERFLIBSRC/src/board/bladerf2/compatibility.h\ + $$LIBBLADERFLIBSRC/src/board/board.h\ + $$LIBBLADERFLIBSRC/src/board/bladerf1/calibration.h\ + $$LIBBLADERFLIBSRC/src/board/bladerf1/capabilities.h\ + $$LIBBLADERFLIBSRC/src/board/bladerf1/compatibility.h\ + $$LIBBLADERFLIBSRC/src/board/bladerf1/flash.h\ + $$LIBBLADERFLIBSRC/src/expansion/xb300.h\ + $$LIBBLADERFLIBSRC/src/expansion/xb100.h\ + $$LIBBLADERFLIBSRC/src/expansion/xb200.h\ + $$LIBBLADERFLIBSRC/src/streaming/sync.h\ + $$LIBBLADERFLIBSRC/src/streaming/sync_worker.h\ + $$LIBBLADERFLIBSRC/src/streaming/metadata.h\ + $$LIBBLADERFLIBSRC/src/streaming/format.h\ + $$LIBBLADERFLIBSRC/src/streaming/async.h\ + $$LIBBLADERFLIBSRC/src/backend/backend.h\ + $$LIBBLADERFLIBSRC/src/backend/dummy/dummy.h\ + $$LIBBLADERFLIBSRC/src/backend/usb/nios_legacy_access.h\ + $$LIBBLADERFLIBSRC/src/backend/usb/nios_access.h\ + $$LIBBLADERFLIBSRC/src/backend/usb/usb.h\ + $$LIBBLADERFLIBSRC/src/devinfo.h\ + $$LIBBLADERFLIBSRC/include/bladeRF2.h\ + $$LIBBLADERFLIBSRC/include/libbladeRF.h\ + $$LIBBLADERFLIBSRC/include/bladeRF1.h CONFIG(MINGW32):LIBS += -LC:\softs\libusb-1.0.20\MinGW32\dll -llibusb-1.0 CONFIG(MINGW64):LIBS += -LC:\softs\libusb-1.0.20\MinGW64\dll -llibusb-1.0 diff --git a/libbladerf/mingw/common/include/host_config.h b/libbladerf/mingw/common/include/host_config.h new file mode 100644 index 000000000..96871ea0e --- /dev/null +++ b/libbladerf/mingw/common/include/host_config.h @@ -0,0 +1,333 @@ +/** + * @file host_config.h.in + * + * This file is part of the bladeRF project: + * http://www.github.com/nuand/bladeRF + * + * Copyright (c) 2013-2018 Nuand LLC. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef HOST_CONFIG_H__ +#define HOST_CONFIG_H__ + +#define BLADERF_OS_LINUX 0 +#define BLADERF_OS_FREEBSD 0 +#define BLADERF_OS_OSX 0 +#define BLADERF_OS_WINDOWS 1 +#define BLADERF_BIG_ENDIAN 0 + +#if !(BLADERF_OS_LINUX || BLADERF_OS_OSX || BLADERF_OS_WINDOWS || BLADERF_OS_FREEBSD) +# error "Build not configured for any supported operating systems" +#endif + +#if 1 < (BLADERF_OS_LINUX + BLADERF_OS_OSX + BLADERF_OS_WINDOWS + BLADERF_OS_FREEBSD) +#error "Build configured for multiple operating systems" +#endif + +#define HAVE_CLOCK_GETTIME 0 + +/******************************************************************************* + * Endianness conversions + * + * HOST_TO_LE16 16-bit host endianness to little endian conversion + * LE16_TO_HOST 16-bit little endian to host endianness conversion + * HOST_TO_BE16 16-bit host endianness to big endian conversion + * BE16_TO_HOST 16-bit big endian to host endianness conversion + * HOST_TO_LE32 32-bit host endianness to little endian conversion + * LE32_TO_HOST 32-bit little endian to host endianness conversion + * HOST_TO_BE32 32-bit host endianness to big endian conversion + * BE32_TO_HOST 32-bit big endian to host endianness conversion + * HOST_TO_BE64 64-bit host endianness to big endian conversion + * BE64_TO_HOST 64-bit big endian to host endianness conversion + ******************************************************************************/ + +/*----------------------- + * Linux + *---------------------*/ +#if BLADERF_OS_LINUX +#include + +#define HOST_TO_LE16(val) htole16(val) +#define LE16_TO_HOST(val) le16toh(val) +#define HOST_TO_BE16(val) htobe16(val) +#define BE16_TO_HOST(val) be16toh(val) + +#define HOST_TO_LE32(val) htole32(val) +#define LE32_TO_HOST(val) le32toh(val) +#define HOST_TO_BE32(val) htobe32(val) +#define BE32_TO_HOST(val) be32toh(val) + +#define HOST_TO_LE64(val) htole64(val) +#define LE64_TO_HOST(val) le64toh(val) +#define HOST_TO_BE64(val) be64toh(val) +#define BE64_TO_HOST(val) be64toh(val) + +/*----------------------- + * FREEBSD + *---------------------*/ +#elif BLADERF_OS_FREEBSD +#include + +#define HOST_TO_LE16(val) htole16(val) +#define LE16_TO_HOST(val) le16toh(val) +#define HOST_TO_BE16(val) htobe16(val) +#define BE16_TO_HOST(val) be16toh(val) + +#define HOST_TO_LE32(val) htole32(val) +#define LE32_TO_HOST(val) le32toh(val) +#define HOST_TO_BE32(val) htobe32(val) +#define BE32_TO_HOST(val) be32toh(val) + +#define HOST_TO_LE64(val) htole64(val) +#define LE64_TO_HOST(val) le64toh(val) +#define HOST_TO_BE64(val) be64toh(val) +#define BE64_TO_HOST(val) be64toh(val) + +/*----------------------- + * Apple OSX + *---------------------*/ +#elif BLADERF_OS_OSX +#include + +#define HOST_TO_LE16(val) OSSwapHostToLittleInt16(val) +#define LE16_TO_HOST(val) OSSwapLittleToHostInt16(val) +#define HOST_TO_BE16(val) OSSwapHostToBigInt16(val) +#define BE16_TO_HOST(val) OSSwapBigToHostInt16(val) + +#define HOST_TO_LE32(val) OSSwapHostToLittleInt32(val) +#define LE32_TO_HOST(val) OSSwapLittleToHostInt32(val) +#define HOST_TO_BE32(val) OSSwapHostToBigInt32(val) +#define BE32_TO_HOST(val) OSSwapBigToHostInt32(val) + +#define HOST_TO_LE64(val) OSSwapHostToLittleInt64(val) +#define LE64_TO_HOST(val) OSSwapLittleToHostInt64(val) +#define HOST_TO_BE64(val) OSSwapHostToBigInt64(val) +#define BE64_TO_HOST(val) OSSwapBigToHostInt64(val) + +/*----------------------- + * Windows + *---------------------*/ +#elif BLADERF_OS_WINDOWS +#include + +/* We'll assume little endian for Windows platforms: + * http://blogs.msdn.com/b/larryosterman/archive/2005/06/07/426334.aspx + */ +#define HOST_TO_LE16(val) (val) +#define LE16_TO_HOST(val) (val) +#define HOST_TO_BE16(val) _byteswap_ushort(val) +#define BE16_TO_HOST(val) _byteswap_ushort(val) + +#define HOST_TO_LE32(val) (val) +#define LE32_TO_HOST(val) (val) +#define HOST_TO_BE32(val) _byteswap_ulong(val) +#define BE32_TO_HOST(val) _byteswap_ulong(val) + + +#define HOST_TO_LE64(val) (val) +#define LE64_TO_HOST(val) (val) +#define HOST_TO_BE64(val) _byteswap_uint64(val) +#define BE64_TO_HOST(val) _byteswap_uint64(val) + +/*----------------------- + * Unsupported or bug + *---------------------*/ +#else +#error "Encountered an OS that we do not have endian wrappers for?" +#endif + +/******************************************************************************* + * Endianness conversions for constants + * + * We shouldn't be using the above items for assigning constants because the + * implementations may be functions [1]. + * + * [1] https://sourceware.org/bugzilla/show_bug.cgi?id=17679#c7 + ******************************************************************************/ + +#define BLADERF_BYTESWAP16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8)) + +#define BLADERF_BYTESWAP32(x) ((((x) & 0xff000000) >> 24) | \ + (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | \ + (((x) & 0x000000ff) << 24) ) + +#define BLADERF_BYTESWAP64(x) ((((x) & 0xff00000000000000llu) >> 56) | \ + (((x) & 0x00ff000000000000llu) >> 40) | \ + (((x) & 0x0000ff0000000000llu) >> 24) | \ + (((x) & 0x000000ff00000000llu) >> 8) | \ + (((x) & 0x00000000ff000000llu) << 8) | \ + (((x) & 0x0000000000ff0000llu) << 24) | \ + (((x) & 0x000000000000ff00llu) << 40) | \ + (((x) & 0x00000000000000ffllu) << 56) | \ + +#if BLADERF_BIG_ENDIAN +# define HOST_TO_LE16_CONST(x) (BLADERF_BYTESWAP16(x)) +# define LE16_TO_HOST_CONST(x) (BLADERF_BYTESWAP16(x)) +# define HOST_TO_BE16_CONST(x) (x) +# define BE16_TO_HOST_CONST(x) (x) + +# define HOST_TO_LE32_CONST(x) (BLADERF_BYTESWAP32(x)) +# define LE32_TO_HOST_CONST(x) (BLADERF_BYTESWAP32(x)) +# define HOST_TO_BE32_CONST(x) (x) +# define BE32_TO_HOST_CONST(x) (x) + +# define HOST_TO_LE64_CONST(x) (BLADERF_BYTESWAP64(x)) +# define LE64_TO_HOST_CONST(x) (BLADERF_BYTESWAP64(x)) +# define HOST_TO_BE64_CONST(x) (x) +# define BE64_TO_HOST_CONST(x) (x) +#else +# define HOST_TO_LE16_CONST(x) (x) +# define LE16_TO_HOST_CONST(x) (x) +# define HOST_TO_BE16_CONST(x) (BLADERF_BYTESWAP16(x)) +# define BE16_TO_HOST_CONST(x) (BLADERF_BYTESWAP16(x)) + +# define HOST_TO_LE32_CONST(x) (x) +# define LE32_TO_HOST_CONST(x) (x) +# define HOST_TO_BE32_CONST(x) (BLADERF_BYTESWAP32(x)) +# define BE32_TO_HOST_CONST(x) (BLADERF_BYTESWAP32(x)) + +# define HOST_TO_LE64_CONST(x) (x) +# define LE64_TO_HOST_CONST(x) (x) +# define HOST_TO_BE64_CONST(x) (BLADERF_BYTESWAP64(x)) +# define BE64_TO_HOST_CONST(x) (BLADERF_BYTESWAP64(x)) +#endif + +/******************************************************************************* + * Miscellaneous Linux fixups + ******************************************************************************/ +#if BLADERF_OS_LINUX + +/* Added here just to keep this out of the other source files. We'll have + * a few Windows replacements for unistd.h items. */ +#include +#include + +/******************************************************************************* + * Miscellaneous FREEBSD fixups + ******************************************************************************/ +#elif BLADERF_OS_FREEBSD + +#include +#include +#include + +/******************************************************************************* + * Miscellaneous OSX fixups + ******************************************************************************/ +#elif BLADERF_OS_OSX + +#include +#include + +/******************************************************************************* + * Miscellaneous Windows fixups + ******************************************************************************/ +#elif BLADERF_OS_WINDOWS + +/* Rename a few functions and types */ +#include +#include +#include +#define usleep(x) Sleep((x+999)/1000) + +/* Changes specific to Microsoft Visual Studio and its C89-compliant ways */ +#if _MSC_VER +# define strtok_r strtok_s +# define strtoull _strtoui64 +#if _MSC_VER < 1900 +# define snprintf _snprintf +# define vsnprintf _vsnprintf +#else +#define STDC99 +#endif +# define strcasecmp _stricmp +# define strncasecmp _strnicmp +# define fileno _fileno +# define strdup _strdup +# define access _access +# define chdir _chdir +# define getcwd _getcwd +# define rmdir _rmdir +# define unlink _unlink +# define mkdir(n, m) _mkdir(n) + +/* ssize_t lives elsewhere */ +# include +# define ssize_t SSIZE_T + +/* With msvc, inline is only available for C++. Otherwise we need to use __inline: + * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx */ +# if !defined(__cplusplus) +# define inline __inline +# endif + +/* Visual studio 2012 compiler (v17.00.XX) doesn't have round functions */ +# if _MSC_VER <= 1700 +# include + static inline float roundf(float x) + { + return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f); + } + static inline double round(double x) + { + return x >= 0.0 ? floor(x + 0.5) : ceil(x - 0.5); + } +# endif + +#endif // _MSC_VER + +#endif + +/* Windows (msvc) does not support C99 designated initializers. + * + * Therefore, the following macro should be used. However, note that you'll + * need to be sure to keep your elements in order to avoid breaking Windows + * portability! + * + * http://stackoverflow.com/questions/5440611/how-to-rewrite-c-struct-designated-initializers-to-c89-resp-msvc-c-compiler + * + * Here's a sample regexep you could use in vim to clean these up in your code: + * @\(\s\+\)\(\.[a-zA-Z0-9_]\+\)\s*=\s*\([a-zA-Z0-9_]\+\)\(,\)\?@\1FIELD_INIT(\2,\3)\4@gc + */ +#if _MSC_VER +# define FIELD_INIT(field, ...) __VA_ARGS__ +#else +# define FIELD_INIT(field, ...) field = __VA_ARGS__ +#endif // _MSC_VER + +/******************************************************************************* + * Miscellaneous utility macros + ******************************************************************************/ +#define ARRAY_SIZE(n) (sizeof(n) / sizeof(n[0])) + +/** + * GCC 7+ warns on implicit fallthroughs in switch statements + * (-Wimplicit-fallthrough), which we use in a couple places for simplicity. + * The statement attribute syntax used to suppress this warning is not + * supported by anything else. + */ +#if __GNUC__ >= 7 +#define EXPLICIT_FALLTHROUGH __attribute__((fallthrough)) +#else +#define EXPLICIT_FALLTHROUGH +#endif // __GNUC__ >= 7 + +#endif diff --git a/libbladerf/mingw/libraries/libbladeRF/src/backend/backend_config.h b/libbladerf/mingw/libraries/libbladeRF/src/backend/backend_config.h new file mode 100644 index 000000000..351d5d12b --- /dev/null +++ b/libbladerf/mingw/libraries/libbladeRF/src/backend/backend_config.h @@ -0,0 +1,88 @@ +/** + * @file backend_config.h + * + * @brief Compile-time backend selection + * + * This file is part of the bladeRF project: + * http://www.github.com/nuand/bladeRF + * + * Copyright (C) 2013 Nuand LLC + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef BACKEND_BACKEND_CONFIG_H_ +#define BACKEND_BACKEND_CONFIG_H_ + +#define ENABLE_BACKEND_USB +#define ENABLE_BACKEND_LIBUSB +/* #undef ENABLE_BACKEND_CYAPI */ +/* #undef ENABLE_BACKEND_DUMMY */ +/* #undef ENABLE_BACKEND_LINUX_DRIVER */ + +#include "backend/backend.h" +#include "backend/usb/usb.h" + +#ifdef ENABLE_BACKEND_DUMMY +extern const struct backend_fns backend_fns_dummy; +#define BACKEND_DUMMY &backend_fns_dummy, +#else +#define BACKEND_DUMMY +#endif + +#ifdef ENABLE_BACKEND_USB +extern const struct backend_fns backend_fns_usb; +#define BACKEND_USB &backend_fns_usb, + +#ifdef ENABLE_BACKEND_LIBUSB +extern const struct usb_driver usb_driver_libusb; +#define BACKEND_USB_LIBUSB &usb_driver_libusb, +#else +#define BACKEND_USB_LIBUSB +#endif + +#ifdef ENABLE_BACKEND_CYAPI +extern const struct usb_driver usb_driver_cypress; +#define BACKEND_USB_CYAPI &usb_driver_cypress, +#else +#define BACKEND_USB_CYAPI +#endif + +#define BLADERF_USB_BACKEND_LIST \ + { \ + BACKEND_USB_LIBUSB \ + BACKEND_USB_CYAPI \ + } + +#if !defined(ENABLE_BACKEND_LIBUSB) && !defined(ENABLE_BACKEND_CYAPI) +#error "No USB backends are enabled. One or more must be enabled." +#endif + +#else +#define BACKEND_USB +#endif + +#if !defined(ENABLE_BACKEND_USB) && !defined(ENABLE_BACKEND_DUMMY) +#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_USB \ + BACKEND_DUMMY \ + } + +#endif diff --git a/libbladerf/mingw/libraries/libbladeRF/src/version.h b/libbladerf/mingw/libraries/libbladeRF/src/version.h new file mode 100644 index 000000000..480695256 --- /dev/null +++ b/libbladerf/mingw/libraries/libbladeRF/src/version.h @@ -0,0 +1,12 @@ +#ifndef VERSION_H_ +#define VERSION_H_ + +#define LIBBLADERF_VERSION "2.0.2-git-32058c47-dirty" + +// clang-format off +#define LIBBLADERF_VERSION_MAJOR 2 +#define LIBBLADERF_VERSION_MINOR 0 +#define LIBBLADERF_VERSION_PATCH 2 +// clang-format on + +#endif diff --git a/plugins/samplesource/bladerf1input/bladerfinput.pro b/plugins/samplesource/bladerf1input/bladerf1input.pro similarity index 80% rename from plugins/samplesource/bladerf1input/bladerfinput.pro rename to plugins/samplesource/bladerf1input/bladerf1input.pro index aabf50f1c..78b56e879 100644 --- a/plugins/samplesource/bladerf1input/bladerfinput.pro +++ b/plugins/samplesource/bladerf1input/bladerf1input.pro @@ -17,15 +17,15 @@ DEFINES += USE_SSE4_1=1 QMAKE_CXXFLAGS += -msse4.1 QMAKE_CXXFLAGS += -std=c++11 -CONFIG(MINGW32):LIBBLADERFSRC = "C:\softs\bladeRF\host\libraries\libbladeRF\include" -CONFIG(MINGW64):LIBBLADERFSRC = "C:\softs\bladeRF\host\libraries\libbladeRF\include" +CONFIG(MINGW32):LIBBLADERF = "C:\Programs\bladeRF" +CONFIG(MINGW64):LIBBLADERF = "C:\Programs\bladeRF" INCLUDEPATH += $$PWD INCLUDEPATH += ../../../exports INCLUDEPATH += ../../../sdrbase INCLUDEPATH += ../../../sdrgui INCLUDEPATH += ../../../swagger/sdrangel/code/qt5/client INCLUDEPATH += ../../../devices -INCLUDEPATH += $$LIBBLADERFSRC +INCLUDEPATH += $$LIBBLADERF/include CONFIG(Release):build_subdir = release CONFIG(Debug):build_subdir = debug @@ -42,12 +42,12 @@ HEADERS += bladerf1inputgui.h\ bladerf1inputsettings.h\ bladerf1inputthread.h -FORMS += bladerfinputgui.ui +FORMS += bladerf1inputgui.ui LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase LIBS += -L../../../sdrgui/$${build_subdir} -lsdrgui LIBS += -L../../../swagger/$${build_subdir} -lswagger -LIBS += -L../../../libbladerf/$${build_subdir} -llibbladerf +LIBS += -L$$LIBBLADERF/lib -lbladeRF LIBS += -L../../../devices/$${build_subdir} -ldevices RESOURCES = ../../../sdrgui/resources/res.qrc diff --git a/sdrangel.windows.pro b/sdrangel.windows.pro index 1a02dfe36..eb23dbc19 100644 --- a/sdrangel.windows.pro +++ b/sdrangel.windows.pro @@ -19,7 +19,7 @@ SUBDIRS += fcdhid SUBDIRS += fcdlib SUBDIRS += libairspy SUBDIRS += libairspyhf -SUBDIRS += libbladerf +#SUBDIRS += libbladerf SUBDIRS += libhackrf SUBDIRS += libiio SUBDIRS += liblimesuite @@ -31,7 +31,7 @@ SUBDIRS += dsdcc #SUBDIRS += cm256cc SUBDIRS += plugins/samplesource/airspy SUBDIRS += plugins/samplesource/airspyhf -SUBDIRS += plugins/samplesource/bladerfinput +SUBDIRS += plugins/samplesource/bladerf1input SUBDIRS += plugins/samplesource/filesource SUBDIRS += plugins/samplesource/hackrfinput SUBDIRS += plugins/samplesource/limesdrinput @@ -40,7 +40,7 @@ SUBDIRS += plugins/samplesource/plutosdrinput SUBDIRS += plugins/samplesource/rtlsdr SUBDIRS += plugins/samplesource/testsource SUBDIRS += plugins/samplesink/filesink -SUBDIRS += plugins/samplesink/bladerf1output +#SUBDIRS += plugins/samplesink/bladerf1output SUBDIRS += plugins/samplesink/hackrfoutput SUBDIRS += plugins/samplesink/limesdroutput SUBDIRS += plugins/samplesink/plutosdroutput