#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_SET | SR_CONF_LIST,
SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,
return std_scan_complete(di, devices);
}
-static void clear_dev_context(void *priv)
+static void clear_helper(struct dev_context *devc)
{
- struct dev_context *devc;
-
- devc = priv;
-
- sr_dbg("Device context cleared.");
-
libusb_free_transfer(devc->xfer_in);
libusb_free_transfer(devc->xfer_out);
- g_free(devc);
}
static int dev_clear(const struct sr_dev_driver *di)
{
- return std_dev_clear(di, &clear_dev_context);
+ return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
}
static int dev_open(struct sr_dev_inst *sdi)
if (sr_usb_open(drvc->sr_ctx->libusb_ctx, usb) != SR_OK)
return SR_ERR;
- /*
- * Determine if a kernel driver is active on this interface and, if so,
- * detach it.
- */
if (libusb_kernel_driver_active(usb->devhdl, USB_INTERFACE) == 1) {
ret = libusb_detach_kernel_driver(usb->devhdl, USB_INTERFACE);
if (ret < 0) {
usb = sdi->conn;
if (!usb->devhdl)
- return SR_OK;
+ return SR_ERR_BUG;
libusb_release_interface(usb->devhdl, USB_INTERFACE);
libusb_close(usb->devhdl);
usb->devhdl = NULL;
- sdi->status = SR_ST_INACTIVE;
return SR_OK;
}
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
- GVariant *gvar, *grange[2];
- GVariantBuilder gvb;
- int ret;
+ GVariant *grange[2];
- (void)sdi;
- (void)cg;
-
- ret = SR_OK;
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"),
- sl2_samplerates, ARRAY_SIZE(sl2_samplerates),
- sizeof(uint64_t));
- g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
- *data = g_variant_builder_end(&gvb);
+ *data = std_gvar_samplerates(sl2_samplerates, ARRAY_SIZE(sl2_samplerates));
break;
case SR_CONF_TRIGGER_MATCH:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
return SR_ERR_NA;
}
- return ret;
+ return SR_OK;
}
static int dev_acquisition_start(const struct sr_dev_inst *sdi)
usb_source_add(sdi->session, drvc->sr_ctx, 100,
ikalogic_scanalogic2_receive_data, (void *)sdi);
- sr_dbg("Acquisition started successfully.");
-
std_session_send_df_header(sdi);
devc->next_state = STATE_SAMPLE;