]> sigrok.org Git - libsigrok.git/commitdiff
zeroplus: Only report supported samplerates.
authorUwe Hermann <redacted>
Fri, 8 Feb 2013 22:13:33 +0000 (23:13 +0100)
committerUwe Hermann <redacted>
Fri, 8 Feb 2013 22:19:50 +0000 (23:19 +0100)
The currently supported model LAP-C(16032) doesn't support the
samplerates 150MHz and 200MHz which some of the other models have.

Thus, do not report these samplerates to the frontends. E.g. sigrok-cli
should not show them via --show and GUIs should not list them in their
"Samplerates" drop-down.

hardware/zeroplus-logic-cube/api.c
hardware/zeroplus-logic-cube/protocol.c
hardware/zeroplus-logic-cube/protocol.h

index 4503e36b1d6d9b0171dc1662e25ccb4551a181f6..27ed1cce9e7d3f7746fa7dfec9ebc5c4053b75a5 100644 (file)
@@ -80,11 +80,27 @@ static struct sr_dev_driver *di = &zeroplus_logic_cube_driver_info;
  * options hardcoded into the vendor's Windows GUI.
  */
 
-/*
- * TODO: We shouldn't support 150MHz and 200MHz on devices that don't go up
- * that high.
- */
-const uint64_t zp_supported_samplerates[] = {
+static const uint64_t zp_supported_samplerates_100[] = {
+       SR_HZ(100),
+       SR_HZ(500),
+       SR_KHZ(1),
+       SR_KHZ(5),
+       SR_KHZ(25),
+       SR_KHZ(50),
+       SR_KHZ(100),
+       SR_KHZ(200),
+       SR_KHZ(400),
+       SR_KHZ(800),
+       SR_MHZ(1),
+       SR_MHZ(10),
+       SR_MHZ(25),
+       SR_MHZ(50),
+       SR_MHZ(80),
+       SR_MHZ(100),
+       0,
+};
+
+const uint64_t zp_supported_samplerates_200[] = {
        SR_HZ(100),
        SR_HZ(500),
        SR_KHZ(1),
@@ -106,11 +122,18 @@ const uint64_t zp_supported_samplerates[] = {
        0,
 };
 
-static const struct sr_samplerates samplerates = {
+static const struct sr_samplerates samplerates_100 = {
        .low  = 0,
        .high = 0,
        .step = 0,
-       .list = zp_supported_samplerates,
+       .list = zp_supported_samplerates_100,
+};
+
+static const struct sr_samplerates samplerates_200 = {
+       .low  = 0,
+       .high = 0,
+       .step = 0,
+       .list = zp_supported_samplerates_200,
 };
 
 static int hw_dev_close(struct sr_dev_inst *sdi);
@@ -295,6 +318,7 @@ static GSList *hw_scan(GSList *options)
                }
 
                sdi->priv = devc;
+               devc->prof = prof;
                devc->num_channels = prof->channels;
 #ifdef ZP_EXPERIMENTAL
                devc->max_memory_size = 128 * 1024;
@@ -512,14 +536,23 @@ static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
 
 static int config_list(int key, const void **data, const struct sr_dev_inst *sdi)
 {
-       (void)sdi;
+       struct dev_context *devc;
 
        switch (key) {
        case SR_CONF_DEVICE_OPTIONS:
                *data = hwcaps;
                break;
        case SR_CONF_SAMPLERATE:
-               *data = &samplerates;
+               devc = sdi->priv;
+               if (devc->prof->max_sampling_freq == 100) {
+                       *data = &samplerates_100;
+               } else if (devc->prof->max_sampling_freq == 200) {
+                       *data = &samplerates_200;
+               } else {
+                       sr_err("Internal error: Unknown max. samplerate: %d.",
+                              devc->prof->max_sampling_freq);
+                       return SR_ERR_ARG;
+               }
                break;
        case SR_CONF_TRIGGER_TYPE:
                *data = TRIGGER_TYPE;
index 92bb32bf11e3b65ef8ac70329c4c8ae1e67fa137..268be5dd9fea5f4d88f21c2b42e9a3a7ddb38803 100644 (file)
@@ -37,11 +37,11 @@ SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate)
 {
        int i;
 
-       for (i = 0; zp_supported_samplerates[i]; i++)
-               if (samplerate == zp_supported_samplerates[i])
+       for (i = 0; zp_supported_samplerates_200[i]; i++)
+               if (samplerate == zp_supported_samplerates_200[i])
                        break;
 
-       if (!zp_supported_samplerates[i] || samplerate > devc->max_samplerate) {
+       if (!zp_supported_samplerates_200[i] || samplerate > devc->max_samplerate) {
                sr_err("Unsupported samplerate: %" PRIu64 "Hz.", samplerate);
                return SR_ERR_ARG;
        }
index 7e34c5d34f58228d738133cd7e6e98ca382fbc40..30b217dac12a3f3a44323a13bc33e529f99d2516 100644 (file)
@@ -52,9 +52,10 @@ struct dev_context {
        int trigger;
        unsigned int capture_ratio;
        struct sr_usb_dev_inst *usb;
+       const struct zp_model *prof;
 };
 
-extern const uint64_t zp_supported_samplerates[];
+extern const uint64_t zp_supported_samplerates_200[];
 
 SR_PRIV unsigned int get_memory_size(int type);
 SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate);