Change in osmo-trx[master]: lms: add device type detection and device specific gains

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Apr 17 18:24:13 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/13663 )

Change subject: lms: add device type detection and device specific gains
......................................................................

lms: add device type detection and device specific gains

add device dependant max gain setup - limesdr mini and limenet micro need slightly reduced maximum gains to get a PASS on phase error measurements
rework clock reference setup - external clock needs to be selected before calling LMS_Init(), internal can only be set after.
remove now unused compat_LMS_VCTCXO* functions - we do not set the VCTXCO directly anymore

Change-Id: I3cf905b0a84bc1ec200891762a6646141ee37181
---
M Transceiver52M/device/lms/LMSDevice.cpp
M Transceiver52M/device/lms/LMSDevice.h
M configure.ac
3 files changed, 40 insertions(+), 58 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp
index 083b88e..34ad6e8 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -41,24 +41,6 @@
 #define LMS_MIN_BW_SUPPORTED 2.5e6 /* 2.5mHz, minimum supported by LMS */
 #define LMS_CALIBRATE_BW_HZ OSMO_MAX(GSM_CARRIER_BW, LMS_MIN_BW_SUPPORTED)
 
-static int compat_LMS_VCTCXORead(lms_device_t *dev, uint16_t *val, bool memory)
-{
-#if HAVE_LMS_VCTCXO_EEPROM_SAVING
-	return LMS_VCTCXORead(dev, val, memory);
-#else
-	return LMS_VCTCXORead(dev, val);
-#endif
-}
-
-static int compat_LMS_VCTCXOWrite(lms_device_t *dev, uint16_t val, bool memory)
-{
-#if HAVE_LMS_VCTCXO_EEPROM_SAVING
-	return LMS_VCTCXOWrite(dev, val, memory);
-#else
-	return LMS_VCTCXOWrite(dev, val);
-#endif
-}
-
 LMSDevice::LMSDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chans, double lo_offset,
 		     const std::vector<std::string>& tx_paths,
 		     const std::vector<std::string>& rx_paths):
