]> sigrok.org Git - libsigrok.git/blobdiff - hardware/openbench-logic-sniffer/ols.c
Changed SR_T_NULL to SR_T_BOOL and adjusted RLE option.
[libsigrok.git] / hardware / openbench-logic-sniffer / ols.c
index 7308d8b2063ae4701e0da19c197b98d77e541cc1..57881f838c9a061b6a0da4615c2737069c929092 100644 (file)
@@ -554,8 +554,6 @@ static int set_configuration_samplerate(struct sr_device_instance *sdi,
        } else if (samplerate < samplerates.low || samplerate > samplerates.high)
                return SR_ERR_SAMPLERATE;
 
-       ols->cur_samplerate = samplerate;
-       ols->period_ps = 1000000000000 / samplerate;
        if (samplerate > CLOCK_RATE) {
                ols->flag_reg |= FLAG_DEMUX;
                ols->cur_samplerate_divider = (CLOCK_RATE * 2 / samplerate) - 1;
@@ -564,6 +562,17 @@ static int set_configuration_samplerate(struct sr_device_instance *sdi,
                ols->cur_samplerate_divider = (CLOCK_RATE / samplerate) - 1;
        }
 
+       /* Calculate actual samplerate used and complain if it is different
+        * from the requested.
+        */
+       ols->cur_samplerate = CLOCK_RATE / (ols->cur_samplerate_divider + 1);
+       if(ols->flag_reg & FLAG_DEMUX)
+               ols->cur_samplerate *= 2;
+       ols->period_ps = 1000000000000 / ols->cur_samplerate;
+       if(ols->cur_samplerate != samplerate)
+               sr_warn("ols: can't match samplerate %" PRIu64 ", using %" PRIu64, 
+                       samplerate, ols->cur_samplerate);
+
        return SR_OK;
 }
 
@@ -609,7 +618,7 @@ static int hw_set_configuration(int device_index, int capability, void *value)
                        ret = SR_OK;
                break;
        case SR_HWCAP_RLE:
-               if (!strcmp(value, "on")) {
+               if (GPOINTER_TO_INT(value)) {
                        sr_info("ols: enabling RLE");
                        ols->flag_reg |= FLAG_RLE;
                }