]> sigrok.org Git - libsigrok.git/blame - hardware/zeroplus-logic-cube/zeroplus.c
sr: la8: Fix typo.
[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,
73017cf9 403 &samplerates.list[0]) == SR_ERR)
e46b8fb1 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{
73017cf9
UH
495 sr_info("zp: Setting samplerate to %" PRIu64 "Hz.", samplerate);
496
59df0c77
UH
497 if (samplerate > SR_MHZ(1))
498 analyzer_set_freq(samplerate / SR_MHZ(1), FREQ_SCALE_MHZ);
499 else if (samplerate > SR_KHZ(1))
500 analyzer_set_freq(samplerate / SR_KHZ(1), FREQ_SCALE_KHZ);
a1bb33af 501 else
fed16f06 502 analyzer_set_freq(samplerate, FREQ_SCALE_HZ);
a1bb33af
UH
503
504 cur_samplerate = samplerate;
9c939c51 505 period_ps = 1000000000000 / samplerate;
a1bb33af 506
e46b8fb1 507 return SR_OK;
a1bb33af
UH
508}
509
510static int hw_set_configuration(int device_index, int capability, void *value)
511{
a00ba012 512 struct sr_device_instance *sdi;
a1bb33af
UH
513 uint64_t *tmp_u64;
514
d32d961d 515 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
e46b8fb1 516 return SR_ERR;
a1bb33af
UH
517
518 switch (capability) {
5a2326a7 519 case SR_HWCAP_SAMPLERATE:
fed16f06
UH
520 tmp_u64 = value;
521 return set_configuration_samplerate(*tmp_u64);
5a2326a7 522 case SR_HWCAP_PROBECONFIG:
fed16f06 523 return configure_probes((GSList *) value);
5a2326a7 524 case SR_HWCAP_LIMIT_SAMPLES:
2458ea65
BV
525 tmp_u64 = value;
526 limit_samples = *tmp_u64;
e46b8fb1 527 return SR_OK;
fed16f06 528 default:
e46b8fb1 529 return SR_ERR;
a1bb33af
UH
530 }
531}
532
9c939c51 533static int hw_start_acquisition(int device_index, gpointer session_data)
a1bb33af 534{
a00ba012 535 struct sr_device_instance *sdi;
b9c735a2 536 struct sr_datafeed_packet packet;
9c939c51 537 struct sr_datafeed_logic logic;
b9c735a2 538 struct sr_datafeed_header header;
9c939c51 539 uint64_t samples_read;
a1bb33af 540 int res;
afc8e4de 541 unsigned int packet_num;
a1bb33af
UH
542 unsigned char *buf;
543
d32d961d 544 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
e46b8fb1 545 return SR_ERR;
a1bb33af 546
a143e4e5
BV
547 /* push configured settings to device */
548 analyzer_configure(sdi->usb->devhdl);
549
a1bb33af 550 analyzer_start(sdi->usb->devhdl);
b08024a8 551 sr_info("Waiting for data");
a1bb33af
UH
552 analyzer_wait_data(sdi->usb->devhdl);
553
9c939c51
BV
554 sr_info("Stop address = 0x%x", analyzer_get_stop_address(sdi->usb->devhdl));
555 sr_info("Now address = 0x%x", analyzer_get_now_address(sdi->usb->devhdl));
556 sr_info("Trigger address = 0x%x", analyzer_get_trigger_address(sdi->usb->devhdl));
a1bb33af 557
5a2326a7 558 packet.type = SR_DF_HEADER;
9c939c51 559 packet.payload = &header;
a1bb33af
UH
560 header.feed_version = 1;
561 gettimeofday(&header.starttime, NULL);
4c100f32 562 header.samplerate = cur_samplerate;
c2616fb9
DR
563 header.num_logic_probes = num_channels;
564 header.num_analog_probes = 0;
9c939c51 565 sr_session_bus(session_data, &packet);
a1bb33af 566
b53738ba 567 if (!(buf = g_try_malloc(PACKET_SIZE))) {
340cfac0 568 sr_err("lap-c: %s: buf malloc failed", __func__);
b53738ba
UH
569 return SR_ERR_MALLOC;
570 }
571
9c939c51 572 samples_read = 0;
a1bb33af 573 analyzer_read_start(sdi->usb->devhdl);
fed16f06
UH
574 /* Send the incoming transfer to the session bus. */
575 for (packet_num = 0; packet_num < (memory_size * 4 / PACKET_SIZE);
576 packet_num++) {
a1bb33af 577 res = analyzer_read_data(sdi->usb->devhdl, buf, PACKET_SIZE);
b08024a8
UH
578 sr_info("Tried to read %llx bytes, actually read %x bytes",
579 PACKET_SIZE, res);
a1bb33af 580
5a2326a7 581 packet.type = SR_DF_LOGIC;
9c939c51
BV
582 packet.timeoffset = samples_read * period_ps;
583 packet.duration = res / 4 * period_ps;
584 packet.payload = &logic;
585 logic.length = PACKET_SIZE;
586 logic.unitsize = 4;
587 logic.data = buf;
588 sr_session_bus(session_data, &packet);
589 samples_read += res / 4;
a1bb33af
UH
590 }
591 analyzer_read_stop(sdi->usb->devhdl);
592 g_free(buf);
593
5a2326a7 594 packet.type = SR_DF_END;
9c939c51 595 sr_session_bus(session_data, &packet);
a1bb33af 596
e46b8fb1 597 return SR_OK;
a1bb33af
UH
598}
599
fed16f06 600/* This stops acquisition on ALL devices, ignoring device_index. */
a1bb33af
UH
601static void hw_stop_acquisition(int device_index, gpointer session_device_id)
602{
b9c735a2 603 struct sr_datafeed_packet packet;
a00ba012 604 struct sr_device_instance *sdi;
a1bb33af 605
5a2326a7 606 packet.type = SR_DF_END;
8a2efef2 607 sr_session_bus(session_device_id, &packet);
a1bb33af 608
d32d961d 609 if (!(sdi = sr_get_device_instance(device_instances, device_index)))
fed16f06 610 return; /* TODO: Cry? */
a1bb33af
UH
611
612 analyzer_reset(sdi->usb->devhdl);
fed16f06 613 /* TODO: Need to cancel and free any queued up transfers. */
a1bb33af
UH
614}
615
5c2d46d1 616struct sr_device_plugin zeroplus_logic_cube_plugin_info = {
e519ba86
UH
617 .name = "zeroplus-logic-cube",
618 .longname = "Zeroplus Logic Cube LAP-C series",
619 .api_version = 1,
620 .init = hw_init,
621 .cleanup = hw_cleanup,
86f5e3d8
UH
622 .opendev = hw_opendev,
623 .closedev = hw_closedev,
e519ba86
UH
624 .get_device_info = hw_get_device_info,
625 .get_status = hw_get_status,
626 .get_capabilities = hw_get_capabilities,
627 .set_configuration = hw_set_configuration,
628 .start_acquisition = hw_start_acquisition,
629 .stop_acquisition = hw_stop_acquisition,
a1bb33af 630};