]> sigrok.org Git - libsigrok.git/commitdiff
kingst-la2016: extend model support (100/500 MHz, 32 channels)
authorGerhard Sittig <redacted>
Mon, 31 Jan 2022 21:38:01 +0000 (22:38 +0100)
committerGerhard Sittig <redacted>
Sun, 6 Feb 2022 17:53:54 +0000 (18:53 +0100)
Extend the code paths which handle supported samplerates and channel
counts. Explicitly test for 100/200/500 MHz rate, and 16/32 channels.
Raise errors for unexpected configurations. Keep all internal data in
32bit wide entities. Pick a suitable unitsize for logic data at runtime
depending on the detected model.

The capture data memory layout for 32 channel devices is yet to get
verified. The implementation is based on an educated guess only.

src/hardware/kingst-la2016/api.c
src/hardware/kingst-la2016/protocol.c

index d9cb9b19e0ebf6e95dc7f3f346c458a784c60627..243b3ab1348fba0f9110d2c7c3e32b8788dec37f 100644 (file)
@@ -974,8 +974,10 @@ static int config_list(uint32_t key, GVariant **data,
                        *data = std_gvar_samplerates(ARRAY_AND_SIZE(rates_500mhz));
                else if (devc->model->samplerate == SR_MHZ(200))
                        *data = std_gvar_samplerates(ARRAY_AND_SIZE(rates_200mhz));
-               else
+               else if (devc->model->samplerate == SR_MHZ(100))
                        *data = std_gvar_samplerates(ARRAY_AND_SIZE(rates_100mhz));
+               else
+                       return SR_ERR_BUG;
                break;
        case SR_CONF_LIMIT_SAMPLES:
                *data = std_gvar_tuple_u64(0, LA2016_NUM_SAMPLES_MAX);
@@ -1001,6 +1003,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        struct drv_context *drvc;
        struct sr_context *ctx;
        struct dev_context *devc;
+       size_t unitsize;
        double voltage;
        int ret;
 
@@ -1010,8 +1013,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        devc = sdi->priv;
 
        if (!devc->feed_queue) {
+               if (devc->model->channel_count == 32)
+                       unitsize = sizeof(uint32_t);
+               else if (devc->model->channel_count == 16)
+                       unitsize = sizeof(uint16_t);
+               else
+                       return SR_ERR_ARG;
                devc->feed_queue = feed_queue_logic_alloc(sdi,
-                       LA2016_CONVBUFFER_SIZE, sizeof(uint16_t));
+                       LA2016_CONVBUFFER_SIZE, unitsize);
                if (!devc->feed_queue) {
                        sr_err("Cannot allocate buffer for session feed.");
                        return SR_ERR_MALLOC;
index 6ab72df02ecc517992a758c798fe50a80b97d53b..d5ac7d2c635daf3cdf4ecd33631f40b28e5390a3 100644 (file)
@@ -499,9 +499,9 @@ static int set_pwm_config(const struct sr_dev_inst *sdi, size_t idx)
        return SR_OK;
 }
 
-static uint16_t get_channels_mask(const struct sr_dev_inst *sdi)
+static uint32_t get_channels_mask(const struct sr_dev_inst *sdi)
 {
-       uint16_t channels;
+       uint32_t channels;
        GSList *l;
        struct sr_channel *ch;
 
@@ -532,7 +532,7 @@ static int set_trigger_config(const struct sr_dev_inst *sdi)
        GSList *channel;
        struct sr_trigger_stage *stage1;
        struct sr_trigger_match *match;
-       uint16_t ch_mask;
+       uint32_t ch_mask;
        int ret;
        uint8_t buf[REG_UNKNOWN_30 - REG_TRIGGER]; /* Width of REG_TRIGGER. */
        uint8_t *wrptr;
@@ -1056,7 +1056,7 @@ static void send_chunk(struct sr_dev_inst *sdi,
        struct dev_context *devc;
        size_t num_pkts;
        const uint8_t *rp;
-       uint16_t sample_value;
+       uint32_t sample_value;
        size_t repetitions;
        uint8_t sample_buff[sizeof(sample_value)];
 
@@ -1071,17 +1071,23 @@ static void send_chunk(struct sr_dev_inst *sdi,
                devc->trigger_marked = TRUE;
        }
 
+       sample_value = 0;
        rp = packets;
        while (num_xfers--) {
+               /* XXX model dependent? 5 or 3? */
                num_pkts = NUM_PACKETS_IN_CHUNK;
                while (num_pkts--) {
 
-                       sample_value = read_u16le_inc(&rp);
+                       /* TODO Verify 32channel layout. */
+                       if (devc->model->channel_count == 32)
+                               sample_value = read_u32le_inc(&rp);
+                       else if (devc->model->channel_count == 16)
+                               sample_value = read_u16le_inc(&rp);
                        repetitions = read_u8_inc(&rp);
 
                        devc->total_samples += repetitions;
 
-                       write_u16le(sample_buff, sample_value);
+                       write_u32le(sample_buff, sample_value);
                        feed_queue_logic_submit(devc->feed_queue,
                                sample_buff, repetitions);
                        sr_sw_limits_update_samples_read(&devc->sw_limits,