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