#include <config.h>
#include "protocol.h"
-static const uint32_t devopts[] = {
+static const uint32_t drvopts[] = {
SR_CONF_LOGIC_ANALYZER,
+};
+
+static const uint32_t devopts[] = {
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
devices = NULL;
- /* Allocate memory for our private device context. */
devc = g_malloc0(sizeof(struct dev_context));
- /* Device-specific settings */
devc->max_samplebytes = devc->max_samplerate = devc->protocol_version = 0;
- /* Acquisition settings */
devc->limit_samples = devc->capture_ratio = 0;
devc->trigger_at = -1;
devc->channel_mask = 0xffffffff;
devc->flag_reg = 0;
- /* Allocate memory for the incoming ftdi data. */
devc->ftdi_buf = g_malloc0(FTDI_BUF_SIZE);
- /* Allocate memory for the FTDI context (ftdic) and initialize it. */
if (!(devc->ftdic = ftdi_new())) {
sr_err("Failed to initialize libftdi.");
goto err_free_ftdi_buf;;
}
- /* Try to open the FTDI device */
- if (p_ols_open(devc) != SR_OK) {
+ if (p_ols_open(devc) != SR_OK)
goto err_free_ftdic;
- }
/* The discovery procedure is like this: first send the Reset
* command (0x00) 5 times, since the device could be anywhere
goto err_close_ftdic;
}
- /* Close device. We'll reopen it again when we need it. */
p_ols_close(devc);
/* Parse the metadata. */
err_close_ftdic:
p_ols_close(devc);
err_free_ftdic:
- ftdi_free(devc->ftdic); /* NOT free() or g_free()! */
+ ftdi_free(devc->ftdic);
err_free_ftdi_buf:
g_free(devc->ftdi_buf);
g_free(devc);
return NULL;
}
-static void clear_helper(void *priv)
+static void clear_helper(struct dev_context *devc)
{
- struct dev_context *devc;
-
- devc = priv;
-
ftdi_free(devc->ftdic);
g_free(devc->ftdi_buf);
}
static int dev_clear(const struct sr_dev_driver *di)
{
- return std_dev_clear(di, clear_helper);
+ return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
}
static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
(void)cg;
- if (sdi->status != SR_ST_ACTIVE)
- return SR_ERR_DEV_CLOSED;
-
devc = sdi->priv;
switch (key) {
GVariantBuilder gvb;
int num_pols_changrp, i;
- (void)cg;
-
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
- *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
- devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
- break;
+ return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
case SR_CONF_SAMPLERATE:
g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), samplerates,
devc = sdi->priv;
- if (p_ols_open(devc) != SR_OK) {
- return SR_ERR;
- } else {
- sdi->status = SR_ST_ACTIVE;
- return SR_OK;
- }
+ return p_ols_open(devc);
}
static int dev_close(struct sr_dev_inst *sdi)
{
- int ret;
struct dev_context *devc;
- ret = SR_OK;
devc = sdi->priv;
- if (sdi->status == SR_ST_ACTIVE) {
- sr_dbg("Status ACTIVE, closing device.");
- ret = p_ols_close(devc);
- } else {
- sr_spew("Status not ACTIVE, nothing to do.");
- }
-
- sdi->status = SR_ST_INACTIVE;
-
- return ret;
+ return p_ols_close(devc);
}
static int set_trigger(const struct sr_dev_inst *sdi, int stage)