]> sigrok.org Git - libsigrok.git/blob - hardware/zeroplus-logic-cube/zeroplus.c
sr: Fix/document probe names.
[libsigrok.git] / hardware / zeroplus-logic-cube / zeroplus.c
1 /*
2  * This file is part of the sigrok project.
3  *
4  * Copyright (C) 2010-2012 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
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <sys/time.h>
24 #include <inttypes.h>
25 #include <glib.h>
26 #include <libusb.h>
27 #include "config.h"
28 #include "sigrok.h"
29 #include "sigrok-internal.h"
30 #include "analyzer.h"
31
32 #define USB_VENDOR                      0x0c12
33 #define USB_VENDOR_NAME                 "Zeroplus"
34 #define USB_MODEL_NAME                  "Logic Cube"
35 #define USB_MODEL_VERSION               ""
36
37 #define USB_INTERFACE                   0
38 #define USB_CONFIGURATION               1
39 #define NUM_TRIGGER_STAGES              4
40 #define TRIGGER_TYPES                   "01"
41
42 #define PACKET_SIZE                     2048    /* ?? */
43
44 typedef struct {
45         unsigned short pid;
46         char model_name[64];
47         unsigned int channels;
48         unsigned int sample_depth;      /* In Ksamples/channel */
49         unsigned int max_sampling_freq;
50 } model_t;
51
52 /*
53  * Note -- 16032, 16064 and 16128 *usually* -- but not always -- have the
54  * same 128K sample depth.
55  */
56 static model_t zeroplus_models[] = {
57         {0x7009, "LAP-C(16064)",  16, 64,   100},
58         {0x700A, "LAP-C(16128)",  16, 128,  200},
59         {0x700B, "LAP-C(32128)",  32, 128,  200},
60         {0x700C, "LAP-C(321000)", 32, 1024, 200},
61         {0x700D, "LAP-C(322000)", 32, 2048, 200},
62         {0x700E, "LAP-C(16032)",  16, 32,   100},
63         {0x7016, "LAP-C(162000)", 16, 2048, 200},
64 };
65
66 static int hwcaps[] = {
67         SR_HWCAP_LOGIC_ANALYZER,
68         SR_HWCAP_SAMPLERATE,
69         SR_HWCAP_PROBECONFIG,
70         SR_HWCAP_CAPTURE_RATIO,
71
72         /* These are really implemented in the driver, not the hardware. */
73         SR_HWCAP_LIMIT_SAMPLES,
74         0,
75 };
76
77 /*
78  * ZEROPLUS LAP-C (16032) numbers the 16 probes A0-A7 and B0-B7.
79  * We currently ignore other untested/unsupported devices here.
80  */
81 static const char *probe_names[] = {
82         "A0",
83         "A1",
84         "A2",
85         "A3",
86         "A4",
87         "A5",
88         "A6",
89         "A7",
90         "B0",
91         "B1",
92         "B2",
93         "B3",
94         "B4",
95         "B5",
96         "B6",
97         "B7",
98         NULL,
99 };
100
101 /* List of struct sr_dev_inst, maintained by dev_open()/dev_close(). */
102 static GSList *dev_insts = NULL;
103
104 static libusb_context *usb_context = NULL;
105
106 /*
107  * The hardware supports more samplerates than these, but these are the
108  * options hardcoded into the vendor's Windows GUI.
109  */
110
111 /*
112  * TODO: We shouldn't support 150MHz and 200MHz on devices that don't go up
113  * that high.
114  */
115 static uint64_t supported_samplerates[] = {
116         SR_HZ(100),
117         SR_HZ(500),
118         SR_KHZ(1),
119         SR_KHZ(5),
120         SR_KHZ(25),
121         SR_KHZ(50),
122         SR_KHZ(100),
123         SR_KHZ(200),
124         SR_KHZ(400),
125         SR_KHZ(800),
126         SR_MHZ(1),
127         SR_MHZ(10),
128         SR_MHZ(25),
129         SR_MHZ(50),
130         SR_MHZ(80),
131         SR_MHZ(100),
132         SR_MHZ(150),
133         SR_MHZ(200),
134         0,
135 };
136
137 static struct sr_samplerates samplerates = {
138         SR_HZ(0),
139         SR_HZ(0),
140         SR_HZ(0),
141         supported_samplerates,
142 };
143
144 /* Private, per-device-instance driver context. */
145 struct context {
146         uint64_t cur_samplerate;
147         uint64_t limit_samples;
148         int num_channels; /* TODO: This isn't initialized before it's needed :( */
149         uint64_t memory_size;
150         uint8_t probe_mask;
151         uint8_t trigger_mask[NUM_TRIGGER_STAGES];
152         uint8_t trigger_value[NUM_TRIGGER_STAGES];
153         // uint8_t trigger_buffer[NUM_TRIGGER_STAGES];
154
155         struct sr_usb_dev_inst *usb;
156 };
157
158 static int hw_dev_config_set(int dev_index, int hwcap, void *value);
159
160 static unsigned int get_memory_size(int type)
161 {
162         if (type == MEMORY_SIZE_8K)
163                 return 8 * 1024;
164         else if (type == MEMORY_SIZE_64K)
165                 return 64 * 1024;
166         else if (type == MEMORY_SIZE_128K)
167                 return 128 * 1024;
168         else if (type == MEMORY_SIZE_512K)
169                 return 512 * 1024;
170         else
171                 return 0;
172 }
173
174 static int opendev4(struct sr_dev_inst **sdi, libusb_device *dev,
175                     struct libusb_device_descriptor *des)
176 {
177         struct context *ctx;
178         unsigned int i;
179         int err;
180
181         /* Note: sdi is non-NULL, the caller already checked this. */
182
183         if (!(ctx = (*sdi)->priv)) {
184                 sr_err("zp: %s: (*sdi)->priv was NULL", __func__);
185                 return -1;
186         }
187
188         if ((err = libusb_get_device_descriptor(dev, des))) {
189                 sr_err("zp: failed to get device descriptor: %d", err);
190                 return -1;
191         }
192
193         if (des->idVendor != USB_VENDOR)
194                 return 0;
195
196         if (libusb_get_bus_number(dev) == ctx->usb->bus
197             && libusb_get_device_address(dev) == ctx->usb->address) {
198
199                 for (i = 0; i < ARRAY_SIZE(zeroplus_models); i++) {
200                         if (!(des->idProduct == zeroplus_models[i].pid))
201                                 continue;
202
203                         sr_info("zp: Found ZeroPlus device 0x%04x (%s)",
204                                 des->idProduct, zeroplus_models[i].model_name);
205                         ctx->num_channels = zeroplus_models[i].channels;
206                         ctx->memory_size = zeroplus_models[i].sample_depth * 1024;
207                         break;
208                 }
209
210                 if (ctx->num_channels == 0) {
211                         sr_err("zp: Unknown ZeroPlus device 0x%04x",
212                                des->idProduct);
213                         return -2;
214                 }
215
216                 /* Found it. */
217                 if (!(err = libusb_open(dev, &(ctx->usb->devhdl)))) {
218                         (*sdi)->status = SR_ST_ACTIVE;
219                         sr_info("zp: opened device %d on %d.%d interface %d",
220                                 (*sdi)->index, ctx->usb->bus,
221                                 ctx->usb->address, USB_INTERFACE);
222                 } else {
223                         sr_err("zp: failed to open device: %d", err);
224                         *sdi = NULL;
225                 }
226         }
227
228         return 0;
229 }
230
231 static struct sr_dev_inst *zp_open_dev(int dev_index)
232 {
233         struct sr_dev_inst *sdi;
234         libusb_device **devlist;
235         struct libusb_device_descriptor des;
236         int err, i;
237
238         if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
239                 return NULL;
240
241         libusb_get_device_list(usb_context, &devlist);
242         if (sdi->status == SR_ST_INACTIVE) {
243                 /* Find the device by vendor, product, bus and address. */
244                 libusb_get_device_list(usb_context, &devlist);
245                 for (i = 0; devlist[i]; i++) {
246                         /* TODO: Error handling. */
247                         err = opendev4(&sdi, devlist[i], &des);
248                 }
249         } else {
250                 /* Status must be SR_ST_ACTIVE, i.e. already in use... */
251                 sdi = NULL;
252         }
253         libusb_free_device_list(devlist, 1);
254
255         if (sdi && sdi->status != SR_ST_ACTIVE)
256                 sdi = NULL;
257
258         return sdi;
259 }
260
261 static void close_dev(struct sr_dev_inst *sdi)
262 {
263         struct context *ctx;
264
265         if (!(ctx = sdi->priv)) {
266                 sr_err("zp: %s: sdi->priv was NULL", __func__);
267                 return; /* FIXME */
268         }
269
270         if (!ctx->usb->devhdl)
271                 return;
272
273         sr_info("zp: closing device %d on %d.%d interface %d", sdi->index,
274                 ctx->usb->bus, ctx->usb->address, USB_INTERFACE);
275         libusb_release_interface(ctx->usb->devhdl, USB_INTERFACE);
276         libusb_reset_device(ctx->usb->devhdl);
277         libusb_close(ctx->usb->devhdl);
278         ctx->usb->devhdl = NULL;
279         /* TODO: Call libusb_exit() here or only in hw_cleanup()? */
280         sdi->status = SR_ST_INACTIVE;
281 }
282
283 static int configure_probes(struct sr_dev_inst *sdi, GSList *probes)
284 {
285         struct context *ctx;
286         struct sr_probe *probe;
287         GSList *l;
288         int probe_bit, stage, i;
289         char *tc;
290
291         /* Note: sdi and sdi->priv are non-NULL, the caller checked this. */
292         ctx = sdi->priv;
293
294         ctx->probe_mask = 0;
295         for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
296                 ctx->trigger_mask[i] = 0;
297                 ctx->trigger_value[i] = 0;
298         }
299
300         stage = -1;
301         for (l = probes; l; l = l->next) {
302                 probe = (struct sr_probe *)l->data;
303                 if (probe->enabled == FALSE)
304                         continue;
305                 probe_bit = 1 << (probe->index - 1);
306                 ctx->probe_mask |= probe_bit;
307
308                 if (probe->trigger) {
309                         stage = 0;
310                         for (tc = probe->trigger; *tc; tc++) {
311                                 ctx->trigger_mask[stage] |= probe_bit;
312                                 if (*tc == '1')
313                                         ctx->trigger_value[stage] |= probe_bit;
314                                 stage++;
315                                 if (stage > NUM_TRIGGER_STAGES)
316                                         return SR_ERR;
317                         }
318                 }
319         }
320
321         return SR_OK;
322 }
323
324 /*
325  * API callbacks
326  */
327
328 static int hw_init(const char *devinfo)
329 {
330         struct sr_dev_inst *sdi;
331         struct libusb_device_descriptor des;
332         libusb_device **devlist;
333         int err, devcnt, i;
334         struct context *ctx;
335
336         /* Avoid compiler warnings. */
337         (void)devinfo;
338
339         /* Allocate memory for our private driver context. */
340         if (!(ctx = g_try_malloc(sizeof(struct context)))) {
341                 sr_err("zp: %s: ctx malloc failed", __func__);
342                 return 0;
343         }
344
345         /* Set some sane defaults. */
346         ctx->cur_samplerate = 0;
347         ctx->limit_samples = 0;
348         ctx->num_channels = 32; /* TODO: This isn't initialized before it's needed :( */
349         ctx->memory_size = 0;
350         ctx->probe_mask = 0;
351         memset(ctx->trigger_mask, 0, NUM_TRIGGER_STAGES);
352         memset(ctx->trigger_value, 0, NUM_TRIGGER_STAGES);
353         // memset(ctx->trigger_buffer, 0, NUM_TRIGGER_STAGES);
354
355         if (libusb_init(&usb_context) != 0) {
356                 sr_err("zp: Failed to initialize USB.");
357                 return 0;
358         }
359
360         /* Find all ZeroPlus analyzers and add them to device list. */
361         devcnt = 0;
362         libusb_get_device_list(usb_context, &devlist); /* TODO: Errors. */
363
364         for (i = 0; devlist[i]; i++) {
365                 err = libusb_get_device_descriptor(devlist[i], &des);
366                 if (err != 0) {
367                         sr_err("zp: failed to get device descriptor: %d", err);
368                         continue;
369                 }
370
371                 if (des.idVendor == USB_VENDOR) {
372                         /*
373                          * Definitely a Zeroplus.
374                          * TODO: Any way to detect specific model/version in
375                          * the zeroplus range?
376                          */
377                         /* Register the device with libsigrok. */
378                         if (!(sdi = sr_dev_inst_new(devcnt,
379                                         SR_ST_INACTIVE, USB_VENDOR_NAME,
380                                         USB_MODEL_NAME, USB_MODEL_VERSION))) {
381                                 sr_err("zp: %s: sr_dev_inst_new failed",
382                                        __func__);
383                                 return 0;
384                         }
385
386                         sdi->priv = ctx;
387
388                         dev_insts =
389                             g_slist_append(dev_insts, sdi);
390                         ctx->usb = sr_usb_dev_inst_new(
391                                 libusb_get_bus_number(devlist[i]),
392                                 libusb_get_device_address(devlist[i]), NULL);
393                         devcnt++;
394                 }
395         }
396         libusb_free_device_list(devlist, 1);
397
398         return devcnt;
399 }
400
401 static int hw_dev_open(int dev_index)
402 {
403         struct sr_dev_inst *sdi;
404         struct context *ctx;
405         int err;
406
407         if (!(sdi = zp_open_dev(dev_index))) {
408                 sr_err("zp: unable to open device");
409                 return SR_ERR;
410         }
411
412         /* TODO: Note: sdi is retrieved in zp_open_dev(). */
413
414         if (!(ctx = sdi->priv)) {
415                 sr_err("zp: %s: sdi->priv was NULL", __func__);
416                 return SR_ERR_ARG;
417         }
418
419         err = libusb_set_configuration(ctx->usb->devhdl, USB_CONFIGURATION);
420         if (err < 0) {
421                 sr_err("zp: Unable to set USB configuration %d: %d",
422                        USB_CONFIGURATION, err);
423                 return SR_ERR;
424         }
425
426         err = libusb_claim_interface(ctx->usb->devhdl, USB_INTERFACE);
427         if (err != 0) {
428                 sr_err("zp: Unable to claim interface: %d", err);
429                 return SR_ERR;
430         }
431
432         analyzer_reset(ctx->usb->devhdl);
433         analyzer_initialize(ctx->usb->devhdl);
434
435         analyzer_set_memory_size(MEMORY_SIZE_512K);
436         // analyzer_set_freq(g_freq, g_freq_scale);
437         analyzer_set_trigger_count(1);
438         // analyzer_set_ramsize_trigger_address((((100 - g_pre_trigger)
439         // * get_memory_size(g_memory_size)) / 100) >> 2);
440         analyzer_set_ramsize_trigger_address(
441                 (100 * get_memory_size(MEMORY_SIZE_512K) / 100) >> 2);
442
443 #if 0
444         if (g_double_mode == 1)
445                 analyzer_set_compression(COMPRESSION_DOUBLE);
446         else if (g_compression == 1)
447                 analyzer_set_compression(COMPRESSION_ENABLE);
448         else
449 #endif
450         analyzer_set_compression(COMPRESSION_NONE);
451
452         if (ctx->cur_samplerate == 0) {
453                 /* Samplerate hasn't been set. Default to the slowest one. */
454                 if (hw_dev_config_set(dev_index, SR_HWCAP_SAMPLERATE,
455                      &samplerates.list[0]) == SR_ERR)
456                         return SR_ERR;
457         }
458
459         return SR_OK;
460 }
461
462 static int hw_dev_close(int dev_index)
463 {
464         struct sr_dev_inst *sdi;
465
466         if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
467                 sr_err("zp: %s: sdi was NULL", __func__);
468                 return SR_ERR; /* TODO: SR_ERR_ARG? */
469         }
470
471         /* TODO */
472         close_dev(sdi);
473
474         return SR_OK;
475 }
476
477 static int hw_cleanup(void)
478 {
479         GSList *l;
480         struct sr_dev_inst *sdi;
481
482         for (l = dev_insts; l; l = l->next) {
483                 sdi = l->data;
484                 /* Properly close all devices... */
485                 close_dev(sdi);
486                 /* ...and free all their memory. */
487                 sr_dev_inst_free(sdi);
488         }
489         g_slist_free(dev_insts);
490         dev_insts = NULL;
491
492         if (usb_context)
493                 libusb_exit(usb_context);
494         usb_context = NULL;
495
496         return SR_OK;
497 }
498
499 static void *hw_dev_info_get(int dev_index, int dev_info_id)
500 {
501         struct sr_dev_inst *sdi;
502         struct context *ctx;
503         void *info;
504
505         if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
506                 sr_err("zp: %s: sdi was NULL", __func__);
507                 return NULL;
508         }
509
510         if (!(ctx = sdi->priv)) {
511                 sr_err("zp: %s: sdi->priv was NULL", __func__);
512                 return NULL;
513         }
514
515         switch (dev_info_id) {
516         case SR_DI_INST:
517                 info = sdi;
518                 break;
519         case SR_DI_NUM_PROBES:
520                 info = GINT_TO_POINTER(ctx->num_channels);
521                 break;
522         case SR_DI_PROBE_NAMES:
523                 info = probe_names;
524                 break;
525         case SR_DI_SAMPLERATES:
526                 info = &samplerates;
527                 break;
528         case SR_DI_TRIGGER_TYPES:
529                 info = TRIGGER_TYPES;
530                 break;
531         case SR_DI_CUR_SAMPLERATE:
532                 info = &ctx->cur_samplerate;
533                 break;
534         default:
535                 /* Unknown device info ID, return NULL. */
536                 sr_err("zp: %s: Unknown device info ID", __func__);
537                 info = NULL;
538                 break;
539         }
540
541         return info;
542 }
543
544 static int hw_dev_status_get(int dev_index)
545 {
546         struct sr_dev_inst *sdi;
547
548         sdi = sr_dev_inst_get(dev_insts, dev_index);
549         if (sdi)
550                 return sdi->status;
551         else
552                 return SR_ST_NOT_FOUND;
553 }
554
555 static int *hw_hwcap_get_all(void)
556 {
557         return hwcaps;
558 }
559
560 static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate)
561 {
562         struct context *ctx;
563
564         if (!sdi) {
565                 sr_err("zp: %s: sdi was NULL", __func__);
566                 return SR_ERR_ARG;
567         }
568
569         if (!(ctx = sdi->priv)) {
570                 sr_err("zp: %s: sdi->priv was NULL", __func__);
571                 return SR_ERR_ARG;
572         }
573
574         sr_info("zp: Setting samplerate to %" PRIu64 "Hz.", samplerate);
575
576         if (samplerate > SR_MHZ(1))
577                 analyzer_set_freq(samplerate / SR_MHZ(1), FREQ_SCALE_MHZ);
578         else if (samplerate > SR_KHZ(1))
579                 analyzer_set_freq(samplerate / SR_KHZ(1), FREQ_SCALE_KHZ);
580         else
581                 analyzer_set_freq(samplerate, FREQ_SCALE_HZ);
582
583         ctx->cur_samplerate = samplerate;
584
585         return SR_OK;
586 }
587
588 static int hw_dev_config_set(int dev_index, int hwcap, void *value)
589 {
590         struct sr_dev_inst *sdi;
591         struct context *ctx;
592
593         if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
594                 sr_err("zp: %s: sdi was NULL", __func__);
595                 return SR_ERR;
596         }
597
598         if (!(ctx = sdi->priv)) {
599                 sr_err("zp: %s: sdi->priv was NULL", __func__);
600                 return SR_ERR_ARG;
601         }
602
603         switch (hwcap) {
604         case SR_HWCAP_SAMPLERATE:
605                 return set_samplerate(sdi, *(uint64_t *)value);
606         case SR_HWCAP_PROBECONFIG:
607                 return configure_probes(sdi, (GSList *)value);
608         case SR_HWCAP_LIMIT_SAMPLES:
609                 ctx->limit_samples = *(uint64_t *)value;
610                 return SR_OK;
611         default:
612                 return SR_ERR;
613         }
614 }
615
616 static int hw_dev_acquisition_start(int dev_index, gpointer session_data)
617 {
618         struct sr_dev_inst *sdi;
619         struct sr_datafeed_packet packet;
620         struct sr_datafeed_logic logic;
621         struct sr_datafeed_header header;
622         uint64_t samples_read;
623         int res;
624         unsigned int packet_num;
625         unsigned char *buf;
626         struct context *ctx;
627
628         if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
629                 sr_err("zp: %s: sdi was NULL", __func__);
630                 return SR_ERR;
631         }
632
633         if (!(ctx = sdi->priv)) {
634                 sr_err("zp: %s: sdi->priv was NULL", __func__);
635                 return SR_ERR_ARG;
636         }
637
638         /* push configured settings to device */
639         analyzer_configure(ctx->usb->devhdl);
640
641         analyzer_start(ctx->usb->devhdl);
642         sr_info("zp: Waiting for data");
643         analyzer_wait_data(ctx->usb->devhdl);
644
645         sr_info("zp: Stop address    = 0x%x",
646                 analyzer_get_stop_address(ctx->usb->devhdl));
647         sr_info("zp: Now address     = 0x%x",
648                 analyzer_get_now_address(ctx->usb->devhdl));
649         sr_info("zp: Trigger address = 0x%x",
650                 analyzer_get_trigger_address(ctx->usb->devhdl));
651
652         packet.type = SR_DF_HEADER;
653         packet.payload = &header;
654         header.feed_version = 1;
655         gettimeofday(&header.starttime, NULL);
656         header.samplerate = ctx->cur_samplerate;
657         header.num_logic_probes = ctx->num_channels;
658         sr_session_bus(session_data, &packet);
659
660         if (!(buf = g_try_malloc(PACKET_SIZE))) {
661                 sr_err("zp: %s: buf malloc failed", __func__);
662                 return SR_ERR_MALLOC;
663         }
664
665         samples_read = 0;
666         analyzer_read_start(ctx->usb->devhdl);
667         /* Send the incoming transfer to the session bus. */
668         for (packet_num = 0; packet_num < (ctx->memory_size * 4 / PACKET_SIZE);
669              packet_num++) {
670                 res = analyzer_read_data(ctx->usb->devhdl, buf, PACKET_SIZE);
671                 sr_info("zp: Tried to read %llx bytes, actually read %x bytes",
672                         PACKET_SIZE, res);
673
674                 packet.type = SR_DF_LOGIC;
675                 packet.payload = &logic;
676                 logic.length = PACKET_SIZE;
677                 logic.unitsize = 4;
678                 logic.data = buf;
679                 sr_session_bus(session_data, &packet);
680                 samples_read += res / 4;
681         }
682         analyzer_read_stop(ctx->usb->devhdl);
683         g_free(buf);
684
685         packet.type = SR_DF_END;
686         sr_session_bus(session_data, &packet);
687
688         return SR_OK;
689 }
690
691 /* This stops acquisition on ALL devices, ignoring dev_index. */
692 static int hw_dev_acquisition_stop(int dev_index, gpointer session_dev_id)
693 {
694         struct sr_datafeed_packet packet;
695         struct sr_dev_inst *sdi;
696         struct context *ctx;
697
698         packet.type = SR_DF_END;
699         sr_session_bus(session_dev_id, &packet);
700
701         if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) {
702                 sr_err("zp: %s: sdi was NULL", __func__);
703                 return SR_ERR_BUG;
704         }
705
706         if (!(ctx = sdi->priv)) {
707                 sr_err("zp: %s: sdi->priv was NULL", __func__);
708                 return SR_ERR_BUG;
709         }
710
711         analyzer_reset(ctx->usb->devhdl);
712         /* TODO: Need to cancel and free any queued up transfers. */
713
714         return SR_OK;
715 }
716
717 SR_PRIV struct sr_dev_plugin zeroplus_logic_cube_plugin_info = {
718         .name = "zeroplus-logic-cube",
719         .longname = "Zeroplus Logic Cube LAP-C series",
720         .api_version = 1,
721         .init = hw_init,
722         .cleanup = hw_cleanup,
723         .dev_open = hw_dev_open,
724         .dev_close = hw_dev_close,
725         .dev_info_get = hw_dev_info_get,
726         .dev_status_get = hw_dev_status_get,
727         .hwcap_get_all = hw_hwcap_get_all,
728         .dev_config_set = hw_dev_config_set,
729         .dev_acquisition_start = hw_dev_acquisition_start,
730         .dev_acquisition_stop = hw_dev_acquisition_stop,
731 };