Skip to content

Commit 69f9e01

Browse files
committed
adrv9002: code refactoring
Signed-off-by: IonutMuthi <[email protected]>
1 parent e4bb3ae commit 69f9e01

16 files changed

+925
-557
lines changed

iio-widgets/src/datastrategy/channelattrdatastrategy.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ QPair<QString, QString> ChannelAttrDataStrategy::read()
106106
}
107107

108108
// the members that contain data need to be refreshed before the signals are emitted
109-
QString oldData = m_data;
110109
m_data = currentValue;
111110
m_optionalData = options;
112111

packages/adrv9002/plugins/adrv9002plugin/include/adrv9002plugin/adrv9002.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ private Q_SLOTS:
8383
const QString &title);
8484
IIOWidget *createRangeWidget(iio_channel *ch, const QString &attr, const QString &range, const QString &title);
8585
IIOWidget *createCheckboxWidget(iio_channel *ch, const QString &attr, const QString &label);
86-
QLabel *createReadOnlyLabel(iio_channel *ch, const QString &attr, double divisor = 1.0,
87-
const QString &title = QString());
86+
87+
IIOWidget *createReadOnlyWidget(iio_channel *ch, const QString &attr, const QString &title);
88+
IIOWidget *createContinuousReadOnlyWidget(iio_channel *ch, const QString &attr, const QString &title);
8889

8990
// Standard Scopy tool components
9091
iio_context *m_ctx = nullptr;

packages/adrv9002/plugins/adrv9002plugin/include/adrv9002plugin/channelconfigwidget.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class SCOPY_ADRV9002PLUGIN_EXPORT ChannelConfigWidget : public QWidget
4848
struct ChannelData
4949
{
5050
bool enabled = true;
51-
bool freqOffsetCorrection = false;
52-
QString bandwidth = "38000000";
53-
QString sampleRate = "61440000";
54-
QString rfInput = "Rx1A"; // Only used for RX channels
51+
bool freqOffsetCorrectionEnable = false;
52+
uint32_t channelBandwidthHz = 38000000;
53+
uint32_t sampleRateHz = 61440000;
54+
uint8_t rfPort = 0; // Only used for RX channels
5555
};
5656

5757
explicit ChannelConfigWidget(const QString &title, ChannelMode mode, const QStringList &rfInputOptions = {},

packages/adrv9002/plugins/adrv9002plugin/include/adrv9002plugin/profilegeneratorconstants.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <QString>
2525
#include <QStringList>
26+
#include "profilegeneratortypes.h"
2627

2728
namespace scopy::adrv9002 {
2829

@@ -78,6 +79,15 @@ class IOOOptions
7879
static const QStringList DUPLEX_MODE_OPTIONS;
7980
};
8081

82+
class ProfileGeneratorConstants
83+
{
84+
public:
85+
// Create complete lte_defaults configuration template
86+
static RadioConfig lteDefaults();
87+
// Create complete lte_lvs_3072_MHz_10 configuration template
88+
static RadioConfig lte_lvs3072MHz10();
89+
};
90+
8191
} // namespace scopy::adrv9002
8292

83-
#endif // PROFILEGENERATORCONSTANTS_H
93+
#endif // PROFILEGENERATORCONSTANTS_H

packages/adrv9002/plugins/adrv9002plugin/include/adrv9002plugin/profilegeneratortypes.h

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,107 @@ enum ChannelType
3434
CHANNEL_TX2
3535
};
3636

37-
struct ChannelConfig
37+
struct RxChannelConfig
3838
{
39+
// Enable channel
3940
bool enabled;
40-
bool freqOffsetCorrection;
41-
QString bandwidth;
42-
QString sampleRate;
43-
QString rfInput; // For RX only
41+
// Enable high performance ADC, otherwise use low-power ADC
42+
bool adcHighPerformanceMode;
43+
// Enable ADC frequency offset correction
44+
bool freqOffsetCorrectionEnable;
45+
// Power mode of front-end analog filter Options are:
46+
// 0 - Low power
47+
// 1 - Medium power
48+
// 2 - High power
49+
uint8_t analogFilterPowerMode;
50+
// Use second order (Biquad) analog filter, otherwise first order TIA is used
51+
bool analogFilterBiquad;
52+
// Front-end analog filter 1dB (Biquad) or 3 dB (TIA) bandwidth in Hz
53+
uint32_t analogFilterBandwidthHz;
54+
// Channel bandwidth of interest at ADC in Hz
55+
uint32_t channelBandwidthHz;
56+
// RX channel sample rate at digital interface
57+
uint32_t sampleRateHz;
58+
// Enable NCO to perform frequency translation
59+
bool ncoEnable;
60+
// NCO frequency in Hz
61+
int32_t ncoFrequencyHz;
62+
// RF port source used for channel Options are:
63+
// 0 - RX_A
64+
// 1 - RX_B
65+
uint8_t rfPort;
4466
};
4567

