1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

LibbladeRF2: migrate devices/bladerf to devices/bladerf1

This commit is contained in:
f4exb 2018-09-19 05:26:18 +02:00
parent d596931209
commit 8433f63a9b
18 changed files with 69 additions and 67 deletions

View File

@ -3,7 +3,7 @@ project(devices)
find_package(LibUSB) find_package(LibUSB)
if (BUILD_DEBIAN) if (BUILD_DEBIAN)
add_subdirectory(bladerf) add_subdirectory(bladerf1)
add_subdirectory(hackrf) add_subdirectory(hackrf)
add_subdirectory(limesdr) add_subdirectory(limesdr)
add_subdirectory(perseus) add_subdirectory(perseus)
@ -11,7 +11,7 @@ if (BUILD_DEBIAN)
else(BUILD_DEBIAN) else(BUILD_DEBIAN)
find_package(LibBLADERF) find_package(LibBLADERF)
if(LIBUSB_FOUND AND LIBBLADERF_FOUND) if(LIBUSB_FOUND AND LIBBLADERF_FOUND)
add_subdirectory(bladerf) add_subdirectory(bladerf1)
endif(LIBUSB_FOUND AND LIBBLADERF_FOUND) endif(LIBUSB_FOUND AND LIBBLADERF_FOUND)
find_package(LibHACKRF) find_package(LibHACKRF)

View File

@ -1,16 +1,16 @@
project(bladerfdevice) project(bladerf1device)
set(bladerfdevice_SOURCES set(bladerf1device_SOURCES
devicebladerf.cpp devicebladerf1.cpp
devicebladerfvalues.cpp devicebladerf1values.cpp
devicebladerfshared.cpp devicebladerf1shared.cpp
) )
set(bladerfdevice_HEADERS set(bladerf1device_HEADERS
devicebladerf.h devicebladerf1.h
devicebladerfvalues.h devicebladerf1values.h
devicebladerfparam.h devicebladerf1param.h
devicebladerfshared.h devicebladerf1shared.h
) )
if (BUILD_DEBIAN) if (BUILD_DEBIAN)
@ -31,20 +31,20 @@ endif (BUILD_DEBIAN)
#add_definitions(${QT_DEFINITIONS}) #add_definitions(${QT_DEFINITIONS})
#add_definitions(-DQT_SHARED) #add_definitions(-DQT_SHARED)
add_library(bladerfdevice SHARED add_library(bladerf1device SHARED
${bladerfdevice_SOURCES} ${bladerf1device_SOURCES}
) )
if (BUILD_DEBIAN) if (BUILD_DEBIAN)
target_link_libraries(bladerfdevice target_link_libraries(bladerf1device
bladerf bladerf
sdrbase sdrbase
) )
else (BUILD_DEBIAN) else (BUILD_DEBIAN)
target_link_libraries(bladerfdevice target_link_libraries(bladerf1device
${LIBBLADERF_LIBRARIES} ${LIBBLADERF_LIBRARIES}
sdrbase sdrbase
) )
endif (BUILD_DEBIAN) endif (BUILD_DEBIAN)
install(TARGETS bladerfdevice DESTINATION lib) install(TARGETS bladerf1device DESTINATION lib)

View File

