]> sigrok.org Git - libsigrok.git/commitdiff
ols: refactor using max_channels
authorWolfram Sang <redacted>
Wed, 2 Jan 2019 12:15:20 +0000 (13:15 +0100)
committerUwe Hermann <redacted>
Sun, 13 Jan 2019 19:07:27 +0000 (20:07 +0100)
Let max_channels really carry the number of maximum channels the
hardware supports. We will handle the limitation of only half the
channels available in 200MHz mode later. Note that there won't be a
regression because we only set the variable but never check it. The
desired result of this patch is the removal of the NUM_CHANNELS macro.
The number of channels needs to be dealt with at runtime.

Signed-off-by: Wolfram Sang <redacted>
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/openbench-logic-sniffer/protocol.h

index 0a9a34a204e6bcb9e13ebc9586cd9b52e57e575b..b9383ddd1e440d50b582980163d926fb9f9f3035 100644 (file)
@@ -148,11 +148,14 @@ SR_PRIV struct dev_context *ols_dev_new(void)
 
 static void ols_channel_new(struct sr_dev_inst *sdi, int num_chan)
 {
+       struct dev_context *devc = sdi->priv;
        int i;
 
        for (i = 0; i < num_chan; i++)
                sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE,
                                ols_channel_names[i]);
+
+       devc->max_channels = num_chan;
 }
 
 SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
@@ -303,13 +306,11 @@ SR_PRIV int ols_set_samplerate(const struct sr_dev_inst *sdi,
                sr_info("Enabling demux mode.");
                devc->flag_reg |= FLAG_DEMUX;
                devc->flag_reg &= ~FLAG_FILTER;
-               devc->max_channels = NUM_CHANNELS / 2;
                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->max_channels = NUM_CHANNELS;
                devc->cur_samplerate_divider = (CLOCK_RATE / samplerate) - 1;
        }
 
index e8e7574ce123a84c438d218f346e80f3b6de764c..1ec671a4d9820c21a08c4fbf9585170a31e702eb 100644 (file)
@@ -28,7 +28,6 @@
 
 #define LOG_PREFIX "openbench-logic-sniffer"
 
-#define NUM_CHANNELS               32
 #define NUM_TRIGGER_STAGES         4
 #define CLOCK_RATE                 SR_MHZ(100)
 #define MIN_NUM_SAMPLES            4