46-
struct OrxConfig
68+
struct TxChannelConfig
4769
{
70+
// Enable channel
4871
bool enabled;
72+
// Data rate at digital interface in Hz
73+
uint32_t sampleRateHz;
74+
// Enable DAC frequency offset correction
75+
bool freqOffsetCorrectionEnable;
76+
// Power mode of front-end analog filter Options are:
77+
// 0 - Low power
78+
// 1 - Medium power
79+
// 2 - High power
80+
uint8_t analogFilterPowerMode;
81+
// Channel bandwidth of interest at DAC in Hz
82+
uint32_t channelBandwidthHz;
83+
// Enable observation path
84+
bool orxEnabled;
85+
// Set external loopback mode. Options are:
86+
// 0 - Disabled
87+
// 1 - Before PA
88+
// 2 - After PA
89+
uint8_t elbType;
90+
};
91+
92+
struct ClockConfig
93+
{
94+
// Template-based parameters (from iio-oscilloscope clock_config)
95+
uint32_t deviceClockFrequencyKhz;
96+
bool deviceClockOutputEnable;
97+
uint8_t deviceClockOutputDivider;
98+
// Enable high performance PLL mode, otherwise low-power mode is used
99+
bool clockPllHighPerformanceEnable;
100+
// PLL power mode. Options:
101+
// 0 = low power
102+
// 1 = medium performance
103+
// 2 = high performance
104+
uint8_t clockPllPowerMode;
105+
// Processor clock divider. Valid values are 1, 2, 4, 8, 16, 32, 64, 128, 256
106+
uint8_t processorClockDivider;
49107
};
50108

51109
struct RadioConfig
52110
{
53-
bool fdd; // Duplex mode (false=TDD, true=FDD)
54-
bool lvds; // SSI interface (true=LVDS, false=CMOS)
111+
// SSI lanes to use Valid cases:
112+
// 1 (CMOS/LVDS)
113+
// 2 (LVDS)
114+
// 4 (CMOS)
55115
uint8_t ssi_lanes; // 1, 2, or 4 lanes
116+
// Use DDR mode at digital interface, false will use SDR
117+
bool ddr;
118+
// Use short strobe mode at digital interface, false will use long strobe
119+
bool shortStrobe;
120+
// Use LVDS mode at digital interface, false will use CMOS
121+
bool lvds;
122+
// ADC clock rate mode select. Options are:
123+
// 1 = LOW
124+
// 2 = MEDIUM
125+
// 3 = HIGH
126+
uint8_t adcRateMode;
127+
// Use FDD duplex mode, false will use TDD
128+
bool fdd;
129+
130+
// Channel configurations
131+
RxChannelConfig rx_config[2]; // RX1, RX2
132+
TxChannelConfig tx_config[2]; // TX1, TX2
56133

57-
ChannelConfig rx_config[2]; // RX1, RX2
58-
ChannelConfig tx_config[2]; // TX1, TX2
59-
bool orx_enabled[2]; // ORX1, ORX2
134+
// Clock configuration
135+
ClockConfig clk_config;
60136
};
61137

62138
} // namespace scopy::adrv9002
63139

64-
#endif // PROFILEGENERATORTYPES_H
140+
#endif // PROFILEGENERATORTYPES_H

