Skip to content

Commit

Permalink
plugins/adrv9009: Reenable and update to libiio v1.x
Browse files Browse the repository at this point in the history
Signed-off-by: Dan <[email protected]>
  • Loading branch information
dNechita committed Dec 10, 2024
1 parent a6dd5d9 commit 7335721
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ set(PLUGINS
#fmcomms11
ad9371
ad9371_adv
#adrv9009
#adrv9009_adv
adrv9009
adrv9009_adv
#ad6676
#fmcadc3
#daq2
Expand Down
42 changes: 21 additions & 21 deletions plugins/adrv9009.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static void multichip_sync()
return;

/* Check for and skip in case of JESD204-FSM support */
ret = iio_device_attr_write_longlong(subcomponents[0].iio_dev, "multichip_sync", 424242);
ret = dev_attr_write_longlong(subcomponents[0].iio_dev, "multichip_sync", 424242);
if (ret != -EINVAL)
return;

Expand All @@ -272,7 +272,7 @@ static void multichip_sync()
for (; i <= 11; i++) {
guint n = 0;
for (; n < phy_devs_count; n++) {
iio_device_attr_write_longlong(subcomponents[n].iio_dev, "multichip_sync", i);
dev_attr_write_longlong(subcomponents[n].iio_dev, "multichip_sync", i);
}
}
}
Expand All @@ -287,7 +287,7 @@ static void update_label_from(GtkWidget *label, struct iio_device *dev, const ch

ch = iio_device_find_channel(dev, channel, output);
if (ch) {
ret = iio_channel_attr_read_longlong(ch, attribute, &val);
ret = chn_attr_read_longlong(ch, attribute, &val);

if (scale == 1)
snprintf(buf, sizeof(buf), "%lld %s", val, unit);
Expand Down Expand Up @@ -362,7 +362,7 @@ int load_tal_profile(const char *file_name,
ret = INT_MAX;
guint i = 0;
for (; i < phy_devs_count; i++) {
ret2 = iio_device_attr_write_raw(subcomponents[i].iio_dev, "profile_config", buf, len);
ret2 = dev_attr_write_raw(subcomponents[i].iio_dev, "profile_config", buf, len);
ret = (ret > ret2) ? ret2 : ret;
}

Expand Down Expand Up @@ -422,7 +422,7 @@ static void glb_settings_update_labels(void)

/* Get ensm_mode from all devices. Notify user if any of devices has a different mode than the others. */
for (; i < phy_devs_count; i++) {
ret = iio_device_attr_read(subcomponents[i].iio_dev, "ensm_mode", buf, sizeof(buf));
ret = dev_attr_read_raw(subcomponents[i].iio_dev, "ensm_mode", buf, sizeof(buf));
if (ret > 0) {
if (i > 0) {
if (strncmp(buf, gtk_label_get_text(GTK_LABEL(ensm_mode)), sizeof(buf))) {
Expand All @@ -441,7 +441,7 @@ static void glb_settings_update_labels(void)
for (i = 0; i < phy_devs_count; i++) {
ch = iio_device_find_channel(subcomponents[i].iio_dev, "voltage0", false);
if (ch) {
ret = iio_channel_attr_read(ch, "gain_control_mode", buf, sizeof(buf));
ret = chn_attr_read_raw(ch, "gain_control_mode", buf, sizeof(buf));
} else {
ret = 0;
}
Expand All @@ -453,7 +453,7 @@ static void glb_settings_update_labels(void)

ch = iio_device_find_channel(subcomponents[i].iio_dev, "voltage1", false);
if (ch) {
ret = iio_channel_attr_read(ch, "gain_control_mode", buf, sizeof(buf));
ret = chn_attr_read_raw(ch, "gain_control_mode", buf, sizeof(buf));
} else {
ret = 0;
}
Expand Down Expand Up @@ -496,7 +496,7 @@ static void set_ensm_mode_of_all_devices(const char *mode)
guint i = 0;

for (; i < phy_devs_count; i++) {
iio_device_attr_write_raw(subcomponents[i].iio_dev, "ensm_mode", mode, strlen(mode));
dev_attr_write_raw(subcomponents[i].iio_dev, "ensm_mode", mode, strlen(mode));
}
}

Expand Down Expand Up @@ -568,7 +568,7 @@ static void int_dec_freq_update(void)
return;

ch = iio_device_find_channel(cap, "voltage0_i", false);
iio_channel_attr_read_double(ch, "sampling_frequency", &freq);
chn_attr_read_double(ch, "sampling_frequency", &freq);
text = g_strdup_printf ("%f", freq / mhz_scale);

guint i = 0;
Expand All @@ -581,7 +581,7 @@ static void int_dec_freq_update(void)

ch = iio_device_find_channel(dds, "voltage0", true);
text = g_strdup_printf ("%f", freq / mhz_scale);
iio_channel_attr_read_double(ch, "sampling_frequency", &freq);
chn_attr_read_double(ch, "sampling_frequency", &freq);

for (i = 0; i < phy_devs_count; i++)
gtk_label_set_text(GTK_LABEL(subcomponents[i].label_sampling_freq_tx), text);
Expand All @@ -603,7 +603,7 @@ static void rssi_update_label(GtkWidget *label, struct iio_channel *ch)
if (!gtk_widget_is_drawable(GTK_WIDGET(label)))
return;

ret = iio_channel_attr_read(ch, "rssi", buf, sizeof(buf));
ret = chn_attr_read_raw(ch, "rssi", buf, sizeof(buf));
if (ret > 0)
gtk_label_set_text(GTK_LABEL(label), buf);
else
Expand Down Expand Up @@ -666,10 +666,10 @@ static void rx_phase_rotation_update()
struct iio_channel *i_chn = g_array_index(out, struct iio_channel*, i);
struct iio_channel *q_chn = g_array_index(out, struct iio_channel*, i + 1);

iio_channel_attr_read_double(i_chn, "calibscale", &val[0]);
iio_channel_attr_read_double(i_chn, "calibphase", &val[1]);
iio_channel_attr_read_double(q_chn, "calibscale", &val[2]);
iio_channel_attr_read_double(q_chn, "calibphase", &val[3]);
chn_attr_read_double(i_chn, "calibscale", &val[0]);
chn_attr_read_double(i_chn, "calibphase", &val[1]);
chn_attr_read_double(q_chn, "calibscale", &val[2]);
chn_attr_read_double(q_chn, "calibphase", &val[3]);

val[0] = acos(val[0]) * 360.0 / (2.0 * M_PI);
val[1] = asin(-1.0 * val[1]) * 360.0 / (2.0 * M_PI);
Expand Down Expand Up @@ -836,10 +836,10 @@ static void rx_phase_rotation_set(GtkSpinButton *spinbutton, gpointer user_data)
}

if (out1 && out0) {
iio_channel_attr_write_double(out0, "calibscale", (double) cos(phase));
iio_channel_attr_write_double(out0, "calibphase", (double)(-1 * sin(phase)));
iio_channel_attr_write_double(out1, "calibscale", (double) cos(phase));
iio_channel_attr_write_double(out1, "calibphase", (double) sin(phase));
chn_attr_write_double(out0, "calibscale", (double) cos(phase));
chn_attr_write_double(out0, "calibphase", (double)(-1 * sin(phase)));
chn_attr_write_double(out1, "calibscale", (double) cos(phase));
chn_attr_write_double(out1, "calibphase", (double) sin(phase));
}
}

Expand Down Expand Up @@ -1032,7 +1032,7 @@ static void load_profile(struct osc_plugin *plugin, const char *ini_fn)
g_free(attrib_name);

if (ch && value) {
iio_channel_attr_write(ch, "gain_control_mode", value);
chn_attr_write_string(ch, "gain_control_mode", value);
free(value);
}

Expand All @@ -1042,7 +1042,7 @@ static void load_profile(struct osc_plugin *plugin, const char *ini_fn)
g_free(attrib_name);

if (ch && value) {
iio_channel_attr_write(ch, "gain_control_mode", value);
chn_attr_write_string(ch, "gain_control_mode", value);
free(value);
}

Expand Down
18 changes: 9 additions & 9 deletions plugins/adrv9009_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <time.h>
#include <unistd.h>

#include <iio.h>
#include <iio/iio.h>

#include "../libini2.h"
#include "../osc.h"
Expand Down Expand Up @@ -791,7 +791,7 @@ static void signal_handler_cb(GtkWidget *widget, gpointer data)
val = (long long) gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));

if (item->lut_len) {
iio_device_debug_attr_read_longlong(plugin->priv->dev, item->name, &mask);
dev_debug_attr_read_longlong(plugin->priv->dev, item->name, &mask);
mask &= ~((1 << item->lut_len) - 1);
mask |= val & ((1 << item->lut_len) - 1);
val = mask;
Expand All @@ -815,23 +815,23 @@ static void signal_handler_cb(GtkWidget *widget, gpointer data)
if (ret != 2)
return;

iio_device_debug_attr_read_longlong(plugin->priv->dev, str, &mask);
dev_debug_attr_read_longlong(plugin->priv->dev, str, &mask);

if (val) {
mask |= (1 << bit);
} else {
mask &= ~(1 << bit);
}

iio_device_debug_attr_write_longlong(plugin->priv->dev, str, mask);
dev_debug_attr_write_longlong(plugin->priv->dev, str, mask);

return;

default:
return;
}

iio_device_debug_attr_write_longlong(plugin->priv->dev, item->name, val);
dev_debug_attr_write_longlong(plugin->priv->dev, item->name, val);

if (!strcmp(item->name, "initialize")) {
reload_settings();
Expand All @@ -854,8 +854,8 @@ static void bist_tone_cb(GtkWidget *widget, gpointer data)

sprintf(temp, "%u %u %u", enable, tx1_freq, tx2_freq);

iio_device_debug_attr_write(plugin->priv->dev, "bist_tone", "0 0 0");
iio_device_debug_attr_write(plugin->priv->dev, "bist_tone", temp);
dev_debug_attr_write_string(plugin->priv->dev, "bist_tone", "0 0 0");
dev_debug_attr_write_string(plugin->priv->dev, "bist_tone", temp);
}

static char *set_widget_value(GtkWidget *widget, struct w_info *item, long long val)
Expand Down Expand Up @@ -990,12 +990,12 @@ static int __update_widget(struct iio_device *dev, const char *attr,

static int connect_widgets(struct osc_plugin *plugin)
{
return iio_device_debug_attr_read_all(plugin->priv->dev, __connect_widget, plugin);
return dev_debug_attr_read_all(plugin->priv->dev, __connect_widget, plugin);
}

static int update_widgets(struct osc_plugin *plugin)
{
return iio_device_debug_attr_read_all(plugin->priv->dev, __update_widget, plugin->priv->builder);
return dev_debug_attr_read_all(plugin->priv->dev, __update_widget, plugin->priv->builder);
}

static void change_page_cb(GtkNotebook *notebook, GtkNotebookTab *page,
Expand Down

0 comments on commit 7335721

Please sign in to comment.