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
This commit is contained in:
Pau Espin 2020-06-08 13:44:24 +02:00
parent 056ce136e6
commit 992c9bd1ce
7 changed files with 59 additions and 61 deletions

View File

@ -125,21 +125,9 @@ class RadioDevice {
/** return minimum Rx Gain **/ /** return minimum Rx Gain **/
virtual double minRxGain(void) = 0; 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 **/ /** returns the Nominal transmit output power of the transceiver in dBm, negative on error **/
virtual int getNominalTxPower(size_t chan = 0) = 0; 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 */ /** 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; virtual bool setRxAntenna(const std::string &ant, size_t chan = 0) = 0;
@ -163,6 +151,18 @@ class RadioDevice {
virtual double getRxFreq(size_t chan = 0) = 0; virtual double getRxFreq(size_t chan = 0) = 0;
virtual double getSampleRate()=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: protected:
size_t tx_sps, rx_sps; size_t tx_sps, rx_sps;
InterfaceType iface; InterfaceType iface;
@ -171,6 +171,15 @@ class RadioDevice {
std::vector<std::string> tx_paths, rx_paths; std::vector<std::string> tx_paths, rx_paths;
std::vector<struct device_counters> m_ctr; 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, 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>& tx_paths,
const std::vector<std::string>& rx_paths): const std::vector<std::string>& rx_paths):

View File

@ -77,6 +77,19 @@ private:
void update_stream_stats_rx(size_t chan, bool *overrun); void update_stream_stats_rx(size_t chan, bool *overrun);
void update_stream_stats_tx(size_t chan, bool *underrun); void update_stream_stats_tx(size_t chan, bool *underrun);
bool do_clock_src_freq(enum ReferenceType ref, double freq); 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: public:
@ -165,20 +178,6 @@ public:
/** return minimum Rx Gain **/ /** return minimum Rx Gain **/
double minRxGain(void); 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); int getNominalTxPower(size_t chan = 0);
/** sets the RX path to use, returns true if successful and false otherwise */ /** sets the RX path to use, returns true if successful and false otherwise */

View File

@ -101,11 +101,6 @@ public:
double maxRxGain(void) { return rx_gain_max; } double maxRxGain(void) { return rx_gain_max; }
double minRxGain(void) { return rx_gain_min; } 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); int getNominalTxPower(size_t chan = 0);
double getTxFreq(size_t chan); double getTxFreq(size_t chan);
@ -136,6 +131,11 @@ public:
}; };
private: 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::usrp::multi_usrp::sptr usrp_dev;
uhd::tx_streamer::sptr tx_stream; uhd::tx_streamer::sptr tx_stream;
uhd::rx_streamer::sptr rx_stream; uhd::rx_streamer::sptr rx_stream;

View File

@ -85,6 +85,18 @@ private:
int writeSamplesControl(std::vector<short *> &bufs, int len, bool *underrun, int writeSamplesControl(std::vector<short *> &bufs, int len, bool *underrun,
TIMESTAMP timestamp = 0xffffffff, bool isControl = false); 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 #ifdef SWLOOPBACK
short loopbackBuffer[1000000]; short loopbackBuffer[1000000];
int loopbackBufferSize; int loopbackBufferSize;
@ -168,18 +180,6 @@ private:
/** return minimum Rx Gain **/ /** return minimum Rx Gain **/
double minRxGain(void); 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); int getNominalTxPower(size_t chan = 0);
/** sets the RX path to use, returns true if successful and false otherwise */ /** sets the RX path to use, returns true if successful and false otherwise */

View File

@ -103,7 +103,7 @@ double RadioInterface::fullScaleOutputValue(void) {
int RadioInterface::setPowerAttenuation(int atten, size_t chan) int RadioInterface::setPowerAttenuation(int atten, size_t chan)
{ {
double rfGain, digAtten; double rfAtten, digAtten;
if (chan >= mChans) { if (chan >= mChans) {
LOG(ALERT) << "Invalid channel requested"; LOG(ALERT) << "Invalid channel requested";
@ -113,8 +113,8 @@ int RadioInterface::setPowerAttenuation(int atten, size_t chan)
if (atten < 0.0) if (atten < 0.0)
atten = 0.0; atten = 0.0;
rfGain = setTxGain(mDevice->maxTxGain() - (double) atten, chan); rfAtten = mDevice->setPowerAttenuation((double) atten, chan);
digAtten = (double) atten - mDevice->maxTxGain() + rfGain; digAtten = (double) atten - rfAtten;
if (digAtten < 1.0) if (digAtten < 1.0)
powerScaling[chan] = 1.0; powerScaling[chan] = 1.0;
@ -318,11 +318,6 @@ double RadioInterface::setRxGain(double dB, size_t chan)
return mDevice->setRxGain(dB, chan); 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 */ /* Receive a timestamped chunk from the device */
int RadioInterface::pullBuffer() int RadioInterface::pullBuffer()
{ {

View File

@ -116,7 +116,8 @@ public:
/** drive reception of GSM bursts. -1: Error. 0: Radio off. 1: Received something. */ /** drive reception of GSM bursts. -1: Error. 0: Radio off. 1: Received something. */
int driveReceiveRadio(); 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); int getNominalTxPower(size_t chan = 0);
/** returns the full-scale transmit amplitude **/ /** returns the full-scale transmit amplitude **/
@ -135,9 +136,6 @@ protected:
/** drive synchronization of Tx/Rx of USRP */ /** drive synchronization of Tx/Rx of USRP */
void alignRadio(); void alignRadio();
/** set transmit gain */
virtual double setTxGain(double dB, size_t chan = 0);
friend void *AlignRadioServiceLoopAdapter(RadioInterface*); friend void *AlignRadioServiceLoopAdapter(RadioInterface*);
}; };
@ -167,7 +165,7 @@ private:
bool pushBuffer(); bool pushBuffer();
int pullBuffer(); int pullBuffer();
bool verify_arfcn_consistency(double freq, size_t chan, bool tx); 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 *outerSendBuffer;
signalVector *outerRecvBuffer; signalVector *outerRecvBuffer;

View File

@ -437,11 +437,8 @@ double RadioInterfaceMulti::setRxGain(double db, size_t chan)
return mDevice->getRxGain(); return mDevice->getRxGain();
} }
double RadioInterfaceMulti::setTxGain(double dB, size_t chan) int RadioInterfaceMulti::setPowerAttenuation(int atten, size_t chan)
{ {
if (chan == 0) return RadioInterface::setPowerAttenuation(atten, 0);
return mDevice->setTxGain(dB);
else
return mDevice->getTxGain();
} }