@@ -151,11 +133,10 @@
 
 int LMSDevice::open(const std::string &args, int ref, bool swap_channels)
 {
-	//lms_info_str_t dev_str;
 	lms_info_str_t* info_list;
+	const lms_dev_info_t* device_info;
 	lms_range_t range_sr;
 	float_type sr_host, sr_rf;
-	uint16_t dac_val;
 	unsigned int i, n;
 	int rc, dev_id;
 
@@ -194,12 +175,45 @@
 
 	delete [] info_list;
 
+	device_info = LMS_GetDeviceInfo(m_lms_dev);
+
+	if ((ref != REF_EXTERNAL) && (ref != REF_INTERNAL)){
+		LOGC(DDEV, ERROR) << "Invalid reference type";
+		goto out_close;
+	}
+
+	/* if reference clock is external setup must happen _before_ calling LMS_Init */
+	/* FIXME make external reference frequency configurable */
+	if (ref == REF_EXTERNAL) {
+		LOGC(DDEV, INFO) << "Setting External clock reference to 10MHz";
+		/* Assume an external 10 MHz reference clock */
+		if (LMS_SetClockFreq(m_lms_dev, LMS_CLOCK_EXTREF, 10000000.0) < 0)
+			goto out_close;
+	}
+
 	LOGC(DDEV, INFO) << "Init LMS device";
 	if (LMS_Init(m_lms_dev) != 0) {
 		LOGC(DDEV, ERROR) << "LMS_Init() failed";
 		goto out_close;
 	}
 
+	/* LimeSDR-Mini does not have switches but needs soldering to select external/internal clock */
+	/* LimeNET-Micro also does not like selecting internal clock*/
+	/* also set device specific maximum tx levels selected by phasenoise measurements*/
+	if (strncmp(device_info->deviceName,"LimeSDR-USB",11) == 0){
+		/* if reference clock is internal setup must happen _after_ calling LMS_Init */
+		/* according to lms using LMS_CLOCK_EXTREF with a frequency <= 0 is the correct way to set clock to internal reference*/
+		if (ref == REF_INTERNAL) {
+			LOGC(DDEV, INFO) << "Setting Internal clock reference";
+			if (LMS_SetClockFreq(m_lms_dev, LMS_CLOCK_EXTREF, -1) < 0)
+				goto out_close;
+		}
+		maxTxGainClamp = 73.0;
+	} else if (strncmp(device_info->deviceName,"LimeSDR-Mini",12) == 0)
+		maxTxGainClamp = 66.0;
+	else
+		maxTxGainClamp = 71.0; /* "LimeNET-Micro", etc FIXME pciE based LMS boards?*/
+
 	/* enable all used channels */
 	for (i=0; i<chans; i++) {
 		if (LMS_EnableChannel(m_lms_dev, LMS_CH_RX, i, true) < 0)
@@ -223,27 +237,6 @@
 	/* FIXME: make this device/model dependent, like UHDDevice:dev_param_map! */
 	ts_offset = static_cast<TIMESTAMP>(8.9e-5 * GSMRATE * tx_sps); /* time * sample_rate */
 
-	switch (ref) {
-	case REF_INTERNAL:
-		LOGC(DDEV, INFO) << "Setting Internal clock reference";
-		/* Ugly API: Selecting clock source implicit by writing to VCTCXO DAC ?!? */
-		if (compat_LMS_VCTCXORead(m_lms_dev, &dac_val, false) < 0)
-			goto out_close;
-		LOGC(DDEV, INFO) << "Setting VCTCXO to " << dac_val;
-		if (compat_LMS_VCTCXOWrite(m_lms_dev, dac_val, false) < 0)
-			goto out_close;
-		break;
-	case REF_EXTERNAL:
-		LOGC(DDEV, INFO) << "Setting External clock reference to " << 10000000.0;
-		/* Assume an external 10 MHz reference clock */
-		if (LMS_SetClockFreq(m_lms_dev, LMS_CLOCK_EXTREF, 10000000.0) < 0)
-			goto out_close;
-		break;
-	default:
-		LOGC(DDEV, ALERT) << "Invalid reference type";
-		goto out_close;
-	}
-
 	if (!set_antennas()) {
 		LOGC(DDEV, ALERT) << "LMS antenna setting failed";
 		return -1;
@@ -275,8 +268,10 @@
 
 	/* configure the channels/streams */
 	for (i=0; i<chans; i++) {
-		// Set gains to midpoint
-		setTxGain((minTxGain() + maxTxGain()) / 2, i);
+		/* Set gains for calibration/filter setup */
+		/* TX gain to maximum */
+		setTxGain(maxTxGain(), i);
+		/* RX gain to midpoint */
 		setRxGain((minRxGain() + maxRxGain()) / 2, i);
 
 		/* set up Rx and Tx filters */
@@ -385,7 +380,7 @@
 
 double LMSDevice::maxTxGain()
 {
-	return 73.0;
+	return maxTxGainClamp;
 }
 
 double LMSDevice::minTxGain()
diff --git a/Transceiver52M/device/lms/LMSDevice.h b/Transceiver52M/device/lms/LMSDevice.h
index 67f4691..d1cb12a 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -64,6 +64,7 @@
 	TIMESTAMP ts_initial, ts_offset;
 
 	double rxGain;
+	double maxTxGainClamp;
 
 	bool do_calib(size_t chan);
 	bool do_filters(size_t chan);
diff --git a/configure.ac b/configure.ac
index 2ce4462..bd421aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -162,20 +162,6 @@
 
 AS_IF([test "x$with_lms" = "xyes"], [
     PKG_CHECK_MODULES(LMS, LimeSuite)
-
-    # LimeSuite dc124e4e2ed9b549b142410af172f0592f9f0c23 > 18.10 broke API compatibility:
-    _cflags_save=$CFLAGS
-    CFLAGS="$CFLAGS $LMS_CFLAGS"
-    AC_COMPILE_IFELSE(
-        [AC_LANG_PROGRAM(
-            [[#include <lime/LimeSuite.h>]],
-            [[LMS_VCTCXOWrite(NULL, 0, false); LMS_VCTCXORead(NULL, 0, false);]]
-        )],
-        [AC_DEFINE([HAVE_LMS_VCTCXO_EEPROM_SAVING], [1],
-            [LMS_VCTCXO* requires memory parameter])],
-        [AC_DEFINE([HAVE_LMS_VCTCXO_EEPROM_SAVING], [0],
-            [LMS_VCTCXO* has no memory parameter])])
-    CFLAGS=$_cflags_save
 ])
 
 AS_IF([test "x$with_uhd" != "xno"],[

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

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3cf905b0a84bc1ec200891762a6646141ee37181
Gerrit-Change-Number: 13663
Gerrit-PatchSet: 4
Gerrit-Owner: roh <jsteiger at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190417/e760ca88/attachment.htm>


More information about the gerrit-log mailing list