zeroplus: Only report supported samplerates.

The currently supported model LAP-C(16032) doesn't support the
samplerates 150MHz and 200MHz which some of the other models have.

Thus, do not report these samplerates to the frontends. E.g. sigrok-cli
should not show them via --show and GUIs should not list them in their
"Samplerates" drop-down.
This commit is contained in:
Uwe Hermann 2013-02-08 23:13:33 +01:00
parent e495a676eb
commit 17548571cc
3 changed files with 47 additions and 13 deletions

View File

@ -80,11 +80,27 @@ static struct sr_dev_driver *di = &zeroplus_logic_cube_driver_info;
* options hardcoded into the vendor's Windows GUI.
*/
/*
* TODO: We shouldn't support 150MHz and 200MHz on devices that don't go up
* that high.
*/
const uint64_t zp_supported_samplerates[] = {
static const uint64_t zp_supported_samplerates_100[] = {
SR_HZ(100),
SR_HZ(500),
SR_KHZ(1),
SR_KHZ(5),
SR_KHZ(25),
SR_KHZ(50),
SR_KHZ(100),
SR_KHZ(200),
SR_KHZ(400),
SR_KHZ(800),
SR_MHZ(1),
SR_MHZ(10),
SR_MHZ(25),
SR_MHZ(50),
SR_MHZ(80),
SR_MHZ(100),
0,
};
const uint64_t zp_supported_samplerates_200[] = {
SR_HZ(100),
SR_HZ(500),
SR_KHZ(1),
@ -106,11 +122,18 @@ const uint64_t zp_supported_samplerates[] = {
0,
};
static const struct sr_samplerates samplerates = {
static const struct sr_samplerates samplerates_100 = {
.low = 0,
.high = 0,
.step = 0,
.list = zp_supported_samplerates,
.list = zp_supported_samplerates_100,
};
static const struct sr_samplerates samplerates_200 = {
.low = 0,
.high = 0,
.step = 0,
.list = zp_supported_samplerates_200,
};
static int hw_dev_close(struct sr_dev_inst *sdi);
@ -295,6 +318,7 @@ static GSList *hw_scan(GSList *options)
}
sdi->priv = devc;
devc->prof = prof;
devc->num_channels = prof->channels;
#ifdef ZP_EXPERIMENTAL
devc->max_memory_size = 128 * 1024;
@ -512,14 +536,23 @@ static int config_set(int id, const void *value, const struct sr_dev_inst *sdi)
static int config_list(int key, const void **data, const struct sr_dev_inst *sdi)
{
(void)sdi;
struct dev_context *devc;
switch (key) {
case SR_CONF_DEVICE_OPTIONS:
*data = hwcaps;
break;
case SR_CONF_SAMPLERATE:
*data = &samplerates;
devc = sdi->priv;
if (devc->prof->max_sampling_freq == 100) {
*data = &samplerates_100;
} else if (devc->prof->max_sampling_freq == 200) {
*data = &samplerates_200;
} else {
sr_err("Internal error: Unknown max. samplerate: %d.",
devc->prof->max_sampling_freq);
return SR_ERR_ARG;
}
break;
case SR_CONF_TRIGGER_TYPE:
*data = TRIGGER_TYPE;

View File

@ -37,11 +37,11 @@ SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate)
{
int i;
for (i = 0; zp_supported_samplerates[i]; i++)
if (samplerate == zp_supported_samplerates[i])
for (i = 0; zp_supported_samplerates_200[i]; i++)
if (samplerate == zp_supported_samplerates_200[i])
break;
if (!zp_supported_samplerates[i] || samplerate > devc->max_samplerate) {
if (!zp_supported_samplerates_200[i] || samplerate > devc->max_samplerate) {
sr_err("Unsupported samplerate: %" PRIu64 "Hz.", samplerate);
return SR_ERR_ARG;
}

View File

@ -52,9 +52,10 @@ struct dev_context {
int trigger;
unsigned int capture_ratio;
struct sr_usb_dev_inst *usb;
const struct zp_model *prof;
};
extern const uint64_t zp_supported_samplerates[];
extern const uint64_t zp_supported_samplerates_200[];
SR_PRIV unsigned int get_memory_size(int type);
SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate);