aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-06-19 18:11:54 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2020-06-25 13:07:22 +0200
commit5bd3d4263bf026c8a5a892b23f01f1413cc51747 (patch)
tree0e4f33d06c5a8f9f02109cbf45ada841d46b8aba
parentf68f19b1101ea0bf25913cdb4c7c3d236f01a806 (diff)
Drop old TxGain APIs from parent radioDevice abstract class
All radioDevice subclasses except USRPDevice have already been reworked to use the new SetPowerAttenuation() methods, hence we can drop the compatibility layer that was added to transition from the old API to the new one, and move those functions to USRPDevice. This way we simplify the parent abstract class with methods not needed by most devices and not used anymore by external users of those classes. Change-Id: Ice005cd0a07c49b6e212c06f1228ef93c24db727
-rw-r--r--Transceiver52M/device/common/radioDevice.h22
-rw-r--r--Transceiver52M/device/lms/LMSDevice.h4
-rw-r--r--Transceiver52M/device/uhd/UHDDevice.h4
-rw-r--r--Transceiver52M/device/usrp1/USRPDevice.cpp31
-rw-r--r--Transceiver52M/device/usrp1/USRPDevice.h9
5 files changed, 20 insertions, 50 deletions
diff --git a/Transceiver52M/device/common/radioDevice.h b/Transceiver52M/device/common/radioDevice.h
index e51527d..cfe65da 100644
--- a/Transceiver52M/device/common/radioDevice.h
+++ b/Transceiver52M/device/common/radioDevice.h
@@ -151,17 +151,8 @@ class RadioDevice {
virtual double getRxFreq(size_t chan = 0) = 0;
virtual double getSampleRate()=0;
- /* Default backward-compatible implementation based on TxGain APIs. New
- implementations should be based on getNominalTxPower() once implemented for
- the specific backend. */
- virtual double setPowerAttenuation(int atten, size_t chan) {
- double rfGain;
- rfGain = setTxGain(maxTxGain() - atten, chan);
- return maxTxGain() - rfGain;
- }
- virtual double getPowerAttenuation(size_t chan=0) {
- return maxTxGain() - getTxGain(chan);
- }
+ virtual double setPowerAttenuation(int atten, size_t chan) = 0;
+ virtual double getPowerAttenuation(size_t chan=0) = 0;
protected:
size_t tx_sps, rx_sps;
@@ -171,15 +162,6 @@ class RadioDevice {
std::vector<std::string> tx_paths, rx_paths;
std::vector<struct device_counters> m_ctr;
- /** sets the transmit chan gain, returns the gain setting **/
- virtual double setTxGain(double dB, size_t chan = 0) = 0;
-
- /** get transmit gain */
- virtual double getTxGain(size_t chan = 0) = 0;
-
- /** return maximum Tx Gain **/
- virtual double maxTxGain(void) = 0;
-
RadioDevice(size_t tx_sps, size_t rx_sps, InterfaceType type, size_t chan_num, double offset,
const std::vector<std::string>& tx_paths,
const std::vector<std::string>& rx_paths):
diff --git a/Transceiver52M/device/lms/LMSDevice.h b/Transceiver52M/device/lms/LMSDevice.h
index b6a6ab9..7af09e2 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -86,10 +86,6 @@ private:
bool do_clock_src_freq(enum ReferenceType ref, double freq);
void get_dev_band_desc(dev_band_desc& desc);
- double setTxGain(double db, size_t chan) {OSMO_ASSERT(false); return 0.0f; }
- double getTxGain(size_t chan = 0) { OSMO_ASSERT(false); return 0.0f; };
- double maxTxGain(void) { OSMO_ASSERT(false); return 0.0f; };
-
public:
/** Object constructor */
diff --git a/Transceiver52M/device/uhd/UHDDevice.h b/Transceiver52M/device/uhd/UHDDevice.h
index 2c428ca..22a0948 100644
--- a/Transceiver52M/device/uhd/UHDDevice.h
+++ b/Transceiver52M/device/uhd/UHDDevice.h
@@ -134,10 +134,6 @@ public:
};
private:
- double setTxGain(double db, size_t chan) {OSMO_ASSERT(false); return 0.0f; }
- double getTxGain(size_t chan = 0) { OSMO_ASSERT(false); return 0.0f; };
- double maxTxGain(void) { OSMO_ASSERT(false); return 0.0f; };
-
uhd::usrp::multi_usrp::sptr usrp_dev;
uhd::tx_streamer::sptr tx_stream;
uhd::rx_streamer::sptr rx_stream;
diff --git a/Transceiver52M/device/usrp1/USRPDevice.cpp b/Transceiver52M/device/usrp1/USRPDevice.cpp
index 73117d2..5c40aa8 100644
--- a/Transceiver52M/device/usrp1/USRPDevice.cpp
+++ b/Transceiver52M/device/usrp1/USRPDevice.cpp
@@ -205,8 +205,8 @@ bool USRPDevice::start()
writeLock.unlock();
// Set gains to midpoint
- setTxGain((minTxGain() + maxTxGain()) / 2);
- setRxGain((minRxGain() + maxRxGain()) / 2);
+ setTxGain((m_dbTx->gain_min() + m_dbTx->gain_max()) / 2);
+ setRxGain((m_dbTx->gain_min() + m_dbTx->gain_max()) / 2);
data = new short[currDataSize];
dataStart = 0;
@@ -243,16 +243,6 @@ bool USRPDevice::stop()
#endif
}
-double USRPDevice::maxTxGain()
-{
- return m_dbTx->gain_max();
-}
-
-double USRPDevice::minTxGain()
-{
- return m_dbTx->gain_min();
-}
-
double USRPDevice::maxRxGain()
{
return m_dbRx->gain_max();
@@ -271,10 +261,10 @@ double USRPDevice::setTxGain(double dB, size_t chan)
}
writeLock.lock();
- if (dB > maxTxGain())
- dB = maxTxGain();
- if (dB < minTxGain())
- dB = minTxGain();
+ if (dB > m_dbTx->gain_max())
+ dB = m_dbTx->gain_max();
+ if (dB < m_dbTx->gain_min())
+ dB = m_dbTx->gain_min();
LOGC(DDEV, NOTICE) << "Setting TX gain to " << dB << " dB.";
@@ -314,6 +304,15 @@ double USRPDevice::setRxGain(double dB, size_t chan)
return rxGain;
}
+double USRPDevice::setPowerAttenuation(int atten, size_t chan) {
+ double rfGain;
+ rfGain = setTxGain(m_dbTx->gain_max() - atten, chan);
+ return m_dbTx->gain_max() - rfGain;
+}
+double USRPDevice::getPowerAttenuation(size_t chan) {
+ return m_dbTx->gain_max() - getTxGain(chan);
+}
+
int USRPDevice::getNominalTxPower(size_t chan)
{
/* TODO: return value based on some experimentally generated table depending on
diff --git a/Transceiver52M/device/usrp1/USRPDevice.h b/Transceiver52M/device/usrp1/USRPDevice.h
index 1c1b3be..f761dc0 100644
--- a/Transceiver52M/device/usrp1/USRPDevice.h
+++ b/Transceiver52M/device/usrp1/USRPDevice.h
@@ -91,12 +91,6 @@ private:
/** get transmit gain */
double getTxGain(size_t chan = 0) { return txGain; }
- /** return maximum Tx Gain **/
- double maxTxGain(void);
-
- /** return minimum Rx Gain **/
- double minTxGain(void);
-
#ifdef SWLOOPBACK
short loopbackBuffer[1000000];
int loopbackBufferSize;
@@ -180,6 +174,9 @@ private:
/** return minimum Rx Gain **/
double minRxGain(void);
+ double setPowerAttenuation(int atten, size_t chan);
+ double getPowerAttenuation(size_t chan=0);
+
int getNominalTxPower(size_t chan = 0);
/** sets the RX path to use, returns true if successful and false otherwise */