From: Gerhard Sittig Date: Mon, 31 Jan 2022 21:38:01 +0000 (+0100) Subject: kingst-la2016: extend model support (100/500 MHz, 32 channels) X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4276ca94b607b97dba44a8a6413426a31ff9df47;p=libsigrok.git kingst-la2016: extend model support (100/500 MHz, 32 channels) 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. --- diff --git a/src/hardware/kingst-la2016/api.c b/src/hardware/kingst-la2016/api.c index d9cb9b19..243b3ab1 100644 --- a/src/hardware/kingst-la2016/api.c +++ b/src/hardware/kingst-la2016/api.c @@ -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; diff --git a/src/hardware/kingst-la2016/protocol.c b/src/hardware/kingst-la2016/protocol.c index 6ab72df0..d5ac7d2c 100644 --- a/src/hardware/kingst-la2016/protocol.c +++ b/src/hardware/kingst-la2016/protocol.c @@ -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,