@ -14,13 +14,14 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include "../bladerf1/devicebladerf1.h"
#include <QtGlobal> #include <QtGlobal>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include "devicebladerf.h"
bool DeviceBladeRF::open_bladerf(struct bladerf **dev, const char *serial) bool DeviceBladeRF1::open_bladerf(struct bladerf **dev, const char *serial)
{ {
int fpga_loaded; int fpga_loaded;
@ -47,7 +48,7 @@ bool DeviceBladeRF::open_bladerf(struct bladerf **dev, const char *serial)
return true; return true;
} }
struct bladerf *DeviceBladeRF::open_bladerf_from_serial(const char *serial) struct bladerf *DeviceBladeRF1::open_bladerf_from_serial(const char *serial)
{ {
int status; int status;
struct bladerf *dev; struct bladerf *dev;

View File

@ -21,7 +21,7 @@
#include "export.h" #include "export.h"
class DEVICES_API DeviceBladeRF class DEVICES_API DeviceBladeRF1
{ {
public: public:
static bool open_bladerf(struct bladerf **dev, const char *serial); static bool open_bladerf(struct bladerf **dev, const char *serial);

View File

@ -14,8 +14,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef DEVICES_BLADERF_DEVICEBLADERFPARAM_H_ #ifndef DEVICES_BLADERF1_DEVICEBLADERF1PARAM_H_
#define DEVICES_BLADERF_DEVICEBLADERFPARAM_H_ #define DEVICES_BLADERF1_DEVICEBLADERF1PARAM_H_
#include <libbladeRF.h> #include <libbladeRF.h>
@ -23,16 +23,16 @@
* This structure is owned by each of the parties sharing the same physical device * This structure is owned by each of the parties sharing the same physical device
* It allows exchange of information on the common resources * It allows exchange of information on the common resources
*/ */
struct DeviceBladeRFParams struct DeviceBladeRF1Params
{ {
struct bladerf *m_dev; //!< device handle if the party has ownership else 0 struct bladerf *m_dev; //!< device handle if the party has ownership else 0
bool m_xb200Attached; //!< true if XB200 is attached and owned by the party bool m_xb200Attached; //!< true if XB200 is attached and owned by the party
DeviceBladeRFParams() : DeviceBladeRF1Params() :
m_dev(0), m_dev(0),
m_xb200Attached(false) m_xb200Attached(false)
{ {
} }
}; };
#endif /* DEVICES_BLADERF_DEVICEBLADERFPARAM_H_ */ #endif /* DEVICES_BLADERF1_DEVICEBLADERF1PARAM_H_ */

View File

@ -14,8 +14,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include "devicebladerfshared.h" #include "../bladerf1/devicebladerf1shared.h"
const float DeviceBladeRFShared::m_sampleFifoLengthInSeconds = 0.25; const float DeviceBladeRF1Shared::m_sampleFifoLengthInSeconds = 0.25;
const int DeviceBladeRFShared::m_sampleFifoMinSize = 75000; // 300 kS/s knee const int DeviceBladeRF1Shared::m_sampleFifoMinSize = 75000; // 300 kS/s knee
const int DeviceBladeRFShared::m_sampleFifoMinSize32 = 150000; // Fixed for interpolation by 32 const int DeviceBladeRF1Shared::m_sampleFifoMinSize32 = 150000; // Fixed for interpolation by 32

View File

@ -20,7 +20,7 @@
#include "util/message.h" #include "util/message.h"
#include "export.h" #include "export.h"
class DEVICES_API DeviceBladeRFShared class DEVICES_API DeviceBladeRF1Shared
{ {
public: public:
static const float m_sampleFifoLengthInSeconds; static const float m_sampleFifoLengthInSeconds;

View File

@ -14,11 +14,11 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include "devicebladerfvalues.h" #include "../bladerf1/devicebladerf1values.h"
unsigned int DeviceBladeRFBandwidths::m_nb_halfbw = 16; unsigned int DeviceBladeRF1Bandwidths::m_nb_halfbw = 16;
unsigned int DeviceBladeRFBandwidths::m_halfbw[] = { unsigned int DeviceBladeRF1Bandwidths::m_halfbw[] = {
750, 750,
875, 875,
1250, 1250,
@ -36,7 +36,7 @@ unsigned int DeviceBladeRFBandwidths::m_halfbw[] = {
10000, 10000,
14000}; 14000};
unsigned int DeviceBladeRFBandwidths::getBandwidth(unsigned int bandwidth_index) unsigned int DeviceBladeRF1Bandwidths::getBandwidth(unsigned int bandwidth_index)
{ {
if (bandwidth_index < m_nb_halfbw) if (bandwidth_index < m_nb_halfbw)
{ {
@ -48,7 +48,7 @@ unsigned int DeviceBladeRFBandwidths::getBandwidth(unsigned int bandwidth_index)
} }
} }
unsigned int DeviceBladeRFBandwidths::getBandwidthIndex(unsigned int bandwidth) unsigned int DeviceBladeRF1Bandwidths::getBandwidthIndex(unsigned int bandwidth)
{ {
for (unsigned int i=0; i < m_nb_halfbw; i++) for (unsigned int i=0; i < m_nb_halfbw; i++)
{ {
@ -61,9 +61,9 @@ unsigned int DeviceBladeRFBandwidths::getBandwidthIndex(unsigned int bandwidth)
return 0; return 0;
} }
unsigned int DeviceBladeRFBandwidths::getNbBandwidths() unsigned int DeviceBladeRF1Bandwidths::getNbBandwidths()
{ {
return DeviceBladeRFBandwidths::m_nb_halfbw; return DeviceBladeRF1Bandwidths::m_nb_halfbw;
} }

View File

@ -14,12 +14,12 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef DEVICES_BLADERF_DEVICEBLADERFVALUES_H_ #ifndef DEVICES_BLADERF1_DEVICEBLADERF1VALUES_H_
#define DEVICES_BLADERF_DEVICEBLADERFVALUES_H_ #define DEVICES_BLADERF1_DEVICEBLADERF1VALUES_H_
#include "export.h" #include "export.h"
class DEVICES_API DeviceBladeRFBandwidths { class DEVICES_API DeviceBladeRF1Bandwidths {
public: public:
static unsigned int getBandwidth(unsigned int bandwidth_index); static unsigned int getBandwidth(unsigned int bandwidth_index);
static unsigned int getBandwidthIndex(unsigned int bandwidth); static unsigned int getBandwidthIndex(unsigned int bandwidth);
@ -29,4 +29,4 @@ private:
static unsigned int m_nb_halfbw; static unsigned int m_nb_halfbw;
}; };
#endif /* DEVICES_BLADERF_DEVICEBLADERFVALUES_H_ */ #endif /* DEVICES_BLADERF1_DEVICEBLADERF1VALUES_H_ */

View File

@ -62,7 +62,7 @@ target_link_libraries(outputbladerf
sdrbase sdrbase
sdrgui sdrgui
swagger swagger
bladerfdevice bladerf1device
) )
else (BUILD_DEBIAN) else (BUILD_DEBIAN)
target_link_libraries(outputbladerf target_link_libraries(outputbladerf
@ -71,7 +71,7 @@ target_link_libraries(outputbladerf
sdrbase sdrbase
sdrgui sdrgui
swagger swagger
bladerfdevice bladerf1device
) )
endif (BUILD_DEBIAN) endif (BUILD_DEBIAN)

View File

@ -26,9 +26,9 @@
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "device/devicesinkapi.h" #include "device/devicesinkapi.h"
#include "device/devicesourceapi.h" #include "device/devicesourceapi.h"
#include "bladerf/devicebladerfshared.h"
#include "bladerfoutput.h" #include "bladerfoutput.h"
#include "../../../devices/bladerf1/devicebladerf1shared.h"
#include "bladerfoutputthread.h" #include "bladerfoutputthread.h"
MESSAGE_CLASS_DEFINITION(BladerfOutput::MsgConfigureBladerf, Message) MESSAGE_CLASS_DEFINITION(BladerfOutput::MsgConfigureBladerf, Message)
@ -74,7 +74,7 @@ bool BladerfOutput::openDevice()
if (m_deviceAPI->getSourceBuddies().size() > 0) if (m_deviceAPI->getSourceBuddies().size() > 0)
{ {
DeviceSourceAPI *sourceBuddy = m_deviceAPI->getSourceBuddies()[0]; DeviceSourceAPI *sourceBuddy = m_deviceAPI->getSourceBuddies()[0];
DeviceBladeRFParams *buddySharedParams = (DeviceBladeRFParams *) sourceBuddy->getBuddySharedPtr(); DeviceBladeRF1Params *buddySharedParams = (DeviceBladeRF1Params *) sourceBuddy->getBuddySharedPtr();
if (buddySharedParams == 0) if (buddySharedParams == 0)
{ {
@ -93,7 +93,7 @@ bool BladerfOutput::openDevice()
} }
else else
{ {
if (!DeviceBladeRF::open_bladerf(&m_dev, qPrintable(m_deviceAPI->getSampleSinkSerial()))) if (!DeviceBladeRF1::open_bladerf(&m_dev, qPrintable(m_deviceAPI->getSampleSinkSerial())))
{ {
qCritical("BladerfOutput::start: could not open BladeRF %s", qPrintable(m_deviceAPI->getSampleSinkSerial())); qCritical("BladerfOutput::start: could not open BladeRF %s", qPrintable(m_deviceAPI->getSampleSinkSerial()));
return false; return false;
@ -318,13 +318,13 @@ bool BladerfOutput::applySettings(const BladeRFOutputSettings& settings, bool fo
if (settings.m_log2Interp >= 5) if (settings.m_log2Interp >= 5)
{ {
fifoSize = DeviceBladeRFShared::m_sampleFifoMinSize32; fifoSize = DeviceBladeRF1Shared::m_sampleFifoMinSize32;
} }
else else
{ {
fifoSize = std::max( fifoSize = std::max(
(int) ((settings.m_devSampleRate/(1<<settings.m_log2Interp)) * DeviceBladeRFShared::m_sampleFifoLengthInSeconds), (int) ((settings.m_devSampleRate/(1<<settings.m_log2Interp)) * DeviceBladeRF1Shared::m_sampleFifoLengthInSeconds),
DeviceBladeRFShared::m_sampleFifoMinSize); DeviceBladeRF1Shared::m_sampleFifoMinSize);
} }
m_sampleSourceFifo.resize(fifoSize); m_sampleSourceFifo.resize(fifoSize);

View File

@ -18,12 +18,11 @@
#define INCLUDE_BLADERFOUTPUT_H #define INCLUDE_BLADERFOUTPUT_H
#include <dsp/devicesamplesink.h> #include <dsp/devicesamplesink.h>
#include "bladerf/devicebladerf.h"
#include "bladerf/devicebladerfparam.h"
#include <libbladeRF.h> #include <libbladeRF.h>
#include <QString> #include <QString>
#include "../../../devices/bladerf1/devicebladerf1.h"
#include "../../../devices/bladerf1/devicebladerf1param.h"
#include "bladerfoutputsettings.h" #include "bladerfoutputsettings.h"
class DeviceSinkAPI; class DeviceSinkAPI;
@ -140,7 +139,7 @@ private:
struct bladerf* m_dev; struct bladerf* m_dev;
BladerfOutputThread* m_bladerfThread; BladerfOutputThread* m_bladerfThread;
QString m_deviceDescription; QString m_deviceDescription;
DeviceBladeRFParams m_sharedParams; DeviceBladeRF1Params m_sharedParams;
bool m_running; bool m_running;
}; };

View File

@ -27,7 +27,8 @@
#include "device/devicesinkapi.h" #include "device/devicesinkapi.h"
#include "device/deviceuiset.h" #include "device/deviceuiset.h"
#include "bladerfoutputgui.h" #include "bladerfoutputgui.h"
#include "bladerf/devicebladerfvalues.h"
#include "../../../devices/bladerf1/devicebladerf1values.h"
BladerfOutputGui::BladerfOutputGui(DeviceUISet *deviceUISet, QWidget* parent) : BladerfOutputGui::BladerfOutputGui(DeviceUISet *deviceUISet, QWidget* parent) :
QWidget(parent), QWidget(parent),

View File

@ -62,7 +62,7 @@ target_link_libraries(inputbladerf
sdrbase sdrbase
sdrgui sdrgui
swagger swagger
bladerfdevice bladerf1device
) )
else (BUILD_DEBIAN) else (BUILD_DEBIAN)
target_link_libraries(inputbladerf target_link_libraries(inputbladerf
@ -71,7 +71,7 @@ target_link_libraries(inputbladerf
sdrbase sdrbase
sdrgui sdrgui
swagger swagger
bladerfdevice bladerf1device
) )
endif (BUILD_DEBIAN) endif (BUILD_DEBIAN)

View File

@ -83,7 +83,7 @@ bool BladerfInput::openDevice()
if (m_deviceAPI->getSinkBuddies().size() > 0) if (m_deviceAPI->getSinkBuddies().size() > 0)
{ {
DeviceSinkAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0]; DeviceSinkAPI *sinkBuddy = m_deviceAPI->getSinkBuddies()[0];
DeviceBladeRFParams *buddySharedParams = (DeviceBladeRFParams *) sinkBuddy->getBuddySharedPtr(); DeviceBladeRF1Params *buddySharedParams = (DeviceBladeRF1Params *) sinkBuddy->getBuddySharedPtr();
if (buddySharedParams == 0) if (buddySharedParams == 0)
{ {
@ -102,7 +102,7 @@ bool BladerfInput::openDevice()
} }
else else
{ {
if (!DeviceBladeRF::open_bladerf(&m_dev, qPrintable(m_deviceAPI->getSampleSourceSerial()))) if (!DeviceBladeRF1::open_bladerf(&m_dev, qPrintable(m_deviceAPI->getSampleSourceSerial())))
{ {
qCritical("BladerfInput::start: could not open BladeRF %s", qPrintable(m_deviceAPI->getSampleSourceSerial())); qCritical("BladerfInput::start: could not open BladeRF %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
return false; return false;

View File

@ -22,8 +22,9 @@
#include <libbladeRF.h> #include <libbladeRF.h>
#include <dsp/devicesamplesource.h> #include <dsp/devicesamplesource.h>
#include "bladerf/devicebladerf.h"
#include "bladerf/devicebladerfparam.h" #include "../../../devices/bladerf1/devicebladerf1.h"
#include "../../../devices/bladerf1/devicebladerf1param.h"
#include "bladerfinputsettings.h" #include "bladerfinputsettings.h"
class DeviceSourceAPI; class DeviceSourceAPI;
@ -144,7 +145,7 @@ private:
struct bladerf* m_dev; struct bladerf* m_dev;
BladerfInputThread* m_bladerfThread; BladerfInputThread* m_bladerfThread;
QString m_deviceDescription; QString m_deviceDescription;
DeviceBladeRFParams m_sharedParams; DeviceBladeRF1Params m_sharedParams;
bool m_running; bool m_running;
FileRecord *m_fileSink; //!< File sink to record device I/Q output FileRecord *m_fileSink; //!< File sink to record device I/Q output
}; };

View File

@ -51,7 +51,7 @@ target_link_libraries(outputbladerfsrv
bladerf bladerf
sdrbase sdrbase
swagger swagger
bladerfdevice bladerf1device
) )
else (BUILD_DEBIAN) else (BUILD_DEBIAN)
target_link_libraries(outputbladerfsrv target_link_libraries(outputbladerfsrv
@ -59,7 +59,7 @@ target_link_libraries(outputbladerfsrv
${LIBBLADERF_LIBRARIES} ${LIBBLADERF_LIBRARIES}
sdrbase sdrbase
swagger swagger
bladerfdevice bladerf1device
) )
endif (BUILD_DEBIAN) endif (BUILD_DEBIAN)

View File

@ -51,7 +51,7 @@ target_link_libraries(inputbladerfsrv
bladerf bladerf
sdrbase sdrbase
swagger swagger
bladerfdevice bladerf1device
) )
else (BUILD_DEBIAN) else (BUILD_DEBIAN)
target_link_libraries(inputbladerfsrv target_link_libraries(inputbladerfsrv
@ -59,7 +59,7 @@ target_link_libraries(inputbladerfsrv
${LIBBLADERF_LIBRARIES} ${LIBBLADERF_LIBRARIES}
sdrbase sdrbase
swagger swagger
bladerfdevice bladerf1device
) )
endif (BUILD_DEBIAN) endif (BUILD_DEBIAN)