Skip to content

Commit

Permalink
plugins: adrv9002: constrain RSSI reads
Browse files Browse the repository at this point in the history
With the changes in the device driver API, reading the RSSI on a channel
that's not enabled will trow an error. Hence, instead of flooding the
device with error's (and the kernel log), don't read the RSSI for
channels that are not enabled.

With the above, as we always need to read the ensm widget, make use
iio_widget_update_value() to update it in case port enable is set to pin
(and hence avoiding another call into the device).

Signed-off-by: Nuno Sa <[email protected]>
  • Loading branch information
nunojsa committed Jun 6, 2024
1 parent 4ceed02 commit 54efaad
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions plugins/adrv9002.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ static void update_label(const struct adrv9002_gtklabel *label)
gtk_label_set_text(label->labels, attr_val);
}

static void update_special_widgets(struct adrv9002_common *chann)
static void update_special_widgets(struct adrv9002_common *chann, const char *ensm, size_t len)
{
char *gain_ctl = gtk_combo_box_text_get_active_text(
GTK_COMBO_BOX_TEXT(chann->gain_ctrl.widget));
Expand All @@ -653,8 +653,8 @@ static void update_special_widgets(struct adrv9002_common *chann)
if (gain_ctl && strcmp(gain_ctl, "spi"))
iio_widget_update_block_signals_by_data(&chann->gain);

if (port_en && strcmp(port_en, "spi"))
iio_widget_update_block_signals_by_data(&chann->ensm);
if (port_en && strcmp(port_en, "spi") && ensm)
iio_widget_update_value(&chann->ensm, ensm, len);

g_free(gain_ctl);
g_free(port_en);
Expand All @@ -667,13 +667,25 @@ static void update_special_rx_widgets(struct adrv9002_rx *rx, const int n_widget
for (i = 0; i < n_widgets; i++) {
char *digital_gain = gtk_combo_box_text_get_active_text(
GTK_COMBO_BOX_TEXT(rx[i].digital_gain_ctl.widget));
char ensm[32] = {0};

if (!rx[i].rx.enabled)
goto nex_widget;

update_label(&rx[i].rssi);
/*
* There was a change in the driver API where an error is returned if we try to read
* the RSSI level if the channel is not enabled. Hence, make sure we only update it
* if the channel is enabled.
*/
if (iio_channel_attr_read(rx[i].rx.ensm.chn, rx[i].rx.ensm.attr_name, ensm,
sizeof(ensm)) > 0 && !strcmp(ensm, "rf_enabled"))
update_label(&rx[i].rssi);
update_label(&rx[i].decimated_power);
update_special_widgets(&rx[i].rx);
/*
* Pass in ensm as we already got it and so no need for another possible
* remote call into the device.
*/
update_special_widgets(&rx[i].rx, ensm, sizeof(ensm));

if (digital_gain && strstr(digital_gain, "automatic"))
iio_widget_update_block_signals_by_data(&rx[i].intf_gain);
Expand All @@ -690,7 +702,7 @@ static void update_special_tx_widgets(struct adrv9002_common *tx, const int n_wi
if (!tx[i].enabled)
continue;

update_special_widgets(&tx[i]);
update_special_widgets(&tx[i], NULL, 0);
}
}

Expand Down

0 comments on commit 54efaad

Please sign in to comment.