Change in osmo-trx[master]: Drop old TxGain APIs from parent radioDevice abstract class

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Jun 29 09:03:49 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/18919 )

Change subject: Drop old TxGain APIs from parent radioDevice abstract class
......................................................................

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
---
M Transceiver52M/device/common/radioDevice.h
M Transceiver52M/device/lms/LMSDevice.h
M Transceiver52M/device/uhd/UHDDevice.h
M Transceiver52M/device/usrp1/USRPDevice.cpp
M Transceiver52M/device/usrp1/USRPDevice.h
5 files changed, 20 insertions(+), 50 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



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 @@
   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 @@
   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 @@
 	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 @@
 	};
 
 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 @@
   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 @@
 #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 @@
   }
 
   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 @@
   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 @@
   /** 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 @@
   /** 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 */

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/18919
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: Ice005cd0a07c49b6e212c06f1228ef93c24db727
Gerrit-Change-Number: 18919
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200629/399b8da7/attachment.htm>


More information about the gerrit-log mailing list