Change in osmo-trx[master]: radioInterface: Operate on real Tx power attenuation rather than on d...

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/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Jun 15 09:08:33 UTC 2020


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

Change subject: radioInterface: Operate on real Tx power attenuation rather than on device specific gains
......................................................................

radioInterface: Operate on real Tx power attenuation rather than on device specific gains

All the Tx gain related APIs are left out of reach from radioInterface,
and in there we simply interact with radioDevice passing the attenuation
received from TRXC.

Prior gain logic is moved in base radiodevice class, with the idea that
the setTxGain() and related functions will be dropped over time in each
sublcass in favour of an specific implementation of the
SetPowerAttenuation API.

Change-Id: I4f8a1bcbed74aa9310306b97b0b1bfb02f7855e6
---
M Transceiver52M/device/common/radioDevice.h
M Transceiver52M/device/lms/LMSDevice.h
M Transceiver52M/device/uhd/UHDDevice.h
M Transceiver52M/device/usrp1/USRPDevice.h
M Transceiver52M/radioInterface.cpp
M Transceiver52M/radioInterface.h
M Transceiver52M/radioInterfaceMulti.cpp
7 files changed, 59 insertions(+), 61 deletions(-)

Approvals:
  Jenkins Builder: Verified
  neels: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve



diff --git a/Transceiver52M/device/common/radioDevice.h b/Transceiver52M/device/common/radioDevice.h
index 8dd8f49..e51527d 100644
--- a/Transceiver52M/device/common/radioDevice.h
+++ b/Transceiver52M/device/common/radioDevice.h
@@ -125,21 +125,9 @@
   /** return minimum Rx Gain **/
   virtual double minRxGain(void) = 0;
 
-  /** sets the transmit chan gain, returns the gain setting **/
-  virtual double setTxGain(double dB, size_t chan = 0) = 0;
-
   /** returns the Nominal transmit output power of the transceiver in dBm, negative on error **/
   virtual int getNominalTxPower(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;
-
-  /** return minimum Tx Gain **/
-  virtual double minTxGain(void) = 0;
-
   /** sets the RX path to use, returns true if successful and false otherwise */
   virtual bool setRxAntenna(const std::string &ant, size_t chan = 0) = 0;
 
@@ -163,6 +151,18 @@
   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);
+  }
+
   protected:
   size_t tx_sps, rx_sps;
   InterfaceType iface;
@@ -171,6 +171,15 @@
   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 78fd62a..c83fed2 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -77,6 +77,19 @@
 	void update_stream_stats_rx(size_t chan, bool *overrun);
 	void update_stream_stats_tx(size_t chan, bool *underrun);
 	bool do_clock_src_freq(enum ReferenceType ref, double freq);
+	/** sets the transmit chan gain, returns the gain setting **/
+	double setTxGain(double dB, size_t chan = 0);
+
+	/** get transmit gain */
+	double getTxGain(size_t chan = 0) {
+		return tx_gains[chan];
+	}
+
+	/** return maximum Tx Gain **/
+	double maxTxGain(void);
+
+	/** return minimum Rx Gain **/
+	double minTxGain(void);
 
 public:
 
@@ -165,20 +178,6 @@
 	/** return minimum Rx Gain **/
 	double minRxGain(void);
 
-	/** sets the transmit chan gain, returns the gain setting **/
-	double setTxGain(double dB, size_t chan = 0);
-
-	/** get transmit gain */
-	double getTxGain(size_t chan = 0) {
-		return tx_gains[chan];
-	}
-
-	/** return maximum Tx Gain **/
-	double maxTxGain(void);
-
-	/** return minimum Rx Gain **/
-	double minTxGain(void);
-
 	int getNominalTxPower(size_t chan = 0);
 
 	/** sets the RX path to use, returns true if successful and false otherwise */
diff --git a/Transceiver52M/device/uhd/UHDDevice.h b/Transceiver52M/device/uhd/UHDDevice.h
index 8a2d592..d87caf2 100644
--- a/Transceiver52M/device/uhd/UHDDevice.h
+++ b/Transceiver52M/device/uhd/UHDDevice.h
@@ -101,11 +101,6 @@
 	double maxRxGain(void) { return rx_gain_max; }
 	double minRxGain(void) { return rx_gain_min; }
 
-	double setTxGain(double db, size_t chan);
-	double getTxGain(size_t chan = 0);
-	double maxTxGain(void) { return tx_gain_max; }
-	double minTxGain(void) { return tx_gain_min; }
-
 	int getNominalTxPower(size_t chan = 0);
 
 	double getTxFreq(size_t chan);
@@ -136,6 +131,11 @@
 	};
 
 private:
+	double setTxGain(double db, size_t chan);
+	double getTxGain(size_t chan = 0);
+	double maxTxGain(void) { return tx_gain_max; }
+	double minTxGain(void) { return tx_gain_min; }
+
 	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.h b/Transceiver52M/device/usrp1/USRPDevice.h
