From: Bert Vermeulen Date: Sun, 5 Aug 2012 16:56:12 +0000 (+0200) Subject: sr/drivers: obsolete SR_HWCAP_PROBECONFIG X-Git-Tag: dsupstream~725 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=014359e3293ef0cdc61fbde4f63dc0a9da98179d sr/drivers: obsolete SR_HWCAP_PROBECONFIG Since probes now live in a struct sr_dev_inst owned by the driver, it already knows about them. Instead of a frontend telling the driver to configure probes, all driver now do this just before starting acquisition. --- diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index 10e2e370..a1dd2072 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -93,7 +93,6 @@ static const int hwcaps[] = { SR_HWCAP_LOGIC_ANALYZER, SR_HWCAP_SAMPLERATE, SR_HWCAP_CAPTURE_RATIO, - SR_HWCAP_PROBECONFIG, SR_HWCAP_LIMIT_MSEC, 0, @@ -689,7 +688,7 @@ static int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate) * The Sigma supports complex triggers using boolean expressions, but this * has not been implemented yet. */ -static int configure_probes(const struct sr_dev_inst *sdi, const GSList *probes) +static int configure_probes(const struct sr_dev_inst *sdi) { struct dev_context *devc = sdi->priv; const struct sr_probe *probe; @@ -699,7 +698,7 @@ static int configure_probes(const struct sr_dev_inst *sdi, const GSList *probes) memset(&devc->trigger, 0, sizeof(struct sigma_trigger)); - for (l = probes; l; l = l->next) { + for (l = sdi->probes; l; l = l->next) { probe = (struct sr_probe *)l->data; probebit = 1 << (probe->index); @@ -837,8 +836,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, if (hwcap == SR_HWCAP_SAMPLERATE) { ret = set_samplerate(sdi, *(const uint64_t *)value); - } else if (hwcap == SR_HWCAP_PROBECONFIG) { - ret = configure_probes(sdi, value); } else if (hwcap == SR_HWCAP_LIMIT_MSEC) { devc->limit_msec = *(const uint64_t *)value; if (devc->limit_msec > 0) @@ -1292,6 +1289,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, devc = sdi->priv; + if (configure_probes(sdi) != SR_OK) { + sr_err("asix-sigma: failed to configured probes"); + return SR_ERR; + } + /* If the samplerate has not been set, default to 200 kHz. */ if (devc->cur_firmware == -1) { if ((ret = set_samplerate(sdi, SR_KHZ(200))) != SR_OK) diff --git a/hardware/chronovu-la8/api.c b/hardware/chronovu-la8/api.c index 7c99ceb5..a7fff108 100644 --- a/hardware/chronovu-la8/api.c +++ b/hardware/chronovu-la8/api.c @@ -338,12 +338,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, } sr_dbg("la8: SAMPLERATE = %" PRIu64, devc->cur_samplerate); break; - case SR_HWCAP_PROBECONFIG: - if (configure_probes(devc, (const GSList *)value) != SR_OK) { - sr_err("la8: %s: probe config failed.", __func__); - return SR_ERR; - } - break; case SR_HWCAP_LIMIT_MSEC: if (*(const uint64_t *)value == 0) { sr_err("la8: %s: LIMIT_MSEC can't be 0.", __func__); @@ -445,6 +439,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, return SR_ERR; } + if (configure_probes(sdi) != SR_OK) { + sr_err("chronovu-la8: failed to configured probes"); + return SR_ERR; + } + sr_dbg("la8: Starting acquisition."); /* Fill acquisition parameters into buf[]. */ diff --git a/hardware/chronovu-la8/driver.c b/hardware/chronovu-la8/driver.c index 47356fd0..850501df 100644 --- a/hardware/chronovu-la8/driver.c +++ b/hardware/chronovu-la8/driver.c @@ -319,19 +319,19 @@ SR_PRIV int la8_reset(struct dev_context *devc) return SR_OK; } -SR_PRIV int configure_probes(struct dev_context *devc, const GSList *probes) +SR_PRIV int configure_probes(const struct sr_dev_inst *sdi) { + struct dev_context *devc; const struct sr_probe *probe; const GSList *l; uint8_t probe_bit; char *tc; - /* Note: Caller checked that devc != NULL. */ - + devc = sdi->priv; devc->trigger_pattern = 0; devc->trigger_mask = 0; /* Default to "don't care" for all probes. */ - for (l = probes; l; l = l->next) { + for (l = sdi->probes; l; l = l->next) { probe = (struct sr_probe *)l->data; if (!probe) { diff --git a/hardware/chronovu-la8/driver.h b/hardware/chronovu-la8/driver.h index 14f8b415..b4aaa900 100644 --- a/hardware/chronovu-la8/driver.h +++ b/hardware/chronovu-la8/driver.h @@ -120,7 +120,7 @@ SR_PRIV int la8_read(struct dev_context *devc, uint8_t *buf, int size); SR_PRIV int la8_close(struct dev_context *devc); SR_PRIV int la8_close_usb_reset_sequencer(struct dev_context *devc); SR_PRIV int la8_reset(struct dev_context *devc); -SR_PRIV int configure_probes(struct dev_context *devc, const GSList *probes); +SR_PRIV int configure_probes(const struct sr_dev_inst *sdi); SR_PRIV int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate); SR_PRIV int la8_read_block(struct dev_context *devc); SR_PRIV void send_block_to_session_bus(struct dev_context *devc, int block); diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index 02d89c72..3e3150af 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -258,10 +258,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, (void)sdi; - if (hwcap == SR_HWCAP_PROBECONFIG) { - /* Nothing to do, but must be supported */ - ret = SR_OK; - } else if (hwcap == SR_HWCAP_SAMPLERATE) { + if (hwcap == SR_HWCAP_SAMPLERATE) { cur_samplerate = *(const uint64_t *)value; sr_dbg("demo: %s: setting samplerate to %" PRIu64, __func__, cur_samplerate); diff --git a/hardware/fx2lafw/fx2lafw.c b/hardware/fx2lafw/fx2lafw.c index b05334a3..44cc9aef 100644 --- a/hardware/fx2lafw/fx2lafw.c +++ b/hardware/fx2lafw/fx2lafw.c @@ -297,20 +297,22 @@ static int fx2lafw_dev_open(struct sr_dev_inst *sdi) return SR_OK; } -static int configure_probes(struct dev_context *devc, GSList *probes) +static int configure_probes(const struct sr_dev_inst *sdi) { + struct dev_context *devc; struct sr_probe *probe; GSList *l; int probe_bit, stage, i; char *tc; + devc = sdi->priv; for (i = 0; i < NUM_TRIGGER_STAGES; i++) { devc->trigger_mask[i] = 0; devc->trigger_value[i] = 0; } stage = -1; - for (l = probes; l; l = l->next) { + for (l = sdi->probes; l; l = l->next) { probe = (struct sr_probe *)l->data; if (probe->enabled == FALSE) continue; @@ -667,8 +669,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, if (hwcap == SR_HWCAP_SAMPLERATE) { devc->cur_samplerate = *(const uint64_t *)value; ret = SR_OK; - } else if (hwcap == SR_HWCAP_PROBECONFIG) { - ret = configure_probes(devc, (GSList *) value); } else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) { devc->limit_samples = *(const uint64_t *)value; ret = SR_OK; @@ -960,6 +960,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, if (devc->submitted_transfers != 0) return SR_ERR; + if (configure_probes(sdi) != SR_OK) { + sr_err("fx2lafw: failed to configured probes"); + return SR_ERR; + } + devc->session_dev_id = cb_data; devc->num_samples = 0; devc->empty_transfer_count = 0; diff --git a/hardware/hantek-dso/api.c b/hardware/hantek-dso/api.c index bf0fd956..c1828b44 100644 --- a/hardware/hantek-dso/api.c +++ b/hardware/hantek-dso/api.c @@ -200,13 +200,16 @@ static struct sr_dev_inst *dso_dev_new(int index, const struct dso_profile *prof return sdi; } -static int configure_probes(struct dev_context *devc, const GSList *probes) +static int configure_probes(const struct sr_dev_inst *sdi) { + struct dev_context *devc; const struct sr_probe *probe; const GSList *l; + devc = sdi->priv; + devc->ch1_enabled = devc->ch2_enabled = FALSE; - for (l = probes; l; l = l->next) { + for (l = sdi->probes; l; l = l->next) { probe = (struct sr_probe *)l->data; if (probe->index == 0) devc->ch1_enabled = probe->enabled; @@ -477,9 +480,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, case SR_HWCAP_LIMIT_FRAMES: devc->limit_frames = *(const uint64_t *)value; break; - case SR_HWCAP_PROBECONFIG: - ret = configure_probes(devc, (const GSList *)value); - break; case SR_HWCAP_TRIGGER_SLOPE: tmp_u64 = *(const int *)value; if (tmp_u64 != SLOPE_NEGATIVE && tmp_u64 != SLOPE_POSITIVE) @@ -847,6 +847,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, devc = sdi->priv; devc->cb_data = cb_data; + if (configure_probes(sdi) != SR_OK) { + sr_err("hantek-dso: failed to configured probes"); + return SR_ERR; + } + if (dso_init(devc) != SR_OK) return SR_ERR; diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 5a73cfc7..7a89d775 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -131,13 +131,16 @@ static int send_longcommand(int fd, uint8_t command, uint32_t data) return SR_OK; } -static int configure_probes(struct dev_context *devc, const GSList *probes) +static int configure_probes(const struct sr_dev_inst *sdi) { + struct dev_context *devc; const struct sr_probe *probe; const GSList *l; int probe_bit, stage, i; char *tc; + devc = sdi->priv; + devc->probe_mask = 0; for (i = 0; i < NUM_TRIGGER_STAGES; i++) { devc->trigger_mask[i] = 0; @@ -145,7 +148,7 @@ static int configure_probes(struct dev_context *devc, const GSList *probes) } devc->num_stages = 0; - for (l = probes; l; l = l->next) { + for (l = sdi->probes; l; l = l->next) { probe = (const struct sr_probe *)l->data; if (!probe->enabled) continue; @@ -667,9 +670,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, case SR_HWCAP_SAMPLERATE: ret = set_samplerate(sdi, *(const uint64_t *)value); break; - case SR_HWCAP_PROBECONFIG: - ret = configure_probes(devc, (const GSList *)value); - break; case SR_HWCAP_LIMIT_SAMPLES: tmp_u64 = value; if (*tmp_u64 < MIN_NUM_SAMPLES) @@ -920,6 +920,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, if (sdi->status != SR_ST_ACTIVE) return SR_ERR; + if (configure_probes(sdi) != SR_OK) { + sr_err("ols: failed to configured probes"); + return SR_ERR; + } + /* * Enable/disable channel groups in the flag register according to the * probe mask. Calculate this here, because num_channels is needed diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 7dcda9cf..72e044bc 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -72,7 +72,6 @@ static model_t zeroplus_models[] = { static const int hwcaps[] = { SR_HWCAP_LOGIC_ANALYZER, SR_HWCAP_SAMPLERATE, - SR_HWCAP_PROBECONFIG, SR_HWCAP_CAPTURE_RATIO, /* These are really implemented in the driver, not the hardware. */ @@ -186,7 +185,7 @@ static unsigned int get_memory_size(int type) return 0; } -static int configure_probes(const struct sr_dev_inst *sdi, const GSList *probes) +static int configure_probes(const struct sr_dev_inst *sdi) { struct dev_context *devc; const struct sr_probe *probe; @@ -204,7 +203,7 @@ static int configure_probes(const struct sr_dev_inst *sdi, const GSList *probes) } stage = -1; - for (l = probes; l; l = l->next) { + for (l = sdi->probes; l; l = l->next) { probe = (struct sr_probe *)l->data; if (probe->enabled == FALSE) continue; @@ -571,8 +570,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, switch (hwcap) { case SR_HWCAP_SAMPLERATE: return set_samplerate(sdi, *(const uint64_t *)value); - case SR_HWCAP_PROBECONFIG: - return configure_probes(sdi, (const GSList *)value); case SR_HWCAP_LIMIT_SAMPLES: devc->limit_samples = *(const uint64_t *)value; return SR_OK; @@ -599,6 +596,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, return SR_ERR_ARG; } + if (configure_probes(sdi) != SR_OK) { + sr_err("zp: failed to configured probes"); + return SR_ERR; + } + /* push configured settings to device */ analyzer_configure(devc->usb->devhdl); diff --git a/libsigrok.h b/libsigrok.h index 306c2057..75f6c3c2 100644 --- a/libsigrok.h +++ b/libsigrok.h @@ -305,10 +305,6 @@ enum { /** The device supports setting/changing its samplerate. */ SR_HWCAP_SAMPLERATE, - /* TODO: Better description? Rename to PROBE_AND_TRIGGER_CONFIG? */ - /** The device supports setting a probe mask. */ - SR_HWCAP_PROBECONFIG, - /** The device supports setting a pre/post-trigger capture ratio. */ SR_HWCAP_CAPTURE_RATIO,