Create a sub struct in the device context which keeps those parameters
which are related to sample memory interpretation. Which also obsoletes
the 'state' struct and only leaves the 'state' enum as a remainder.
Use the "samples per event" condition instead of the samplerate when
extracting a number of samples from an event's storage. Rename the
de-interleaving routines to better reflect their purpose.
* Derive a mask where bits are set for unavailable channels.
* Either send the single byte, or the full byte sequence.
*/
* Derive a mask where bits are set for unavailable channels.
* Either send the single byte, or the full byte sequence.
*/
- pindis_mask = ~BITS_MASK(devc->num_channels);
+ pindis_mask = ~BITS_MASK(devc->interp.num_channels);
if (devc->clock.samplerate > SR_MHZ(50)) {
ret = sigma_set_register(devc, WRITE_CLOCK_SELECT,
pindis_mask & 0xff);
if (devc->clock.samplerate > SR_MHZ(50)) {
ret = sigma_set_register(devc, WRITE_CLOCK_SELECT,
pindis_mask & 0xff);
if (ret != SR_OK)
return ret;
if (ret != SR_OK)
return ret;
- devc->state.state = SIGMA_CAPTURE;
+ devc->state = SIGMA_CAPTURE;
* already. The detour is required to have sample data retrieved
* for forced acquisition stops.
*/
* already. The detour is required to have sample data retrieved
* for forced acquisition stops.
*/
- if (devc->state.state == SIGMA_CAPTURE) {
- devc->state.state = SIGMA_STOPPING;
+ if (devc->state == SIGMA_CAPTURE) {
+ devc->state = SIGMA_STOPPING;
- devc->state.state = SIGMA_IDLE;
+ devc->state = SIGMA_IDLE;
(void)sr_session_source_remove(sdi->session, -1);
}
(void)sr_session_source_remove(sdi->session, -1);
}
- devc->state.state = SIGMA_CONFIG;
+ devc->state = SIGMA_CONFIG;
/* Set the cable to bitbang mode. */
ret = ftdi_set_bitmode(&devc->ftdi.ctx, BB_PINMASK, BITMODE_BITBANG);
/* Set the cable to bitbang mode. */
ret = ftdi_set_bitmode(&devc->ftdi.ctx, BB_PINMASK, BITMODE_BITBANG);
}
/* Keep track of successful firmware download completion. */
}
/* Keep track of successful firmware download completion. */
- devc->state.state = SIGMA_IDLE;
+ devc->state = SIGMA_IDLE;
devc->firmware_idx = firmware_idx;
sr_info("Firmware uploaded.");
devc->firmware_idx = firmware_idx;
sr_info("Firmware uploaded.");
* firmware is required and higher rates might limit the set
* of available channels.
*/
* firmware is required and higher rates might limit the set
* of available channels.
*/
- num_channels = devc->num_channels;
+ num_channels = devc->interp.num_channels;
if (samplerate <= SR_MHZ(50)) {
ret = upload_firmware(drvc->sr_ctx, devc, SIGMA_FW_50MHZ);
num_channels = 16;
if (samplerate <= SR_MHZ(50)) {
ret = upload_firmware(drvc->sr_ctx, devc, SIGMA_FW_50MHZ);
num_channels = 16;
* which the device will communicate within an "event").
*/
if (ret == SR_OK) {
* which the device will communicate within an "event").
*/
if (ret == SR_OK) {
- devc->num_channels = num_channels;
- devc->samples_per_event = 16 / devc->num_channels;
+ devc->interp.num_channels = num_channels;
+ devc->interp.samples_per_event = 16 / devc->interp.num_channels;
* One 16bit item contains two samples of 8bits each. The bits of
* multiple samples are interleaved.
*/
* One 16bit item contains two samples of 8bits each. The bits of
* multiple samples are interleaved.
*/
-static uint16_t sigma_deinterlace_100mhz_data(uint16_t indata, int idx)
+static uint16_t sigma_deinterlace_data_2x8(uint16_t indata, int idx)
* One 16bit item contains four samples of 4bits each. The bits of
* multiple samples are interleaved.
*/
* One 16bit item contains four samples of 4bits each. The bits of
* multiple samples are interleaved.
*/
-static uint16_t sigma_deinterlace_200mhz_data(uint16_t indata, int idx)
+static uint16_t sigma_deinterlace_data_4x4(uint16_t indata, int idx)
struct sigma_dram_cluster *dram_cluster,
size_t events_in_cluster, gboolean triggered)
{
struct sigma_dram_cluster *dram_cluster,
size_t events_in_cluster, gboolean triggered)
{
- struct sigma_state *ss;
uint16_t tsdiff, ts, sample, item16;
size_t count;
size_t evt;
uint16_t tsdiff, ts, sample, item16;
size_t count;
size_t evt;
* for simple level and edge triggers. It would not for timed or
* counted conditions, which currently are not supported.)
*/
* for simple level and edge triggers. It would not for timed or
* counted conditions, which currently are not supported.)
*/
ts = sigma_dram_cluster_ts(dram_cluster);
ts = sigma_dram_cluster_ts(dram_cluster);
- tsdiff = ts - ss->lastts;
+ tsdiff = ts - devc->interp.lastts;
- sample = ss->lastsample;
- count = tsdiff * devc->samples_per_event;
+ sample = devc->interp.lastsample;
+ count = tsdiff * devc->interp.samples_per_event;
(void)check_and_submit_sample(devc, sample, count, FALSE);
}
(void)check_and_submit_sample(devc, sample, count, FALSE);
}
- ss->lastts = ts + EVENTS_PER_CLUSTER;
+ devc->interp.lastts = ts + EVENTS_PER_CLUSTER;
/*
* Grab sample data from the current cluster and prepare their
/*
* Grab sample data from the current cluster and prepare their
sample = 0;
for (evt = 0; evt < events_in_cluster; evt++) {
item16 = sigma_dram_cluster_data(dram_cluster, evt);
sample = 0;
for (evt = 0; evt < events_in_cluster; evt++) {
item16 = sigma_dram_cluster_data(dram_cluster, evt);
- if (devc->clock.samplerate == SR_MHZ(200)) {
- sample = sigma_deinterlace_200mhz_data(item16, 0);
+ if (devc->interp.samples_per_event == 4) {
+ sample = sigma_deinterlace_data_4x4(item16, 0);
check_and_submit_sample(devc, sample, 1, triggered);
check_and_submit_sample(devc, sample, 1, triggered);
- sample = sigma_deinterlace_200mhz_data(item16, 1);
+ sample = sigma_deinterlace_data_4x4(item16, 1);
check_and_submit_sample(devc, sample, 1, triggered);
check_and_submit_sample(devc, sample, 1, triggered);
- sample = sigma_deinterlace_200mhz_data(item16, 2);
+ sample = sigma_deinterlace_data_4x4(item16, 2);
check_and_submit_sample(devc, sample, 1, triggered);
check_and_submit_sample(devc, sample, 1, triggered);
- sample = sigma_deinterlace_200mhz_data(item16, 3);
+ sample = sigma_deinterlace_data_4x4(item16, 3);
check_and_submit_sample(devc, sample, 1, triggered);
check_and_submit_sample(devc, sample, 1, triggered);
- } else if (devc->clock.samplerate == SR_MHZ(100)) {
- sample = sigma_deinterlace_100mhz_data(item16, 0);
+ } else if (devc->interp.samples_per_event == 2) {
+ sample = sigma_deinterlace_data_2x8(item16, 0);
check_and_submit_sample(devc, sample, 1, triggered);
check_and_submit_sample(devc, sample, 1, triggered);
- sample = sigma_deinterlace_100mhz_data(item16, 1);
+ sample = sigma_deinterlace_data_2x8(item16, 1);
check_and_submit_sample(devc, sample, 1, triggered);
} else {
sample = item16;
check_and_submit_sample(devc, sample, 1, triggered);
}
}
check_and_submit_sample(devc, sample, 1, triggered);
} else {
sample = item16;
check_and_submit_sample(devc, sample, 1, triggered);
}
}
- ss->lastsample = sample;
+ devc->interp.lastsample = sample;
devc = sdi->priv;
sr_info("Downloading sample data.");
devc = sdi->priv;
sr_info("Downloading sample data.");
- devc->state.state = SIGMA_DOWNLOAD;
+ devc->state = SIGMA_DOWNLOAD;
/*
* Ask the hardware to stop data acquisition. Reception of the
/*
* Ask the hardware to stop data acquisition. Reception of the
/* This is the first DRAM line, so find the initial timestamp. */
if (dl_lines_done == 0) {
/* This is the first DRAM line, so find the initial timestamp. */
if (dl_lines_done == 0) {
sigma_dram_cluster_ts(&dram_line[0].cluster[0]);
sigma_dram_cluster_ts(&dram_line[0].cluster[0]);
- devc->state.lastsample = 0;
+ devc->interp.lastsample = 0;
}
for (line_idx = 0; line_idx < dl_lines_curr; line_idx++) {
}
for (line_idx = 0; line_idx < dl_lines_curr; line_idx++) {
std_session_send_df_end(sdi);
std_session_send_df_end(sdi);
- devc->state.state = SIGMA_IDLE;
+ devc->state = SIGMA_IDLE;
sr_dev_acquisition_stop(sdi);
return TRUE;
sr_dev_acquisition_stop(sdi);
return TRUE;
sdi = cb_data;
devc = sdi->priv;
sdi = cb_data;
devc = sdi->priv;
- if (devc->state.state == SIGMA_IDLE)
+ if (devc->state == SIGMA_IDLE)
* keep checking configured limits which will terminate the
* acquisition and initiate download.
*/
* keep checking configured limits which will terminate the
* acquisition and initiate download.
*/
- if (devc->state.state == SIGMA_STOPPING)
+ if (devc->state == SIGMA_STOPPING)
return download_capture(sdi);
return download_capture(sdi);
- if (devc->state.state == SIGMA_CAPTURE)
+ if (devc->state == SIGMA_CAPTURE)
return sigma_capture_mode(sdi);
return TRUE;
return sigma_capture_mode(sdi);
return TRUE;
-struct sigma_state {
- enum {
- SIGMA_UNINITIALIZED = 0,
- SIGMA_CONFIG,
- SIGMA_IDLE,
- SIGMA_CAPTURE,
- SIGMA_STOPPING,
- SIGMA_DOWNLOAD,
- } state;
- uint16_t lastts;
- uint16_t lastsample;
-};
-
enum sigma_firmware_idx {
SIGMA_FW_NONE,
SIGMA_FW_50MHZ,
enum sigma_firmware_idx {
SIGMA_FW_NONE,
SIGMA_FW_50MHZ,
struct sr_sw_limits submit;
} limit;
enum sigma_firmware_idx firmware_idx;
struct sr_sw_limits submit;
} limit;
enum sigma_firmware_idx firmware_idx;
- size_t num_channels;
- size_t samples_per_event;
+ struct {
+ /* Interpretation of sample memory. */
+ size_t num_channels;
+ size_t samples_per_event;
+ uint16_t lastts;
+ uint16_t lastsample;
+ } interp;
uint64_t capture_ratio;
struct sigma_trigger trigger;
gboolean use_triggers;
uint64_t capture_ratio;
struct sigma_trigger trigger;
gboolean use_triggers;
- struct sigma_state state;
+ enum {
+ SIGMA_UNINITIALIZED = 0,
+ SIGMA_CONFIG,
+ SIGMA_IDLE,
+ SIGMA_CAPTURE,
+ SIGMA_STOPPING,
+ SIGMA_DOWNLOAD,
+ } state;
struct submit_buffer *buffer;
};
struct submit_buffer *buffer;
};