zeroplus-logic-cube: fix samplerate setting

This commit is contained in:
Bert Vermeulen 2013-03-31 20:47:01 +02:00
parent e0e150672a
commit 3316e149d0
3 changed files with 27 additions and 29 deletions

View File

@ -210,6 +210,33 @@ static int configure_probes(const struct sr_dev_inst *sdi)
return SR_OK;
}
SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate)
{
int i;
for (i = 0; ARRAY_SIZE(samplerates_200); i++)
if (samplerate == samplerates_200[i])
break;
if (i == ARRAY_SIZE(samplerates_200) || samplerate > devc->max_samplerate) {
sr_err("Unsupported samplerate: %" PRIu64 "Hz.", samplerate);
return SR_ERR_ARG;
}
sr_info("Setting samplerate to %" PRIu64 "Hz.", samplerate);
if (samplerate >= SR_MHZ(1))
analyzer_set_freq(samplerate / SR_MHZ(1), FREQ_SCALE_MHZ);
else if (samplerate >= SR_KHZ(1))
analyzer_set_freq(samplerate / SR_KHZ(1), FREQ_SCALE_KHZ);
else
analyzer_set_freq(samplerate, FREQ_SCALE_HZ);
devc->cur_samplerate = samplerate;
return SR_OK;
}
static int clear_instances(void)
{
GSList *l;

View File

@ -33,33 +33,6 @@ SR_PRIV unsigned int get_memory_size(int type)
return 0;
}
SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate)
{
int i;
for (i = 0; zp_supported_samplerates_200[i]; i++)
if (samplerate == zp_supported_samplerates_200[i])
break;
if (!zp_supported_samplerates_200[i] || samplerate > devc->max_samplerate) {
sr_err("Unsupported samplerate: %" PRIu64 "Hz.", samplerate);
return SR_ERR_ARG;
}
sr_info("Setting samplerate to %" PRIu64 "Hz.", samplerate);
if (samplerate >= SR_MHZ(1))
analyzer_set_freq(samplerate / SR_MHZ(1), FREQ_SCALE_MHZ);
else if (samplerate >= SR_KHZ(1))
analyzer_set_freq(samplerate / SR_KHZ(1), FREQ_SCALE_KHZ);
else
analyzer_set_freq(samplerate, FREQ_SCALE_HZ);
devc->cur_samplerate = samplerate;
return SR_OK;
}
SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples)
{
devc->limit_samples = samples;

View File

@ -55,8 +55,6 @@ struct dev_context {
const struct zp_model *prof;
};
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);
SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples);