]> sigrok.org Git - libsigrok.git/commitdiff
ols: Rename "flags" to "capture flags".
authorv1ne <redacted>
Tue, 31 Mar 2020 17:32:23 +0000 (19:32 +0200)
committerGerhard Sittig <redacted>
Mon, 24 Aug 2020 05:29:03 +0000 (07:29 +0200)
In the current implementation the "flags" are exclusively used for
captures. Prepare the introduction of device flags by renaming the
capture related flags which are specific to an operation.

Reviewed-By: Wolfram Sang <redacted>
src/hardware/openbench-logic-sniffer/api.c
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/openbench-logic-sniffer/protocol.h

index c8915fbbed3e316e1fbc8a14e363f9a200570bf6..3e632b4752d0ee020fba47fb534570f7dae62a79 100644 (file)
@@ -213,15 +213,15 @@ static int config_get(uint32_t key, GVariant **data,
                *data = g_variant_new_uint64(devc->limit_samples);
                break;
        case SR_CONF_PATTERN_MODE:
-               if (devc->flag_reg & FLAG_EXTERNAL_TEST_MODE)
+               if (devc->capture_flags & CAPTURE_FLAG_EXTERNAL_TEST_MODE)
                        *data = g_variant_new_string(STR_PATTERN_EXTERNAL);
-               else if (devc->flag_reg & FLAG_INTERNAL_TEST_MODE)
+               else if (devc->capture_flags & CAPTURE_FLAG_INTERNAL_TEST_MODE)
                        *data = g_variant_new_string(STR_PATTERN_INTERNAL);
                else
                        *data = g_variant_new_string(STR_PATTERN_NONE);
                break;
        case SR_CONF_RLE:
-               *data = g_variant_new_boolean(devc->flag_reg & FLAG_RLE ? TRUE : FALSE);
+               *data = g_variant_new_boolean(devc->capture_flags & CAPTURE_FLAG_RLE ? TRUE : FALSE);
                break;
        default:
                return SR_ERR_NA;
@@ -260,10 +260,10 @@ static int config_set(uint32_t key, GVariant *data,
        case SR_CONF_EXTERNAL_CLOCK:
                if (g_variant_get_boolean(data)) {
                        sr_info("Enabling external clock.");
-                       devc->flag_reg |= FLAG_CLOCK_EXTERNAL;
+                       devc->capture_flags |= CAPTURE_FLAG_CLOCK_EXTERNAL;
                } else {
                        sr_info("Disabled external clock.");
-                       devc->flag_reg &= ~FLAG_CLOCK_EXTERNAL;
+                       devc->capture_flags &= ~CAPTURE_FLAG_CLOCK_EXTERNAL;
                }
                break;
        case SR_CONF_PATTERN_MODE:
@@ -273,33 +273,33 @@ static int config_set(uint32_t key, GVariant *data,
                        flag = 0x0000;
                } else if (!strcmp(stropt, STR_PATTERN_INTERNAL)) {
                        sr_info("Enabling internal test mode.");
-                       flag = FLAG_INTERNAL_TEST_MODE;
+                       flag = CAPTURE_FLAG_INTERNAL_TEST_MODE;
                } else if (!strcmp(stropt, STR_PATTERN_EXTERNAL)) {
                        sr_info("Enabling external test mode.");
-                       flag = FLAG_EXTERNAL_TEST_MODE;
+                       flag = CAPTURE_FLAG_EXTERNAL_TEST_MODE;
                } else {
                        return SR_ERR;
                }
-               devc->flag_reg &= ~FLAG_INTERNAL_TEST_MODE;
-               devc->flag_reg &= ~FLAG_EXTERNAL_TEST_MODE;
-               devc->flag_reg |= flag;
+               devc->capture_flags &= ~CAPTURE_FLAG_INTERNAL_TEST_MODE;
+               devc->capture_flags &= ~CAPTURE_FLAG_EXTERNAL_TEST_MODE;
+               devc->capture_flags |= flag;
                break;
        case SR_CONF_SWAP:
                if (g_variant_get_boolean(data)) {
                        sr_info("Enabling channel swapping.");
-                       devc->flag_reg |= FLAG_SWAP_CHANNELS;
+                       devc->capture_flags |= CAPTURE_FLAG_SWAP_CHANNELS;
                } else {
                        sr_info("Disabling channel swapping.");
-                       devc->flag_reg &= ~FLAG_SWAP_CHANNELS;
+                       devc->capture_flags &= ~CAPTURE_FLAG_SWAP_CHANNELS;
                }
                break;
        case SR_CONF_RLE:
                if (g_variant_get_boolean(data)) {
                        sr_info("Enabling RLE.");
-                       devc->flag_reg |= FLAG_RLE;
+                       devc->capture_flags |= CAPTURE_FLAG_RLE;
                } else {
                        sr_info("Disabling RLE.");
-                       devc->flag_reg &= ~FLAG_RLE;
+                       devc->capture_flags &= ~CAPTURE_FLAG_RLE;
                }
                break;
        default:
@@ -332,7 +332,7 @@ static int config_list(uint32_t key, GVariant **data,
                if (!sdi)
                        return SR_ERR_ARG;
                devc = sdi->priv;
-               if (devc->flag_reg & FLAG_RLE)
+               if (devc->capture_flags & CAPTURE_FLAG_RLE)
                        return SR_ERR_NA;
                if (devc->max_samples == 0)
                        /* Device didn't specify sample memory size in metadata. */
@@ -492,18 +492,18 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
        /* Flag register. */
        sr_dbg("Setting intpat %s, extpat %s, RLE %s, noise_filter %s, demux %s",
-                       devc->flag_reg & FLAG_INTERNAL_TEST_MODE ? "on": "off",
-                       devc->flag_reg & FLAG_EXTERNAL_TEST_MODE ? "on": "off",
-                       devc->flag_reg & FLAG_RLE ? "on" : "off",
-                       devc->flag_reg & FLAG_FILTER ? "on": "off",
-                       devc->flag_reg & FLAG_DEMUX ? "on" : "off");
+                       devc->capture_flags & CAPTURE_FLAG_INTERNAL_TEST_MODE ? "on": "off",
+                       devc->capture_flags & CAPTURE_FLAG_EXTERNAL_TEST_MODE ? "on": "off",
+                       devc->capture_flags & CAPTURE_FLAG_RLE ? "on" : "off",
+                       devc->capture_flags & CAPTURE_FLAG_NOISE_FILTER ? "on": "off",
+                       devc->capture_flags & CAPTURE_FLAG_DEMUX ? "on" : "off");
        /*
         * Enable/disable OLS channel groups in the flag register according
         * to the channel mask. 1 means "disable channel".
         */
-       devc->flag_reg |= ~(ols_changrp_mask << 2) & 0x3c;
-       arg[0] = devc->flag_reg & 0xff;
-       arg[1] = devc->flag_reg >> 8;
+       devc->capture_flags |= ~(ols_changrp_mask << 2) & 0x3c;
+       arg[0] = devc->capture_flags & 0xff;
+       arg[1] = devc->capture_flags >> 8;
        arg[2] = arg[3] = 0x00;
        if (send_longcommand(serial, CMD_SET_FLAGS, arg) != SR_OK)
                return SR_ERR;
index a1b168062fb3bef990b39a2e77d22a1ffa091087..0a2bc4dd60b999903a2963ce9ebff6fdc4504dcd 100644 (file)
@@ -322,13 +322,13 @@ SR_PRIV int ols_set_samplerate(const struct sr_dev_inst *sdi,
 
        if (samplerate > CLOCK_RATE) {
                sr_info("Enabling demux mode.");
-               devc->flag_reg |= FLAG_DEMUX;
-               devc->flag_reg &= ~FLAG_FILTER;
+               devc->capture_flags |= CAPTURE_FLAG_DEMUX;
+               devc->capture_flags &= ~CAPTURE_FLAG_NOISE_FILTER;
                devc->cur_samplerate_divider = (CLOCK_RATE * 2 / samplerate) - 1;
        } else {
                sr_info("Disabling demux mode.");
-               devc->flag_reg &= ~FLAG_DEMUX;
-               devc->flag_reg |= FLAG_FILTER;
+               devc->capture_flags &= ~CAPTURE_FLAG_DEMUX;
+               devc->capture_flags |= CAPTURE_FLAG_NOISE_FILTER;
                devc->cur_samplerate_divider = (CLOCK_RATE / samplerate) - 1;
        }
 
@@ -336,7 +336,7 @@ SR_PRIV int ols_set_samplerate(const struct sr_dev_inst *sdi,
         * from the requested.
         */
        devc->cur_samplerate = CLOCK_RATE / (devc->cur_samplerate_divider + 1);
-       if (devc->flag_reg & FLAG_DEMUX)
+       if (devc->capture_flags & CAPTURE_FLAG_DEMUX)
                devc->cur_samplerate *= 2;
        if (devc->cur_samplerate != samplerate)
                sr_info("Can't match samplerate %" PRIu64 ", using %"
@@ -390,7 +390,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
 
        num_ols_changrp = 0;
        for (i = 0x20; i > 0x02; i >>= 1) {
-               if ((devc->flag_reg & i) == 0) {
+               if ((devc->capture_flags & i) == 0) {
                        num_ols_changrp++;
                }
        }
@@ -416,7 +416,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
                        sample = devc->sample[0] | (devc->sample[1] << 8) \
                                        | (devc->sample[2] << 16) | (devc->sample[3] << 24);
                        sr_dbg("Received sample 0x%.*x.", devc->num_bytes * 2, sample);
-                       if (devc->flag_reg & FLAG_RLE) {
+                       if (devc->capture_flags & CAPTURE_FLAG_RLE) {
                                /*
                                 * In RLE mode the high bit of the sample is the
                                 * "count" flag, meaning this sample is the number
@@ -452,14 +452,14 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
                                j = 0;
                                memset(devc->tmp_sample, 0, 4);
                                for (i = 0; i < 4; i++) {
-                                       if (((devc->flag_reg >> 2) & (1 << i)) == 0) {
+                                       if (((devc->capture_flags >> 2) & (1 << i)) == 0) {
                                                /*
                                                 * This channel group was
                                                 * enabled, copy from received
                                                 * sample.
                                                 */
                                                devc->tmp_sample[i] = devc->sample[j++];
-                                       } else if (devc->flag_reg & FLAG_DEMUX && (i > 2)) {
+                                       } else if (devc->capture_flags & CAPTURE_FLAG_DEMUX && (i > 2)) {
                                                /* group 2 & 3 get added to 0 & 1 */
                                                devc->tmp_sample[i - 2] = devc->sample[j++];
                                        }
index 2303c3fd21998f0c8dc03d325a6e9808e0cd7285..fa78ca79a1ea9c624e5a1644b729796f5c7580cb 100644 (file)
 /* Trigger config */
 #define TRIGGER_START              (1 << 3)
 
-/* Bitmasks for CMD_FLAGS */
+/* Bitmasks for capture_flags */
 /* 12-13 unused, 14-15 RLE mode (we hardcode mode 0). */
-#define FLAG_INTERNAL_TEST_MODE    (1 << 11)
-#define FLAG_EXTERNAL_TEST_MODE    (1 << 10)
-#define FLAG_SWAP_CHANNELS         (1 << 9)
-#define FLAG_RLE                   (1 << 8)
-#define FLAG_SLOPE_FALLING         (1 << 7)
-#define FLAG_CLOCK_EXTERNAL        (1 << 6)
-#define FLAG_CHANNELGROUP_4        (1 << 5)
-#define FLAG_CHANNELGROUP_3        (1 << 4)
-#define FLAG_CHANNELGROUP_2        (1 << 3)
-#define FLAG_CHANNELGROUP_1        (1 << 2)
-#define FLAG_FILTER                (1 << 1)
-#define FLAG_DEMUX                 (1 << 0)
+#define CAPTURE_FLAG_INTERNAL_TEST_MODE (1 << 11)
+#define CAPTURE_FLAG_EXTERNAL_TEST_MODE (1 << 10)
+#define CAPTURE_FLAG_SWAP_CHANNELS      (1 << 9)
+#define CAPTURE_FLAG_RLE                (1 << 8)
+#define CAPTURE_FLAG_SLOPE_FALLING      (1 << 7)
+#define CAPTURE_FLAG_CLOCK_EXTERNAL     (1 << 6)
+#define CAPTURE_FLAG_CHANNELGROUP_4     (1 << 5)
+#define CAPTURE_FLAG_CHANNELGROUP_3     (1 << 4)
+#define CAPTURE_FLAG_CHANNELGROUP_2     (1 << 3)
+#define CAPTURE_FLAG_CHANNELGROUP_1     (1 << 2)
+#define CAPTURE_FLAG_NOISE_FILTER       (1 << 1)
+#define CAPTURE_FLAG_DEMUX              (1 << 0)
 
 /* Capture context magic numbers */
 #define OLS_NO_TRIGGER (-1)
@@ -85,7 +85,7 @@ struct dev_context {
        uint32_t trigger_mask[NUM_TRIGGER_STAGES];
        uint32_t trigger_value[NUM_TRIGGER_STAGES];
        int num_stages;
-       uint16_t flag_reg;
+       uint16_t capture_flags;
 
        unsigned int num_transfers;
        unsigned int num_samples;