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.
This commit is contained in:
Bert Vermeulen 2012-08-05 18:56:12 +02:00
parent a56f148094
commit 014359e329
10 changed files with 54 additions and 43 deletions

View File

@ -93,7 +93,6 @@ static const int hwcaps[] = {
SR_HWCAP_LOGIC_ANALYZER, SR_HWCAP_LOGIC_ANALYZER,
SR_HWCAP_SAMPLERATE, SR_HWCAP_SAMPLERATE,
SR_HWCAP_CAPTURE_RATIO, SR_HWCAP_CAPTURE_RATIO,
SR_HWCAP_PROBECONFIG,
SR_HWCAP_LIMIT_MSEC, SR_HWCAP_LIMIT_MSEC,
0, 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 * The Sigma supports complex triggers using boolean expressions, but this
* has not been implemented yet. * 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; struct dev_context *devc = sdi->priv;
const struct sr_probe *probe; 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)); 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; probe = (struct sr_probe *)l->data;
probebit = 1 << (probe->index); 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) { if (hwcap == SR_HWCAP_SAMPLERATE) {
ret = set_samplerate(sdi, *(const uint64_t *)value); 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) { } else if (hwcap == SR_HWCAP_LIMIT_MSEC) {
devc->limit_msec = *(const uint64_t *)value; devc->limit_msec = *(const uint64_t *)value;
if (devc->limit_msec > 0) if (devc->limit_msec > 0)
@ -1292,6 +1289,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
devc = sdi->priv; 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 the samplerate has not been set, default to 200 kHz. */
if (devc->cur_firmware == -1) { if (devc->cur_firmware == -1) {
if ((ret = set_samplerate(sdi, SR_KHZ(200))) != SR_OK) if ((ret = set_samplerate(sdi, SR_KHZ(200))) != SR_OK)

View File

@ -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); sr_dbg("la8: SAMPLERATE = %" PRIu64, devc->cur_samplerate);
break; 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: case SR_HWCAP_LIMIT_MSEC:
if (*(const uint64_t *)value == 0) { if (*(const uint64_t *)value == 0) {
sr_err("la8: %s: LIMIT_MSEC can't be 0.", __func__); 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; 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."); sr_dbg("la8: Starting acquisition.");
/* Fill acquisition parameters into buf[]. */ /* Fill acquisition parameters into buf[]. */

View File

@ -319,19 +319,19 @@ SR_PRIV int la8_reset(struct dev_context *devc)
return SR_OK; 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 struct sr_probe *probe;
const GSList *l; const GSList *l;
uint8_t probe_bit; uint8_t probe_bit;
char *tc; char *tc;
/* Note: Caller checked that devc != NULL. */ devc = sdi->priv;
devc->trigger_pattern = 0; devc->trigger_pattern = 0;
devc->trigger_mask = 0; /* Default to "don't care" for all probes. */ 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; probe = (struct sr_probe *)l->data;
if (!probe) { if (!probe) {

View File

@ -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(struct dev_context *devc);
SR_PRIV int la8_close_usb_reset_sequencer(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 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 set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate);
SR_PRIV int la8_read_block(struct dev_context *devc); SR_PRIV int la8_read_block(struct dev_context *devc);
SR_PRIV void send_block_to_session_bus(struct dev_context *devc, int block); SR_PRIV void send_block_to_session_bus(struct dev_context *devc, int block);

View File

@ -258,10 +258,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
(void)sdi; (void)sdi;
if (hwcap == SR_HWCAP_PROBECONFIG) { if (hwcap == SR_HWCAP_SAMPLERATE) {
/* Nothing to do, but must be supported */
ret = SR_OK;
} else if (hwcap == SR_HWCAP_SAMPLERATE) {
cur_samplerate = *(const uint64_t *)value; cur_samplerate = *(const uint64_t *)value;
sr_dbg("demo: %s: setting samplerate to %" PRIu64, __func__, sr_dbg("demo: %s: setting samplerate to %" PRIu64, __func__,
cur_samplerate); cur_samplerate);

View File

@ -297,20 +297,22 @@ static int fx2lafw_dev_open(struct sr_dev_inst *sdi)
return SR_OK; 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; struct sr_probe *probe;
GSList *l; GSList *l;
int probe_bit, stage, i; int probe_bit, stage, i;
char *tc; char *tc;
devc = sdi->priv;
for (i = 0; i < NUM_TRIGGER_STAGES; i++) { for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
devc->trigger_mask[i] = 0; devc->trigger_mask[i] = 0;
devc->trigger_value[i] = 0; devc->trigger_value[i] = 0;
} }
stage = -1; stage = -1;
for (l = probes; l; l = l->next) { for (l = sdi->probes; l; l = l->next) {
probe = (struct sr_probe *)l->data; probe = (struct sr_probe *)l->data;
if (probe->enabled == FALSE) if (probe->enabled == FALSE)
continue; continue;
@ -667,8 +669,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
if (hwcap == SR_HWCAP_SAMPLERATE) { if (hwcap == SR_HWCAP_SAMPLERATE) {
devc->cur_samplerate = *(const uint64_t *)value; devc->cur_samplerate = *(const uint64_t *)value;
ret = SR_OK; ret = SR_OK;
} else if (hwcap == SR_HWCAP_PROBECONFIG) {
ret = configure_probes(devc, (GSList *) value);
} else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) { } else if (hwcap == SR_HWCAP_LIMIT_SAMPLES) {
devc->limit_samples = *(const uint64_t *)value; devc->limit_samples = *(const uint64_t *)value;
ret = SR_OK; ret = SR_OK;
@ -960,6 +960,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
if (devc->submitted_transfers != 0) if (devc->submitted_transfers != 0)
return SR_ERR; 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->session_dev_id = cb_data;
devc->num_samples = 0; devc->num_samples = 0;
devc->empty_transfer_count = 0; devc->empty_transfer_count = 0;

View File

@ -200,13 +200,16 @@ static struct sr_dev_inst *dso_dev_new(int index, const struct dso_profile *prof
return sdi; 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 struct sr_probe *probe;
const GSList *l; const GSList *l;
devc = sdi->priv;
devc->ch1_enabled = devc->ch2_enabled = FALSE; 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; probe = (struct sr_probe *)l->data;
if (probe->index == 0) if (probe->index == 0)
devc->ch1_enabled = probe->enabled; 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: case SR_HWCAP_LIMIT_FRAMES:
devc->limit_frames = *(const uint64_t *)value; devc->limit_frames = *(const uint64_t *)value;
break; break;
case SR_HWCAP_PROBECONFIG:
ret = configure_probes(devc, (const GSList *)value);
break;
case SR_HWCAP_TRIGGER_SLOPE: case SR_HWCAP_TRIGGER_SLOPE:
tmp_u64 = *(const int *)value; tmp_u64 = *(const int *)value;
if (tmp_u64 != SLOPE_NEGATIVE && tmp_u64 != SLOPE_POSITIVE) 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 = sdi->priv;
devc->cb_data = cb_data; 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) if (dso_init(devc) != SR_OK)
return SR_ERR; return SR_ERR;

View File

@ -131,13 +131,16 @@ static int send_longcommand(int fd, uint8_t command, uint32_t data)
return SR_OK; 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 struct sr_probe *probe;
const GSList *l; const GSList *l;
int probe_bit, stage, i; int probe_bit, stage, i;
char *tc; char *tc;
devc = sdi->priv;
devc->probe_mask = 0; devc->probe_mask = 0;
for (i = 0; i < NUM_TRIGGER_STAGES; i++) { for (i = 0; i < NUM_TRIGGER_STAGES; i++) {
devc->trigger_mask[i] = 0; devc->trigger_mask[i] = 0;
@ -145,7 +148,7 @@ static int configure_probes(struct dev_context *devc, const GSList *probes)
} }
devc->num_stages = 0; 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; probe = (const struct sr_probe *)l->data;
if (!probe->enabled) if (!probe->enabled)
continue; continue;
@ -667,9 +670,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
case SR_HWCAP_SAMPLERATE: case SR_HWCAP_SAMPLERATE:
ret = set_samplerate(sdi, *(const uint64_t *)value); ret = set_samplerate(sdi, *(const uint64_t *)value);
break; break;
case SR_HWCAP_PROBECONFIG:
ret = configure_probes(devc, (const GSList *)value);
break;
case SR_HWCAP_LIMIT_SAMPLES: case SR_HWCAP_LIMIT_SAMPLES:
tmp_u64 = value; tmp_u64 = value;
if (*tmp_u64 < MIN_NUM_SAMPLES) 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) if (sdi->status != SR_ST_ACTIVE)
return SR_ERR; 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 * Enable/disable channel groups in the flag register according to the
* probe mask. Calculate this here, because num_channels is needed * probe mask. Calculate this here, because num_channels is needed

View File

@ -72,7 +72,6 @@ static model_t zeroplus_models[] = {
static const int hwcaps[] = { static const int hwcaps[] = {
SR_HWCAP_LOGIC_ANALYZER, SR_HWCAP_LOGIC_ANALYZER,
SR_HWCAP_SAMPLERATE, SR_HWCAP_SAMPLERATE,
SR_HWCAP_PROBECONFIG,
SR_HWCAP_CAPTURE_RATIO, SR_HWCAP_CAPTURE_RATIO,
/* These are really implemented in the driver, not the hardware. */ /* These are really implemented in the driver, not the hardware. */
@ -186,7 +185,7 @@ static unsigned int get_memory_size(int type)
return 0; 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; struct dev_context *devc;
const struct sr_probe *probe; const struct sr_probe *probe;
@ -204,7 +203,7 @@ static int configure_probes(const struct sr_dev_inst *sdi, const GSList *probes)
} }
stage = -1; stage = -1;
for (l = probes; l; l = l->next) { for (l = sdi->probes; l; l = l->next) {
probe = (struct sr_probe *)l->data; probe = (struct sr_probe *)l->data;
if (probe->enabled == FALSE) if (probe->enabled == FALSE)
continue; continue;
@ -571,8 +570,6 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
switch (hwcap) { switch (hwcap) {
case SR_HWCAP_SAMPLERATE: case SR_HWCAP_SAMPLERATE:
return set_samplerate(sdi, *(const uint64_t *)value); return set_samplerate(sdi, *(const uint64_t *)value);
case SR_HWCAP_PROBECONFIG:
return configure_probes(sdi, (const GSList *)value);
case SR_HWCAP_LIMIT_SAMPLES: case SR_HWCAP_LIMIT_SAMPLES:
devc->limit_samples = *(const uint64_t *)value; devc->limit_samples = *(const uint64_t *)value;
return SR_OK; return SR_OK;
@ -599,6 +596,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
return SR_ERR_ARG; 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 */ /* push configured settings to device */
analyzer_configure(devc->usb->devhdl); analyzer_configure(devc->usb->devhdl);

View File

@ -305,10 +305,6 @@ enum {
/** The device supports setting/changing its samplerate. */ /** The device supports setting/changing its samplerate. */
SR_HWCAP_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. */ /** The device supports setting a pre/post-trigger capture ratio. */
SR_HWCAP_CAPTURE_RATIO, SR_HWCAP_CAPTURE_RATIO,