ols: Symbolic name for magic value, reflect units in variable names
Reviewed-By: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
parent
f1a37f3924
commit
a2b1a53bb4
|
@ -440,7 +440,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
|||
return SR_ERR;
|
||||
|
||||
delaycount = readcount * (1 - devc->capture_ratio / 100.0);
|
||||
devc->trigger_at = (readcount - delaycount) * 4 - devc->num_stages;
|
||||
devc->trigger_at_smpl = (readcount - delaycount) * 4 - devc->num_stages;
|
||||
for (i = 0; i <= devc->num_stages; i++) {
|
||||
sr_dbg("Setting OLS stage %d trigger.", i);
|
||||
if ((ret = set_trigger(sdi, i)) != SR_OK)
|
||||
|
|
|
@ -134,7 +134,7 @@ SR_PRIV struct dev_context *ols_dev_new(void)
|
|||
struct dev_context *devc;
|
||||
|
||||
devc = g_malloc0(sizeof(struct dev_context));
|
||||
devc->trigger_at = -1;
|
||||
devc->trigger_at_smpl = OLS_NO_TRIGGER;
|
||||
|
||||
return devc;
|
||||
}
|
||||
|
@ -491,16 +491,16 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
|
|||
sr_dbg("Received %d bytes, %d samples, %d decompressed samples.",
|
||||
devc->cnt_bytes, devc->cnt_samples,
|
||||
devc->cnt_samples_rle);
|
||||
if (devc->trigger_at != -1) {
|
||||
if (devc->trigger_at_smpl != OLS_NO_TRIGGER) {
|
||||
/*
|
||||
* A trigger was set up, so we need to tell the frontend
|
||||
* about it.
|
||||
*/
|
||||
if (devc->trigger_at > 0) {
|
||||
if (devc->trigger_at_smpl > 0) {
|
||||
/* There are pre-trigger samples, send those first. */
|
||||
packet.type = SR_DF_LOGIC;
|
||||
packet.payload = &logic;
|
||||
logic.length = devc->trigger_at * 4;
|
||||
logic.length = devc->trigger_at_smpl * 4;
|
||||
logic.unitsize = 4;
|
||||
logic.data = devc->raw_sample_buf +
|
||||
(devc->limit_samples - devc->num_samples) * 4;
|
||||
|
@ -513,9 +513,9 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
|
|||
/* Send post-trigger samples. */
|
||||
packet.type = SR_DF_LOGIC;
|
||||
packet.payload = &logic;
|
||||
logic.length = (devc->num_samples * 4) - (devc->trigger_at * 4);
|
||||
logic.length = (devc->num_samples * 4) - (devc->trigger_at_smpl * 4);
|
||||
logic.unitsize = 4;
|
||||
logic.data = devc->raw_sample_buf + devc->trigger_at * 4 +
|
||||
logic.data = devc->raw_sample_buf + devc->trigger_at_smpl * 4 +
|
||||
(devc->limit_samples - devc->num_samples) * 4;
|
||||
sr_session_send(sdi, &packet);
|
||||
} else {
|
||||
|
|
|
@ -65,6 +65,9 @@
|
|||
#define FLAG_FILTER (1 << 1)
|
||||
#define FLAG_DEMUX (1 << 0)
|
||||
|
||||
/* Capture context magic numbers */
|
||||
#define OLS_NO_TRIGGER (-1)
|
||||
|
||||
struct dev_context {
|
||||
/* constant device properties: */
|
||||
int max_channels;
|
||||
|
@ -77,7 +80,7 @@ struct dev_context {
|
|||
uint32_t cur_samplerate_divider;
|
||||
uint64_t limit_samples;
|
||||
uint64_t capture_ratio;
|
||||
int trigger_at;
|
||||
int trigger_at_smpl;
|
||||
uint32_t channel_mask;
|
||||
uint32_t trigger_mask[NUM_TRIGGER_STAGES];
|
||||
uint32_t trigger_value[NUM_TRIGGER_STAGES];
|
||||
|
|
Loading…
Reference in New Issue