Change in osmo-trx[master]: move LMS_GetLPFBWRange and LMS_Calibrate calls from open to start (bw...

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

roh gerrit-no-reply at lists.osmocom.org
Tue Apr 16 15:20:28 UTC 2019


roh has uploaded this change for review. ( https://gerrit.osmocom.org/13662


Change subject: move LMS_GetLPFBWRange and LMS_Calibrate calls from open to start (bw, freq, power need to be set)
......................................................................

move LMS_GetLPFBWRange and LMS_Calibrate calls from open to start (bw, freq, power need to be set)

Change-Id: I1090effdf0f43e5183a402e4c1a1ffe5abdefd37
---
M Transceiver52M/device/lms/LMSDevice.cpp
M Transceiver52M/device/lms/LMSDevice.h
2 files changed, 50 insertions(+), 27 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/62/13662/1

diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp
index cb41858..ab4e868 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -153,8 +153,8 @@
 {
 	//lms_info_str_t dev_str;
 	lms_info_str_t* info_list;
-	lms_range_t range_lpfbw_rx, range_lpfbw_tx, range_sr;
-	float_type sr_host, sr_rf, lpfbw_rx, lpfbw_tx;
+	lms_range_t range_sr;
+	float_type sr_host, sr_rf;
 	uint16_t dac_val;
 	unsigned int i, n;
 	int rc, dev_id;
@@ -244,36 +244,11 @@
 		goto out_close;
 	}
 
-	if (LMS_GetLPFBWRange(m_lms_dev, LMS_CH_RX, &range_lpfbw_rx))
-		goto out_close;
-	print_range("LPFBWRange Rx", &range_lpfbw_rx);
-	if (LMS_GetLPFBWRange(m_lms_dev, LMS_CH_RX, &range_lpfbw_tx))
-		goto out_close;
-	print_range("LPFBWRange Tx", &range_lpfbw_tx);
-	lpfbw_rx = OSMO_MIN(OSMO_MAX(1.4001e6, range_lpfbw_rx.min), range_lpfbw_rx.max);
-	lpfbw_tx = OSMO_MIN(OSMO_MAX(5.2e6, range_lpfbw_tx.min), range_lpfbw_tx.max);
-
-	LOGC(DDEV, INFO) << "LPFBW: Rx=" << lpfbw_rx << " Tx=" << lpfbw_tx;
-
 	if (!set_antennas()) {
 		LOGC(DDEV, ALERT) << "LMS antenna setting failed";
 		return -1;
 	}
 
-	/* Perform Rx and Tx calibration */
-	for (i=0; i<chans; i++) {
-		LOGC(DDEV, INFO) << "Setting LPFBW chan " << i;
-		if (LMS_SetLPFBW(m_lms_dev, LMS_CH_RX, i, lpfbw_rx) < 0)
-			goto out_close;
-		if (LMS_SetLPFBW(m_lms_dev, LMS_CH_TX, i, lpfbw_tx) < 0)
-			goto out_close;
-		LOGC(DDEV, INFO) << "Calibrating chan " << i;
-		if (LMS_Calibrate(m_lms_dev, LMS_CH_RX, i, LMS_CALIBRATE_BW_HZ, 0) < 0)
-			goto out_close;
-		if (LMS_Calibrate(m_lms_dev, LMS_CH_TX, i, LMS_CALIBRATE_BW_HZ, 0) < 0)
-			goto out_close;
-	}
-
 	samplesRead = 0;
 	samplesWritten = 0;
 	started = false;
@@ -304,6 +279,13 @@
 		setTxGain((minTxGain() + maxTxGain()) / 2, i);
 		setRxGain((minRxGain() + maxRxGain()) / 2, i);
 
+		/* set up Rx and Tx filters */
+		if (!do_filters(i))
+			return false;
+		/* Perform Rx and Tx calibration */
+		if (!do_calib(i))
+			return false;
+
 		m_lms_stream_rx[i] = {};
 		m_lms_stream_rx[i].isTx = false;
 		m_lms_stream_rx[i].channel = i;
@@ -362,6 +344,45 @@
 	return true;
 }
 
+/* do rx and tx calibration - depends on gain, freq and bw */
+bool LMSDevice::do_calib(size_t chan)
+{
+	LOGC(DDEV, INFO) << "Calibrating chan " << chan;
+	if (LMS_Calibrate(m_lms_dev, LMS_CH_RX, chan, LMS_CALIBRATE_BW_HZ, 0) < 0)
+		return false;
+	if (LMS_Calibrate(m_lms_dev, LMS_CH_TX, chan, LMS_CALIBRATE_BW_HZ, 0) < 0)
+		return false;
+	return true;
+}
+
+/* do filter config - depends on bw only? */
+bool LMSDevice::do_filters(size_t chan)
+{
+	lms_range_t range_lpfbw_rx, range_lpfbw_tx;
+	float_type lpfbw_rx, lpfbw_tx;
+
+	LOGC(DDEV, INFO) << "Setting filters on chan " << chan;
+	if (LMS_GetLPFBWRange(m_lms_dev, LMS_CH_RX, &range_lpfbw_rx))
+		return false;
+	print_range("LPFBWRange Rx", &range_lpfbw_rx);
+	if (LMS_GetLPFBWRange(m_lms_dev, LMS_CH_RX, &range_lpfbw_tx))
+		return false;
+	print_range("LPFBWRange Tx", &range_lpfbw_tx);
+
+	lpfbw_rx = OSMO_MIN(OSMO_MAX(1.4001e6, range_lpfbw_rx.min), range_lpfbw_rx.max);
+	lpfbw_tx = OSMO_MIN(OSMO_MAX(5.2e6, range_lpfbw_tx.min), range_lpfbw_tx.max);
+
+	LOGC(DDEV, INFO) << "LPFBW: Rx=" << lpfbw_rx << " Tx=" << lpfbw_tx;
+
+	LOGC(DDEV, INFO) << "Setting LPFBW chan " << chan;
+	if (LMS_SetLPFBW(m_lms_dev, LMS_CH_RX, chan, lpfbw_rx) < 0)
+		return false;
+	if (LMS_SetLPFBW(m_lms_dev, LMS_CH_TX, chan, lpfbw_tx) < 0)
+		return false;
+	return true;
+}
+
+
 double LMSDevice::maxTxGain()
 {
 	return 73.0;
diff --git a/Transceiver52M/device/lms/LMSDevice.h b/Transceiver52M/device/lms/LMSDevice.h
index fde2408..67f4691 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -65,6 +65,8 @@
 
 	double rxGain;
 
+	bool do_calib(size_t chan);
+	bool do_filters(size_t chan);
 	int get_ant_idx(const std::string & name, bool dir_tx, size_t chan);
 	bool flush_recv(size_t num_pkts);
 	void update_stream_stats(size_t chan, bool * underrun, bool * overrun);

-- 
To view, visit https://gerrit.osmocom.org/13662
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1090effdf0f43e5183a402e4c1a1ffe5abdefd37
Gerrit-Change-Number: 13662
Gerrit-PatchSet: 1
Gerrit-Owner: roh <jsteiger at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190416/145ea85d/attachment.htm>


More information about the gerrit-log mailing list