From: Gerhard Sittig Date: Sun, 15 Oct 2023 08:08:11 +0000 (+0200) Subject: feed_queue: rename routines for submission of a single sample value X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=f40d8479b0cccf031feb0fc52b19333e85a9c4b3 feed_queue: rename routines for submission of a single sample value Common feed queue support originated from input module RLE compression. Its API would accept a single sample value and optionally repeat that value several times. Rename the routines and its parameter for improved awareness. Adjust existing callers: The asix-omega, atorch, kingst-la, rdtech-tc, and rdtech-um acquisition device drivers, as well as the protocoldata, stf, and vcd input modules. See a word diff for the essence of the change. --- diff --git a/src/hardware/asix-omega-rtm-cli/protocol.c b/src/hardware/asix-omega-rtm-cli/protocol.c index e72036bf..d7434951 100644 --- a/src/hardware/asix-omega-rtm-cli/protocol.c +++ b/src/hardware/asix-omega-rtm-cli/protocol.c @@ -215,7 +215,7 @@ static int omega_rtm_cli_process_rawdata(const struct sr_dev_inst *sdi) devc->samples.remain_count -= count; } if (count) { - ret = feed_queue_logic_submit(devc->samples.queue, + ret = feed_queue_logic_submit_one(devc->samples.queue, devc->samples.last_sample, count); if (ret != SR_OK) break; @@ -229,13 +229,13 @@ static int omega_rtm_cli_process_rawdata(const struct sr_dev_inst *sdi) * hand because future chunks might repeat it. */ write_u16le(devc->samples.last_sample, sample1); - ret = feed_queue_logic_submit(devc->samples.queue, + ret = feed_queue_logic_submit_one(devc->samples.queue, devc->samples.last_sample, 1); if (ret != SR_OK) break; write_u16le(devc->samples.last_sample, sample2); - ret = feed_queue_logic_submit(devc->samples.queue, + ret = feed_queue_logic_submit_one(devc->samples.queue, devc->samples.last_sample, 1); if (ret != SR_OK) break; diff --git a/src/hardware/atorch/protocol.c b/src/hardware/atorch/protocol.c index 53f03313..595e619b 100644 --- a/src/hardware/atorch/protocol.c +++ b/src/hardware/atorch/protocol.c @@ -183,7 +183,7 @@ static void parse_report_msg(struct sr_dev_inst *sdi, const uint8_t *report_ptr) for (i = 0; i < devc->profile->channel_count; i++) { bv_get_value(&val, &devc->profile->channels[i].spec, report_ptr); - feed_queue_analog_submit(devc->feeds[i], val, 1); + feed_queue_analog_submit_one(devc->feeds[i], val, 1); } std_session_send_df_frame_end(sdi); diff --git a/src/hardware/kingst-la2016/protocol.c b/src/hardware/kingst-la2016/protocol.c index ace0cd51..dd806eaa 100644 --- a/src/hardware/kingst-la2016/protocol.c +++ b/src/hardware/kingst-la2016/protocol.c @@ -1391,7 +1391,7 @@ static void send_chunk(struct sr_dev_inst *sdi, devc->total_samples += repetitions; write_u32le(sample_buff, sample_value); - feed_queue_logic_submit(devc->feed_queue, + feed_queue_logic_submit_one(devc->feed_queue, sample_buff, repetitions); sr_sw_limits_update_samples_read(&devc->sw_limits, repetitions); @@ -1508,7 +1508,8 @@ static void stream_data(struct sr_dev_inst *sdi, for (bit_idx = 0; bit_idx < bit_count; bit_idx++) { sample_value = stream->sample_data[bit_idx]; write_u32le(sample_buff, sample_value); - feed_queue_logic_submit(devc->feed_queue, sample_buff, 1); + feed_queue_logic_submit_one(devc->feed_queue, + sample_buff, 1); } sr_sw_limits_update_samples_read(&devc->sw_limits, bit_count); devc->total_samples += bit_count; diff --git a/src/hardware/rdtech-tc/protocol.c b/src/hardware/rdtech-tc/protocol.c index 99297ba6..291604a0 100644 --- a/src/hardware/rdtech-tc/protocol.c +++ b/src/hardware/rdtech-tc/protocol.c @@ -268,7 +268,7 @@ static int handle_poll_data(struct sr_dev_inst *sdi) ret = bv_get_value_len(&v, &pch->spec, poll_pkt, TC_POLL_LEN); if (ret != SR_OK) break; - ret = feed_queue_analog_submit(devc->feeds[ch_idx], v, 1); + ret = feed_queue_analog_submit_one(devc->feeds[ch_idx], v, 1); if (ret != SR_OK) break; } diff --git a/src/hardware/rdtech-um/protocol.c b/src/hardware/rdtech-um/protocol.c index aa32768a..806f9c2d 100644 --- a/src/hardware/rdtech-um/protocol.c +++ b/src/hardware/rdtech-um/protocol.c @@ -214,7 +214,7 @@ static int process_data(struct sr_dev_inst *sdi, ret = bv_get_value_len(&v, &p->channels[ch_idx].spec, data, dlen); if (ret != SR_OK) break; - ret = feed_queue_analog_submit(devc->feeds[ch_idx], v, 1); + ret = feed_queue_analog_submit_one(devc->feeds[ch_idx], v, 1); if (ret != SR_OK) break; } diff --git a/src/input/feed_queue.c b/src/input/feed_queue.c index 1647d8b0..4e01313d 100644 --- a/src/input/feed_queue.c +++ b/src/input/feed_queue.c @@ -57,14 +57,14 @@ SR_API struct feed_queue_logic *feed_queue_logic_alloc( return q; } -SR_API int feed_queue_logic_submit(struct feed_queue_logic *q, - const uint8_t *data, size_t count) +SR_API int feed_queue_logic_submit_one(struct feed_queue_logic *q, + const uint8_t *data, size_t repeat_count) { uint8_t *wrptr; int ret; wrptr = &q->data_bytes[q->fill_count * q->unit_size]; - while (count--) { + while (repeat_count--) { memcpy(wrptr, data, q->unit_size); wrptr += q->unit_size; q->fill_count++; @@ -201,12 +201,12 @@ SR_API int feed_queue_analog_scale_offset(struct feed_queue_analog *q, return SR_OK; } -SR_API int feed_queue_analog_submit(struct feed_queue_analog *q, - float data, size_t count) +SR_API int feed_queue_analog_submit_one(struct feed_queue_analog *q, + float data, size_t repeat_count) { int ret; - while (count--) { + while (repeat_count--) { q->data_values[q->fill_count++] = data; if (q->fill_count == q->alloc_count) { ret = feed_queue_analog_flush(q); diff --git a/src/input/protocoldata.c b/src/input/protocoldata.c index e8591b22..c1d516f4 100644 --- a/src/input/protocoldata.c +++ b/src/input/protocoldata.c @@ -714,7 +714,8 @@ static int send_idle_capture(struct context *inc) return ret; count *= inc->curr_opts.samples_per_bit; while (count--) { - ret = feed_queue_logic_submit(inc->feed_logic, &data, sizeof(data)); + ret = feed_queue_logic_submit_one(inc->feed_logic, + &data, sizeof(data)); if (ret != SR_OK) return ret; } @@ -738,7 +739,8 @@ static int send_idle_interframe(struct context *inc) if (ret != SR_OK) return ret; while (count--) { - ret = feed_queue_logic_submit(inc->feed_logic, &data, sizeof(data)); + ret = feed_queue_logic_submit_one(inc->feed_logic, + &data, sizeof(data)); if (ret != SR_OK) return ret; } @@ -759,7 +761,7 @@ static int send_frame(struct sr_input *in) data = inc->sample_levels[index]; count = inc->sample_widths[index]; while (count--) { - feed_queue_logic_submit(inc->feed_logic, + feed_queue_logic_submit_one(inc->feed_logic, &data, sizeof(data)); } } diff --git a/src/input/stf.c b/src/input/stf.c index 431b0cbc..ddef5de6 100644 --- a/src/input/stf.c +++ b/src/input/stf.c @@ -623,7 +623,7 @@ static void add_sample(const struct sr_input *in, uint16_t data, size_t count) count -= inc->submit.samples_to_trigger; } if (send_first) { - (void)feed_queue_logic_submit(inc->submit.feed, + (void)feed_queue_logic_submit_one(inc->submit.feed, unit_buffer, send_first); inc->submit.submit_count += send_first; inc->submit.samples_to_trigger -= send_first; @@ -632,7 +632,7 @@ static void add_sample(const struct sr_input *in, uint16_t data, size_t count) feed_queue_logic_send_trigger(inc->submit.feed); } if (count) { - (void)feed_queue_logic_submit(inc->submit.feed, + (void)feed_queue_logic_submit_one(inc->submit.feed, unit_buffer, count); inc->submit.submit_count += count; if (inc->submit.samples_to_trigger) diff --git a/src/input/vcd.c b/src/input/vcd.c index bd764571..d5471a47 100644 --- a/src/input/vcd.c +++ b/src/input/vcd.c @@ -1152,7 +1152,7 @@ static void add_samples(const struct sr_input *in, size_t count, gboolean flush) inc = in->priv; if (inc->logic_count) { - feed_queue_logic_submit(inc->feed_logic, + feed_queue_logic_submit_one(inc->feed_logic, inc->current_logic, count); if (flush) feed_queue_logic_flush(inc->feed_logic); @@ -1165,7 +1165,7 @@ static void add_samples(const struct sr_input *in, size_t count, gboolean flush) if (!q) continue; value = inc->current_floats[vcd_ch->array_index]; - feed_queue_analog_submit(q, value, count); + feed_queue_analog_submit_one(q, value, count); if (flush) feed_queue_analog_flush(q); } diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index c2c324c4..7a67911d 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -2854,8 +2854,8 @@ struct feed_queue_analog; SR_API struct feed_queue_logic *feed_queue_logic_alloc( const struct sr_dev_inst *sdi, size_t sample_count, size_t unit_size); -SR_API int feed_queue_logic_submit(struct feed_queue_logic *q, - const uint8_t *data, size_t count); +SR_API int feed_queue_logic_submit_one(struct feed_queue_logic *q, + const uint8_t *data, size_t repeat_count); SR_API int feed_queue_logic_flush(struct feed_queue_logic *q); SR_API int feed_queue_logic_send_trigger(struct feed_queue_logic *q); SR_API void feed_queue_logic_free(struct feed_queue_logic *q); @@ -2867,8 +2867,8 @@ SR_API int feed_queue_analog_mq_unit(struct feed_queue_analog *q, enum sr_mq mq, enum sr_mqflag mq_flag, enum sr_unit unit); SR_API int feed_queue_analog_scale_offset(struct feed_queue_analog *q, const struct sr_rational *scale, const struct sr_rational *offset); -SR_API int feed_queue_analog_submit(struct feed_queue_analog *q, - float data, size_t count); +SR_API int feed_queue_analog_submit_one(struct feed_queue_analog *q, + float data, size_t repeat_count); SR_API int feed_queue_analog_flush(struct feed_queue_analog *q); SR_API void feed_queue_analog_free(struct feed_queue_analog *q);