"asix-sigma-phasor.fw", /* Frequency counter */
};
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data);
static int sigma_read(void *buf, size_t size, struct context *ctx)
{
if (running_msec < ctx->limit_msec && numchunks < 32767)
return TRUE; /* While capturing... */
else
- hw_dev_acquisition_stop(sdi->index, sdi);
+ hw_dev_acquisition_stop(sdi, sdi);
} else if (ctx->state.state == SIGMA_DOWNLOAD) {
if (ctx->state.chunks_downloaded >= numchunks) {
return SR_OK;
}
-static int hw_dev_acquisition_start(int dev_index, void *cb_data)
+static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
- struct sr_dev_inst *sdi;
struct context *ctx;
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
struct triggerinout triggerinout_conf;
struct triggerlut lut;
- if (!(sdi = sr_dev_inst_get(adi->instances, dev_index)))
- return SR_ERR;
-
ctx = sdi->priv;
/* If the samplerate has not been set, default to 200 kHz. */
sr_session_send(ctx->session_dev_id, packet);
/* Add capture source. */
- sr_source_add(0, G_IO_IN, 10, receive_data, sdi);
+ sr_source_add(0, G_IO_IN, 10, receive_data, (void *)sdi);
g_free(header);
g_free(packet);
return SR_OK;
}
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
- struct sr_dev_inst *sdi;
struct context *ctx;
uint8_t modestatus;
/* Avoid compiler warnings. */
(void)cb_data;
- if (!(sdi = sr_dev_inst_get(adi->instances, dev_index))) {
- sr_err("sigma: %s: sdi was NULL", __func__);
- return SR_ERR_BUG;
- }
-
if (!(ctx = sdi->priv)) {
sr_err("sigma: %s: sdi->priv was NULL", __func__);
return SR_ERR_BUG;
};
/* Function prototypes. */
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data);
static void clear_instances(void)
{
/* Get one block of data. */
if ((ret = la8_read_block(ctx)) < 0) {
sr_err("la8: %s: la8_read_block error: %d", __func__, ret);
- hw_dev_acquisition_stop(sdi->index, sdi);
+ hw_dev_acquisition_stop(sdi, sdi);
return FALSE;
}
for (i = 0; i < NUM_BLOCKS; i++)
send_block_to_session_bus(ctx, i);
- hw_dev_acquisition_stop(sdi->index, sdi);
+ hw_dev_acquisition_stop(sdi, sdi);
// return FALSE; /* FIXME? */
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, void *cb_data)
+static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
- struct sr_dev_inst *sdi;
struct context *ctx;
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
uint8_t buf[4];
int bytes_written;
- if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) {
- sr_err("la8: %s: sdi was NULL", __func__);
- return SR_ERR_BUG;
- }
-
if (!(ctx = sdi->priv)) {
sr_err("la8: %s: sdi->priv was NULL", __func__);
return SR_ERR_BUG;
ctx->trigger_found = 0;
/* Hook up a dummy handler to receive data from the LA8. */
- sr_source_add(-1, G_IO_IN, 0, receive_data, sdi);
+ sr_source_add(-1, G_IO_IN, 0, receive_data, (void *)sdi);
return SR_OK;
}
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
- struct sr_dev_inst *sdi;
struct context *ctx;
struct sr_datafeed_packet packet;
sr_dbg("la8: Stopping acquisition.");
- if (!(sdi = sr_dev_inst_get(cdi->instances, dev_index))) {
- sr_err("la8: %s: sdi was NULL", __func__);
- return SR_ERR_BUG;
- }
-
if (!(ctx = sdi->priv)) {
sr_err("la8: %s: sdi->priv was NULL", __func__);
return SR_ERR_BUG;
uint8_t sample_generator;
uint8_t thread_running;
uint64_t samples_counter;
- int dev_index;
void *session_dev_id;
GTimer *timer;
};
static GThread *my_thread;
static int thread_running;
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data);
static int hw_init(void)
{
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, void *cb_data)
+static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
struct sr_datafeed_packet *packet;
struct sr_datafeed_header *header;
struct sr_datafeed_meta_logic meta;
struct context *ctx;
+ (void)sdi;
+
/* TODO: 'ctx' is never g_free()'d? */
if (!(ctx = g_try_malloc(sizeof(struct context)))) {
sr_err("demo: %s: ctx malloc failed", __func__);
ctx->sample_generator = default_pattern;
ctx->session_dev_id = cb_data;
- ctx->dev_index = dev_index;
ctx->samples_counter = 0;
if (pipe(ctx->pipe_fds)) {
return SR_OK;
}
-/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
/* Avoid compiler warnings. */
- (void)dev_index;
+ (void)sdi;
(void)cb_data;
/* Stop generate thread. */
static int hw_dev_close(struct sr_dev_inst *sdi);
static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
const void *value);
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data);
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data);
/**
* Check the USB configuration to determine if this is an fx2lafw device.
return timeout + timeout / 4; /* Leave a headroom of 25% percent */
}
-static int hw_dev_acquisition_start(int dev_index, void *cb_data)
+static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
- struct sr_dev_inst *sdi;
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_logic meta;
int ret;
unsigned char *buf;
- if (!(sdi = sr_dev_inst_get(fdi->instances, dev_index)))
- return SR_ERR;
ctx = sdi->priv;
-
if (ctx->submitted_transfers != 0)
return SR_ERR;
}
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
- struct sr_dev_inst *sdi;
/* Avoid compiler warnings. */
(void)cb_data;
- if (!(sdi = sr_dev_inst_get(fdi->instances, dev_index)))
- return SR_ERR;
-
abort_acquisition(sdi->priv);
return SR_OK;
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, void *cb_data)
+static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
- struct sr_dev_inst *sdi;
struct context *ctx;
- if (!(sdi = sr_dev_inst_get(gdi->instances, dev_index))) {
- sr_err("genericdmm: sdi was NULL.");
- return SR_ERR_BUG;
- }
-
if (!(ctx = sdi->priv)) {
sr_err("genericdmm: sdi->priv was NULL.");
return SR_ERR_BUG;
return SR_OK;
}
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
struct sr_datafeed_packet packet;
/* Avoid compiler warnings. */
- (void)dev_index;
+ (void)sdi;
sr_dbg("genericdmm: Stopping acquisition.");
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, void *cb_data)
+static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
const struct libusb_pollfd **lupfd;
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
- struct sr_dev_inst *sdi;
struct context *ctx;
int i;
- if (!(sdi = sr_dev_inst_get(hdi->instances, dev_index)))
- return SR_ERR;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR;
/* TODO: doesn't really cancel pending transfers so they might come in after
* SR_DF_END is sent.
*/
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
struct sr_datafeed_packet packet;
- struct sr_dev_inst *sdi;
struct context *ctx;
- if (!(sdi = sr_dev_inst_get(hdi->instances, dev_index)))
- return SR_ERR;
-
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR;
}
}
-static int hw_dev_acquisition_start(int dev_index, void *cb_data)
+static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
- struct sr_dev_inst *sdi;
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
struct sr_datafeed_header header;
unsigned char *buf;
struct context *ctx;
- if (!(sdi = sr_dev_inst_get(zdi->instances, dev_index))) {
- sr_err("zp: %s: sdi was NULL", __func__);
- return SR_ERR;
- }
-
if (!(ctx = sdi->priv)) {
sr_err("zp: %s: sdi->priv was NULL", __func__);
return SR_ERR_ARG;
}
/* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
struct sr_datafeed_packet packet;
- struct sr_dev_inst *sdi;
struct context *ctx;
packet.type = SR_DF_END;
sr_session_send(cb_data, &packet);
- if (!(sdi = sr_dev_inst_get(zdi->instances, dev_index))) {
- sr_err("zp: %s: sdi was NULL", __func__);
- return SR_ERR_BUG;
- }
-
if (!(ctx = sdi->priv)) {
sr_err("zp: %s: sdi->priv was NULL", __func__);
return SR_ERR_BUG;
int (*dev_status_get) (int dev_index);
int (*dev_config_set) (const struct sr_dev_inst *sdi, int hwcap,
const void *value);
- int (*dev_acquisition_start) (int dev_index, void *session_dev_id);
- int (*dev_acquisition_stop) (int dev_index, void *session_dev_id);
+ int (*dev_acquisition_start) (const struct sr_dev_inst *sdi,
+ void *cb_data);
+ int (*dev_acquisition_stop) (const struct sr_dev_inst *sdi,
+ void *cb_data);
/* Dynamic */
GSList *instances;