]> sigrok.org Git - libsigrok.git/commitdiff
fx2lafw: Use wide_sampling only if necessary.
authorJan Losinski <redacted>
Thu, 12 Jan 2017 03:45:08 +0000 (04:45 +0100)
committerUwe Hermann <redacted>
Tue, 14 Mar 2017 23:26:49 +0000 (00:26 +0100)
This changes the fx2lafw code to only enable the wide_sampling (16bit)
method, if at least one of the higher eight channels is enabled. This
has the benefit, that we can use higher samplerates on 16bit LA
devices if we use only the first eight channels.

The wide sampling is also enabled if we have one or more analog
channels.

Signed-off-by: Jan Losinski <redacted>
src/hardware/fx2lafw/api.c

index 370b1c0ea808670e988536fe87491768836c7b9b..4e4c3cfabce53befad346ec69a8e22773056b9c7 100644 (file)
@@ -383,8 +383,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
                devc = fx2lafw_dev_new();
                devc->profile = prof;
 
                devc = fx2lafw_dev_new();
                devc->profile = prof;
-               if ((prof->dev_caps & DEV_CAPS_16BIT) || (prof->dev_caps & DEV_CAPS_AX_ANALOG))
-                       devc->sample_wide = TRUE;
                sdi->priv = devc;
                devices = g_slist_append(devices, sdi);
 
                sdi->priv = devc;
                devices = g_slist_append(devices, sdi);
 
@@ -981,6 +979,7 @@ static int configure_channels(const struct sr_dev_inst *sdi)
        const GSList *l;
        int p;
        struct sr_channel *ch;
        const GSList *l;
        int p;
        struct sr_channel *ch;
+       uint32_t channel_mask = 0, num_analog = 0;
 
        devc = sdi->priv;
 
 
        devc = sdi->priv;
 
@@ -991,12 +990,18 @@ 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)) {
        for (l = sdi->channels, p = 0; l; l = l->next, p++) {
                ch = l->data;
                if ((p <= NUM_CHANNELS) && (ch->type == SR_CHANNEL_ANALOG)) {
+                       num_analog++;
                        devc->ch_enabled[p] = ch->enabled;
                        devc->enabled_analog_channels =
                            g_slist_append(devc->enabled_analog_channels, ch);
                        devc->ch_enabled[p] = ch->enabled;
                        devc->enabled_analog_channels =
                            g_slist_append(devc->enabled_analog_channels, ch);
+               } else {
+                       channel_mask |= ch->enabled << p;
                }
        }
 
                }
        }
 
+       /* Use no wide sampling if we have only the first 8 channels set. */
+       devc->sample_wide = (channel_mask > 0xff || num_analog > 0);
+
        return SR_OK;
 }
 
        return SR_OK;
 }