]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/beaglelogic/api.c
drivers: SR_CONF_CAPTURE_RATIO fixes.
[libsigrok.git] / src / hardware / beaglelogic / api.c
index e904833da69d3095e4131b8e30bbdae697862692..2f632e7c6493782d9ffd32bc7d410b41a560182f 100644 (file)
@@ -38,7 +38,7 @@ static const uint32_t devopts[] = {
        SR_CONF_NUM_LOGIC_CHANNELS | SR_CONF_GET,
 };
 
-static const int32_t soft_trigger_matches[] = {
+static const int32_t trigger_matches[] = {
        SR_TRIGGER_ZERO,
        SR_TRIGGER_ONE,
        SR_TRIGGER_RISING,
@@ -169,8 +169,8 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_get(uint32_t key, GVariant **data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc = sdi->priv;
 
@@ -196,8 +196,8 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
        return SR_OK;
 }
 
-static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_set(uint32_t key, GVariant *data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        struct dev_context *devc = sdi->priv;
        uint64_t tmp_u64;
@@ -227,9 +227,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
                return beaglelogic_set_triggerflags(devc);
        case SR_CONF_CAPTURE_RATIO:
                devc->capture_ratio = g_variant_get_uint64(data);
-               if (devc->capture_ratio > 100)
-                       return SR_ERR;
-               return SR_OK;
+               break;
        default:
                return SR_ERR_NA;
        }
@@ -237,20 +235,18 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        return SR_OK;
 }
 
-static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_channel_group *cg)
+static int config_list(uint32_t key, GVariant **data,
+       const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
 {
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
        case SR_CONF_DEVICE_OPTIONS:
                return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
        case SR_CONF_SAMPLERATE:
-               *data = std_gvar_samplerates_steps(samplerates, ARRAY_SIZE(samplerates));
+               *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates));
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches),
-                               sizeof(int32_t));
+               *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
                break;
        default:
                return SR_ERR_NA;
@@ -281,7 +277,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        if ((trigger = sr_session_trigger_get(sdi->session))) {
                int pre_trigger_samples = 0;
                if (devc->limit_samples > 0)
-                       pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100;
+                       pre_trigger_samples = (devc->capture_ratio * devc->limit_samples) / 100;
                devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples);
                if (!devc->stl)
                        return SR_ERR_MALLOC;