2 * This file is part of the sigrok project.
4 * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
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.
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.
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/>.
23 #include <sys/types.h>
38 #include <arpa/inet.h>
41 #include "libsigrok.h"
42 #include "libsigrok-internal.h"
45 #define SERIALCOMM "115200/8n1"
47 static const int hwcaps[] = {
48 SR_HWCAP_LOGIC_ANALYZER,
50 SR_HWCAP_CAPTURE_RATIO,
51 SR_HWCAP_LIMIT_SAMPLES,
56 /* Probes are numbered 0-31 (on the PCB silkscreen). */
57 static const char *probe_names[NUM_PROBES + 1] = {
93 /* default supported samplerates, can be overridden by device metadata */
94 static const struct sr_samplerates samplerates = {
101 SR_PRIV struct sr_dev_driver ols_driver_info;
102 static struct sr_dev_driver *odi = &ols_driver_info;
104 static int send_shortcommand(struct sr_serial_dev_inst *serial,
109 sr_dbg("ols: sending cmd 0x%.2x", command);
111 if (serial_write(serial, buf, 1) != 1)
117 static int send_longcommand(struct sr_serial_dev_inst *serial,
118 uint8_t command, uint32_t data)
122 sr_dbg("ols: sending cmd 0x%.2x data 0x%.8x", command, data);
124 buf[1] = (data & 0xff000000) >> 24;
125 buf[2] = (data & 0xff0000) >> 16;
126 buf[3] = (data & 0xff00) >> 8;
127 buf[4] = data & 0xff;
128 if (serial_write(serial, buf, 5) != 5)
134 static int configure_probes(const struct sr_dev_inst *sdi)
136 struct dev_context *devc;
137 const struct sr_probe *probe;
139 int probe_bit, stage, i;
144 devc->probe_mask = 0;
145 for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
146 devc->trigger_mask[i] = 0;
147 devc->trigger_value[i] = 0;
150 devc->num_stages = 0;
151 for (l = sdi->probes; l; l = l->next) {
152 probe = (const struct sr_probe *)l->data;
157 * Set up the probe mask for later configuration into the
160 probe_bit = 1 << (probe->index);
161 devc->probe_mask |= probe_bit;
166 /* Configure trigger mask and value. */
168 for (tc = probe->trigger; tc && *tc; tc++) {
169 devc->trigger_mask[stage] |= probe_bit;
171 devc->trigger_value[stage] |= probe_bit;
175 * TODO: Only supporting parallel mode, with
180 if (stage > devc->num_stages)
181 devc->num_stages = stage;
187 static uint32_t reverse16(uint32_t in)
191 out = (in & 0xff) << 8;
192 out |= (in & 0xff00) >> 8;
193 out |= (in & 0xff0000) << 8;
194 out |= (in & 0xff000000) >> 8;
199 static uint32_t reverse32(uint32_t in)
203 out = (in & 0xff) << 24;
204 out |= (in & 0xff00) << 8;
205 out |= (in & 0xff0000) >> 8;
206 out |= (in & 0xff000000) >> 24;
211 static struct dev_context *ols_dev_new(void)
213 struct dev_context *devc;
215 if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
216 sr_err("ols: %s: devc malloc failed", __func__);
220 devc->trigger_at = -1;
221 devc->probe_mask = 0xffffffff;
222 devc->cur_samplerate = SR_KHZ(200);
228 static struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
230 struct sr_dev_inst *sdi;
231 struct dev_context *devc;
232 struct sr_probe *probe;
233 uint32_t tmp_int, ui;
234 uint8_t key, type, token;
235 GString *tmp_str, *devname, *version;
238 sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, NULL, NULL, NULL);
240 devc = ols_dev_new();
243 devname = g_string_new("");
244 version = g_string_new("");
248 if (serial_read(serial, &key, 1) != 1 || key == 0x00)
254 /* NULL-terminated string */
255 tmp_str = g_string_new("");
256 while (serial_read(serial, &tmp_c, 1) == 1 && tmp_c != '\0')
257 g_string_append_c(tmp_str, tmp_c);
258 sr_dbg("ols: got metadata key 0x%.2x value '%s'",
263 devname = g_string_append(devname, tmp_str->str);
266 /* FPGA firmware version */
268 g_string_append(version, ", ");
269 g_string_append(version, "FPGA version ");
270 g_string_append(version, tmp_str->str);
273 /* Ancillary version */
275 g_string_append(version, ", ");
276 g_string_append(version, "Ancillary version ");
277 g_string_append(version, tmp_str->str);
280 sr_info("ols: unknown token 0x%.2x: '%s'",
281 token, tmp_str->str);
284 g_string_free(tmp_str, TRUE);
287 /* 32-bit unsigned integer */
288 if (serial_read(serial, &tmp_int, 4) != 4)
290 tmp_int = reverse32(tmp_int);
291 sr_dbg("ols: got metadata key 0x%.2x value 0x%.8x",
295 /* Number of usable probes */
296 for (ui = 0; ui < tmp_int; ui++) {
297 if (!(probe = sr_probe_new(ui, SR_PROBE_LOGIC, TRUE,
300 sdi->probes = g_slist_append(sdi->probes, probe);
304 /* Amount of sample memory available (bytes) */
305 devc->max_samples = tmp_int;
308 /* Amount of dynamic memory available (bytes) */
309 /* what is this for? */
312 /* Maximum sample rate (hz) */
313 devc->max_samplerate = tmp_int;
316 /* protocol version */
317 devc->protocol_version = tmp_int;
320 sr_info("ols: unknown token 0x%.2x: 0x%.8x",
326 /* 8-bit unsigned integer */
327 if (serial_read(serial, &tmp_c, 1) != 1)
329 sr_dbg("ols: got metadata key 0x%.2x value 0x%.2x",
333 /* Number of usable probes */
334 for (ui = 0; ui < tmp_c; ui++) {
335 if (!(probe = sr_probe_new(ui, SR_PROBE_LOGIC, TRUE,
338 sdi->probes = g_slist_append(sdi->probes, probe);
342 /* protocol version */
343 devc->protocol_version = tmp_c;
346 sr_info("ols: unknown token 0x%.2x: 0x%.2x",
357 sdi->model = devname->str;
358 sdi->version = version->str;
359 g_string_free(devname, FALSE);
360 g_string_free(version, FALSE);
365 static int hw_init(void)
367 struct drv_context *drvc;
369 if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
370 sr_err("ols: driver context malloc failed.");
371 return SR_ERR_MALLOC;
378 static GSList *hw_scan(GSList *options)
380 struct sr_hwopt *opt;
381 struct sr_dev_inst *sdi;
382 struct drv_context *drvc;
383 struct dev_context *devc;
384 struct sr_probe *probe;
385 struct sr_serial_dev_inst *serial;
389 const char *conn, *serialcomm;
396 conn = serialcomm = NULL;
397 for (l = options; l; l = l->next) {
399 switch (opt->hwopt) {
403 case SR_HWOPT_SERIALCOMM:
404 serialcomm = opt->value;
411 if (serialcomm == NULL)
412 serialcomm = SERIALCOMM;
414 if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
417 /* The discovery procedure is like this: first send the Reset
418 * command (0x00) 5 times, since the device could be anywhere
419 * in a 5-byte command. Then send the ID command (0x02).
420 * If the device responds with 4 bytes ("OLS1" or "SLA1"), we
423 sr_info("ols: probing %s .", conn);
424 if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
428 for (i = 0; i < 5; i++) {
429 if ((ret = send_shortcommand(serial, CMD_RESET)) != SR_OK) {
430 sr_err("ols: port %s is not writable.", conn);
435 serial_close(serial);
436 sr_err("ols: Could not use port %s. Quitting.", conn);
439 send_shortcommand(serial, CMD_ID);
441 /* Wait 10ms for a response. */
444 probefd.fd = serial->fd;
445 probefd.events = G_IO_IN;
446 g_poll(&probefd, 1, 1);
448 if (probefd.revents != G_IO_IN)
450 if (serial_read(serial, buf, 4) != 4)
452 if (strncmp(buf, "1SLO", 4) && strncmp(buf, "1ALS", 4))
455 /* Definitely using the OLS protocol, check if it supports
456 * the metadata command.
458 send_shortcommand(serial, CMD_METADATA);
459 if (g_poll(&probefd, 1, 10) > 0) {
461 sdi = get_metadata(serial);
465 /* Not an OLS -- some other board that uses the sump protocol. */
466 sdi = sr_dev_inst_new(0, SR_ST_INACTIVE,
467 "Sump", "Logic Analyzer", "v1.0");
469 devc = ols_dev_new();
470 for (i = 0; i < 32; i++) {
471 if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE,
474 sdi->probes = g_slist_append(sdi->probes, probe);
478 devc->serial = serial;
479 drvc->instances = g_slist_append(drvc->instances, sdi);
480 devices = g_slist_append(devices, sdi);
482 serial_close(serial);
487 static GSList *hw_dev_list(void)
489 struct drv_context *drvc;
493 return drvc->instances;
496 static int hw_dev_open(struct sr_dev_inst *sdi)
498 struct dev_context *devc;
502 if (serial_open(devc->serial, SERIAL_RDWR) != SR_OK)
505 sdi->status = SR_ST_ACTIVE;
510 static int hw_dev_close(struct sr_dev_inst *sdi)
512 struct dev_context *devc;
516 if (devc->serial && devc->serial->fd != -1) {
517 serial_close(devc->serial);
518 sdi->status = SR_ST_INACTIVE;
524 static int hw_cleanup(void)
527 struct sr_dev_inst *sdi;
528 struct drv_context *drvc;
529 struct dev_context *devc;
532 if (!(drvc = odi->priv))
535 /* Properly close and free all devices. */
536 for (l = drvc->instances; l; l = l->next) {
537 if (!(sdi = l->data)) {
538 /* Log error, but continue cleaning up the rest. */
539 sr_err("ols: %s: sdi was NULL, continuing", __func__);
543 if (!(devc = sdi->priv)) {
544 /* Log error, but continue cleaning up the rest. */
545 sr_err("ols: %s: sdi->priv was NULL, continuing",
551 sr_serial_dev_inst_free(devc->serial);
552 sr_dev_inst_free(sdi);
554 g_slist_free(drvc->instances);
555 drvc->instances = NULL;
560 static int hw_info_get(int info_id, const void **data,
561 const struct sr_dev_inst *sdi)
563 struct dev_context *devc;
569 case SR_DI_NUM_PROBES:
570 *data = GINT_TO_POINTER(1);
572 case SR_DI_PROBE_NAMES:
575 case SR_DI_SAMPLERATES:
576 *data = &samplerates;
578 case SR_DI_TRIGGER_TYPES:
579 *data = (char *)TRIGGER_TYPES;
581 case SR_DI_CUR_SAMPLERATE:
584 *data = &devc->cur_samplerate;
595 static int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate)
597 struct dev_context *devc;
600 if (devc->max_samplerate) {
601 if (samplerate > devc->max_samplerate)
602 return SR_ERR_SAMPLERATE;
603 } else if (samplerate < samplerates.low || samplerate > samplerates.high)
604 return SR_ERR_SAMPLERATE;
606 if (samplerate > CLOCK_RATE) {
607 devc->flag_reg |= FLAG_DEMUX;
608 devc->cur_samplerate_divider = (CLOCK_RATE * 2 / samplerate) - 1;
610 devc->flag_reg &= ~FLAG_DEMUX;
611 devc->cur_samplerate_divider = (CLOCK_RATE / samplerate) - 1;
614 /* Calculate actual samplerate used and complain if it is different
615 * from the requested.
617 devc->cur_samplerate = CLOCK_RATE / (devc->cur_samplerate_divider + 1);
618 if (devc->flag_reg & FLAG_DEMUX)
619 devc->cur_samplerate *= 2;
620 if (devc->cur_samplerate != samplerate)
621 sr_err("ols: can't match samplerate %" PRIu64 ", using %"
622 PRIu64, samplerate, devc->cur_samplerate);
627 static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
630 struct dev_context *devc;
632 const uint64_t *tmp_u64;
636 if (sdi->status != SR_ST_ACTIVE)
640 case SR_HWCAP_SAMPLERATE:
641 ret = set_samplerate(sdi, *(const uint64_t *)value);
643 case SR_HWCAP_LIMIT_SAMPLES:
645 if (*tmp_u64 < MIN_NUM_SAMPLES)
647 if (*tmp_u64 > devc->max_samples)
648 sr_err("ols: sample limit exceeds hw max");
649 devc->limit_samples = *tmp_u64;
650 sr_info("ols: sample limit %" PRIu64, devc->limit_samples);
653 case SR_HWCAP_CAPTURE_RATIO:
654 devc->capture_ratio = *(const uint64_t *)value;
655 if (devc->capture_ratio < 0 || devc->capture_ratio > 100) {
656 devc->capture_ratio = 0;
662 if (GPOINTER_TO_INT(value)) {
663 sr_info("ols: enabling RLE");
664 devc->flag_reg |= FLAG_RLE;
675 static void abort_acquisition(const struct sr_dev_inst *sdi)
677 struct sr_datafeed_packet packet;
678 struct dev_context *devc;
681 sr_source_remove(devc->serial->fd);
683 /* Terminate session */
684 packet.type = SR_DF_END;
685 sr_session_send(sdi, &packet);
691 static int receive_data(int fd, int revents, void *cb_data)
693 struct sr_datafeed_packet packet;
694 struct sr_datafeed_logic logic;
695 struct sr_dev_inst *sdi;
696 struct drv_context *drvc;
697 struct dev_context *devc;
699 int num_channels, offset, i, j;
704 /* Find this device's devc struct by its fd. */
706 for (l = drvc->instances; l; l = l->next) {
709 if (devc->serial->fd == fd)
714 /* Shouldn't happen. */
717 if (devc->num_transfers++ == 0) {
719 * First time round, means the device started sending data,
720 * and will not stop until done. If it stops sending for
721 * longer than it takes to send a byte, that means it's
722 * finished. We'll double that to 30ms to be sure...
724 sr_source_remove(fd);
725 sr_source_add(fd, G_IO_IN, 30, receive_data, cb_data);
726 /* TODO: Check malloc return code. */
727 devc->raw_sample_buf = g_try_malloc(devc->limit_samples * 4);
728 if (!devc->raw_sample_buf) {
729 sr_err("ols: %s: devc->raw_sample_buf malloc failed",
733 /* fill with 1010... for debugging */
734 memset(devc->raw_sample_buf, 0x82, devc->limit_samples * 4);
738 for (i = 0x20; i > 0x02; i /= 2) {
739 if ((devc->flag_reg & i) == 0)
743 if (revents == G_IO_IN) {
744 if (serial_read(devc->serial, &byte, 1) != 1)
747 /* Ignore it if we've read enough. */
748 if (devc->num_samples >= devc->limit_samples)
751 devc->sample[devc->num_bytes++] = byte;
752 sr_dbg("ols: received byte 0x%.2x", byte);
753 if (devc->num_bytes == num_channels) {
754 /* Got a full sample. */
755 sr_dbg("ols: received sample 0x%.*x",
756 devc->num_bytes * 2, *(int *)devc->sample);
757 if (devc->flag_reg & FLAG_RLE) {
759 * In RLE mode -1 should never come in as a
760 * sample, because bit 31 is the "count" flag.
762 if (devc->sample[devc->num_bytes - 1] & 0x80) {
763 devc->sample[devc->num_bytes - 1] &= 0x7f;
765 * FIXME: This will only work on
766 * little-endian systems.
768 devc->rle_count = *(int *)(devc->sample);
769 sr_dbg("ols: RLE count = %d", devc->rle_count);
774 devc->num_samples += devc->rle_count + 1;
775 if (devc->num_samples > devc->limit_samples) {
776 /* Save us from overrunning the buffer. */
777 devc->rle_count -= devc->num_samples - devc->limit_samples;
778 devc->num_samples = devc->limit_samples;
781 if (num_channels < 4) {
783 * Some channel groups may have been turned
784 * off, to speed up transfer between the
785 * hardware and the PC. Expand that here before
786 * submitting it over the session bus --
787 * whatever is listening on the bus will be
788 * expecting a full 32-bit sample, based on
789 * the number of probes.
792 memset(devc->tmp_sample, 0, 4);
793 for (i = 0; i < 4; i++) {
794 if (((devc->flag_reg >> 2) & (1 << i)) == 0) {
796 * This channel group was
797 * enabled, copy from received
800 devc->tmp_sample[i] = devc->sample[j++];
803 memcpy(devc->sample, devc->tmp_sample, 4);
804 sr_dbg("ols: full sample 0x%.8x", *(int *)devc->sample);
807 /* the OLS sends its sample buffer backwards.
808 * store it in reverse order here, so we can dump
809 * this on the session bus later.
811 offset = (devc->limit_samples - devc->num_samples) * 4;
812 for (i = 0; i <= devc->rle_count; i++) {
813 memcpy(devc->raw_sample_buf + offset + (i * 4),
816 memset(devc->sample, 0, 4);
822 * This is the main loop telling us a timeout was reached, or
823 * we've acquired all the samples we asked for -- we're done.
824 * Send the (properly-ordered) buffer to the frontend.
826 if (devc->trigger_at != -1) {
827 /* a trigger was set up, so we need to tell the frontend
830 if (devc->trigger_at > 0) {
831 /* there are pre-trigger samples, send those first */
832 packet.type = SR_DF_LOGIC;
833 packet.payload = &logic;
834 logic.length = devc->trigger_at * 4;
836 logic.data = devc->raw_sample_buf +
837 (devc->limit_samples - devc->num_samples) * 4;
838 sr_session_send(cb_data, &packet);
841 /* send the trigger */
842 packet.type = SR_DF_TRIGGER;
843 sr_session_send(cb_data, &packet);
845 /* send post-trigger samples */
846 packet.type = SR_DF_LOGIC;
847 packet.payload = &logic;
848 logic.length = (devc->num_samples * 4) - (devc->trigger_at * 4);
850 logic.data = devc->raw_sample_buf + devc->trigger_at * 4 +
851 (devc->limit_samples - devc->num_samples) * 4;
852 sr_session_send(cb_data, &packet);
854 /* no trigger was used */
855 packet.type = SR_DF_LOGIC;
856 packet.payload = &logic;
857 logic.length = devc->num_samples * 4;
859 logic.data = devc->raw_sample_buf +
860 (devc->limit_samples - devc->num_samples) * 4;
861 sr_session_send(cb_data, &packet);
863 g_free(devc->raw_sample_buf);
865 serial_flush(devc->serial);
866 abort_acquisition(sdi);
867 serial_close(devc->serial);
873 static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
876 struct sr_datafeed_packet *packet;
877 struct sr_datafeed_header *header;
878 struct sr_datafeed_meta_logic meta;
879 struct dev_context *devc;
880 uint32_t trigger_config[4];
882 uint16_t readcount, delaycount;
883 uint8_t changrp_mask;
889 if (sdi->status != SR_ST_ACTIVE)
892 if (configure_probes(sdi) != SR_OK) {
893 sr_err("ols: failed to configured probes");
898 * Enable/disable channel groups in the flag register according to the
899 * probe mask. Calculate this here, because num_channels is needed
900 * to limit readcount.
904 for (i = 0; i < 4; i++) {
905 if (devc->probe_mask & (0xff << (i * 8))) {
906 changrp_mask |= (1 << i);
912 * Limit readcount to prevent reading past the end of the hardware
915 readcount = MIN(devc->max_samples / num_channels, devc->limit_samples) / 4;
917 memset(trigger_config, 0, 16);
918 trigger_config[devc->num_stages - 1] |= 0x08;
919 if (devc->trigger_mask[0]) {
920 delaycount = readcount * (1 - devc->capture_ratio / 100.0);
921 devc->trigger_at = (readcount - delaycount) * 4 - devc->num_stages;
923 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_MASK_0,
924 reverse32(devc->trigger_mask[0])) != SR_OK)
926 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_VALUE_0,
927 reverse32(devc->trigger_value[0])) != SR_OK)
929 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_CONFIG_0,
930 trigger_config[0]) != SR_OK)
933 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_MASK_1,
934 reverse32(devc->trigger_mask[1])) != SR_OK)
936 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_VALUE_1,
937 reverse32(devc->trigger_value[1])) != SR_OK)
939 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_CONFIG_1,
940 trigger_config[1]) != SR_OK)
943 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_MASK_2,
944 reverse32(devc->trigger_mask[2])) != SR_OK)
946 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_VALUE_2,
947 reverse32(devc->trigger_value[2])) != SR_OK)
949 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_CONFIG_2,
950 trigger_config[2]) != SR_OK)
953 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_MASK_3,
954 reverse32(devc->trigger_mask[3])) != SR_OK)
956 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_VALUE_3,
957 reverse32(devc->trigger_value[3])) != SR_OK)
959 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_CONFIG_3,
960 trigger_config[3]) != SR_OK)
963 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_MASK_0,
964 devc->trigger_mask[0]) != SR_OK)
966 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_VALUE_0,
967 devc->trigger_value[0]) != SR_OK)
969 if (send_longcommand(devc->serial, CMD_SET_TRIGGER_CONFIG_0,
970 0x00000008) != SR_OK)
972 delaycount = readcount;
975 sr_info("ols: setting samplerate to %" PRIu64 " Hz (divider %u, "
976 "demux %s)", devc->cur_samplerate, devc->cur_samplerate_divider,
977 devc->flag_reg & FLAG_DEMUX ? "on" : "off");
978 if (send_longcommand(devc->serial, CMD_SET_DIVIDER,
979 reverse32(devc->cur_samplerate_divider)) != SR_OK)
982 /* Send sample limit and pre/post-trigger capture ratio. */
983 data = ((readcount - 1) & 0xffff) << 16;
984 data |= (delaycount - 1) & 0xffff;
985 if (send_longcommand(devc->serial, CMD_CAPTURE_SIZE, reverse16(data)) != SR_OK)
988 /* The flag register wants them here, and 1 means "disable channel". */
989 devc->flag_reg |= ~(changrp_mask << 2) & 0x3c;
990 devc->flag_reg |= FLAG_FILTER;
992 data = (devc->flag_reg << 24) | ((devc->flag_reg << 8) & 0xff0000);
993 if (send_longcommand(devc->serial, CMD_SET_FLAGS, data) != SR_OK)
996 /* Start acquisition on the device. */
997 if (send_shortcommand(devc->serial, CMD_RUN) != SR_OK)
1000 sr_source_add(devc->serial->fd, G_IO_IN, -1, receive_data,
1003 if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
1004 sr_err("ols: %s: packet malloc failed", __func__);
1005 return SR_ERR_MALLOC;
1008 if (!(header = g_try_malloc(sizeof(struct sr_datafeed_header)))) {
1009 sr_err("ols: %s: header malloc failed", __func__);
1011 return SR_ERR_MALLOC;
1014 /* Send header packet to the session bus. */
1015 packet->type = SR_DF_HEADER;
1016 packet->payload = (unsigned char *)header;
1017 header->feed_version = 1;
1018 gettimeofday(&header->starttime, NULL);
1019 sr_session_send(cb_data, packet);
1021 /* Send metadata about the SR_DF_LOGIC packets to come. */
1022 packet->type = SR_DF_META_LOGIC;
1023 packet->payload = &meta;
1024 meta.samplerate = devc->cur_samplerate;
1025 meta.num_probes = NUM_PROBES;
1026 sr_session_send(cb_data, packet);
1034 /* TODO: This stops acquisition on ALL devices, ignoring dev_index. */
1035 static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
1037 /* Avoid compiler warnings. */
1040 abort_acquisition(sdi);
1045 SR_PRIV struct sr_dev_driver ols_driver_info = {
1047 .longname = "Openbench Logic Sniffer",
1050 .cleanup = hw_cleanup,
1052 .dev_list = hw_dev_list,
1053 .dev_clear = hw_cleanup,
1054 .dev_open = hw_dev_open,
1055 .dev_close = hw_dev_close,
1056 .info_get = hw_info_get,
1057 .dev_config_set = hw_dev_config_set,
1058 .dev_acquisition_start = hw_dev_acquisition_start,
1059 .dev_acquisition_stop = hw_dev_acquisition_stop,