blob: ac5084d3be2f76fa28544042748bd192b96297a9 [file] [log] [blame]
Marc Schink16e76ba2013-06-07 20:34:40 +02001/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2013 Marc Schink <sigrok-dev@marcschink.de>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "protocol.h"
21
Marc Schinke52e7122013-06-10 10:10:13 +020022static const int hwcaps[] = {
23 SR_CONF_LOGIC_ANALYZER,
24 SR_CONF_SAMPLERATE,
25 SR_CONF_LIMIT_SAMPLES,
26 SR_CONF_TRIGGER_TYPE,
Uwe Hermannc824eb62013-06-11 18:55:47 +020027 SR_CONF_CAPTURE_RATIO,
Marc Schinke52e7122013-06-10 10:10:13 +020028};
29
Uwe Hermann79914b32013-06-11 18:55:47 +020030SR_PRIV const uint64_t sl2_samplerates[NUM_SAMPLERATES] = {
Marc Schinke52e7122013-06-10 10:10:13 +020031 SR_KHZ(1.25),
32 SR_KHZ(10),
33 SR_KHZ(50),
34 SR_KHZ(100),
35 SR_KHZ(250),
36 SR_KHZ(500),
37 SR_MHZ(1),
38 SR_MHZ(2.5),
39 SR_MHZ(5),
40 SR_MHZ(10),
Uwe Hermannc824eb62013-06-11 18:55:47 +020041 SR_MHZ(20),
Marc Schinke52e7122013-06-10 10:10:13 +020042};
43
44static const char *probe_names[NUM_PROBES + 1] = {
45 "0", "1", "2", "3",
Uwe Hermannc824eb62013-06-11 18:55:47 +020046 NULL,
Marc Schinke52e7122013-06-10 10:10:13 +020047};
48
Marc Schink16e76ba2013-06-07 20:34:40 +020049SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info;
50static struct sr_dev_driver *di = &ikalogic_scanalogic2_driver_info;
51
Marc Schink16e76ba2013-06-07 20:34:40 +020052static int init(struct sr_context *sr_ctx)
53{
Marc Schinke52e7122013-06-10 10:10:13 +020054 return std_init(sr_ctx, di, LOG_PREFIX);
Marc Schink16e76ba2013-06-07 20:34:40 +020055}
56
57static GSList *scan(GSList *options)
58{
Marc Schinke52e7122013-06-10 10:10:13 +020059 GSList *usb_devices, *devices, *l;
Marc Schink16e76ba2013-06-07 20:34:40 +020060 struct drv_context *drvc;
Marc Schinke52e7122013-06-10 10:10:13 +020061 struct sr_dev_inst *sdi;
62 struct sr_probe *probe;
63 struct dev_context *devc;
64 struct sr_usb_dev_inst *usb;
65 struct device_info dev_info;
66 int ret, device_index, i;
67 char *fw_ver_str;
Marc Schink16e76ba2013-06-07 20:34:40 +020068
69 (void)options;
70
71 devices = NULL;
72 drvc = di->priv;
73 drvc->instances = NULL;
Marc Schinke52e7122013-06-10 10:10:13 +020074 device_index = 0;
Marc Schink16e76ba2013-06-07 20:34:40 +020075
Marc Schinke52e7122013-06-10 10:10:13 +020076 usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_VID_PID);
77
78 if (usb_devices == NULL)
79 return NULL;
80
Uwe Hermannc824eb62013-06-11 18:55:47 +020081 for (l = usb_devices; l; l = l->next) {
Marc Schinke52e7122013-06-10 10:10:13 +020082 usb = l->data;
83
Uwe Hermann79914b32013-06-11 18:55:47 +020084 if ((ret = sl2_get_device_info(*usb, &dev_info)) < 0) {
85 sr_warn("Failed to get device information: %d.", ret);
Marc Schinke52e7122013-06-10 10:10:13 +020086 sr_usb_dev_inst_free(usb);
87 continue;
88 }
89
Uwe Hermannc824eb62013-06-11 18:55:47 +020090 if (!(devc = g_try_malloc(sizeof(struct dev_context)))) {
Marc Schinke52e7122013-06-10 10:10:13 +020091 sr_err("Device instance malloc failed.");
92 sr_usb_dev_inst_free(usb);
93 continue;
94 }
95
96 if (!(devc->xfer_in = libusb_alloc_transfer(0))) {
97 sr_err("Transfer malloc failed.");
98 sr_usb_dev_inst_free(usb);
99 g_free(devc);
100 continue;
101 }
102
103 if (!(devc->xfer_out = libusb_alloc_transfer(0))) {
104 sr_err("Transfer malloc failed.");
105 sr_usb_dev_inst_free(usb);
106 libusb_free_transfer(devc->xfer_in);
107 g_free(devc);
108 continue;
109 }
110
111 fw_ver_str = g_strdup_printf("%u.%u", dev_info.fw_ver_major,
112 dev_info.fw_ver_minor);
Marc Schinke52e7122013-06-10 10:10:13 +0200113 if (!fw_ver_str) {
114 sr_err("Firmware string malloc failed.");
115 sr_usb_dev_inst_free(usb);
116 libusb_free_transfer(devc->xfer_in);
117 libusb_free_transfer(devc->xfer_out);
118 g_free(devc);
119 continue;
120 }
121
122 sdi = sr_dev_inst_new(device_index, SR_ST_INACTIVE, VENDOR_NAME,
123 MODEL_NAME, fw_ver_str);
Marc Schinke52e7122013-06-10 10:10:13 +0200124 g_free(fw_ver_str);
Marc Schinke52e7122013-06-10 10:10:13 +0200125 if (!sdi) {
126 sr_err("sr_dev_inst_new failed.");
127 sr_usb_dev_inst_free(usb);
128 libusb_free_transfer(devc->xfer_in);
129 libusb_free_transfer(devc->xfer_out);
130 g_free(devc);
131 continue;
132 }
133
134 sdi->priv = devc;
135 sdi->driver = di;
136 sdi->inst_type = SR_INST_USB;
137 sdi->conn = usb;
138
139 for (i = 0; probe_names[i]; i++) {
140 probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE,
141 probe_names[i]);
142 sdi->probes = g_slist_append(sdi->probes, probe);
143 devc->probes[i] = probe;
144 }
145
146 devc->state = STATE_IDLE;
147 devc->next_state = STATE_IDLE;
148
149 /* Set default samplerate. */
Uwe Hermann79914b32013-06-11 18:55:47 +0200150 sl2_set_samplerate(sdi, DEFAULT_SAMPLERATE);
Marc Schinke52e7122013-06-10 10:10:13 +0200151
152 /* Set default capture ratio. */
153 devc->capture_ratio = 0;
154
155 /* Set default after trigger delay. */
156 devc->after_trigger_delay = 0;
157
158 memset(devc->xfer_buf_in, 0, LIBUSB_CONTROL_SETUP_SIZE +
159 PACKET_LENGTH);
160 memset(devc->xfer_buf_out, 0, LIBUSB_CONTROL_SETUP_SIZE +
161 PACKET_LENGTH);
162
163 libusb_fill_control_setup(devc->xfer_buf_in,
Marc Schinkfb8d5932013-07-02 21:52:23 +0200164 USB_REQUEST_TYPE_IN, USB_HID_GET_REPORT,
Marc Schinke52e7122013-06-10 10:10:13 +0200165 USB_HID_REPORT_TYPE_FEATURE, USB_INTERFACE,
166 PACKET_LENGTH);
167 libusb_fill_control_setup(devc->xfer_buf_out,
168 USB_REQUEST_TYPE_OUT, USB_HID_SET_REPORT,
169 USB_HID_REPORT_TYPE_FEATURE, USB_INTERFACE,
170 PACKET_LENGTH);
171
172 devc->xfer_data_in = devc->xfer_buf_in +
173 LIBUSB_CONTROL_SETUP_SIZE;
174 devc->xfer_data_out = devc->xfer_buf_out +
175 LIBUSB_CONTROL_SETUP_SIZE;
176
177 drvc->instances = g_slist_append(drvc->instances, sdi);
178 devices = g_slist_append(devices, sdi);
179
180 device_index++;
181 }
182
183 g_slist_free(usb_devices);
Marc Schink16e76ba2013-06-07 20:34:40 +0200184
185 return devices;
186}
187
188static GSList *dev_list(void)
189{
Uwe Hermannc824eb62013-06-11 18:55:47 +0200190 return ((struct drv_context *)(di->priv))->instances;
Marc Schink16e76ba2013-06-07 20:34:40 +0200191}
192
Marc Schinke52e7122013-06-10 10:10:13 +0200193static void clear_dev_context(void *priv)
194{
Uwe Hermannc824eb62013-06-11 18:55:47 +0200195 struct dev_context *devc;
Marc Schinke52e7122013-06-10 10:10:13 +0200196
Uwe Hermannc824eb62013-06-11 18:55:47 +0200197 devc = priv;
198
199 sr_dbg("Device context cleared.");
Marc Schinke52e7122013-06-10 10:10:13 +0200200
201 libusb_free_transfer(devc->xfer_in);
202 libusb_free_transfer(devc->xfer_out);
203 g_free(devc);
204}
205
Marc Schink16e76ba2013-06-07 20:34:40 +0200206static int dev_clear(void)
207{
Marc Schinke52e7122013-06-10 10:10:13 +0200208 return std_dev_clear(di, &clear_dev_context);
Marc Schink16e76ba2013-06-07 20:34:40 +0200209}
210
211static int dev_open(struct sr_dev_inst *sdi)
212{
Marc Schinke52e7122013-06-10 10:10:13 +0200213 struct drv_context *drvc;
214 struct dev_context *devc;
215 struct sr_usb_dev_inst *usb;
216 uint8_t buffer[PACKET_LENGTH];
217 int ret;
Marc Schink16e76ba2013-06-07 20:34:40 +0200218
Marc Schinke52e7122013-06-10 10:10:13 +0200219 if (!(drvc = di->priv)) {
220 sr_err("Driver was not initialized.");
221 return SR_ERR;
222 }
223
224 usb = sdi->conn;
225 devc = sdi->priv;
226
227 if (sr_usb_open(drvc->sr_ctx->libusb_ctx, usb) != SR_OK)
228 return SR_ERR;
229
230 /*
231 * Determine if a kernel driver is active on this interface and, if so,
232 * detach it.
233 */
234 if (libusb_kernel_driver_active(usb->devhdl, USB_INTERFACE) == 1) {
235 ret = libusb_detach_kernel_driver(usb->devhdl, USB_INTERFACE);
Marc Schinke52e7122013-06-10 10:10:13 +0200236 if (ret < 0) {
Uwe Hermann9526f2d2013-06-11 18:55:47 +0200237 sr_err("Failed to detach kernel driver: %s.",
Marc Schinke52e7122013-06-10 10:10:13 +0200238 libusb_error_name(ret));
239 return SR_ERR;
240 }
241 }
242
Uwe Hermann79914b32013-06-11 18:55:47 +0200243 if ((ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE)) < 0) {
Marc Schinke52e7122013-06-10 10:10:13 +0200244 sr_err("Failed to claim interface: %s.",
245 libusb_error_name(ret));
246 return SR_ERR;
247 }
248
249 libusb_fill_control_transfer(devc->xfer_in, usb->devhdl,
Uwe Hermann79914b32013-06-11 18:55:47 +0200250 devc->xfer_buf_in, sl2_receive_transfer_in,
Marc Schinke52e7122013-06-10 10:10:13 +0200251 sdi, USB_TIMEOUT);
252
253 libusb_fill_control_transfer(devc->xfer_out, usb->devhdl,
Uwe Hermann79914b32013-06-11 18:55:47 +0200254 devc->xfer_buf_out, sl2_receive_transfer_out,
Marc Schinke52e7122013-06-10 10:10:13 +0200255 sdi, USB_TIMEOUT);
256
257 memset(buffer, 0, sizeof(buffer));
258
259 buffer[0] = CMD_RESET;
Uwe Hermann79914b32013-06-11 18:55:47 +0200260 if ((ret = sl2_transfer_out(usb->devhdl, buffer)) != PACKET_LENGTH) {
Marc Schinke52e7122013-06-10 10:10:13 +0200261 sr_err("Device reset failed: %s.", libusb_error_name(ret));
262 return SR_ERR;
263 }
264
265 /*
266 * Set the device to idle state. If the device is not in idle state it
Uwe Hermannc824eb62013-06-11 18:55:47 +0200267 * possibly will reset itself after a few seconds without being used
268 * and thereby close the connection.
Marc Schinke52e7122013-06-10 10:10:13 +0200269 */
270 buffer[0] = CMD_IDLE;
Uwe Hermann79914b32013-06-11 18:55:47 +0200271 if ((ret = sl2_transfer_out(usb->devhdl, buffer)) != PACKET_LENGTH) {
Marc Schinke52e7122013-06-10 10:10:13 +0200272 sr_err("Failed to set device in idle state: %s.",
273 libusb_error_name(ret));
274 return SR_ERR;
275 }
Marc Schink16e76ba2013-06-07 20:34:40 +0200276
277 sdi->status = SR_ST_ACTIVE;
278
279 return SR_OK;
280}
281
282static int dev_close(struct sr_dev_inst *sdi)
283{
Marc Schinke52e7122013-06-10 10:10:13 +0200284 struct sr_usb_dev_inst *usb;
Marc Schink16e76ba2013-06-07 20:34:40 +0200285
Marc Schinke52e7122013-06-10 10:10:13 +0200286 if (!di->priv) {
287 sr_err("Driver was not initialized.");
288 return SR_ERR;
289 }
Marc Schink16e76ba2013-06-07 20:34:40 +0200290
Marc Schinke52e7122013-06-10 10:10:13 +0200291 usb = sdi->conn;
292
293 if (!usb->devhdl)
294 return SR_OK;
295
296 libusb_release_interface(usb->devhdl, USB_INTERFACE);
297 libusb_close(usb->devhdl);
298
299 usb->devhdl = NULL;
Marc Schink16e76ba2013-06-07 20:34:40 +0200300 sdi->status = SR_ST_INACTIVE;
301
302 return SR_OK;
303}
304
305static int cleanup(void)
306{
Uwe Hermannc824eb62013-06-11 18:55:47 +0200307 return dev_clear();
Marc Schink16e76ba2013-06-07 20:34:40 +0200308}
309
Bert Vermeulend3c74a62013-10-31 23:58:33 +0100310static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
Uwe Hermann53b46802014-03-20 21:58:01 +0100311 const struct sr_channel_group *cg)
Marc Schink16e76ba2013-06-07 20:34:40 +0200312{
Marc Schinke52e7122013-06-10 10:10:13 +0200313 struct dev_context *devc;
Marc Schink16e76ba2013-06-07 20:34:40 +0200314 int ret;
315
Uwe Hermann53b46802014-03-20 21:58:01 +0100316 (void)cg;
Bert Vermeulend3c74a62013-10-31 23:58:33 +0100317
Marc Schink16e76ba2013-06-07 20:34:40 +0200318 ret = SR_OK;
Marc Schinke52e7122013-06-10 10:10:13 +0200319 devc = sdi->priv;
320
Marc Schink16e76ba2013-06-07 20:34:40 +0200321 switch (key) {
Marc Schinke52e7122013-06-10 10:10:13 +0200322 case SR_CONF_SAMPLERATE:
323 *data = g_variant_new_uint64(devc->samplerate);
324 break;
325 case SR_CONF_CAPTURE_RATIO:
326 *data = g_variant_new_uint64(devc->capture_ratio);
327 break;
Marc Schink16e76ba2013-06-07 20:34:40 +0200328 default:
329 return SR_ERR_NA;
330 }
331
332 return ret;
333}
334
Bert Vermeulend3c74a62013-10-31 23:58:33 +0100335static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
Uwe Hermann53b46802014-03-20 21:58:01 +0100336 const struct sr_channel_group *cg)
Marc Schink16e76ba2013-06-07 20:34:40 +0200337{
Marc Schinke52e7122013-06-10 10:10:13 +0200338 uint64_t samplerate, limit_samples, capture_ratio;
Marc Schink16e76ba2013-06-07 20:34:40 +0200339 int ret;
340
Uwe Hermann53b46802014-03-20 21:58:01 +0100341 (void)cg;
Bert Vermeulend3c74a62013-10-31 23:58:33 +0100342
Marc Schink16e76ba2013-06-07 20:34:40 +0200343 if (sdi->status != SR_ST_ACTIVE)
344 return SR_ERR_DEV_CLOSED;
345
346 ret = SR_OK;
Marc Schinke52e7122013-06-10 10:10:13 +0200347
Marc Schink16e76ba2013-06-07 20:34:40 +0200348 switch (key) {
Marc Schinke52e7122013-06-10 10:10:13 +0200349 case SR_CONF_LIMIT_SAMPLES:
350 limit_samples = g_variant_get_uint64(data);
Uwe Hermann79914b32013-06-11 18:55:47 +0200351 ret = sl2_set_limit_samples(sdi, limit_samples);
Marc Schinke52e7122013-06-10 10:10:13 +0200352 break;
353 case SR_CONF_SAMPLERATE:
354 samplerate = g_variant_get_uint64(data);
Uwe Hermann79914b32013-06-11 18:55:47 +0200355 ret = sl2_set_samplerate(sdi, samplerate);
Marc Schinke52e7122013-06-10 10:10:13 +0200356 break;
357 case SR_CONF_CAPTURE_RATIO:
358 capture_ratio = g_variant_get_uint64(data);
Uwe Hermann79914b32013-06-11 18:55:47 +0200359 ret = sl2_set_capture_ratio(sdi, capture_ratio);
Marc Schinke52e7122013-06-10 10:10:13 +0200360 break;
Marc Schink16e76ba2013-06-07 20:34:40 +0200361 default:
362 return SR_ERR_NA;
363 }
364
365 return ret;
366}
367
Bert Vermeulend3c74a62013-10-31 23:58:33 +0100368static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
Uwe Hermann53b46802014-03-20 21:58:01 +0100369 const struct sr_channel_group *cg)
Marc Schink16e76ba2013-06-07 20:34:40 +0200370{
Bert Vermeulenf0de2dd2014-01-19 17:18:59 +0100371 GVariant *gvar, *grange[2];
Marc Schinke52e7122013-06-10 10:10:13 +0200372 GVariantBuilder gvb;
373 int ret;
374
Marc Schink16e76ba2013-06-07 20:34:40 +0200375 (void)sdi;
Uwe Hermann53b46802014-03-20 21:58:01 +0100376 (void)cg;
Marc Schinke52e7122013-06-10 10:10:13 +0200377
378 ret = SR_OK;
379
380 switch (key) {
381 case SR_CONF_DEVICE_OPTIONS:
382 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, hwcaps,
383 ARRAY_SIZE(hwcaps), sizeof(int32_t));
384 break;
385 case SR_CONF_SAMPLERATE:
386 g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}"));
387 gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"),
Uwe Hermann79914b32013-06-11 18:55:47 +0200388 sl2_samplerates, ARRAY_SIZE(sl2_samplerates),
Marc Schinke52e7122013-06-10 10:10:13 +0200389 sizeof(uint64_t));
390 g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar);
391 *data = g_variant_builder_end(&gvb);
392 break;
393 case SR_CONF_TRIGGER_TYPE:
394 *data = g_variant_new_string(TRIGGER_TYPES);
395 break;
Bert Vermeulenf0de2dd2014-01-19 17:18:59 +0100396 case SR_CONF_LIMIT_SAMPLES:
397 grange[0] = g_variant_new_uint64(0);
398 grange[1] = g_variant_new_uint64(MAX_SAMPLES);
399 *data = g_variant_new_tuple(grange, 2);
400 break;
Marc Schinke52e7122013-06-10 10:10:13 +0200401 default:
402 return SR_ERR_NA;
403 }
404
405 return ret;
406}
407
408static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
409{
Marc Schinke52e7122013-06-10 10:10:13 +0200410 struct drv_context *drvc;
411 struct dev_context *devc;
412 uint16_t trigger_bytes, tmp;
413 unsigned int i, j;
414 int ret;
Marc Schink16e76ba2013-06-07 20:34:40 +0200415
416 if (sdi->status != SR_ST_ACTIVE)
417 return SR_ERR_DEV_CLOSED;
418
Marc Schinke52e7122013-06-10 10:10:13 +0200419 devc = sdi->priv;
420 drvc = di->priv;
421
422 devc->cb_data = cb_data;
423 devc->wait_data_ready_locked = TRUE;
424 devc->stopping_in_progress = FALSE;
425 devc->transfer_error = FALSE;
426 devc->samples_processed = 0;
427 devc->channel = 0;
428 devc->sample_packet = 0;
429
430 /*
431 * The trigger must be configured first because the calculation of the
432 * pre and post trigger samples depends on a configured trigger.
433 */
Uwe Hermann79914b32013-06-11 18:55:47 +0200434 sl2_configure_trigger(sdi);
435 sl2_calculate_trigger_samples(sdi);
Marc Schinke52e7122013-06-10 10:10:13 +0200436
437 trigger_bytes = devc->pre_trigger_bytes + devc->post_trigger_bytes;
438
439 /* Calculate the number of expected sample packets. */
440 devc->num_sample_packets = trigger_bytes / PACKET_NUM_SAMPLE_BYTES;
441
442 /* Round up the number of expected sample packets. */
443 if (trigger_bytes % PACKET_NUM_SAMPLE_BYTES != 0)
444 devc->num_sample_packets++;
445
446 devc->num_enabled_probes = 0;
447
448 /*
449 * Count the number of enabled probes and number them for a sequential
450 * access.
451 */
452 for (i = 0, j = 0; i < NUM_PROBES; i++) {
453 if (devc->probes[i]->enabled) {
454 devc->num_enabled_probes++;
455 devc->probe_map[j] = i;
456 j++;
457 }
458 }
459
460 sr_dbg("Number of enabled probes: %i.", devc->num_enabled_probes);
461
462 /* Set up the transfer buffer for the acquisition. */
463 devc->xfer_data_out[0] = CMD_SAMPLE;
464 devc->xfer_data_out[1] = 0x00;
465
466 tmp = GUINT16_TO_LE(devc->pre_trigger_bytes);
467 memcpy(devc->xfer_data_out + 2, &tmp, sizeof(tmp));
468
469 tmp = GUINT16_TO_LE(devc->post_trigger_bytes);
470 memcpy(devc->xfer_data_out + 4, &tmp, sizeof(tmp));
471
472 devc->xfer_data_out[6] = devc->samplerate_id;
473 devc->xfer_data_out[7] = devc->trigger_type;
474 devc->xfer_data_out[8] = devc->trigger_channel;
475 devc->xfer_data_out[9] = 0x00;
476
477 tmp = GUINT16_TO_LE(devc->after_trigger_delay);
478 memcpy(devc->xfer_data_out + 10, &tmp, sizeof(tmp));
479
Marc Schinke52e7122013-06-10 10:10:13 +0200480 if ((ret = libusb_submit_transfer(devc->xfer_out)) != 0) {
Uwe Hermannc824eb62013-06-11 18:55:47 +0200481 sr_err("Submit transfer failed: %s.", libusb_error_name(ret));
Marc Schinke52e7122013-06-10 10:10:13 +0200482 return SR_ERR;
483 }
484
Martin Ling6c60fac2013-12-21 23:03:24 +0000485 usb_source_add(drvc->sr_ctx, 100, ikalogic_scanalogic2_receive_data, (void *)sdi);
Marc Schinke52e7122013-06-10 10:10:13 +0200486
487 sr_dbg("Acquisition started successfully.");
488
489 /* Send header packet to the session bus. */
490 std_session_send_df_header(cb_data, LOG_PREFIX);
491
492 devc->next_state = STATE_SAMPLE;
Marc Schink16e76ba2013-06-07 20:34:40 +0200493
494 return SR_OK;
495}
496
497static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
498{
499 (void)cb_data;
500
501 if (sdi->status != SR_ST_ACTIVE)
502 return SR_ERR_DEV_CLOSED;
503
Marc Schinke52e7122013-06-10 10:10:13 +0200504 sr_dbg("Stopping acquisition.");
505
506 sdi->status = SR_ST_STOPPING;
Marc Schink16e76ba2013-06-07 20:34:40 +0200507
508 return SR_OK;
509}
510
511SR_PRIV struct sr_dev_driver ikalogic_scanalogic2_driver_info = {
512 .name = "ikalogic-scanalogic2",
Marc Schinke52e7122013-06-10 10:10:13 +0200513 .longname = "IKALOGIC Scanalogic-2",
Marc Schink16e76ba2013-06-07 20:34:40 +0200514 .api_version = 1,
515 .init = init,
516 .cleanup = cleanup,
517 .scan = scan,
518 .dev_list = dev_list,
519 .dev_clear = dev_clear,
520 .config_get = config_get,
521 .config_set = config_set,
522 .config_list = config_list,
523 .dev_open = dev_open,
524 .dev_close = dev_close,
525 .dev_acquisition_start = dev_acquisition_start,
526 .dev_acquisition_stop = dev_acquisition_stop,
527 .priv = NULL,
528};