]> sigrok.org Git - libsigrok.git/commitdiff
openbench-logic-sniffer: Properly set samplerate range
authorKen Taylor <redacted>
Sat, 7 Oct 2023 09:02:12 +0000 (02:02 -0700)
committerSoeren Apel <redacted>
Mon, 19 Aug 2024 21:02:52 +0000 (23:02 +0200)
Driver does query max_samplerate from SUMP metadata,
but previously replied to SR_CONF_SAMPLERATE with fixed
1Hz-200MHz range. Update to use max_samplerate as top
of range.

May fix http://sigrok.org/bugzilla/show_bug.cgi?id=1465

src/hardware/openbench-logic-sniffer/api.c

index b644c9232193cfc9731a7a3096976b6f29fa7196..988a157abd93913df9f41af7b693ea190370a5e1 100644 (file)
@@ -383,6 +383,9 @@ static int config_list(uint32_t key, GVariant **data,
 {
        struct dev_context *devc;
        int num_ols_changrp, i;
+       uint64_t samplerates_ovrd[3];
+
+       devc = (sdi) ? sdi->priv : NULL;
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
@@ -390,7 +393,14 @@ static int config_list(uint32_t key, GVariant **data,
                return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts,
                                       devopts);
        case SR_CONF_SAMPLERATE:
-               *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
+               if (!devc)
+                       return SR_ERR_ARG;
+               samplerates_ovrd[0] = samplerates[0];
+               samplerates_ovrd[1] = samplerates[1];
+               samplerates_ovrd[2] = samplerates[2];
+               if (devc->max_samplerate)
+                       samplerates_ovrd[1] = devc->max_samplerate;
+               *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates_ovrd));
                break;
        case SR_CONF_TRIGGER_MATCH:
                *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));