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

Change subject: lms: move LMS_EnableChannel from Start/Stop to Open/Close device
......................................................................

lms: move LMS_EnableChannel from Start/Stop to Open/Close device

move enable: it is important that channels are actually enabled before applying 
any configuration (besides external clock)
move disable: move to close, so channels are not disabled and not enabled again 
while osmotrx is active.

Change-Id: I82878913254ce15a85db8d006e13d5eb639793e9
---
M Transceiver52M/device/lms/LMSDevice.cpp
1 file changed, 14 insertions(+), 8 deletions(-)

Approvals:
  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 33e3cbd..45427cf 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -78,8 +78,14 @@

 LMSDevice::~LMSDevice()
 {
+       unsigned int i;
        LOGC(DDEV, INFO) << "Closing LMS device";
        if (m_lms_dev) {
+               /* disable all channels */
+               for (i=0; i<chans; i++) {
+                       LMS_EnableChannel(m_lms_dev, LMS_CH_RX, i, false);
+                       LMS_EnableChannel(m_lms_dev, LMS_CH_TX, i, false);
+               }
                LMS_Close(m_lms_dev);
                m_lms_dev = NULL;
        }
@@ -194,6 +200,14 @@
                goto out_close;
        }

+       /* enable all used channels */
+       for (i=0; i<chans; i++) {
+               if (LMS_EnableChannel(m_lms_dev, LMS_CH_RX, i, true) < 0)
+                       goto out_close;
+               if (LMS_EnableChannel(m_lms_dev, LMS_CH_TX, i, true) < 0)
+                       goto out_close;
+       }
+
        if (LMS_GetSampleRateRange(m_lms_dev, LMS_CH_RX, &range_sr))
                goto out_close;
        print_range("Sample Rate", &range_sr);
@@ -286,12 +300,6 @@

        /* configure the channels/streams */
        for (i=0; i<chans; i++) {
-               if (LMS_EnableChannel(m_lms_dev, LMS_CH_RX, i, true) < 0)
-                       return false;
-
-               if (LMS_EnableChannel(m_lms_dev, LMS_CH_TX, i, true) < 0)
-                       return false;
-
                // Set gains to midpoint
                setTxGain((minTxGain() + maxTxGain()) / 2, i);
                setRxGain((minRxGain() + maxRxGain()) / 2, i);
@@ -348,8 +356,6 @@
        for (i=0; i<chans; i++) {
                LMS_DestroyStream(m_lms_dev, &m_lms_stream_tx[i]);
                LMS_DestroyStream(m_lms_dev, &m_lms_stream_rx[i]);
-               LMS_EnableChannel(m_lms_dev, LMS_CH_RX, i, false);
-               LMS_EnableChannel(m_lms_dev, LMS_CH_TX, i, false);
        }

        started = false;

--
To view, visit https://gerrit.osmocom.org/13661
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: I82878913254ce15a85db8d006e13d5eb639793e9
Gerrit-Change-Number: 13661
Gerrit-PatchSet: 3
Gerrit-Owner: roh <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <[email protected]>

Reply via email to