index 0549192..1c1b3be 100644
--- a/Transceiver52M/device/usrp1/USRPDevice.h
+++ b/Transceiver52M/device/usrp1/USRPDevice.h
@@ -85,6 +85,18 @@
   int writeSamplesControl(std::vector<short *> &bufs, int len, bool *underrun,
                    TIMESTAMP timestamp = 0xffffffff, bool isControl = false);
 
+  /** sets the transmit chan gain, returns the gain setting **/
+  double setTxGain(double dB, size_t chan = 0);
+
+  /** 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;
@@ -168,18 +180,6 @@
   /** return minimum Rx Gain **/
   double minRxGain(void);
 
-  /** sets the transmit chan gain, returns the gain setting **/
-  double setTxGain(double dB, size_t chan = 0);
-
-  /** 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);
-
   int getNominalTxPower(size_t chan = 0);
 
   /** sets the RX path to use, returns true if successful and false otherwise */
diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp
index fb724d2..adc2ee7 100644
--- a/Transceiver52M/radioInterface.cpp
+++ b/Transceiver52M/radioInterface.cpp
@@ -103,7 +103,7 @@
 
 int RadioInterface::setPowerAttenuation(int atten, size_t chan)
 {
-  double rfGain, digAtten;
+  double rfAtten, digAtten;
 
   if (chan >= mChans) {
     LOG(ALERT) << "Invalid channel requested";
@@ -113,8 +113,8 @@
   if (atten < 0.0)
     atten = 0.0;
 
-  rfGain = setTxGain(mDevice->maxTxGain() - (double) atten, chan);
-  digAtten = (double) atten - mDevice->maxTxGain() + rfGain;
+  rfAtten = mDevice->setPowerAttenuation((double) atten, chan);
+  digAtten = (double) atten - rfAtten;
 
   if (digAtten < 1.0)
     powerScaling[chan] = 1.0;
@@ -318,11 +318,6 @@
   return mDevice->setRxGain(dB, chan);
 }
 
-double RadioInterface::setTxGain(double dB, size_t chan)
-{
-  return mDevice->setTxGain(dB, chan);
-}
-
 /* Receive a timestamped chunk from the device */
 int RadioInterface::pullBuffer()
 {
diff --git a/Transceiver52M/radioInterface.h b/Transceiver52M/radioInterface.h
index eb7ed3b..8e5f4c1 100644
--- a/Transceiver52M/radioInterface.h
+++ b/Transceiver52M/radioInterface.h
@@ -116,7 +116,8 @@
   /** drive reception of GSM bursts. -1: Error. 0: Radio off. 1: Received something. */
   int driveReceiveRadio();
 
-  int setPowerAttenuation(int atten, size_t chan = 0);
+  /** set transmit power attenuation */
+  virtual int setPowerAttenuation(int atten, size_t chan = 0);
   int getNominalTxPower(size_t chan = 0);
 
   /** returns the full-scale transmit amplitude **/
@@ -135,9 +136,6 @@
   /** drive synchronization of Tx/Rx of USRP */
   void alignRadio();
 
-  /** set transmit gain */
-  virtual double setTxGain(double dB, size_t chan = 0);
-
   friend void *AlignRadioServiceLoopAdapter(RadioInterface*);
 };
 
@@ -167,7 +165,7 @@
   bool pushBuffer();
   int pullBuffer();
   bool verify_arfcn_consistency(double freq, size_t chan, bool tx);
-  virtual double setTxGain(double dB, size_t chan);
+  virtual int setPowerAttenuation(int atten, size_t chan = 0);
 
   signalVector *outerSendBuffer;
   signalVector *outerRecvBuffer;
diff --git a/Transceiver52M/radioInterfaceMulti.cpp b/Transceiver52M/radioInterfaceMulti.cpp
index a0c24b5..29f85ca 100644
--- a/Transceiver52M/radioInterfaceMulti.cpp
+++ b/Transceiver52M/radioInterfaceMulti.cpp
@@ -437,11 +437,8 @@
     return mDevice->getRxGain();
 }
 
-double RadioInterfaceMulti::setTxGain(double dB, size_t chan)
+int RadioInterfaceMulti::setPowerAttenuation(int atten, size_t chan)
 {
-	if (chan == 0)
-		return mDevice->setTxGain(dB);
-	else
-		return mDevice->getTxGain();
+		return RadioInterface::setPowerAttenuation(atten, 0);
 
 }

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

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I4f8a1bcbed74aa9310306b97b0b1bfb02f7855e6
Gerrit-Change-Number: 18722
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: roh <jsteiger at sysmocom.de>
Gerrit-Reviewer: tnt <tnt at 246tNt.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200615/8c5a5e1b/attachment.htm>


More information about the gerrit-log mailing list