static struct sr_dev_driver yokogawa_dlm_driver_info;
static const char *MANUFACTURER_ID = "YOKOGAWA";
-static const char *MANUFACTURER_NAME = "Yokogawa";
-static const uint32_t dlm_scanopts[] = {
+static const uint32_t scanopts[] = {
SR_CONF_CONN,
};
-static const uint32_t dlm_drvopts[] = {
+static const uint32_t drvopts[] = {
SR_CONF_LOGIC_ANALYZER,
SR_CONF_OSCILLOSCOPE,
};
-static const uint32_t dlm_devopts[] = {
+static const uint32_t devopts[] = {
SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,
SR_CONF_SAMPLERATE | SR_CONF_GET,
SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
};
-static const uint32_t dlm_analog_devopts[] = {
+static const uint32_t devopts_cg_analog[] = {
SR_CONF_NUM_VDIV | SR_CONF_GET,
SR_CONF_VDIV | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_COUPLING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
};
-static const uint32_t dlm_digital_devopts[] = {
+static const uint32_t devopts_cg_digital[] = {
};
enum {
goto fail;
sdi = g_malloc0(sizeof(struct sr_dev_inst));
- sdi->vendor = g_strdup(MANUFACTURER_NAME);
+ sdi->vendor = g_strdup("Yokogawa");
sdi->model = g_strdup(model_name);
sdi->version = g_strdup(hw_info->firmware_version);
return CG_INVALID;
}
-static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
- const struct sr_channel_group *cg)
+static int config_get(uint32_t key, GVariant **data,
+ const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
int ret, cg_type;
unsigned int i;
return ret;
}
-static GVariant *build_tuples(const uint64_t (*array)[][2], unsigned int n)
-{
- unsigned int i;
- GVariant *rational[2];
- GVariantBuilder gvb;
-
- g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
-
- for (i = 0; i < n; i++) {
- rational[0] = g_variant_new_uint64((*array)[i][0]);
- rational[1] = g_variant_new_uint64((*array)[i][1]);
-
- /* FIXME: Valgrind reports a memory leak here. */
- g_variant_builder_add_value(&gvb, g_variant_new_tuple(rational, 2));
- }
-
- return g_variant_builder_end(&gvb);
-}
-
-static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
- const struct sr_channel_group *cg)
+static int config_set(uint32_t key, GVariant *data,
+ const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
int ret, cg_type;
unsigned int i, j;
}
static int config_channel_set(const struct sr_dev_inst *sdi,
- struct sr_channel *ch, unsigned int changes)
+ struct sr_channel *ch, unsigned int changes)
{
/* Currently we only handle SR_CHANNEL_SET_ENABLED. */
if (changes != SR_CHANNEL_SET_ENABLED)
return dlm_channel_state_set(sdi, ch->index, ch->enabled);
}
-static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
- const struct sr_channel_group *cg)
+static int config_list(uint32_t key, GVariant **data,
+ const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
int cg_type = CG_NONE;
struct dev_context *devc;
switch (key) {
case SR_CONF_SCAN_OPTIONS:
case SR_CONF_DEVICE_OPTIONS:
- return STD_CONFIG_LIST(key, data, sdi, cg, dlm_scanopts, dlm_drvopts, dlm_devopts);
+ return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
case SR_CONF_TIMEBASE:
- *data = build_tuples(&dlm_timebases, ARRAY_SIZE(dlm_timebases));
+ *data = std_gvar_tuple_array(ARRAY_AND_SIZE(dlm_timebases));
return SR_OK;
case SR_CONF_TRIGGER_SOURCE:
if (!model)
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- if (cg_type == CG_ANALOG) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- dlm_analog_devopts, ARRAY_SIZE(dlm_analog_devopts), sizeof(uint32_t));
- } else if (cg_type == CG_DIGITAL) {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- dlm_digital_devopts, ARRAY_SIZE(dlm_digital_devopts), sizeof(uint32_t));
- } else {
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- NULL, 0, sizeof(uint32_t));
- }
+ if (cg_type == CG_ANALOG)
+ *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog));
+ else if (cg_type == CG_DIGITAL)
+ *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_digital));
+ else
+ *data = std_gvar_array_u32(NULL, 0);
break;
case SR_CONF_COUPLING:
if (cg_type == CG_NONE)
case SR_CONF_VDIV:
if (cg_type == CG_NONE)
return SR_ERR_CHANNEL_GROUP;
- *data = build_tuples(&dlm_vdivs, ARRAY_SIZE(dlm_vdivs));
+ *data = std_gvar_tuple_array(ARRAY_AND_SIZE(dlm_vdivs));
break;
default:
return SR_ERR_NA;