]> sigrok.org Git - libsigrok.git/blame - hardware/zeroplus-logic-cube/zeroplus.c
Update/enforce/document our build requirements.
[libsigrok.git] / hardware / zeroplus-logic-cube / zeroplus.c
CommitLineData
a1bb33af
UH
1/*
2 * This file is part of the sigrok project.
3 *
4 * Copyright (C) 2010 Bert Vermeulen <bert@biot.com>
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
22b02383 20#include "config.h"
a1bb33af
UH
21#include <stdio.h>
22#include <stdlib.h>
23#include <sys/time.h>
24#include <inttypes.h>
25#include <glib.h>
26#include <libusb.h>
b7f09cf8
UH
27#include "sigrok.h"
28#include "sigrok-internal.h"
a1bb33af
UH
29#include "analyzer.h"
30
fed16f06
UH
31#define USB_VENDOR 0x0c12
32#define USB_VENDOR_NAME "Zeroplus"
a1bb33af
UH
33#define USB_MODEL_NAME "Logic Cube"
34#define USB_MODEL_VERSION ""
35
36#define USB_INTERFACE 0
37#define USB_CONFIGURATION 1
38#define NUM_TRIGGER_STAGES 4
39#define TRIGGER_TYPES "01"
40
fed16f06 41#define PACKET_SIZE 2048 /* ?? */
a1bb33af
UH
42
43typedef struct {
44 unsigned short pid;
45 char model_name[64];
46 unsigned int channels;
fed16f06 47 unsigned int sample_depth; /* In Ksamples/channel */
a1bb33af
UH
48 unsigned int max_sampling_freq;
49} model_t;
50
fed16f06
UH
51/*
52 * Note -- 16032, 16064 and 16128 *usually* -- but not always -- have the
53 * same 128K sample depth.
54 */
29cbfeaf 55static model_t zeroplus_models[] = {
a1bb33af
UH
56 {0x7009, "LAP-C(16064)", 16, 64, 100},
57 {0x700A, "LAP-C(16128)", 16, 128, 200},
58 {0x700B, "LAP-C(32128)", 32, 128, 200},
59 {0x700C, "LAP-C(321000)", 32, 1024, 200},
60 {0x700D, "LAP-C(322000)", 32, 2048, 200},
61 {0x700E, "LAP-C(16032)", 16, 32, 100},
62 {0x7016, "LAP-C(162000)", 16, 2048, 200},
63};
64
65static int capabilities[] = {
5a2326a7
UH
66 SR_HWCAP_LOGIC_ANALYZER,
67 SR_HWCAP_SAMPLERATE,
68 SR_HWCAP_PROBECONFIG,
69 SR_HWCAP_CAPTURE_RATIO,
a1bb33af 70
fed16f06 71 /* These are really implemented in the driver, not the hardware. */
5a2326a7 72 SR_HWCAP_LIMIT_SAMPLES,
fed16f06 73 0,
a1bb33af
UH
74};
75
c37d2b1b 76static const char *probe_names[] = {
464d12c7
KS
77 "0",
78 "1",
79 "2",
80 "3",
81 "4",
82 "5",
83 "6",
84 "7",
85 "8",
86 "9",
87 "10",
88 "11",
89 "12",
90 "13",
91 "14",
92 "15",
93 "16",
94 "17",
95 "18",
96 "19",
97 "20",
98 "21",
99 "22",
100 "23",
101 "24",
102 "25",
103 "26",
104 "27",
105 "28",
106 "29",
107 "30",
108 "31",
109 NULL,
110};
111
a00ba012 112/* List of struct sr_device_instance, maintained by opendev()/closedev(). */
a1bb33af
UH
113static GSList *device_instances = NULL;
114
115static libusb_context *usb_context = NULL;
116
fed16f06
UH
117/*
118 * The hardware supports more samplerates than these, but these are the
119 * options hardcoded into the vendor's Windows GUI.
120 */
a1bb33af 121
fed16f06
UH
122/*
123 * TODO: We shouldn't support 150MHz and 200MHz on devices that don't go up
124 * that high.
125 */
a1bb33af 126static uint64_t supported_samplerates[] = {
c9140419
UH
127 SR_HZ(100),
128 SR_HZ(500),
59df0c77
UH
129 SR_KHZ(1),
130 SR_KHZ(5),
131 SR_KHZ(25),
132 SR_KHZ(50),
133 SR_KHZ(100),
134 SR_KHZ(200),
135 SR_KHZ(400),
136 SR_KHZ(800),
137 SR_MHZ(1),
138 SR_MHZ(10),
139 SR_MHZ(25),
140 SR_MHZ(50),
141 SR_MHZ(80),
142 SR_MHZ(100),
143 SR_MHZ(150),
144 SR_MHZ(200),
fed16f06 145 0,
a1bb33af
UH
146};
147
60679b18 148static struct sr_samplerates samplerates = {
c9140419
UH
149 SR_HZ(0),
150 SR_HZ(0),
151 SR_HZ(0),
fed16f06 152 supported_samplerates,
a1bb33af
UH
153};
154
fed16f06 155/* TODO: All of these should go in a device-specific struct. */
a1bb33af 156static uint64_t cur_samplerate = 0;
9c939c51 157static uint64_t period_ps = 0;
a1bb33af 158static uint64_t limit_samples = 0;
29cbfeaf
UH
159static int num_channels = 32; /* TODO: This isn't initialized before it's needed :( */
160static uint64_t memory_size = 0;
86c5e279 161static uint8_t probe_mask = 0;
fed16f06
UH
162static uint8_t trigger_mask[NUM_TRIGGER_STAGES] = { 0 };
163static uint8_t trigger_value[NUM_TRIGGER_STAGES] = { 0 };
a1bb33af 164
fed16f06 165// static uint8_t trigger_buffer[NUM_TRIGGER_STAGES] = { 0 };
a1bb33af
UH
166
167static int hw_set_configuration(int device_index, int capability, void *value);
168
169static unsigned int get_memory_size(int type)
170{
fed16f06
UH
171 if (type == MEMORY_SIZE_8K)
172 return 8 * 1024;
173 else if (type == MEMORY_SIZE_64K)
174 return 64 * 1024;
175 else if (type == MEMORY_SIZE_128K)
176 return 128 * 1024;
177 else if (type == MEMORY_SIZE_512K)
178 return 512 * 1024;
179 else
180 return 0;
a1bb33af
UH
181}
182
a00ba012 183static int opendev4(struct sr_device_instance **sdi, libusb_device *dev,
408e7199
UH
184 struct libusb_device_descriptor *des)
185{
9a498834
UH
186 unsigned int i;
187 int err;
408e7199
UH
188
189 if ((err = libusb_get_device_descriptor(dev, des))) {
b08024a8 190 sr_warn("failed to get device descriptor: %d", err);
408e7199
UH
191 return -1;
192 }
193
9a498834 194 if (des->idVendor != USB_VENDOR)
408e7199
UH
195 return 0;
196
197 if (libusb_get_bus_number(dev) == (*sdi)->usb->bus
198 && libusb_get_device_address(dev) == (*sdi)->usb->address) {
199
9a498834
UH
200 for (i = 0; i < ARRAY_SIZE(zeroplus_models); i++) {
201 if (!(des->idProduct == zeroplus_models[i].pid))
408e7199
UH
202 continue;
203
b08024a8
UH
204 sr_info("Found PID=%04X (%s)", des->idProduct,
205 zeroplus_models[i].model_name);
9a498834
UH
206 num_channels = zeroplus_models[i].channels;
207 memory_size = zeroplus_models[i].sample_depth * 1024;
408e7199
UH
208 break;
209 }
210
211 if (num_channels == 0) {
b08024a8 212 sr_warn("Unknown ZeroPlus device %04X", des->idProduct);
408e7199
UH
213 return -2;
214 }
215
216 /* Found it. */
217 if (!(err = libusb_open(dev, &((*sdi)->usb->devhdl)))) {
5a2326a7 218 (*sdi)->status = SR_ST_ACTIVE;
b08024a8
UH
219 sr_info("opened device %d on %d.%d interface %d",
220 (*sdi)->index, (*sdi)->usb->bus,
221 (*sdi)->usb->address, USB_INTERFACE);
408e7199 222 } else {
b08024a8 223 sr_warn("failed to open device: %d", err);
408e7199
UH
224 *sdi = NULL;
225 }
226 }
227
228 return 0;
229}
230
29cbfeaf 231static struct sr_device_instance *zp_open_device(int device_index)
a1bb33af 232{
a00ba012 233 struct sr_device_instance *sdi;
a1bb33af
UH
234 libusb_device **devlist;
235 struct libusb_device_descriptor des;
afc8e4de 236 int err, i;
a1bb33af 237
d32d961d 238 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
a1bb33af
UH
239 return NULL;
240
241 libusb_get_device_list(usb_context, &devlist);
5a2326a7 242 if (sdi->status == SR_ST_INACTIVE) {
fed16f06 243 /* Find the device by vendor, product, bus and address. */
a1bb33af 244 libusb_get_device_list(usb_context, &devlist);
fed16f06 245 for (i = 0; devlist[i]; i++) {
408e7199 246 /* TODO: Error handling. */
9a5c6dcf 247 err = opendev4(&sdi, devlist[i], &des);
a1bb33af 248 }
fed16f06 249 } else {
5a2326a7 250 /* Status must be SR_ST_ACTIVE, i.e. already in use... */
a1bb33af
UH
251 sdi = NULL;
252 }
253 libusb_free_device_list(devlist, 1);
254
5a2326a7 255 if (sdi && sdi->status != SR_ST_ACTIVE)
a1bb33af
UH
256 sdi = NULL;
257
258 return sdi;
259}
260
a00ba012 261static void close_device(struct sr_device_instance *sdi)
a1bb33af 262{
408e7199
UH
263 if (!sdi->usb->devhdl)
264 return;
265
b08024a8
UH
266 sr_info("closing device %d on %d.%d interface %d", sdi->index,
267 sdi->usb->bus, sdi->usb->address, USB_INTERFACE);
408e7199
UH
268 libusb_release_interface(sdi->usb->devhdl, USB_INTERFACE);
269 libusb_close(sdi->usb->devhdl);
270 sdi->usb->devhdl = NULL;
5a2326a7 271 sdi->status = SR_ST_INACTIVE;
a1bb33af
UH
272}
273
a1bb33af
UH
274static int configure_probes(GSList *probes)
275{
1afe8989 276 struct sr_probe *probe;
a1bb33af
UH
277 GSList *l;
278 int probe_bit, stage, i;
279 char *tc;
280
281 probe_mask = 0;
fed16f06 282 for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
a1bb33af
UH
283 trigger_mask[i] = 0;
284 trigger_value[i] = 0;
285 }
286
287 stage = -1;
fed16f06 288 for (l = probes; l; l = l->next) {
1afe8989 289 probe = (struct sr_probe *)l->data;
fed16f06 290 if (probe->enabled == FALSE)
a1bb33af
UH
291 continue;
292 probe_bit = 1 << (probe->index - 1);
293 probe_mask |= probe_bit;
fed16f06
UH
294
295 if (probe->trigger) {
a1bb33af 296 stage = 0;
fed16f06 297 for (tc = probe->trigger; *tc; tc++) {
a1bb33af 298 trigger_mask[stage] |= probe_bit;
fed16f06 299 if (*tc == '1')
a1bb33af
UH
300 trigger_value[stage] |= probe_bit;
301 stage++;
fed16f06 302 if (stage > NUM_TRIGGER_STAGES)
e46b8fb1 303 return SR_ERR;
a1bb33af
UH
304 }
305 }
306 }
307
e46b8fb1 308 return SR_OK;
a1bb33af
UH
309}
310
a1bb33af
UH
311/*
312 * API callbacks
313 */
314
54ac5277 315static int hw_init(const char *deviceinfo)
a1bb33af 316{
a00ba012 317 struct sr_device_instance *sdi;
a1bb33af
UH
318 struct libusb_device_descriptor des;
319 libusb_device **devlist;
320 int err, devcnt, i;
321
17e1afcb 322 /* Avoid compiler warnings. */
cb93f8a9 323 (void)deviceinfo;
afc8e4de 324
fed16f06 325 if (libusb_init(&usb_context) != 0) {
b08024a8 326 sr_warn("Failed to initialize USB.");
a1bb33af
UH
327 return 0;
328 }
329
fed16f06 330 /* Find all ZeroPlus analyzers and add them to device list. */
a1bb33af
UH
331 devcnt = 0;
332 libusb_get_device_list(usb_context, &devlist);
fed16f06
UH
333
334 for (i = 0; devlist[i]; i++) {
a1bb33af 335 err = libusb_get_device_descriptor(devlist[i], &des);
fed16f06 336 if (err != 0) {
b08024a8 337 sr_warn("failed to get device descriptor: %d", err);
a1bb33af
UH
338 continue;
339 }
340
fed16f06
UH
341 if (des.idVendor == USB_VENDOR) {
342 /*
343 * Definitely a Zeroplus.
344 * TODO: Any way to detect specific model/version in
345 * the zeroplus range?
346 */
a00ba012 347 sdi = sr_device_instance_new(devcnt,
5a2326a7 348 SR_ST_INACTIVE, USB_VENDOR_NAME,
fed16f06
UH
349 USB_MODEL_NAME, USB_MODEL_VERSION);
350 if (!sdi)
a1bb33af 351 return 0;
fed16f06
UH
352 device_instances =
353 g_slist_append(device_instances, sdi);
6c290072 354 sdi->usb = sr_usb_device_instance_new(
fed16f06
UH
355 libusb_get_bus_number(devlist[i]),
356 libusb_get_device_address(devlist[i]), NULL);
a1bb33af
UH
357 devcnt++;
358 }
359 }
360 libusb_free_device_list(devlist, 1);
361
362 return devcnt;
363}
364
a1bb33af
UH
365static int hw_opendev(int device_index)
366{
a00ba012 367 struct sr_device_instance *sdi;
a1bb33af
UH
368 int err;
369
fed16f06 370 if (!(sdi = zp_open_device(device_index))) {
b08024a8 371 sr_warn("unable to open device");
e46b8fb1 372 return SR_ERR;
a1bb33af
UH
373 }
374
375 err = libusb_claim_interface(sdi->usb->devhdl, USB_INTERFACE);
fed16f06 376 if (err != 0) {
b08024a8 377 sr_warn("Unable to claim interface: %d", err);
e46b8fb1 378 return SR_ERR;
a1bb33af
UH
379 }
380 analyzer_reset(sdi->usb->devhdl);
381 analyzer_initialize(sdi->usb->devhdl);
a1bb33af
UH
382
383 analyzer_set_memory_size(MEMORY_SIZE_512K);
fed16f06 384 // analyzer_set_freq(g_freq, g_freq_scale);
a1bb33af 385 analyzer_set_trigger_count(1);
408e7199
UH
386 // analyzer_set_ramsize_trigger_address((((100 - g_pre_trigger)
387 // * get_memory_size(g_memory_size)) / 100) >> 2);
fed16f06
UH
388 analyzer_set_ramsize_trigger_address(
389 (100 * get_memory_size(MEMORY_SIZE_512K) / 100) >> 2);
a1bb33af 390
fed16f06
UH
391#if 0
392 if (g_double_mode == 1)
a1bb33af
UH
393 analyzer_set_compression(COMPRESSION_DOUBLE);
394 else if (g_compression == 1)
395 analyzer_set_compression(COMPRESSION_ENABLE);
fed16f06
UH
396 else
397#endif
398 analyzer_set_compression(COMPRESSION_NONE);
a1bb33af 399
fed16f06 400 if (cur_samplerate == 0) {
408e7199 401 /* Samplerate hasn't been set. Default to the slowest one. */
5a2326a7 402 if (hw_set_configuration(device_index, SR_HWCAP_SAMPLERATE,
e46b8fb1
UH
403 &samplerates.low) == SR_ERR)
404 return SR_ERR;
a1bb33af
UH
405 }
406
e46b8fb1 407 return SR_OK;
a1bb33af
UH
408}
409
697785d1 410static int hw_closedev(int device_index)
a1bb33af 411{
a00ba012 412 struct sr_device_instance *sdi;
a1bb33af 413
697785d1
UH
414 if (!(sdi = sr_get_device_instance(device_instances, device_index))) {
415 sr_err("lap-c: %s: sdi was NULL", __func__);
416 return SR_ERR; /* TODO: SR_ERR_ARG? */
417 }
418
419 /* TODO */
420 close_device(sdi);
421
422 return SR_OK;
a1bb33af
UH
423}
424
a1bb33af
UH
425static void hw_cleanup(void)
426{
427 GSList *l;
428
408e7199 429 /* Properly close all devices... */
fed16f06 430 for (l = device_instances; l; l = l->next)
a00ba012 431 close_device((struct sr_device_instance *)l->data);
a1bb33af 432
408e7199 433 /* ...and free all their memory. */
fed16f06 434 for (l = device_instances; l; l = l->next)
a1bb33af
UH
435 g_free(l->data);
436 g_slist_free(device_instances);
437 device_instances = NULL;
438
fed16f06 439 if (usb_context)
a1bb33af
UH
440 libusb_exit(usb_context);
441 usb_context = NULL;
a1bb33af
UH
442}
443
a1bb33af
UH
444static void *hw_get_device_info(int device_index, int device_info_id)
445{
a00ba012 446 struct sr_device_instance *sdi;
408e7199 447 void *info = NULL;
a1bb33af 448
d32d961d 449 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
a1bb33af
UH
450 return NULL;
451
fed16f06 452 switch (device_info_id) {
5a2326a7 453 case SR_DI_INSTANCE:
a1bb33af
UH
454 info = sdi;
455 break;
5a2326a7 456 case SR_DI_NUM_PROBES:
a1bb33af
UH
457 info = GINT_TO_POINTER(num_channels);
458 break;
464d12c7
KS
459 case SR_DI_PROBE_NAMES:
460 info = probe_names;
461 break;
5a2326a7 462 case SR_DI_SAMPLERATES:
a1bb33af
UH
463 info = &samplerates;
464 break;
5a2326a7 465 case SR_DI_TRIGGER_TYPES:
a1bb33af
UH
466 info = TRIGGER_TYPES;
467 break;
5a2326a7 468 case SR_DI_CUR_SAMPLERATE:
a1bb33af
UH
469 info = &cur_samplerate;
470 break;
471 }
472
473 return info;
474}
475
a1bb33af
UH
476static int hw_get_status(int device_index)
477{
a00ba012 478 struct sr_device_instance *sdi;
a1bb33af 479
d32d961d 480 sdi = sr_get_device_instance(device_instances, device_index);
fed16f06 481 if (sdi)
a1bb33af
UH
482 return sdi->status;
483 else
5a2326a7 484 return SR_ST_NOT_FOUND;
a1bb33af
UH
485}
486
a1bb33af
UH
487static int *hw_get_capabilities(void)
488{
a1bb33af
UH
489 return capabilities;
490}
491
fed16f06 492/* TODO: This will set the same samplerate for all devices. */
afc8e4de 493static int set_configuration_samplerate(uint64_t samplerate)
a1bb33af 494{
6bb5c5fa 495 sr_info("%s(%" PRIu64 ")", __func__, samplerate);
59df0c77
UH
496 if (samplerate > SR_MHZ(1))
497 analyzer_set_freq(samplerate / SR_MHZ(1), FREQ_SCALE_MHZ);
498 else if (samplerate > SR_KHZ(1))
499 analyzer_set_freq(samplerate / SR_KHZ(1), FREQ_SCALE_KHZ);
a1bb33af 500 else
fed16f06 501 analyzer_set_freq(samplerate, FREQ_SCALE_HZ);
a1bb33af
UH
502
503 cur_samplerate = samplerate;
9c939c51 504 period_ps = 1000000000000 / samplerate;
a1bb33af 505
e46b8fb1 506 return SR_OK;
a1bb33af
UH
507}
508
509static int hw_set_configuration(int device_index, int capability, void *value)
510{
a00ba012 511 struct sr_device_instance *sdi;
a1bb33af
UH
512 uint64_t *tmp_u64;
513
d32d961d 514 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
e46b8fb1 515 return SR_ERR;
a1bb33af
UH
516
517 switch (capability) {
5a2326a7 518 case SR_HWCAP_SAMPLERATE:
fed16f06
UH
519 tmp_u64 = value;
520 return set_configuration_samplerate(*tmp_u64);
5a2326a7 521 case SR_HWCAP_PROBECONFIG:
fed16f06 522 return configure_probes((GSList *) value);
5a2326a7 523 case SR_HWCAP_LIMIT_SAMPLES:
2458ea65
BV
524 tmp_u64 = value;
525 limit_samples = *tmp_u64;
e46b8fb1 526 return SR_OK;
fed16f06 527 default:
e46b8fb1 528 return SR_ERR;
a1bb33af
UH
529 }
530}
531
9c939c51 532static int hw_start_acquisition(int device_index, gpointer session_data)
a1bb33af 533{
a00ba012 534 struct sr_device_instance *sdi;
b9c735a2 535 struct sr_datafeed_packet packet;
9c939c51 536 struct sr_datafeed_logic logic;
b9c735a2 537 struct sr_datafeed_header header;
9c939c51 538 uint64_t samples_read;
a1bb33af 539 int res;
afc8e4de 540 unsigned int packet_num;
a1bb33af
UH
541 unsigned char *buf;
542
d32d961d 543 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
e46b8fb1 544 return SR_ERR;
a1bb33af 545
a143e4e5
BV
546 /* push configured settings to device */
547 analyzer_configure(sdi->usb->devhdl);
548
a1bb33af 549 analyzer_start(sdi->usb->devhdl);
b08024a8 550 sr_info("Waiting for data");
a1bb33af
UH
551 analyzer_wait_data(sdi->usb->devhdl);
552
9c939c51
BV
553 sr_info("Stop address = 0x%x", analyzer_get_stop_address(sdi->usb->devhdl));
554 sr_info("Now address = 0x%x", analyzer_get_now_address(sdi->usb->devhdl));
555 sr_info("Trigger address = 0x%x", analyzer_get_trigger_address(sdi->usb->devhdl));
a1bb33af 556
5a2326a7 557 packet.type = SR_DF_HEADER;
9c939c51 558 packet.payload = &header;
a1bb33af
UH
559 header.feed_version = 1;
560 gettimeofday(&header.starttime, NULL);
4c100f32 561 header.samplerate = cur_samplerate;
c2616fb9
DR
562 header.num_logic_probes = num_channels;
563 header.num_analog_probes = 0;
9c939c51 564 sr_session_bus(session_data, &packet);
a1bb33af 565
b53738ba 566 if (!(buf = g_try_malloc(PACKET_SIZE))) {
340cfac0 567 sr_err("lap-c: %s: buf malloc failed", __func__);
b53738ba
UH
568 return SR_ERR_MALLOC;
569 }
570
9c939c51 571 samples_read = 0;
a1bb33af 572 analyzer_read_start(sdi->usb->devhdl);
fed16f06
UH
573 /* Send the incoming transfer to the session bus. */
574 for (packet_num = 0; packet_num < (memory_size * 4 / PACKET_SIZE);
575 packet_num++) {
a1bb33af 576 res = analyzer_read_data(sdi->usb->devhdl, buf, PACKET_SIZE);
b08024a8
UH
577 sr_info("Tried to read %llx bytes, actually read %x bytes",
578 PACKET_SIZE, res);
a1bb33af 579
5a2326a7 580 packet.type = SR_DF_LOGIC;
9c939c51
BV
581 packet.timeoffset = samples_read * period_ps;
582 packet.duration = res / 4 * period_ps;
583 packet.payload = &logic;
584 logic.length = PACKET_SIZE;
585 logic.unitsize = 4;
586 logic.data = buf;
587 sr_session_bus(session_data, &packet);
588 samples_read += res / 4;
a1bb33af
UH
589 }
590 analyzer_read_stop(sdi->usb->devhdl);
591 g_free(buf);
592
5a2326a7 593 packet.type = SR_DF_END;
9c939c51 594 sr_session_bus(session_data, &packet);
a1bb33af 595
e46b8fb1 596 return SR_OK;
a1bb33af
UH
597}
598
fed16f06 599/* This stops acquisition on ALL devices, ignoring device_index. */
a1bb33af
UH
600static void hw_stop_acquisition(int device_index, gpointer session_device_id)
601{
b9c735a2 602 struct sr_datafeed_packet packet;
a00ba012 603 struct sr_device_instance *sdi;
a1bb33af 604
5a2326a7 605 packet.type = SR_DF_END;
8a2efef2 606 sr_session_bus(session_device_id, &packet);
a1bb33af 607
d32d961d 608 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
fed16f06 609 return; /* TODO: Cry? */
a1bb33af
UH
610
611 analyzer_reset(sdi->usb->devhdl);
fed16f06 612 /* TODO: Need to cancel and free any queued up transfers. */
a1bb33af
UH
613}
614
5c2d46d1 615struct sr_device_plugin zeroplus_logic_cube_plugin_info = {
e519ba86
UH
616 .name = "zeroplus-logic-cube",
617 .longname = "Zeroplus Logic Cube LAP-C series",
618 .api_version = 1,
619 .init = hw_init,
620 .cleanup = hw_cleanup,
86f5e3d8
UH
621 .opendev = hw_opendev,
622 .closedev = hw_closedev,
e519ba86
UH
623 .get_device_info = hw_get_device_info,
624 .get_status = hw_get_status,
625 .get_capabilities = hw_get_capabilities,
626 .set_configuration = hw_set_configuration,
627 .start_acquisition = hw_start_acquisition,
628 .stop_acquisition = hw_stop_acquisition,
a1bb33af 629};