packages/adrv9002/plugins/adrv9002plugin/include/adrv9002plugin/profilegeneratorwidget.h

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,29 @@ namespace scopy::adrv9002 {
6565
// Device Configuration Parser (Phase 1 addition)
6666
class DeviceConfigurationParser
6767
{
68+
6869
public:
6970
struct ParsedChannelData
7071
{
72+
// Enable channel
7173
bool enabled;
72-
QString bandwidth;
73-
QString sampleRate;
74-
bool freqOffsetCorrection;
75-
QString rfPort; // RX only
74+
uint32_t analogFilterBandwidthHz;
75+
// Channel bandwidth of interest at ADC in Hz
76+
uint32_t channelBandwidthHz;
77+
// RX channel sample rate at digital interface
78+
uint32_t sampleRateHz;
79+
// Enable ADC frequency offset correction
80+
bool freqOffsetCorrectionEnable;
81+
// RF port source used for channel Options are:
82+
// 0 - RX_A
83+
// 1 - RX_B
84+
uint8_t rfPort; // RX only
85+
// Enable observation path
7686
bool orxEnabled; // TX only
87+
88+
// Data source tracking (NEW)
89+
bool hasChannelData; // indicates if IIO channel attributes were read
90+
QString dataSource; // "profile_config", "iio_attributes", or "unavailable"
7791
};
7892

7993
struct ParsedDeviceConfig
@@ -86,11 +100,11 @@ class DeviceConfigurationParser
86100
ParsedChannelData txChannels[2];
87101

88102
// Clock config
89-
QString deviceClock;
90-
QString clockDivider;
103+
uint32_t deviceClock;
104+
uint32_t clockDivider;
91105
};
92106

93-
static ParsedDeviceConfig parseProfileConfig(const QString &profileConfigText);
107+
static ParsedDeviceConfig parseProfileConfig(iio_device *dev, const QString &profileConfigText);
94108
static QString extractValueBetween(const QString &text, const QString &begin, const QString &end);
95109
static QString mapRfPortFromDevice(const QString &devicePort, int channel);
96110
};
@@ -118,7 +132,7 @@ public Q_SLOTS:
118132
private Q_SLOTS:
119133
void onPresetChanged();
120134
void onRefreshProfile();
121-
void onSaveToFile();
135+
void onSaveToFile(bool isStreamFile);
122136
void onLoadToDevice();
123137
void updateProfileData();
124138
void onDownloadCLI();
@@ -141,10 +155,15 @@ private Q_SLOTS:
141155
void loadPresetData(const QString &presetName);
142156
void updateDebugInfo();
143157
void updateConfigFromUI();
158+
int getConfigFromCurrent(RadioConfig &config);
159+
int getConfigFromDefault(RadioConfig &config);
160+
int getConfigFromDevice(RadioConfig &config);
161+
void populateConfigFromUI(RadioConfig &config);
162+
void populateConfigFromDeviceData(RadioConfig &config,
163+
const DeviceConfigurationParser::ParsedDeviceConfig &deviceConfig);
144164

145165
// Preset Management
146166
void applyLTEDefaults();
147-
void applyLTEPresetLogic();
148167
bool isLTEModeActive() const;
149168
bool isLiveDeviceModeActive() const;
150169

@@ -162,10 +181,6 @@ private Q_SLOTS:
162181
bool getTddModeEnabled();
163182
bool isOrxAvailable(int orxIndex);
164183

165-
// Validation helpers
166-
void validateChannelConfiguration();
167-
void updateAllDependentControls();
168-
169184
// Phase 2: Complete UI Refresh System
170185
void refreshAllUIStates();
171186

@@ -187,11 +202,12 @@ private Q_SLOTS:
187202

188203
// Device Communication
189204
QString readDeviceAttribute(const QString &attributeName);
205+
QString getDeviceDriverVersion();
190206

191207
// Phase 1: Device Configuration Reading
192208
bool readDeviceConfiguration();
209+
iio_channel *findIIOChannel(const QString &channelName, bool isOutput);
193210
void populateUIFromDeviceConfig(const DeviceConfigurationParser::ParsedDeviceConfig &config);
194-
bool isDeviceConfigurationAvailable();
195211
void resetPresetTracking();
196212
void forceUpdateAllUIControls();
197213
bool readAndApplyDeviceConfiguration();
@@ -216,7 +232,8 @@ private Q_SLOTS:
216232
// Action Bar Components
217233
QComboBox *m_presetCombo;
218234
QPushButton *m_refreshProfileBtn;
219-
AnimatedLoadingButton *m_saveToFileBtn;
235+
AnimatedLoadingButton *m_saveStreamToFileBtn;
236+
AnimatedLoadingButton *m_saveProfileToFileBtn;
220237
AnimatedLoadingButton *m_loadToDeviceBtn;
221238

222239
// Radio Config Components

packages/adrv9002/plugins/adrv9002plugin/include/adrv9002plugin/profilemanager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public Q_SLOTS:
7070

7171
private Q_SLOTS:
7272
void onProfileFileChanged();
73-
void doOnProfileFileChangedInThread();
7473
void onStreamFileChanged();
7574
void updateStatus();
7675

0 commit comments

Comments
 (0)