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:
parent
e495a676eb
commit
17548571cc
|
@ -80,11 +80,27 @@ static struct sr_dev_driver *di = &zeroplus_logic_cube_driver_info;
|
||||||
* options hardcoded into the vendor's Windows GUI.
|
* options hardcoded into the vendor's Windows GUI.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
static const uint64_t zp_supported_samplerates_100[] = {
|
||||||
* TODO: We shouldn't support 150MHz and 200MHz on devices that don't go up
|
SR_HZ(100),
|
||||||
* that high.
|
SR_HZ(500),
|
||||||
*/
|
SR_KHZ(1),
|
||||||
const uint64_t zp_supported_samplerates[] = {
|
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(100),
|
||||||
SR_HZ(500),
|
SR_HZ(500),
|
||||||
SR_KHZ(1),
|
SR_KHZ(1),
|
||||||
|
@ -106,11 +122,18 @@ const uint64_t zp_supported_samplerates[] = {
|
||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct sr_samplerates samplerates = {
|
static const struct sr_samplerates samplerates_100 = {
|
||||||
.low = 0,
|
.low = 0,
|
||||||
.high = 0,
|
.high = 0,
|
||||||
.step = 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);
|
static int hw_dev_close(struct sr_dev_inst *sdi);
|
||||||
|
@ -295,6 +318,7 @@ static GSList *hw_scan(GSList *options)
|
||||||
}
|
}
|
||||||
|
|
||||||
sdi->priv = devc;
|
sdi->priv = devc;
|
||||||
|
devc->prof = prof;
|
||||||
devc->num_channels = prof->channels;
|
devc->num_channels = prof->channels;
|
||||||
#ifdef ZP_EXPERIMENTAL
|
#ifdef ZP_EXPERIMENTAL
|
||||||
devc->max_memory_size = 128 * 1024;
|
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)
|
static int config_list(int key, const void **data, const struct sr_dev_inst *sdi)
|
||||||
{
|
{
|
||||||
(void)sdi;
|
struct dev_context *devc;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case SR_CONF_DEVICE_OPTIONS:
|
case SR_CONF_DEVICE_OPTIONS:
|
||||||
*data = hwcaps;
|
*data = hwcaps;
|
||||||
break;
|
break;
|
||||||
case SR_CONF_SAMPLERATE:
|
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;
|
break;
|
||||||
case SR_CONF_TRIGGER_TYPE:
|
case SR_CONF_TRIGGER_TYPE:
|
||||||
*data = TRIGGER_TYPE;
|
*data = TRIGGER_TYPE;
|
||||||
|
|
|
@ -37,11 +37,11 @@ SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; zp_supported_samplerates[i]; i++)
|
for (i = 0; zp_supported_samplerates_200[i]; i++)
|
||||||
if (samplerate == zp_supported_samplerates[i])
|
if (samplerate == zp_supported_samplerates_200[i])
|
||||||
break;
|
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);
|
sr_err("Unsupported samplerate: %" PRIu64 "Hz.", samplerate);
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,10 @@ struct dev_context {
|
||||||
int trigger;
|
int trigger;
|
||||||
unsigned int capture_ratio;
|
unsigned int capture_ratio;
|
||||||
struct sr_usb_dev_inst *usb;
|
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 unsigned int get_memory_size(int type);
|
||||||
SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate);
|
SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate);
|
||||||
|
|
Loading…
Reference in New Issue