]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fx2lafw/fx2lafw.c
sr: fx2lafw: Add 16bit support for USBee DX and clones
[libsigrok.git] / hardware / fx2lafw / fx2lafw.c
index 11e41fffe410f31c14af570948498b5f129c860a..951c9196ffeebd147e8e38075676c52f5caba8ce 100644 (file)
@@ -24,8 +24,8 @@
 #include <inttypes.h>
 #include <libusb.h>
 #include "config.h"
-#include "sigrok.h"
-#include "sigrok-internal.h"
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
 #include "fx2lafw.h"
 #include "command.h"
 
@@ -38,6 +38,13 @@ static const struct fx2lafw_profile supported_fx2[] = {
        { 0x08a9, 0x0014, "CWAV", "USBee AX", NULL,
                FIRMWARE_DIR "/fx2lafw-cwav-usbeeax.fw",
                0 },
+       /*
+        * CWAV USBee DX
+        * XZL-Studio DX
+        */
+       { 0x08a9, 0x0015, "CWAV", "USBee DX", NULL,
+               FIRMWARE_DIR "/fx2lafw-cwav-usbeedx.fw",
+               DEV_CAPS_16BIT },
 
        /*
         * CWAV USBee SX
@@ -662,11 +669,11 @@ static int receive_data(int fd, int revents, void *cb_data)
 
 static void abort_acquisition(struct context *ctx)
 {
-       unsigned int i;
+       int i;
 
        ctx->num_samples = -1;
 
-       for (i = 0; i < ctx->num_transfers; i++) {
+       for (i = ctx->num_transfers - 1; i >= 0; i--) {
                if (ctx->transfers[i])
                        libusb_cancel_transfer(ctx->transfers[i]);
        }
@@ -946,9 +953,9 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
                                2 | LIBUSB_ENDPOINT_IN, buf, size,
                                receive_transfer, ctx, timeout);
                if (libusb_submit_transfer(transfer) != 0) {
-                       /* TODO: Free them all. */
                        libusb_free_transfer(transfer);
                        g_free(buf);
+                       abort_acquisition(ctx);
                        return SR_ERR;
                }
                ctx->transfers[i] = transfer;
@@ -976,6 +983,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
 
        if ((ret = command_start_acquisition (ctx->usb->devhdl,
                ctx->cur_samplerate, ctx->sample_wide)) != SR_OK) {
+               abort_acquisition(ctx);
                return ret;
        }