]> sigrok.org Git - libsigrok.git/commitdiff
fx2lafw: Only sample/send analog data if analog channels are enabled.
authorUwe Hermann <redacted>
Wed, 15 Mar 2017 01:31:09 +0000 (02:31 +0100)
committerUwe Hermann <redacted>
Wed, 15 Mar 2017 02:30:11 +0000 (03:30 +0100)
src/hardware/fx2lafw/api.c
src/hardware/fx2lafw/protocol.c

index 872804ec67f5493b4857f9ae41469d72d77077ba..1ad9bedc56b3b18e83096d7b646c24510f3fc497 100644 (file)
@@ -878,7 +878,12 @@ static int start_transfers(const struct sr_dev_inst *sdi)
                devc->submitted_transfers++;
        }
 
-       if (devc->profile->dev_caps & DEV_CAPS_AX_ANALOG)
+       /*
+        * If this device has analog channels and at least one of them is
+        * enabled, use mso_send_data_proc() to properly handle the analog
+        * data. Otherwise use la_send_data_proc().
+        */
+       if (g_slist_length(devc->enabled_analog_channels) > 0)
                devc->send_data_proc = mso_send_data_proc;
        else
                devc->send_data_proc = la_send_data_proc;
@@ -988,7 +993,8 @@ static int configure_channels(const struct sr_dev_inst *sdi)
 
        for (l = sdi->channels, p = 0; l; l = l->next, p++) {
                ch = l->data;
-               if ((p <= NUM_CHANNELS) && (ch->type == SR_CHANNEL_ANALOG)) {
+               if ((p <= NUM_CHANNELS) && (ch->type == SR_CHANNEL_ANALOG)
+                               && (ch->enabled)) {
                        num_analog++;
                        devc->enabled_analog_channels =
                            g_slist_append(devc->enabled_analog_channels, ch);
@@ -997,7 +1003,10 @@ static int configure_channels(const struct sr_dev_inst *sdi)
                }
        }
 
-       /* Use no wide sampling if we have only the first 8 channels set. */
+       /*
+        * Use wide sampling if either any of the LA channels 8..15 is enabled
+        * and/or at least one analog channel is enabled.
+        */
        devc->sample_wide = (channel_mask > 0xff || num_analog > 0);
 
        return SR_OK;
@@ -1036,7 +1045,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        } else {
                size = fx2lafw_get_buffer_size(devc);
                /* Prepare for analog sampling. */
-               if (devc->profile->dev_caps & DEV_CAPS_AX_ANALOG) {
+               if (g_slist_length(devc->enabled_analog_channels) > 0) {
                        /* We need a buffer half the size of a transfer. */
                        devc->logic_buffer = g_try_malloc(size / 2);
                        devc->analog_buffer = g_try_malloc(
index 70186518b6d5ade6b983a7b70f66ce8e1fd4eb9a..e2112af13abc6d96a0f1893f60451d0e04e22d72 100644 (file)
@@ -126,7 +126,7 @@ SR_PRIV int fx2lafw_command_start_acquisition(const struct sr_dev_inst *sdi)
        cmd.flags |= devc->sample_wide ? CMD_START_FLAGS_SAMPLE_16BIT :
                CMD_START_FLAGS_SAMPLE_8BIT;
        /* Enable CTL2 clock. */
-       cmd.flags |= (devc->profile->dev_caps & DEV_CAPS_AX_ANALOG) ? CMD_START_FLAGS_CLK_CTL2 : 0;
+       cmd.flags |= (g_slist_length(devc->enabled_analog_channels) > 0) ? CMD_START_FLAGS_CLK_CTL2 : 0;
 
        /* Send the control message. */
        ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
@@ -338,9 +338,11 @@ static void finish_acquisition(struct sr_dev_inst *sdi)
        devc->num_transfers = 0;
        g_free(devc->transfers);
 
-       /* Free the deinterlace buffers if we had them */
-       g_free(devc->logic_buffer);
-       g_free(devc->analog_buffer);
+       /* Free the deinterlace buffers if we had them. */
+       if (g_slist_length(devc->enabled_analog_channels) > 0) {
+               g_free(devc->logic_buffer);
+               g_free(devc->analog_buffer);
+       }
 
        if (devc->stl) {
                soft_trigger_logic_free(devc->stl);